/* Acceleration Voltage: its colours, the drawings of fields, particles and energy bars, the options, the
   explorer; the general look is in ui.css (shared by the apps). As in the textbook figure: field lines
   gold, velocity blue, the charge red; equipotentials dashed green; energy bars: E_pot blue, E_kin red,
   the total grey (as in Energy Conservation). */
:root {
  --ef-line: #1f5fc4; --ef-force: #c62828; --ef-equi: #c2620c; --ef-part: #7a8aa3; --ef-traj: #8e44ad;
  --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-part: #8d9bb3; --ef-traj: #c7a6ff; --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 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; }
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 .sub { font-size: 75%; }
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 .v-part { stroke: var(--ef-part); fill: none; stroke-dasharray: 5 3; }
svg.ef .v-part-head { fill: var(--ef-part); }
svg.ef .v-vel { stroke: var(--ink); fill: none; }
svg.ef .v-vel-head { fill: var(--ink); }
svg.ef .axis { stroke: var(--ink); fill: none; }
svg.ef .axis-head { fill: var(--ink); }
svg.ef .gcurve { fill: none; stroke: var(--ef-line); stroke-width: 2.6; }
svg.ef .gmark { stroke: var(--muted); stroke-dasharray: 3 3; }
svg.ef .tick { fill: var(--muted); font: 11px system-ui, sans-serif; }
svg.ef .jump { stroke: var(--muted); stroke-dasharray: 3 3; }
svg.ef .gcurve.c-v { stroke: #1b7f3b; }
svg.ef .gcurve.c-e { stroke: var(--ef-line); }
svg.ef .lbl.c-v { fill: #1b7f3b; }
svg.ef .lbl.c-e { fill: var(--ef-line); }
svg.ef .equi-lbl { fill: var(--ef-equi); }
svg.ef circle.equi { fill: none; }
svg.ef path.equi { fill: none; }
svg.ef .traj { fill: none; stroke: var(--ef-traj); stroke-width: 2.6; stroke-linecap: round; }

/* sketching the potential (sketch.js, sketch.css; the drawing is exercises.js's sketchBody) */
:root { --ef-v: #1b7f3b; }
@media (prefers-color-scheme: dark) { :root { --ef-v: #5cc97c; } }
svg.sketch-plot { display: block; width: 100%; max-width: 440px; height: auto; margin: 0 auto; }
svg.sk-columns { cursor: crosshair; }
svg.ef .skline { fill: none; stroke: var(--ef-v); stroke-width: 2.6; stroke-linejoin: round; }
svg.ef .skline.right { stroke: var(--muted); stroke-width: 1.8; stroke-dasharray: 5 4; }
svg.ef .skline.bad { stroke: var(--bad); stroke-width: 3.4; }
svg.ef .skbad { fill: none; stroke: var(--bad); stroke-width: 2; }
svg.ef .skname, svg.ef .readout { fill: var(--ef-v); }
svg.ef .metalband { fill: var(--ef-metal); opacity: 0.6; }
svg.ef .wrongband { fill: var(--bad); opacity: 0.14; }
svg.ef .handle { fill: var(--ef-v); stroke: var(--card); stroke-width: 1.5; }
svg.ef .handle.active { stroke: var(--ink); }
#sketch-area { margin: 6px 0 12px; }
.sketch-how { margin: 4px 0 6px; }
#sketch-area .linklike { display: block; margin: 2px auto 0; }
.sketch-fb { margin: 6px 0 2px; font-size: 0.95rem; }
.sketch-fb:empty { display: none; }
.sketch-fb p { margin: 0; }
.sketch-fb.ok { color: var(--ok); }
.sketch-fb.bad > p { color: var(--bad); }
.sketch-fb ul { margin: 4px 0 0; padding-left: 1.3em; }
.sketch-fb li { margin: 2px 0; }
.t-draw .actions { margin-top: 8px; align-items: center; }

/* 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 and direction tiles 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; }

/* 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; }

/* a small table of cases */
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); }

/* ---------------------------------------------------------------- Acceleration Voltage */
:root { --av-line: #d29a1e; --av-vel: #1f3fd6; --av-force: #c62828; --av-equi: #2e8b57; --av-path: #8a6a8a;
  --e-pot: #1f5fd6; --e-kin: #c0392b; --e-tot: #8b9096; --av-tube: #cfd3d8; --av-hl: #fff4cc; }
@media (prefers-color-scheme: dark) {
  :root { --av-line: #e8b84a; --av-vel: #7ea0ff; --av-force: #ff7b72; --av-equi: #6fd39a; --av-path: #c2a5c2;
    --e-pot: #74a7ff; --e-kin: #ff8a80; --e-tot: #9aa0a6; --av-tube: #4b5157; --av-hl: #2c2a22; }
}
svg.av .fline { stroke: var(--av-line); stroke-width: 1.8; opacity: 1; }
svg.av .fline-head { fill: var(--av-line); }
svg.av .fl-lbl { fill: var(--av-line); font-style: italic; }
svg.av .equi { stroke: var(--av-equi); stroke-width: 1.4; stroke-dasharray: 6 4; fill: none; }
svg.av .avpath { fill: none; stroke: var(--av-path); stroke-width: 1.5; stroke-dasharray: 4 4; }
svg.av .v-vel { stroke: var(--av-vel); fill: none; }
svg.av .v-vel-head { fill: var(--av-vel); }
svg.av .vel-lbl { fill: var(--av-vel); font-style: italic; }
svg.av .v-force { stroke: var(--av-force); fill: none; }
svg.av .v-force-head { fill: var(--av-force); }
svg.av .force-lbl { fill: var(--av-force); font-style: italic; }
svg.av .charge.part.pos { fill: #e53935; stroke: #b71c1c; }
svg.av .charge.part.neg { fill: #3d6fd8; stroke: #1c3f8f; }
svg.av .charge.part.neu { fill: #8b9096; stroke: #555a60; }
svg.av .q-lbl { fill: var(--av-force); font-style: italic; }
svg.av .v-lbl { fill: var(--av-equi); }
svg.av .plate { fill: var(--muted); }
svg.av .tube { fill: var(--av-tube); stroke: var(--ink); stroke-width: 1.2; }
svg.av .bar.e-pot { fill: var(--e-pot); }
svg.av .bar.e-kin { fill: var(--e-kin); }
svg.av .bar.e-tot { fill: var(--e-tot); }
svg.av .bar-q { fill: none; stroke: var(--muted); stroke-dasharray: 4 3; }
svg.av .e-pot-t { fill: var(--e-pot); }
svg.av .e-kin-t { fill: var(--e-kin); }
svg.av .e-tot-t { fill: var(--muted); }
svg.av .bar-val { font-size: 10px; }
svg.av .bars-hl { fill: var(--av-hl); }
svg.av .probe { fill: none; stroke: var(--ink); stroke-width: 2; }
svg.av .probe-dot { fill: var(--ink); }
svg.av .start { fill: var(--card); stroke: var(--ink); stroke-width: 2; }
.figs svg.bars { max-width: 440px; }
.k-pot { color: var(--e-pot); font-weight: 600; }
.k-kin { color: var(--e-kin); font-weight: 600; }
.k-v { color: var(--av-equi); font-weight: 600; }

/* the explorer (explore.js) */
.ex-controls { display: grid; gap: 8px; margin: 10px 0 4px; }
.ex-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.ex-row .what { font-weight: 600; min-width: 9.5em; }
.ex-row .levels > label > span { padding: 4px 12px; font-size: 0.9rem; }
.ex-row input[type="range"] { flex: 1 1 160px; max-width: 280px; accent-color: var(--accent); }
.ex-check { font-size: 0.95rem; cursor: pointer; }
#ex-fig svg.explore-fig { max-width: 620px; cursor: crosshair; touch-action: none; }
#ex-fig svg.explore-fig:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ex-how { margin-top: -8px; text-align: center; }
.ex-read { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 8px 24px; margin: 10px 0 4px; }
.ex-read .fig svg.gauge-fig { width: 180px; height: auto; }
.ex-read .fig svg.bars { width: 300px; max-width: 100%; height: auto; }
svg.av .gauge { fill: var(--ef-grid); stroke: var(--line); }
svg.av .gmark-A, svg.av .gmark-P { stroke: var(--ink); stroke-width: 3; }
svg.av .gmark-P { stroke: var(--accent); }
.ex-lines { margin: 6px 0; padding-left: 1.2em; }
.ex-lines li { margin: 3px 0; }
@media (max-width: 560px) { .ex-row .what { min-width: 0; width: 100%; } }

/* the simulation (sim/) */
#sim-fig svg.sim-fig { max-width: 680px; cursor: crosshair; touch-action: none; }
#sim-fig svg.sim-fig:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
svg.av .sim-trace { fill: none; stroke-width: 2; opacity: 0.8; }
svg.av .sim-trace.tp { stroke: #e53935; }
svg.av .sim-trace.tn { stroke: #3d6fd8; }
svg.av .sim-trace.tz { stroke: #8b9096; }
svg.av .sim-dir { stroke: var(--av-vel); stroke-width: 2; stroke-dasharray: 5 4; }
svg.av .sim-tip { fill: var(--av-vel); fill-opacity: 0.18; stroke: var(--av-vel); stroke-width: 1.5; cursor: grab; } /* the handle at the tip of the initial velocity */
.sim-actions { justify-content: center; margin: 12px 0 0; }
.sim-stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px 24px; align-items: center; margin: 12px 0 10px; }
.sim-stage .fig { overflow: visible; }
.sim-bars { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 12px; }
.sim-bars svg.bars { width: 150px; max-width: 100%; height: auto; }
.sim-stage.no-bars .sim-bars { display: none; } /* the energy bars switched off */
.sim-tbl { display: flex; justify-content: center; overflow-x: auto; transition: opacity 0.2s; }
.sim-tbl.running { opacity: 0.5; } /* the table holds still while the motion plays */
.ex-row input.sim-num { width: 4.6em; padding: 3px 6px; font: inherit; color: var(--ink); background: var(--card, transparent); border: 1px solid var(--line, #c8cdd2); border-radius: 6px; }
/* a wide screen: the page wider, the energy bars beside the field */
@media (min-width: 1000px) {
  body.sim-page .wrap { max-width: 1160px; }
  .sim-stage { grid-template-columns: minmax(0, 1fr) minmax(200px, 300px); }
  .sim-bars svg.bars { width: min(100%, 220px); }
  .sim-bars.many svg.bars { width: calc(50% - 6px); }
  .sim-stage.no-bars { grid-template-columns: minmax(0, 1fr); }
}
.sim-table td, .sim-table th { padding: 0.25em 0.6em; }
.sim-table tbody th { font-weight: 700; color: var(--ink); }
.ex-row .ex-check { margin-right: 10px; }
.ex-row .levels small { font-size: 0.75em; opacity: 0.85; }
.sim-link { margin: 14px 0 0; text-align: center; font-weight: 600; }

/* the explorer on its own page (explore/): on a wide screen the gauge, the bars and the readout beside the field */
@media (min-width: 1000px) {
  body.explore-page .ex-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 480px); gap: 12px 28px; align-items: start; margin-top: 8px; }
  body.explore-page .ex-main .ex-how { margin-top: 2px; }
  body.explore-page .ex-read { gap: 8px 16px; }
}
.sim-link + .sim-link { margin-top: 6px; }
/* the time slider of the simulation: under the buttons, centred, the time it stands at beside it */
.sim-scrub { justify-content: center; margin: 10px 0 0; }
.sim-scrub .what { min-width: 0; }
.sim-scrub input[type="range"] { flex: 1 1 220px; max-width: 420px; }
.sim-scrub #sim-tv { min-width: 5.5em; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .ex-row.sim-scrub { flex-wrap: nowrap; } .ex-row.sim-scrub .what { width: auto; } .sim-scrub input[type="range"] { flex: 1 1 0; min-width: 0; } .sim-scrub #sim-tv { min-width: 4.5em; } }
