/* Field Lines and Equipotentials: its colours, the drawings of charges, field lines, equipotentials
   and fields, the options; the general look is in ui.css (shared by the apps). Field lines and field
   blue, equipotentials orange, force red. */
:root {
  --ef-line: #1f5fc4; --ef-force: #c62828; --ef-equi: #c2620c;
  --ef-pos: #f2c2bb; --ef-neg: #bcd3f2; --ef-neu: #e4e2dc; --ef-metal: #cfd3d8; --ef-grid: #ebe8e1;
}
@media (prefers-color-scheme: dark) {
  :root { --ef-line: #79a8ff; --ef-force: #ff7b72; --ef-equi: #ffb36b; --ef-pos: #7a3e37; --ef-neg: #34507a; --ef-neu: #4a4a46; --ef-metal: #4b5157; --ef-grid: #2c3035; }
}

#prompt p { margin: 6px 0; }
/* a vector: an arrow above the letter */
.vec { position: relative; display: inline-block; }
.vec::before { content: "→"; position: absolute; left: 0; right: 0; top: -0.62em; text-align: center; font-size: 0.7em; font-style: normal; line-height: 1; }
.figs .fig { flex: 1 1 100%; }
.figs .fig.half { flex: 1 1 240px; }
.figs svg.ef { display: block; width: 100%; max-width: 440px; height: auto; margin: 0 auto; }

/* drawings */
svg.ef text { font-family: var(--serif); }
svg.ef .bg { fill: var(--card); }
svg.ef .grid { stroke: var(--ef-grid); stroke-width: 1; }
svg.ef .axisline { stroke: var(--muted); stroke-width: 1; }
svg.ef .fline { fill: none; stroke: var(--ef-line); stroke-width: 1.4; opacity: 0.9; }
svg.ef .fline-head { fill: var(--ef-line); }
svg.ef .equi { stroke: var(--ef-equi); stroke-width: 1.4; fill: none; }
svg.ef .charge { stroke: var(--ink); stroke-width: 1.3; }
svg.ef .charge.pos { fill: var(--ef-pos); }
svg.ef .charge.neg { fill: var(--ef-neg); }
svg.ef .charge.neu { fill: var(--ef-neu); }
svg.ef .charge.named { fill: var(--card); stroke-width: 1.6; }
svg.ef .sign { fill: var(--ink); font: 700 14px system-ui, sans-serif; }
svg.ef .sign.small { font-size: 10px; }
svg.ef .sign.big { font-size: 20px; }
svg.ef .lbl { fill: var(--ink); font-size: 15px; paint-order: stroke; stroke: var(--card); stroke-width: 3px; }
svg.ef .lbl.name { font-weight: 700; font-family: system-ui, sans-serif; font-size: 13px; }
svg.ef .lbl.small { font-size: 12px; }
svg.ef .it { font-style: italic; }
svg.ef .pt { fill: var(--ink); }
svg.ef .metal { fill: var(--ef-metal); }
svg.ef .metal-edge { stroke: var(--ink); stroke-width: 1.2; }
svg.ef .plate { fill: var(--muted); }
svg.ef .rod { stroke: var(--ink); stroke-width: 3; }
svg.ef :is(.v-field, .v-dir) { stroke: var(--ef-line); fill: none; }
svg.ef :is(.v-field-head, .v-dir-head) { fill: var(--ef-line); }
svg.ef .v-force { stroke: var(--ef-force); fill: none; }
svg.ef .v-force-head { fill: var(--ef-force); }
svg.ef .v-force-lbl { fill: var(--ef-force); }
svg.ef .v-field-lbl { fill: var(--ef-line); }
svg.ef .equi-lbl { fill: var(--ef-equi); }

/* direction tiles: one, or all that fit */
.ask { font-weight: 600; margin: 12px 0 6px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 6px 0 10px; }
.tile { position: relative; display: block; border: 2px solid var(--line); border-radius: 10px; background: var(--card); padding: 6px 10px; cursor: pointer; }
.tile input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.tile:hover { border-color: var(--accent); }
.tile:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.tile:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.tiles[role="group"] .tile:has(input:checked)::after { content: "✓"; position: absolute; top: 4px; right: 8px; color: var(--accent); font-weight: 700; }
.tile.ok { border-color: var(--ok); background: var(--ok-bg); }
.tile.bad { border-color: var(--bad); background: var(--bad-bg); }
.tile.miss { border-color: var(--ok); border-style: dashed; }
.dtile { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.dtile svg.icon { width: 40px; height: 40px; flex: none; }
.qfb { color: var(--bad); margin: 0 0 12px; padding-left: 1.2em; }
.qfb:empty { display: none; }
.qfb li { margin: 3px 0; }

/* drawings to choose from */
.cands { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 8px 0; }
.cand { position: relative; display: block; border: 2px solid var(--line); border-radius: 10px; background: var(--card); padding: 4px; cursor: pointer; }
.cand svg { display: block; width: 100%; height: auto; }
.cand input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.cand .letter { position: absolute; left: 10px; top: 6px; font-weight: 700; color: var(--accent); }
.cand:hover { border-color: var(--accent); }
.cand:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.cand:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.cand.ok { border-color: var(--ok); background: var(--ok-bg); }
.cand.bad { border-color: var(--bad); background: var(--bad-bg); }
@media (max-width: 560px) { .cands { grid-template-columns: minmax(0, 1fr); } }

/* answers: a row of options per question; statements to tick */
#fields .field { display: grid; gap: 6px; margin-bottom: 14px; }
.field .what { font-weight: 600; }
.field .fb { font-size: 0.9rem; }
.field .fb:empty { display: none; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opts label { position: relative; }
.opts input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opts span { display: block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.opts label:hover span { border-color: var(--accent); }
.opts input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.opts input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.field.ok input:checked + span { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.field.bad input:checked + span { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.field.ok .fb { color: var(--ok); }
.stmts { list-style: none; margin: 8px 0 14px; padding: 0; display: grid; gap: 8px; }
.stmts li { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--card); }
.stmts label { display: flex; gap: 10px; align-items: baseline; cursor: pointer; }
.stmts input { flex: none; transform: translateY(1px); }
.stmts li.ok { border-color: var(--ok); background: var(--ok-bg); }
.stmts li.bad { border-color: var(--bad); background: var(--bad-bg); }
.stmts .fb { display: block; font-size: 0.9rem; margin: 4px 0 0 26px; }
.stmts .fb:empty { display: none; }

/* check: drawings as options */
#ck .ck-opt .val svg.ef:not(.icon) { width: 100%; max-width: 260px; }
#ck .ck-opt .val svg.icon { width: 40px; height: 40px; }
#ck .ck-opt .dtile { justify-content: center; }

/* two situations side by side */
table.cmp { border-collapse: collapse; margin: 0.6em 0; font-size: 0.95em; }
table.cmp th, table.cmp td { border: 1px solid var(--line); padding: 0.3em 0.8em; text-align: center; }
table.cmp thead th { color: var(--accent); }
table.cmp tbody th { text-align: left; font-weight: normal; color: var(--muted); }

/* the nudge after a wrong check of statements */
.stmts-fb { color: var(--bad); font-size: 0.9rem; margin: 4px 0 0; }
.stmts-fb:empty { display: none; }

/* the dipole animations (anim.js): the figure with a small button to replay it under it; for
   reduced motion, faint positions along the way */
.dip-anim-wrap { display: grid; justify-items: center; gap: 6px; }
.dip-anim-wrap svg.ef { display: block; width: 100%; max-width: 440px; height: auto; }
.dip-replay { font-size: 0.85rem; padding: 3px 10px; color: var(--muted); }
.dip-replay:hover:not(:disabled) { color: var(--ink); }
svg.ef .ghost { opacity: 0.3; }
/* in practice, the animation of the exercise's own dipole once it is answered */
.observe { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.observe .note { margin: 0 0 8px; }

/* the probe (probe.js): a figure to measure the field or the potential in */
svg.ef.probe { touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
svg.ef.probe:focus { outline: none; }
svg.ef.probe:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
svg.ef .pr-arrow { stroke: var(--ef-line); stroke-linecap: round; fill: none; }
svg.ef :is(.pr-head, .pr-base) { fill: var(--ef-line); }
svg.ef .pr-zero { fill: none; stroke: var(--ef-line); stroke-width: 1.6; }
svg.ef .pr-dot { fill: var(--ef-equi); stroke: var(--card); stroke-width: 1; }
svg.ef .pr-cross { fill: none; stroke: var(--ink); stroke-width: 1.3; }
svg.ef .pr-val { fill: var(--ink); font: 600 11.5px system-ui, sans-serif; paint-order: stroke; stroke: var(--card); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
svg.ef .pr-val.live { fill: var(--accent); }
.probe-bar { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; max-width: 440px; margin: 6px auto 0; }
.probe-read { flex: 1 1 200px; min-height: 1.5em; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.probe-clear { flex: none; font-size: 0.9rem; }
