/* Figures: diagrams (inline SVG), real-data images and before/after comparisons. Shared by every level.
   Colours come from the theme tokens, so every diagram follows light and dark mode. */
.fig { margin: 14px 0 6px; min-width: 0; position: relative; }
.fig > img, .fig .fig-img { display: block; width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--rule); background: #101719; }
.fig figcaption { font-size: 0.86rem; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.fig figcaption b { color: var(--ink); }
.fig.narrow { max-width: 34rem; }
.fig.center { margin-inline: auto; }
.fig-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 12px; margin: 14px 0 6px; }
.fig-row > .fig { margin: 0; }
.fig-tag { position: absolute; top: 8px; left: 8px; font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: #E5ECEE; background: rgba(12, 18, 20, 0.72); padding: 2px 7px; border-radius: 999px; pointer-events: none; }
.fig-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.82rem; color: var(--muted); margin-top: 6px; }
.fig-legend .sw { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: 0.2em; margin-right: 6px; background: currentColor; }

/* before/after: <div class="fig-compare"><img …before><img class="after" …><span class="lab lab-a">Before</span><span class="lab lab-b">After</span>
   <input type="range" min="0" max="100" value="50" aria-label="…"></div>  (js/game/figs.js wires the slider) */
.fig-compare { --pos: 50%; position: relative; overflow: hidden; border-radius: 8px; border: 1px solid var(--rule); background: #101719; aspect-ratio: 4 / 3; touch-action: pan-y; }
.fig-compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; -webkit-user-drag: none; }
.fig-compare img.after { clip-path: inset(0 0 0 var(--pos)); }
.fig-compare::after { content: ""; position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px; background: #E5ECEE; box-shadow: 0 0 0 1px rgba(0,0,0,0.35); pointer-events: none; }
.fig-compare .knob { position: absolute; top: 50%; left: var(--pos); width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; background: #E5ECEE; color: #101719;
  display: grid; place-items: center; font: 700 13px/1 var(--f-mono); box-shadow: 0 1px 4px rgba(0,0,0,0.4); pointer-events: none; z-index: 2; }
.fig-compare .lab { position: absolute; bottom: 8px; font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: #E5ECEE;
  background: rgba(12, 18, 20, 0.72); padding: 2px 7px; border-radius: 999px; pointer-events: none; z-index: 2; }
.fig-compare .lab-a { left: 8px; } .fig-compare .lab-b { right: 8px; }
.fig-compare input[type=range] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; z-index: 3; }
.fig-compare:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* diagrams: <svg class="dg" viewBox="0 0 480 260" role="img" aria-label="…"> with the classes below */
svg.dg { display: block; width: 100%; height: auto; font-family: var(--f-body); font-size: 14px; overflow: visible; }
svg.dg path, svg.dg line, svg.dg polyline, svg.dg circle, svg.dg ellipse, svg.dg rect, svg.dg polygon { fill: none; stroke-linecap: round; stroke-linejoin: round; }
svg.dg text { stroke: none; fill: var(--ink); }
.dg .k-src { stroke: var(--source); } .dg .k-tgt { stroke: var(--target); } .dg .k-ink { stroke: var(--ink); } .dg .k-mut { stroke: var(--muted); }
.dg .k-rule { stroke: var(--rule); } .dg .k-grid { stroke: var(--grid); } .dg .k-match { stroke: var(--match); } .dg .k-good { stroke: var(--good); }
.dg .k-bad { stroke: var(--bad); } .dg .k-acc { stroke: var(--accent); }
.dg .f-src { fill: var(--source); } .dg .f-tgt { fill: var(--target); } .dg .f-ink { fill: var(--ink); } .dg .f-mut { fill: var(--muted); }
.dg .f-match { fill: var(--match); } .dg .f-good { fill: var(--good); } .dg .f-bad { fill: var(--bad); } .dg .f-acc { fill: var(--accent); }
.dg .f-surface { fill: var(--surface); } .dg .f-bg { fill: var(--bg); } .dg .f-tint { fill: var(--tint); } .dg .f-rule { fill: var(--rule); } .dg .f-grid { fill: var(--grid); }
.dg .f-src-soft { fill: color-mix(in srgb, var(--source) 18%, transparent); } .dg .f-tgt-soft { fill: color-mix(in srgb, var(--target) 18%, transparent); }
.dg .f-bad-soft { fill: color-mix(in srgb, var(--bad) 16%, transparent); } .dg .f-good-soft { fill: color-mix(in srgb, var(--good) 16%, transparent); }
.dg .f-acc-soft { fill: color-mix(in srgb, var(--accent) 16%, transparent); }
.dg .w1 { stroke-width: 1; } .dg .w15 { stroke-width: 1.5; } .dg .w2 { stroke-width: 2; } .dg .w3 { stroke-width: 3; } .dg .w4 { stroke-width: 4; }
.dg .dash { stroke-dasharray: 5 5; } .dg .dot { stroke-dasharray: 1 5; }
.dg .tm { fill: var(--muted); } .dg .ts { fill: var(--source); } .dg .tt { fill: var(--target); } .dg .ta { fill: var(--accent); }
.dg .tb { fill: var(--bad); } .dg .tg { fill: var(--good); }
.dg .mono { font-family: var(--f-mono); font-size: 12.5px; } .dg .small { font-size: 12.5px; } .dg .big { font-size: 17px; font-weight: 700; }
.dg .bold { font-weight: 700; } .dg .disp { font-family: var(--f-display); font-weight: 700; }
.dg .mid { text-anchor: middle; } .dg .end { text-anchor: end; }
/* simple motion helpers (off when the reader prefers reduced motion) */
@keyframes dg-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes dg-dash { to { stroke-dashoffset: -20; } }
.dg .pulse { animation: dg-pulse 2.4s ease-in-out infinite; }
.dg .flow { stroke-dasharray: 6 4; animation: dg-dash 1.2s linear infinite; }
@media (prefers-reduced-motion: reduce) { .dg *, .fig * { animation: none !important; transition: none !important; } }
