/* The deck runtime, version 2: stage, background layers, slide transitions, builds, footer, progress, toolbar, popover,
   overlays, reader mode, print. Stage sizes are in stage px (1920 x 1080, scaled as a whole). Overlays outside the stage
   use screen px. Every color is a token from tokens.css (or a color-mix() of tokens); every duration is a motion token,
   0 under reduced motion. Slide transitions and chart draw-ins are run by js/deck.js and js/charts.js (Web Animations);
   builds, arrow draws and the background drift are CSS. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* an author display rule must never resurrect a hidden overlay */
html.is-booting *, html.is-booting *::before, html.is-booting *::after { transition: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
html.is-reader, html.is-reader body { height: auto; overflow: visible; }
html.is-reader body { background: var(--bg); }   /* the page itself scrolls, so the browser's scroll keys work */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
kbd { font-family: var(--font-sans); }

/* ---------------------------------------------------------------- viewport and stage */
.deck-viewport { position: fixed; inset: 0; display: grid; place-items: center; }
.deck-frame {
  position: relative;
  width: calc(1920px * var(--scale, 1));
  height: calc(1080px * var(--scale, 1));
  overflow: hidden;
  touch-action: pan-y;   /* the browser keeps vertical scrolling and pinch zoom; horizontal swipes reach the deck */
}
.deck-stage {
  position: absolute; left: 0; top: 0;
  width: 1920px; height: 1080px;
  transform: scale(var(--scale, 1));
  transform-origin: 0 0;
  background: var(--bg);
  font-size: var(--fs-body);
  line-height: 1.35;
  font-feature-settings: "tnum" 0;
}
.deck-slides, .deck-slides > section.part { display: contents; }

/* ---------------------------------------------------------------- slides and transitions
   A slide is hidden until it is current. The runtime (js/deck.js) animates the old slide out and the new one in with the
   Web Animations API, so nothing here transitions the slide itself; with motion off the classes simply swap. */
.slide {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: var(--pad-top) var(--pad-x) var(--pad-bottom);
  visibility: hidden;
  opacity: 0;
  isolation: isolate;   /* the background layer sits at z-index -1 inside the slide, behind its content */
}
.slide.is-current { visibility: visible; opacity: 1; }
.slide.is-leaving { visibility: visible; }
.slide.is-instant *, .slide.is-settling * { transition: none !important; }
.slide > .notes { display: none; }

/* builds: anything with data-build appears at its step. HTML and SVG both use the `translate` property, which leaves
   an SVG element's transform attribute alone. A build that goes away (going back) disappears at once. */
[data-build], [data-build-to] {
  transition: opacity var(--d-build) var(--ease-out), translate var(--d-build) var(--ease-out), visibility 0s;
}
.is-hidden {
  opacity: 0 !important;
  visibility: hidden;
  translate: 0 var(--shift-build);
  transition: none;
}
/* an edge that draws itself: give the path pathLength="1" and class "draw" */
.draw { stroke-dasharray: 1 1; stroke-dashoffset: 0; transition: stroke-dashoffset var(--d-draw) var(--ease-move); }
.is-hidden .draw, .draw.is-hidden { stroke-dashoffset: 1; }
.is-hidden .draw, .draw.is-hidden, .draw.marker-wait { marker-end: none; }   /* the arrowhead appears only when the line has finished drawing */

/* ---------------------------------------------------------------- part colors and the background layer
   --part is the current part's color: opening, close and references are cyan, then amber, violet and green for parts 1 to 3.
   The runtime copies each section's data-part to its slides and the current slide's to .deck-stage. The glow and wash are
   derived from --part, so they are set here, where --part is final. */
.deck-stage, .slide { --part: var(--part-0); --glow-part: color-mix(in oklab, var(--part) 45%, transparent); --wash-part: color-mix(in oklab, var(--part) 12%, var(--surface)); }
.deck-stage[data-part="1"], .slide[data-part="1"] { --part: var(--part-1); }
.deck-stage[data-part="2"], .slide[data-part="2"] { --part: var(--part-2); }
.deck-stage[data-part="3"], .slide[data-part="3"] { --part: var(--part-3); }
.deck-stage[data-part="1"], .slide[data-part="1"], .deck-stage[data-part="2"], .slide[data-part="2"], .deck-stage[data-part="3"], .slide[data-part="3"] { --glow-part: color-mix(in oklab, var(--part) 45%, transparent); --wash-part: color-mix(in oklab, var(--part) 12%, var(--surface)); }

/* One layer per slide, .slide > .decor-bg, added by the runtime: a glow, a texture and (dark only) scan lines. It holds no
   text and no element of the slide's content, and it is skipped by the overflow, size, label and contrast audits, but not by
   the token, text-on-texture and texture checks (plan amendments R1, R12, R15). */
.decor-bg { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.decor-bg .glow { position: absolute; inset: 0;
  background:
    radial-gradient(1100px 700px at 100% 0%, color-mix(in oklab, var(--part) calc(var(--glow-max) * 100%), transparent), transparent 70%),
    radial-gradient(900px 600px at 0% 100%, color-mix(in oklab, var(--accent) calc(var(--glow-max) * 60%), transparent), transparent 70%); }
/* The texture is a layer filled with the part's color and masked by an SVG file (an alpha mask: white strokes with opacity, from
   tools/gen_textures.mjs), intersected with a text-safe gradient (--tex-mask) and a fade at the foot (--tex-mask-v). Drift
   animates the first mask layer's position only. */
.decor-bg .tex { position: absolute; left: -120px; top: -68px; width: 2160px; height: 1215px;
  background-color: var(--part); opacity: var(--tex-o, var(--tex-quiet));
  -webkit-mask-image: var(--tex-img), var(--tex-mask), var(--tex-mask-v); mask-image: var(--tex-img), var(--tex-mask), var(--tex-mask-v);
  -webkit-mask-size: 2160px 1215px, 100% 100%, 100% 100%; mask-size: 2160px 1215px, 100% 100%, 100% 100%;
  -webkit-mask-repeat: repeat, no-repeat, no-repeat; mask-repeat: repeat, no-repeat, no-repeat;
  -webkit-mask-composite: source-in, source-in; mask-composite: intersect, intersect;
  -webkit-mask-position: 0 0, 0 0, 0 0; mask-position: 0 0, 0 0, 0 0;
  animation: drift var(--d-drift) var(--ease-move) infinite alternate; }
.slide { --tex-img: url("../img/textures/tex-hexgrid.svg"); }   /* opening, close, references, and any other section */
.slide[data-part="1"] { --tex-img: url("../img/textures/tex-hexdump.svg"); }
.slide[data-part="2"] { --tex-img: url("../img/textures/tex-network.svg"); }
.slide[data-part="3"] { --tex-img: url("../img/textures/tex-circuit.svg"); }
/* masks by slide kind (design section 6.3): the texture is strongest where no text sits */
.slide { --tex-mask: linear-gradient(100deg, transparent 0 24%, black 64%); --tex-mask-v: linear-gradient(180deg, black 0 78%, transparent 92%); }
.slide--title, .slide--divider { --tex-mask-v: linear-gradient(black, black); --tex-o: var(--tex-loud); }
/* a part divider fades its texture out behind the part-nav row and the page number (plan 02 X3) */
.slide--divider { --tex-mask-v: linear-gradient(180deg, black 0 68%, transparent 80%); }
.slide--title { --tex-mask: radial-gradient(1000px 640px at 32% 40%, transparent 45%, black 100%); }
.slide--divider { --tex-mask: radial-gradient(980px 560px at 68% 44%, transparent 42%, black 100%); }
.slide--statement { --tex-mask: linear-gradient(90deg, transparent 0 38%, black 82%); }
/* charts, timelines and every slide that carries data stay faint, so a mark never competes with a texture stroke */
.slide[data-kind="chart"], .slide[data-kind="timeline"], .slide[data-kind="references"], .slide--statement-chart, .slide:has(figure.chart, table) { --tex-o: var(--tex-data); }
@keyframes drift {
  from { -webkit-mask-position: 0 0, 0 0, 0 0; mask-position: 0 0, 0 0, 0 0; }
  to { -webkit-mask-position: -64px -36px, 0 0, 0 0; mask-position: -64px -36px, 0 0, 0 0; }
}
/* capture mode (?capture=1): the drift is paused at phase 0; a --drift-phase of .25, .5 or .75 (a negative delay) picks another phase */
:root[data-capture] .decor-bg .tex { animation-play-state: paused; animation-delay: calc(var(--drift-phase) * -1 * var(--d-drift)); }
.decor-bg .scan { position: absolute; inset: 0; opacity: .6;
  background: repeating-linear-gradient(0deg, color-mix(in oklab, var(--ink) 2.2%, transparent) 0 1px, transparent 1px 4px); }
.decor-bg .scan { display: none; }
:root[data-theme="dark"] .decor-bg .scan { display: block; }

/* infinite decorative motion in illustrations: the title core's rotating arcs and the opener's blinking cursor */
.spin { animation: spin 120s linear infinite; }
.blink { animation: blink 1.1s steps(1) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
:root[data-capture] .spin, :root[data-capture] .blink { animation-play-state: paused; animation-delay: 0s; }
/* draw-in geometry: SVG marks scale from their own box (bars and spans from the left end, cells and markers from the middle of
   their base), never from the SVG's corner */
.chart-svg rect, .chart-svg circle, .chart-svg path.mark, .chart-svg line, .diagram .ix-pulse { transform-box: fill-box; }
.bars .bar, .bars .stack-part, .timeline .span-bar, .strip-solved { transform-origin: 0 50%; }
.bars .meter .unit { transform-origin: 50% 100%; }
.chart-svg circle.mark, .chart-svg path.mark, .scatter .mark, .timeline .mark { transform-origin: 50% 50%; }

/* Motion off in every place the plan lists (reduced motion, the M switch, presenter previews, the overview, reader mode, print):
   no animation and no transition, so charts and diagrams show their end state at once */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after,
html.is-embed *, html.is-embed *::before, html.is-embed *::after,
html.is-reader .deck-stage *, html.is-reader .deck-stage *::before, html.is-reader .deck-stage *::after,
.deck-overview *, .deck-overview *::before, .deck-overview *::after { animation: none !important; transition: none !important; }

/* ---------------------------------------------------------------- footer and progress (inside the stage) */
.deck-footer {
  position: absolute; left: var(--pad-x); right: var(--pad-x); bottom: 30px;
  display: flex; justify-content: space-between; align-items: center;
  font: 500 var(--fs-label-min)/1 var(--font-mono); color: var(--ink-3);
  letter-spacing: .04em;
  pointer-events: none;
}
.deck-footer.is-off .deck-footer-part { visibility: hidden; }
.deck-footer-part { display: inline-flex; align-items: center; gap: 12px; }
.deck-footer-count { font-variant-numeric: tabular-nums; }
.part-mark { fill: none; stroke: currentColor; stroke-width: 2.6; flex: none; }
.deck-footer-part .part-mark { color: var(--part); }
.deck-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; display: flex; gap: 6px; }
.deck-progress .seg { position: relative; background: var(--rule); overflow: hidden; }
.deck-progress .seg-fill { position: absolute; inset: 0 auto 0 0; background: var(--neutral); transition: width var(--d-slide) var(--ease-move); }
.deck-progress .seg.is-current .seg-fill { background: var(--part); box-shadow: 0 0 18px var(--glow-part); }

/* ---------------------------------------------------------------- toolbar, back control, toast (screen px) */
.deck-toolbar {
  position: fixed; top: 12px; right: 12px; z-index: 20;
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface); border: 1px solid var(--rule-2); border-radius: 12px; box-shadow: var(--shadow-1);
  transition: opacity var(--d-ui) var(--ease-out);
}
.deck-toolbar.is-idle:not(:focus-within) { opacity: 0; pointer-events: none; }
:root[data-capture] .deck-toolbar.is-idle:not(:focus-within) { opacity: 1; }   /* capture mode (?capture=1, the checks): the toolbar never idle-fades, so a screenshot does not depend on when the last key was pressed */
html.is-reader .deck-toolbar.is-idle { opacity: 1; pointer-events: auto; }   /* the toolbar stays visible in reader mode */
html.is-reader .deck-toolbar { opacity: 1; pointer-events: auto; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 14px/1 var(--font-sans); color: var(--ink);
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 8px 10px; cursor: pointer;
}
.tb-btn:hover { background: var(--surface-2); }
.tb-btn[aria-pressed="true"] { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-ink); }
.tb-btn kbd { font-size: 12px; color: var(--ink-3); border: 1px solid var(--rule-3); border-radius: 4px; padding: 1px 5px; }
.deck-back {
  position: fixed; top: 12px; left: 12px; z-index: 21;
  font: 600 15px/1 var(--font-sans); color: var(--on-accent); background: var(--accent);
  border: 0; border-radius: 999px; padding: 12px 18px; cursor: pointer; box-shadow: var(--shadow-2);
}
.deck-toast {
  position: fixed; left: 50%; bottom: 32px; translate: -50% 0; z-index: 40;
  font: 500 15px/1.3 var(--font-sans); color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule-2); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow-2);
}
.deck-error { padding: 40px; font-size: 18px; }

a.cite.is-dup { display: none; }   /* a second chip for the same source in one text block: kept in the page, not shown */
/* ---------------------------------------------------------------- citation markers (stage) and popover (screen px) */
a.cite {
  display: inline-block;
  font: 550 var(--fs-label-min)/1 var(--font-sans);
  color: var(--accent-ink);
  text-decoration: none;
  vertical-align: .32em;
  padding: 5px 10px 6px;
  margin-left: 4px;
  border: 2px solid transparent;   /* v1's chip: an --accent-wash fill and a transparent 2 px outline that shows on hover and focus */
  background: var(--accent-wash);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 40%, transparent);   /* v2: a thin magenta hairline around the chip */
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  letter-spacing: 0;
}
a.cite:hover, a.cite:focus-visible, a.cite[aria-expanded="true"] { border-color: var(--accent); box-shadow: none; }
/* on a surface that already is --accent-wash (the model node, a wash rectangle, the current trajectory step, the fine-tuned
   column, the current safety band, a highlighted reference) the chip keeps a 1 px outline instead of a fill */
:is(.diagram .node--model, .traj-list li.is-current, .compare-col.era-tuned, .pipe-band.is-current, .ref.is-target) a.cite,
a.cite.on-wash { background: transparent; border: 1px solid var(--accent); padding: 6px 11px 7px; box-shadow: none; }
:is(.diagram .node--model, .traj-list li.is-current, .compare-col.era-tuned, .pipe-band.is-current, .ref.is-target) a.cite:hover,
a.cite.on-wash:hover { border-width: 2px; padding: 5px 10px 6px; }
a.cite.is-broken { color: var(--bad-ink); border-color: var(--bad); border-style: dashed; }
.deck-popover {
  position: fixed; z-index: 30; width: min(440px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule-2); border-radius: 12px; box-shadow: var(--shadow-2);
  padding: 16px 18px; font: 400 15px/1.45 var(--font-sans);
}
.deck-popover p { margin: 0 0 6px; }
.pop-kind { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.pop-label { text-transform: none; letter-spacing: 0; color: var(--accent-ink); }
.pop-title { font: 700 17px/1.35 var(--font-display); }
.pop-meta { color: var(--ink-2); font-size: 14px; }
.pop-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pop-btn {
  font: 600 14px/1 var(--font-sans); color: var(--accent-ink); background: var(--accent-wash);
  border: 1px solid var(--accent); border-radius: 8px; padding: 9px 12px; text-decoration: none; cursor: pointer;
}

/* ---------------------------------------------------------------- overlays: overview and keys (screen px) */
.deck-overlay { position: fixed; inset: 0; z-index: 25; background: var(--bg); overflow: auto; }
.deck-overview { padding: 24px 40px 64px; }
.ov-head { display: flex; align-items: baseline; gap: 24px; position: sticky; top: -24px; padding: 20px 0 16px; background: var(--bg); border-bottom: 1px solid var(--rule-2); z-index: 1; }
.ov-head h2 { margin: 0; font: 700 26px/1.2 var(--font-display); }
.ov-head p { margin: 0; color: var(--ink-3); font-size: 14px; flex: 1; }
.ov-section h3 { display: flex; align-items: center; gap: 10px; margin: 28px 0 12px; font: 600 16px/1.3 var(--font-sans); color: var(--ink-2); }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.ov-thumb { all: unset; display: flex; flex-direction: column; gap: 8px; cursor: pointer; border-radius: 10px; scroll-margin: 140px 0 40px; }
.ov-scale {
  display: block; position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  border: 1px solid var(--rule-2); border-radius: 8px; background: var(--bg);
}
.ov-stage { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform: scale(var(--thumb-scale, .13)); transform-origin: 0 0; font-size: var(--fs-body); line-height: 1.35; }
.ov-stage .slide { visibility: visible; opacity: 1; translate: none; }
.ov-stage .decor-bg .tex { animation: none; }
.ov-caption { font-size: 13.5px; color: var(--ink-2); line-height: 1.35; }
.ov-caption b { font-variant-numeric: tabular-nums; color: var(--ink); margin-right: 4px; }
.ov-thumb:focus-visible .ov-scale, .ov-thumb:hover .ov-scale { outline: 3px solid var(--accent); outline-offset: 2px; }
.ov-thumb.is-here .ov-scale { outline: 3px solid var(--ink); outline-offset: 2px; }
.ov-thumb.is-here .ov-caption::after { content: " · current"; color: var(--ink-3); }
.deck-help { display: grid; place-items: center; background: var(--scrim); }
.help-card { background: var(--surface); color: var(--ink); border-radius: 16px; padding: 28px 32px; max-width: 640px; box-shadow: var(--shadow-2); font-size: 15px; line-height: 1.45; }
.help-card h2 { margin: 0 0 12px; font: 700 24px/1.2 var(--font-display); }
.help-card table { border-collapse: collapse; width: 100%; margin-bottom: 12px; }
.help-card th, .help-card td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.help-card th { white-space: nowrap; font-weight: 400; }
.help-card kbd { display: inline-block; margin: 0 4px 2px 0; padding: 2px 7px; border: 1px solid var(--rule-3); border-radius: 5px; font-size: 13px; background: var(--surface-2); }
.help-card p { color: var(--ink-2); }

/* ---------------------------------------------------------------- reader mode */
.deck-reader { display: none; }
html.is-reader .deck-viewport { position: static; display: block; padding: 64px 16px 64px; }
html.is-reader .deck-frame { margin: 0 auto; border-radius: 10px; border: 1px solid var(--rule-2); box-shadow: var(--shadow-1); }
html.is-reader .deck-reader {
  display: block; max-width: 760px; margin: 28px auto 0; padding: 0 4px;
  font: 400 19px/1.62 var(--font-display); color: var(--ink);
}
.reader-eyebrow { margin: 0; font: 600 13px/1.4 var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.reader-title { margin: 4px 0 12px; font: 700 26px/1.25 var(--font-display); }
.reader-notes p { margin: 0 0 14px; }
.reader-notes a.cite { font-size: 13px; padding: 2px 7px 3px; vertical-align: .15em; border-width: 1.5px; }
.reader-notes .muted { color: var(--ink-3); }
.reader-nav { display: flex; justify-content: space-between; margin-top: 24px; border-top: 1px solid var(--rule); padding-top: 16px; }
.reader-nav .tb-btn { border-color: var(--rule-3); }

/* ---------------------------------------------------------------- embed (presenter previews) */
html.is-embed .deck-viewport { place-items: start; }
html.is-embed body { background: var(--bg); }

/* ---------------------------------------------------------------- print: always light, no texture, no motion; one slide per page, each at its final build step
   The runtime applies the final step to the current slide on "beforeprint" (every other slide always sits at its final
   step), so builds that are gone by then stay gone. The page is the stage: 1920 x 1080 stage px. */
@page { size: 1920px 1080px; margin: 0; }
@media print {
  html, html.is-reader, body, html.is-reader body { height: auto; overflow: visible; background: var(--bg); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .deck-viewport { position: static; display: block; }
  .deck-frame { width: 1920px; height: auto; overflow: visible; }
  .deck-stage { position: static; transform: none; width: 1920px; height: auto; }
  .deck-slides { display: block; }
  .slide, .slide.is-current, .slide.is-leaving {
    position: relative; inset: auto; width: 1920px; height: 1080px; overflow: hidden;
    visibility: visible; opacity: 1; translate: none; transition: none;
    break-after: page; break-inside: avoid;
  }
  .slide.is-last { break-after: auto; }
  .deck-footer, .deck-progress, .deck-toolbar, .deck-back, .deck-overlay, .deck-toast, .deck-popover, .deck-reader, .chart-toggle { display: none !important; }
  .decor-bg { display: none !important; }   /* print has no texture, no glow and no scan lines; the light tokens come from tokens.css */
  .deck > .sr-only { display: none; }   /* the live region sits after the last slide; its 1 px would add a blank page */
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
