/* Eleven Years of Puzzles — deck styles.
   Main talk: squared paper and navy ink, colour reserved for difficulty.
   Developer section (data-theme="dev"): the solver shell's own palette. */

/* Fonts are bundled (fonts/, SIL Open Font License — see the OFL-*.txt files beside them):
   the deck then looks the same offline and under the web app's same-origin CSP, which
   blocks a Google Fonts stylesheet. Latin subsets, as Google Fonts serves them. */
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400 500; font-display: swap;
  src: url("fonts/newsreader.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("fonts/newsreader-italic.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/atkinson-hyperlegible-400.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/atkinson-hyperlegible-700.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/jetbrains-mono.woff2") format("woff2"); }

:root {
  --paper: #F2F4F6;
  --rule: #E3E7EC;
  --ink: #16233B;
  --ink-soft: #4A5870;
  --cell-empty: #DCE1E7;
  --heat-1: #8FB8D8;
  --heat-2: #3E7CB1;
  --heat-3: #7A5BA6;
  --heat-4: #C2456B;
  --heat-5: #E0703A;

  --dev-bg: #18181B;
  --dev-panel: #27272A;
  --dev-border: #3F3F46;
  --dev-text: #E5E7EB;
  --dev-muted: #9CA3AF;
  --dev-accent: #F97316;
  --dev-amber: #FBBF24;
  --dev-blue: #60A5FA;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0F1726;
  color: var(--ink);
  font-family: var(--sans);
}

/* ---- stage: a fixed 1600×900 canvas scaled to the window ---- */

.viewport {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

/* The canvas's centre is pinned to the window's, and deck.js scales it about that centre.
   Not left to the grid's centring: that only centres a child narrower than the window, so
   on anything under 1600px wide the canvas started at the left edge and its centre sat at
   x = 800 — the scaled slide landed off to the right, wholly off-screen on a phone. */
.stage {
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -450px 0 0 -800px;
  width: 1600px;
  height: 900px;
  flex: none;
  transform-origin: center center;
  overflow: hidden;
}

.slide {
  position: absolute;
  inset: 0;
  padding: 96px 120px 88px;
  display: none;
  flex-direction: column;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: -1px -1px;
}

.slide.active { display: flex; }

/* ---- type ---- */

h1, h2, .statement {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

h1 { font-size: 112px; line-height: 1.0; font-optical-sizing: auto; }
h2 { font-size: 60px; line-height: 1.08; max-width: 22ch; }
.statement { font-size: 76px; line-height: 1.1; max-width: 20ch; }

.lede {
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1.4;
  color: var(--ink-soft);
  max-width: 40ch;
  margin: 28px 0 0;
}

.caption {
  font-size: 22px;
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 60ch;
}

.big-number {
  font-family: var(--serif);
  font-size: 220px;
  line-height: 0.9;
  font-variant-numeric: lining-nums tabular-nums;
}

/* ---- layout helpers ---- */

.fill { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; }
.bottom { margin-top: auto; }
.row { display: flex; gap: 64px; align-items: flex-end; }
.viz { margin-top: 32px; flex: 1; min-height: 0; position: relative; }
.viz svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* ---- the grid ---- */

.cell { fill: var(--cell-empty); }
.cell.h1 { fill: var(--heat-1); }
.cell.h2 { fill: var(--heat-2); }
.cell.h3 { fill: var(--heat-3); }
.cell.h4 { fill: var(--heat-4); }
.cell.h5 { fill: var(--heat-5); }
.cell.lit { animation: pop 420ms ease-out; }

@keyframes pop {
  0% { transform: scale(1.9); }
  100% { transform: scale(1); }
}
.cell { transform-box: fill-box; transform-origin: center; }

.title-grid { position: absolute; inset: 0; opacity: 0.22; pointer-events: none; }
.title-grid svg { width: 100%; height: 100%; }
.slide-title > :not(.title-grid) { position: relative; }

.legend { display: flex; gap: 6px; align-items: center; font-size: 18px; color: var(--ink-soft); }
.legend i { width: 18px; height: 18px; border-radius: 3px; display: inline-block; }

/* timeline readout beside the grid */
.readout { display: flex; align-items: baseline; gap: 40px; font-variant-numeric: tabular-nums; }
.readout .date { font-family: var(--serif); font-size: 64px; min-width: 7ch; }
.readout .count { font-size: 26px; color: var(--ink-soft); }
.interlude {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 72px;
  font-style: italic;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  opacity: 0;
  transition: opacity 260ms ease;
  pointer-events: none;
}
.interlude.show { opacity: 1; }

/* ---- charts ---- */

.axis text, .chart-label { font-family: var(--sans); font-size: 18px; fill: var(--ink-soft); }
.axis line, .axis path { stroke: #B9C2CE; }
.chart-line { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linejoin: round; }
.chart-area { fill: var(--heat-2); opacity: 0.12; }
.gap-band { fill: var(--ink); opacity: 0.05; }
.gap-label { font-family: var(--serif); font-style: italic; font-size: 26px; fill: var(--ink-soft); }
.gap-sub { font-family: var(--sans); font-size: 18px; fill: var(--ink-soft); }
.chapter-label { font-family: var(--serif); font-size: 28px; fill: var(--ink); }
.chapter-sub { font-family: var(--sans); font-size: 18px; fill: var(--ink-soft); }
.milestone circle { fill: var(--paper); stroke: var(--ink); stroke-width: 3; }
.milestone text { font-size: 18px; fill: var(--ink); }
.bar-total { fill: var(--cell-empty); }
.bar-label { font-size: 22px; fill: var(--ink); }
.bar-value { font-size: 22px; fill: var(--ink-soft); font-variant-numeric: tabular-nums; }
.dot-other { fill: #C3CBD5; opacity: 0.7; }
.dot-ring { fill: none; stroke: var(--ink); stroke-width: 2.5; }
.dot-label { font-size: 19px; fill: var(--ink); paint-order: stroke; stroke: var(--paper); stroke-width: 5px; stroke-linejoin: round; }

.empty-state {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 26px;
  color: var(--ink-soft);
}
.empty-state code { font-family: var(--mono); font-size: 0.9em; color: var(--ink); }

/* ---- draft slides: the outline, still to be built ---- */

.draft-list {
  margin: 40px 0 0;
  padding: 0 0 0 1.1em;
  font-size: 30px;
  line-height: 1.5;
  max-width: 48ch;
  color: var(--ink-soft);
}
.draft-mark {
  position: absolute;
  top: 40px;
  right: 48px;
  font-size: 18px;
  padding: 6px 14px;
  border: 2px dashed currentColor;
  border-radius: 6px;
  color: var(--ink-soft);
}

/* ---- developer section: the shell's palette ---- */

.slide[data-theme="dev"] {
  background: var(--dev-bg);
  color: var(--dev-text);
}
.slide[data-theme="dev"] h1,
.slide[data-theme="dev"] h2 { font-family: var(--mono); font-weight: 600; letter-spacing: -0.02em; }
.slide[data-theme="dev"] h2 { font-size: 52px; color: var(--dev-accent); }
.slide[data-theme="dev"] h1 { font-size: 88px; color: var(--dev-accent); }
.slide[data-theme="dev"] .lede,
.slide[data-theme="dev"] .draft-list,
.slide[data-theme="dev"] .draft-mark { color: var(--dev-muted); }
.slide[data-theme="dev"] .lede { font-family: var(--sans); }
.prompt { font-family: var(--mono); font-size: 32px; color: var(--dev-text); margin-top: 48px; }
.prompt .sym { color: var(--dev-accent); }
.prompt .path { color: var(--dev-blue); }

/* ---- chrome: counter, notes, slide index, nav buttons ---- */

.counter {
  position: absolute;
  right: 48px;
  bottom: 32px;
  font-size: 18px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  z-index: 2;
}
.stage[data-theme="dev"] .counter { color: var(--dev-muted); }

.notes { display: none; }

/* The speaker notes: a pop-up card at the bottom right, raised clear of the nav buttons
   (bottom-left, 12px + one button high) so neither ever covers the other. */
.notes-panel {
  position: fixed;
  right: 16px;
  bottom: 64px;
  width: min(620px, calc(100vw - 32px));
  max-height: min(60vh, calc(100vh - 96px));
  display: flex;
  flex-direction: column;
  background: #0F1726F7;
  color: #E8ECF2;
  font: 17px/1.5 var(--sans);
  border: 1px solid #2C3A52;
  border-radius: 10px;
  box-shadow: 0 12px 32px #0008;
  z-index: 10;
}
.notes-panel[hidden] { display: none; }
.notes-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 10px 8px 18px; border-bottom: 1px solid #2C3A52;
  font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase; color: #9FB0C8;
}
.notes-head button {
  font: 22px/1 var(--sans); width: 32px; height: 32px; border-radius: 6px;
  border: 1px solid transparent; background: transparent; color: #E8ECF2; cursor: pointer;
}
.notes-head button:hover, .notes-head button:focus-visible { border-color: #2C3A52; background: #16233B; }
.notes-body { overflow: auto; padding: 14px 18px 16px; }
.notes-body p { margin: 0 0 8px; }
.notes-body p:last-child { margin-bottom: 0; }
.notes-body p.pn { padding: 10px 12px; background: #16233B; border-left: 3px solid var(--heat-1); border-radius: 4px; }

/* The slide index: one thumbnail per slide, in the deck's order, popped up over the nav buttons
   as the notes are. A panel, not a strip along the bottom: it covers nothing while closed,
   and its grid wraps to a phone's width. */
.index-panel {
  position: fixed;
  left: 16px;
  bottom: 64px;
  width: min(860px, calc(100vw - 32px));
  max-height: min(70vh, calc(100vh - 96px));
  display: flex;
  flex-direction: column;
  background: #0F1726F7;
  color: #E8ECF2;
  font: 17px/1.5 var(--sans);
  border: 1px solid #2C3A52;
  border-radius: 10px;
  box-shadow: 0 12px 32px #0008;
  z-index: 11;
}
.index-panel[hidden] { display: none; }
.index-panel .notes-head span { text-transform: none; letter-spacing: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.index-grid {
  --thumb-width: 132px;
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--thumb-width));
  grid-auto-rows: calc(var(--thumb-width) * 9 / 16);
  justify-content: center;
  gap: 8px;
  padding: 12px;
  overflow: auto;
}
/* A small slide: the paper of the story, or the dark of the developer section. */
.index-grid button {
  position: relative;
  overflow: hidden;
  padding: 0;
  font: 13px var(--sans);
  font-variant-numeric: tabular-nums;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid #2C3A52;
  border-radius: 4px;
  cursor: pointer;
}
.index-grid button[data-theme="dev"] { background: var(--dev-bg); color: var(--dev-text); border-color: var(--dev-border); }
/* The slide's own size, scaled down to the button's width: a thumbnail is the slide itself. */
.index-thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 1600px;
  height: 900px;
  transform: scale(calc(132 / 1600));
  transform-origin: 0 0;
  pointer-events: none;
}
.index-thumb * { animation: none !important; transition: none !important; }
.index-number {
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 20px;
  padding: 0 4px;
  background: #0F1726D9;
  color: #E8ECF2;
  border-radius: 3px;
}
.index-grid button:hover { border-color: var(--heat-1); }
.index-grid button:focus-visible { outline: 3px solid var(--heat-1); outline-offset: 1px; }
.index-grid button[aria-current="true"] { border-color: var(--heat-1); box-shadow: 0 0 0 2px var(--heat-1); }

.nav {
  position: fixed;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
  z-index: 11;
  opacity: 0.35;
  transition: opacity 150ms;
}
.nav:hover, .nav:focus-within { opacity: 1; }
.figure .nav, .figure .counter, .figure .notes-panel, .figure .index-panel { display: none; }
.nav button {
  font: 15px var(--sans);
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #2C3A52;
  background: #16233B;
  color: #E8ECF2;
  cursor: pointer;
}
.nav button:focus-visible { outline: 3px solid var(--heat-1); outline-offset: 2px; }
.nav button[aria-pressed="true"] { border-color: var(--heat-1); }
.nav button[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  :root:not(.motion-on) :is(.cell.lit) { animation: none; }
  :root:not(.motion-on) :is(.interlude) { transition: none; }
}

@media print {
  html, body { overflow: visible; background: white; }
  .viewport { position: static; display: block; }
  .stage { position: static; margin: 0; transform: none !important; overflow: visible; height: auto; }
  .slide { display: flex !important; position: relative; height: 900px; page-break-after: always; }
  .nav, .notes-panel, .index-panel, .counter { display: none !important; }
}

.slide code { font-family: var(--mono); font-size: 0.86em; color: var(--ink); }
.slide[data-theme="dev"] code { color: var(--dev-amber); }

/* ---- mini-stories: a visual on the left, the narration on the right ---- */

.story { flex: 1; min-height: 0; display: grid; grid-template-columns: 640px 1fr; gap: 72px; margin-top: 32px; }
.story-visual { position: relative; min-height: 0; }
.story-visual svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.story-side { display: flex; flex-direction: column; justify-content: center; }
.story-step { font-family: var(--serif); font-size: 52px; line-height: 1.12; margin: 0 0 20px; }
.story-tally { font-size: 22px; color: var(--ink-soft); font-variant-numeric: tabular-nums; margin: 20px 0 0; }

.sv rect { fill: #FFFFFF; stroke: var(--rule); stroke-width: 1.5; transition: fill 240ms ease, stroke 240ms ease; }
.sv text { font-family: var(--serif); font-size: 27px; fill: var(--ink); transition: fill 240ms ease, opacity 240ms ease; font-variant-numeric: lining-nums; }
.sv line { stroke: var(--heat-4); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.sv.one text { opacity: 0.3; }
.sv.crossed text { opacity: 0.28; }
.sv.crossed line { stroke-dashoffset: 0; }
.sv.crossed.fresh line { animation: strike 260ms ease-out var(--d, 0ms) both; }
.sv.crossed.fresh text { animation: fade 260ms ease-out var(--d, 0ms) both; }
.sv.prime rect { fill: var(--ink); stroke: var(--ink); }
.sv.prime text { fill: var(--paper); }
.sv.current rect { stroke: var(--heat-4); stroke-width: 5; }
@keyframes strike { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes fade { from { opacity: 1; } to { opacity: 0.28; } }

.slide.racing .story-tally { display: none; }
.race { margin-top: 28px; display: flex; flex-direction: column; gap: 22px; }
.race-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 20px; align-items: baseline; }
.race-name { grid-column: 1 / -1; font-size: 22px; color: var(--ink-soft); }
.race-row .bar { height: 26px; background: var(--cell-empty); border-radius: 4px; overflow: hidden; }
.race-row .bar i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 4px; }
.race-row[data-race="trial"] .bar i { background: var(--ink-soft); }
.race-row .time { font-family: var(--serif); font-size: 34px; font-variant-numeric: tabular-nums; min-width: 4.5ch; text-align: right; }
.race-row .ops { grid-column: 1 / -1; font-size: 19px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.verdict { font-family: var(--serif); font-size: 30px; line-height: 1.3; margin: 8px 0 0; min-height: 2.6em; }

@media (prefers-reduced-motion: reduce) {
  :root:not(.motion-on) :is(.sv.crossed.fresh line, .sv.crossed.fresh text) { animation: none; }
}
.race[hidden] { display: none; }

/* ---- lattice paths ---- */

.lp-layer { opacity: 0; transition: opacity 320ms ease; }
.lp-layer.on { opacity: 1; }
.lp-grid { stroke: #B9C2CE; stroke-width: 2; }
.lp-route { fill: none; stroke: var(--ink); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 0; }
.lp-routes.play .lp-route { animation: strike 520ms ease-in-out var(--d, 0ms) both; }
.lp-end { fill: var(--ink); }

.lp-tilt { transform-box: view-box; transform-origin: 350px 350px; transition: transform 1100ms cubic-bezier(.6, 0, .25, 1); }
.lp-counted.tilted .lp-tilt { transform: rotate(45deg) scale(0.74); }
.lp-node circle { fill: var(--paper); stroke: #C9D1DB; stroke-width: 2; transition: fill 240ms ease, stroke 240ms ease; }
.lp-node text { font-family: var(--serif); font-size: 25px; fill: var(--ink); opacity: 0; font-variant-numeric: lining-nums;
  transform-box: fill-box; transform-origin: center; transition: transform 1100ms cubic-bezier(.6, 0, .25, 1); }
.lp-node text.small { font-size: 20px; }
.lp-node.shown circle { fill: #FFFFFF; stroke: var(--ink); }
.lp-node.shown text { opacity: 1; }
.lp-node.fresh text { animation: rise 360ms ease-out var(--d, 0ms) both; }
.lp-counted.tilted .lp-node text { transform: rotate(-45deg); }
.lp-node.focus circle { fill: var(--ink); }
.lp-node.focus text { fill: var(--paper); }
.lp-node.source circle { stroke: var(--heat-4); stroke-width: 5; }
.lp-counted.no-motion .lp-tilt, .lp-counted.no-motion .lp-node text { transition: none; }
@keyframes rise { from { opacity: 0; } to { opacity: 1; } }

.lp-dot { fill: var(--ink); transform-box: fill-box; transform-origin: center; }
.lp-big.play .lp-dot { animation: grow 300ms ease-out var(--d, 0ms) both; }
.lp-goal { fill: none; stroke: var(--heat-4); stroke-width: 4; }
@keyframes grow { from { transform: scale(0); } to { transform: scale(1); } }

.lp-table { margin-top: 28px; border-collapse: collapse; font-size: 26px; font-variant-numeric: tabular-nums; }
.lp-table th { text-align: left; font-weight: 400; font-size: 19px; color: var(--ink-soft); padding: 0 48px 8px 0; }
.lp-table td { padding: 8px 48px 8px 0; border-top: 1px solid #C9D1DB; }
.lp-table td:first-child { font-family: var(--serif); }
.lp-table td:last-child { text-align: right; padding-right: 0; }
.lp-table[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  :root:not(.motion-on) :is(.lp-routes.play .lp-route, .lp-node.fresh text, .lp-big.play .lp-dot) { animation: none; }
  :root:not(.motion-on) :is(.lp-tilt, .lp-node text) { transition: none; }
}

/* ---- the triangle ---- */

.tr-layer { opacity: 0; transition: opacity 320ms ease; }
.tr-layer.on { opacity: 1; }
.tr-edge { stroke: #C9D1DB; stroke-width: 3; transition: stroke 240ms ease, opacity 240ms ease; }
.tr-edge.chosen { stroke: var(--heat-4); stroke-width: 6; }
.tr-edge.spent { opacity: 0.4; }
.tr-trail { fill: none; stroke: var(--ink); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.tr-trail.best { stroke: var(--heat-4); }
.tr-node circle { fill: #FFFFFF; stroke: var(--ink); stroke-width: 2.5; transition: fill 240ms ease, opacity 240ms ease; }
.tr-value { font-family: var(--serif); font-size: 36px; fill: var(--ink); font-variant-numeric: lining-nums; }
.tr-node.folded circle { fill: var(--heat-1); }
.tr-node.spent circle { stroke: #C9D1DB; }
.tr-node.spent .tr-value { fill: #A3AEBD; }
.tr-node.folded.spent circle { fill: #D3E2EE; }
.tr-node.folded.spent .tr-value { fill: #7D8DA3; }
.tr-node.answer circle { fill: var(--ink); }
.tr-node.answer .tr-value { fill: var(--paper); }

.tr-dots circle { fill: #C9D1DB; }
.tr-big.folding .tr-dots circle { animation: fold-dot 260ms ease-out var(--d, 0ms) both; }
.tr-big.folded-all .tr-dots circle { fill: var(--ink); }
@keyframes fold-dot { from { fill: #C9D1DB; } to { fill: var(--ink); } }

@media (prefers-reduced-motion: reduce) {
  :root:not(.motion-on) :is(.tr-big.folding .tr-dots circle) { animation: none; fill: var(--ink); }
}

/* ---- Collatz ---- */

.cz-layer { opacity: 0; transition: opacity 320ms ease; }
.cz-layer.on { opacity: 1; }
.cz-line { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; }
.cz-layer.play .cz-line { animation: strike 2400ms ease-in-out both; }
.cz-six.play .cz-line { animation-duration: 1400ms; }
.cz-point { fill: #FFFFFF; stroke: var(--ink); stroke-width: 3; }
.cz-value { font-family: var(--serif); font-size: 24px; fill: var(--ink); paint-order: stroke; stroke: var(--paper); stroke-width: 6px; stroke-linejoin: round; }
.cz-peak { fill: none; stroke: var(--heat-4); stroke-width: 3.5; }
.cz-note { font-size: 20px; fill: var(--ink); paint-order: stroke; stroke: var(--paper); stroke-width: 6px; stroke-linejoin: round; }
.cz-dots circle { fill: var(--heat-2); opacity: 0.55; }
.cz-cloud.play .cz-dots { animation: rise 900ms ease-out both; }
.cz-cloud.muted .cz-dots circle { opacity: 0.2; }
.cz-bar-all { fill: var(--cell-empty); }
.cz-bar-new { fill: var(--ink); }
.cz-memo.play .cz-bar-new { animation: rise 300ms ease-out var(--d, 0ms) both; }
.cz-bar-label { font-size: 26px; fill: var(--ink); }
.cz-bar-value { font-family: var(--serif); font-size: 34px; fill: var(--ink); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  :root:not(.motion-on) :is(.cz-layer.play .cz-line, .cz-cloud.play .cz-dots, .cz-memo.play .cz-bar-new) { animation: none; }
}

/* ---- big numbers ---- */

.bn-stage { position: absolute; inset: 0; }
.bn-layer { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center;
  opacity: 0; visibility: hidden; transition: opacity 320ms ease, visibility 0s linear 320ms; }
.bn-layer.on { opacity: 1; visibility: visible; transition: opacity 320ms ease; }

.bn-ladder { gap: 4px; }
.bn-rung { display: grid; grid-template-columns: 96px 1fr; align-items: baseline; font-family: var(--serif);
  font-variant-numeric: lining-nums tabular-nums; border-bottom: 1px solid var(--rule); padding: 4px 0; }
.bn-exp { font-size: 26px; color: var(--ink-soft); }
.bn-val { font-size: 34px; color: var(--ink); }
.bn-ladder.play .bn-rung { animation: rise 260ms ease-out var(--d, 0ms) both; }

.bn-display { align-self: flex-start; display: flex; align-items: baseline; gap: 18px; padding: 28px 36px;
  background: #DDE5D5; border: 3px solid var(--ink); border-radius: 14px; font-family: var(--mono); color: #1E2A1A; }
.bn-mantissa { font-size: 48px; letter-spacing: 0.04em; }
.bn-power { font-size: 34px; }
.bn-lost { font-family: var(--serif); font-size: 32px; color: var(--ink-soft); margin: 36px 0 0; }

.bn-digits { display: grid; grid-template-columns: repeat(18, 1fr); align-content: center; row-gap: 2px; }
.bn-d { font-family: var(--serif); font-size: 27px; line-height: 1.18; text-align: center; color: var(--ink);
  font-variant-numeric: lining-nums tabular-nums; border-radius: 3px; transition: background 300ms ease, color 300ms ease; }
.bn-d.atom { background: var(--heat-2); color: var(--paper); }
.bn-digits.atoms .bn-d:not(.atom) { color: var(--ink-soft); }

.bn-sum-table { display: grid; grid-template-columns: repeat(var(--cols), 72px); justify-content: center;
  font-family: var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.bn-sum-row { display: contents; }
.bn-sum-row span { text-align: center; font-size: 64px; line-height: 1.25; }
.bn-sum-row.carries span { font-size: 28px; line-height: 1.4; color: var(--heat-4); }
.bn-sum-row.times span { border-bottom: 3px solid var(--ink); }
.bn-sum-row .op { color: var(--ink-soft); }
.bn-sum-row.result span.out { font-weight: 500; }
.bn-sum-row span.play { animation: rise 300ms ease-out var(--d, 0ms) both; }

@media (prefers-reduced-motion: reduce) {
  :root:not(.motion-on) :is(.bn-ladder.play .bn-rung, .bn-sum-row span.play) { animation: none; }
}

/* ---- Su Doku ---- */

.sd-stage { position: absolute; inset: 0; }
.sd-layer { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity 320ms ease, visibility 0s 320ms; }
.sd-layer.on { opacity: 1; visibility: visible; transition: opacity 320ms ease; }
.sd-board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sd-cell rect { fill: #FFFFFF; transition: fill 240ms ease; }
.sd-thin { stroke: #C9D1DB; stroke-width: 1.5; }
.sd-thick { stroke: var(--ink); stroke-width: 3.5; stroke-linecap: square; }
.sd-digit { font-family: var(--serif); font-size: 38px; fill: var(--ink); font-variant-numeric: lining-nums; }
.sd-cell.given .sd-digit { font-weight: 500; }
.sd-cell.given rect { fill: #EEF1F5; }
.sd-cell.guessed .sd-digit { fill: var(--ink-soft); opacity: 0.75; }
.sd-cell.wrong .sd-digit { fill: var(--heat-4); }
.sd-cell.placed .sd-digit { fill: var(--heat-2); }
.sd-cell.fresh rect { fill: #DCE8F3; }
.sd-cell.fresh .sd-digit { animation: rise 420ms ease-out both; }
.sd-cell.corner rect { fill: var(--ink); }
.sd-cell.corner .sd-digit { fill: var(--paper); }
.sd-mark { font-family: var(--sans); font-size: 15px; fill: var(--ink-soft); opacity: 0; transition: opacity 400ms ease; }
.sd-mark.on { opacity: 1; }

.sd-ladder { display: flex; flex-direction: column; justify-content: center; gap: 30px; }
.sd-rung { display: flex; flex-direction: column; gap: 6px; opacity: 0; transition: opacity 400ms ease; }
.sd-rung.on { opacity: 1; }
.sd-rule { font-size: 22px; color: var(--ink-soft); }
.sd-num { font-family: var(--mono); font-size: 13px; line-height: 1.4; color: var(--ink); white-space: nowrap;
  font-variant-numeric: tabular-nums; }
.sd-sci { font-family: var(--serif); font-size: 30px; font-variant-numeric: lining-nums; }
.sd-rung.final .sd-num, .sd-rung.final .sd-sci { color: var(--heat-4); }

.sd-table { margin-top: 28px; border-collapse: collapse; font-size: 23px; font-variant-numeric: tabular-nums; }
.sd-table th { text-align: left; font-weight: 400; font-size: 19px; color: var(--ink-soft); padding: 0 32px 8px 0; }
.sd-table td { padding: 8px 32px 8px 0; border-top: 1px solid #C9D1DB; }
.sd-table td:not(:first-child), .sd-table th:not(:first-child) { text-align: right; }
.sd-table td:last-child, .sd-table th:last-child { padding-right: 0; }
.sd-table small { display: block; font-size: 17px; color: var(--ink-soft); }
.sd-table[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  :root:not(.motion-on) :is(.sd-cell.fresh .sd-digit) { animation: none; }
  :root:not(.motion-on) :is(.sd-layer, .sd-rung, .sd-mark) { transition: none; }
}

/* ---- the opener ---- */

.ob-table { display: grid; grid-template-columns: 250px 1fr 280px 210px; gap: 0 18px; align-content: center; }
.ob-head, .ob-row { display: contents; }
.ob-head span { font-size: 19px; color: var(--ink-soft); padding-bottom: 10px; }
.ob-row > span { padding: 14px 0; border-top: 1px solid #C9D1DB; opacity: 0; transition: opacity 300ms ease; align-self: stretch; display: flex; align-items: center; }
.ob-row.on > span { opacity: 1; }
.ob-limit { font-family: var(--serif); font-size: 26px; }
.ob-bar i { display: block; height: 18px; background: var(--ink-soft); border-radius: 3px; width: 0; transition: width 600ms ease-out; }
.ob-bar { min-width: 0; }
.ob-bar i { flex: none; }
.ob-slow { font-size: 21px; color: var(--ink); white-space: nowrap; }
.ob-fast { font-size: 21px; color: var(--heat-2); white-space: nowrap; }
.slide[data-viz="opener"] .story { grid-template-columns: 900px 1fr; gap: 56px; }
.slide[data-viz="opener"] .ob-head span:nth-child(2) { grid-column: 2 / 4; }
.slide[data-viz="opener"] .ob-head span:nth-child(3) { display: none; }

/* ---- the Project Euler intro ---- */

.pe-intro { flex: 1; display: grid; grid-template-columns: 620px 1fr; gap: 72px; align-items: center; }
.pe-card { background: #FFFFFF; border: 2px solid var(--ink); border-radius: 10px; padding: 36px 40px; }
.pe-card-title { font-family: var(--serif); font-size: 34px; margin: 0 0 18px; }
.pe-card-body { font-family: var(--serif); font-size: 25px; line-height: 1.5; color: var(--ink); margin: 0; }
.pe-answer { font-size: 22px; margin: 28px 0 0; color: var(--ink-soft); display: flex; align-items: center; gap: 14px; }
.pe-blank { display: inline-block; width: 220px; height: 40px; border: 2px solid #C9D1DB; border-radius: 6px; }
.pe-facts { margin: 0; padding: 0 0 0 1.1em; font-size: 27px; line-height: 1.45; color: var(--ink); max-width: 30ch; }
.pe-facts li + li { margin-top: 16px; }

/* ---- harder and rarer: two charts side by side ---- */

.pair { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 72px; margin-top: 28px; }
.pair-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pair-head { font-family: var(--serif); font-size: 30px; line-height: 1.2; margin: 0; }
.pair .viz { margin-top: 20px; }
.pair .caption { margin: 12px 0 0; font-size: 19px; }

/* ---- the story behind the solver: challenge → feature ---- */

.ch-lede { margin-top: 8px; font-size: 26px; }
.ch-list { list-style: none; margin: 24px 0 0; padding: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.ch-list li {
  display: grid; grid-template-columns: 560px 1fr; gap: 0 56px; align-items: center;
  padding: 12px 24px; border-left: 4px solid transparent; border-radius: 4px;
  opacity: 0.4; transition: opacity 0.3s, background-color 0.3s, border-color 0.3s;
}
.ch-list li.done { opacity: 0.85; }
.ch-list li.now { opacity: 1; background: #FFFFFF; border-left-color: var(--heat-2); box-shadow: 0 6px 18px #16233B14; }
.ch-problem { font-family: var(--serif); font-size: 28px; line-height: 1.2; margin: 0; position: relative; }
.ch-problem::after { content: "→"; position: absolute; right: -44px; top: 0; font-family: var(--sans); color: var(--heat-2); }
.ch-feature { font-size: 21px; line-height: 1.35; color: var(--ink-soft); margin: 0; }
.ch-feature code { color: var(--heat-2); font-size: 0.9em; white-space: nowrap; }
.ch-gens { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; }
.ch-gen { position: relative; font-size: 18px; line-height: 1.2; color: var(--ink-soft); }
.ch-gen s { text-decoration-color: #9AA6B6; }
.ch-gen small { display: block; margin-top: 2px; font-size: 15px; }
.ch-gen + .ch-gen::before { content: "→"; position: absolute; left: -22px; top: 0; color: #9AA6B6; }
.ch-gen-now { color: var(--ink); text-decoration: none; font-weight: 700; }
.ch-gen-now small { font-weight: 400; color: var(--ink-soft); }
@media (prefers-reduced-motion: reduce) { :root:not(.motion-on) :is(.ch-list li) { transition: none; } }

/* ---- the framework: from problem to solution ---- */

.fw-flow { list-style: none; margin: 40px 0 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; }
.fw-flow li {
  display: flex; flex-direction: column; gap: 8px;
  padding: 20px 20px 22px; border: 2px solid #C9D1DB; border-radius: 10px; background: #FFFFFF;
  opacity: 0.45; transition: opacity 0.3s, border-color 0.3s, transform 0.3s;
}
.fw-flow li.done { opacity: 1; }
.fw-flow li.now { opacity: 1; border-color: var(--heat-2); transform: translateY(-6px); box-shadow: 0 8px 20px #16233B1F; }
.fw-n { font-size: 18px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.fw-verb { font-family: var(--serif); font-size: 34px; line-height: 1.1; }
.fw-flow code { font-size: 19px; color: var(--heat-2); }
.fw-side { flex: 1; display: flex; flex-direction: column; justify-content: center; max-width: 1100px; }
.fw-side .caption { font-size: 26px; max-width: 64ch; }
.fw-side .caption code { color: var(--heat-2); }
@media (prefers-reduced-motion: reduce) { :root:not(.motion-on) :is(.fw-flow li) { transition: none; } :root:not(.motion-on) :is(.fw-flow li.now) { transform: none; } }

/* ---- what changed ---- */

.wc-list { flex: 1; display: grid; grid-template-columns: auto 1fr; gap: 6px 40px; align-content: center; }
.wc-row { display: contents; }
.wc-n { font-family: var(--serif); font-size: 76px; line-height: 1.12; text-align: right; font-variant-numeric: lining-nums tabular-nums; }
.wc-text { font-size: 28px; color: var(--ink-soft); align-self: center; max-width: 40ch; }

/* ---- the vault ---- */

.vault-visual { position: relative; min-height: 0; }
.vault-pane { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center;
  opacity: 0; visibility: hidden; transition: opacity 320ms ease, visibility 0s linear 320ms; }
.vault-pane.on { opacity: 1; visibility: visible; transition: opacity 320ms ease; }
.vault-label { font-size: 20px; color: var(--ink-soft); margin: 0 0 10px; }
.vault-code pre { margin: 0; padding: 24px 26px; background: #FFFFFF; border: 2px solid var(--ink); border-radius: 10px;
  font: 17px/1.5 var(--mono); color: var(--ink); white-space: pre; overflow: hidden; height: 470px; }
.vault-code pre.sealed { color: var(--ink-soft); word-break: break-all; }
.vk-master { align-self: center; font-family: var(--serif); font-size: 34px; padding: 18px 32px; background: var(--ink); color: var(--paper); border-radius: 10px; }
.vk-holders { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 96px; position: relative; }
.vk-holders::before { content: ""; position: absolute; left: 16.6%; right: 16.6%; top: -48px; border-top: 3px solid var(--ink); }
.vk-holder { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 23px; }
.vk-holder::before { content: ""; position: absolute; top: -48px; height: 48px; border-left: 3px solid var(--ink); }
.vk-lock { padding: 14px 18px; border: 3px solid var(--heat-4); border-radius: 10px; font-family: var(--serif); font-size: 24px; background: #FFFFFF; }
.vk-note { text-align: center; font-size: 22px; color: var(--ink-soft); margin: 40px 0 0; }
.vault-keys::before { content: ""; align-self: center; height: 48px; border-left: 3px solid var(--ink); order: 1; margin-bottom: -96px; }
.vk-holders { order: 2; }
.vk-note { order: 3; }
.vault-map svg { width: 100%; }
.vm-open { fill: var(--heat-1); }
.vm-locked { fill: var(--ink); }

/* ---- working with AI ---- */

.ai-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 64px; margin-top: 36px; }
.ai-head { font-family: var(--serif); font-size: 34px; margin: 0 0 10px; }
.ai-col ul { margin: 0; padding-left: 1.1em; font-size: 25px; line-height: 1.5; color: var(--ink); }
.ai-example { display: grid; grid-template-columns: 1fr 1fr; gap: 64px; margin-top: 64px; align-items: center; }
.ai-label { margin: 0 0 -48px; font-size: 19px; color: var(--ink-soft); align-self: end; }
.ai-code { margin: 0; padding: 20px 24px; background: #FFFFFF; border: 2px solid var(--ink); border-radius: 10px; font: 17px/1.5 var(--mono); }
.ai-notes { margin: 0; font-family: var(--serif); font-style: italic; font-size: 23px; line-height: 1.5; color: var(--ink-soft); }

/* ---- live demo ---- */

.demo { flex: 1; display: grid; grid-template-columns: 520px 1fr; gap: 72px; align-items: center; }
.demo-number { font-family: var(--serif); font-size: 300px; line-height: 1; text-align: center; font-variant-numeric: lining-nums tabular-nums;
  border: 3px solid var(--ink); border-radius: 24px; height: 400px; display: grid; place-items: center; background: #FFFFFF; }
.demo-title:empty { display: none; }
.demo-steps { margin: 32px 0 0; padding-left: 1.3em; font-size: 25px; line-height: 1.5; color: var(--ink-soft); }

/* ---- developer section ---- */

.dev-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 32px; min-height: 0; }
.dev-label { font: 17px var(--mono); color: var(--dev-muted); margin: 0 0 10px; }
.dev-code { margin: 0; padding: 18px 22px; background: var(--dev-panel); border: 1px solid var(--dev-border); border-radius: 8px;
  font: 16px/1.5 var(--mono); color: var(--dev-text); white-space: pre; overflow: hidden; }
.dev-code.dev-big { font-size: 22px; line-height: 1.55; white-space: pre-wrap; min-height: 230px; }
.dev-code + .dev-code { margin-top: 14px; }
.dev-bad { border-left: 4px solid #EF4444; }
.dev-good { border-left: 4px solid #22C55E; }
.dev-foot { margin: auto 0 0; font-size: 23px; line-height: 1.5; color: var(--dev-muted); max-width: 70ch; }
.dev-points { margin: 18px 0 0; padding-left: 1.1em; font-size: 21px; line-height: 1.55; color: var(--dev-text); }
.slide[data-theme="dev"] .dev-foot code, .slide[data-theme="dev"] .dev-points code { font-size: 0.9em; }

.dev-box { background: var(--dev-panel); border: 1px solid var(--dev-border); border-radius: 10px; padding: 18px 22px;
  font: 600 24px var(--mono); color: var(--dev-amber); display: flex; flex-direction: column; gap: 6px; }
.dev-box small { font: 18px/1.45 var(--sans); color: var(--dev-muted); }
.dev-flow { display: grid; grid-template-columns: 1fr auto 1fr; gap: 24px; align-items: center; margin-top: 40px; }
.dev-flow-4 { grid-template-columns: 1fr auto 1fr auto 1fr; }
.dev-arrows { display: flex; flex-direction: column; gap: 10px; font: 19px var(--mono); color: var(--dev-accent); text-align: center; }
.dev-attr { margin-top: 28px; font-size: 20px; }
.dev-chain { display: flex; align-items: center; gap: 16px; margin-top: 36px; flex-wrap: wrap; }
.dev-key { display: flex; flex-direction: column; gap: 4px; padding: 14px 18px; border: 2px solid var(--dev-accent); border-radius: 10px;
  font: 600 21px var(--mono); color: var(--dev-text); }
.dev-key small { font: 16px var(--sans); color: var(--dev-muted); }
.dev-then { font: 18px var(--mono); color: var(--dev-muted); }
.dev-chain-5 { gap: 12px; flex-wrap: nowrap; align-items: stretch; }
.dev-chain-5 .dev-key { flex: 1 1 0; min-width: 0; padding: 12px 14px; font-size: 19px; }
.dev-chain-5 .dev-key small { font-size: 15px; }
.dev-chain-5 .dev-then { font-size: 16px; align-self: center; }
/* Who changes each secret in the chain above: quieter than the chain (a thin, muted
   border), so it reads as a footnote to it rather than a fifth step. */
.dev-rotate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 28px; }
.dev-turn { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px;
  border: 1px solid var(--dev-border); border-radius: 10px; }
.dev-turn b { font: 600 18px var(--mono); }
.dev-turn i { font: italic 15px var(--sans); color: var(--dev-accent); }
.dev-turn small { font: 15px/1.4 var(--sans); color: var(--dev-muted); }
.dev-turn code { font-size: 0.9em; }

.dev-web { display: flex; flex-direction: column; align-items: stretch; margin-top: 28px; gap: 6px; }
.dev-wide { align-self: center; width: 760px; }
.dev-down { text-align: center; font: 18px var(--mono); color: var(--dev-accent); }
.dev-users { display: grid; grid-template-columns: 1fr 1fr 0.8fr; gap: 20px; }
.dev-side-box { border-style: dashed; color: var(--dev-blue); }
.dev-users-4 { grid-template-columns: 1fr 1fr 1fr 0.9fr; }
.dev-stack { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.dev-stack .dev-down { font-size: 16px; }
.dev-layers { grid-template-columns: 220px 1fr; gap: 18px 40px; margin-top: 32px; }

.dev-gates { margin-top: 48px; }
.dev-thrown { display: grid; grid-template-columns: 300px 1fr; gap: 22px 40px; margin: 40px 0 0; }
.dev-thrown dt { font: 600 25px var(--mono); color: var(--dev-amber); }
.dev-thrown dd { margin: 0; font-size: 23px; line-height: 1.5; color: var(--dev-text); max-width: 60ch; }
.slide[data-theme="dev"] h2 { max-width: none; }
.slide[data-theme="dev"] code, .dev-code, .dev-label, .dev-box, .dev-key, .dev-thrown dt, .prompt { font-variant-ligatures: none; }
.dev-pair > * { min-width: 0; }
.dev-code { font-size: 15px; white-space: pre-wrap; }
.dev-points-tight { font-size: 19px; line-height: 1.45; margin-top: 14px; }
.dev-points-tight li + li { margin-top: 4px; }

/* ---- the problem reference: one footer link on every example slide (deck.js problemRef) ---- */

.ref {
  position: absolute;
  right: 136px;   /* beside the counter; the window's nav buttons own the bottom-left corner */
  bottom: 32px;
  margin: 0;
  font-size: 18px;
  color: var(--ink-soft);
  z-index: 2;
}
.ref a { color: inherit; text-decoration: underline; text-decoration-color: #B9C2CE; text-underline-offset: 3px; }
.ref a:hover, .ref a:focus-visible { color: var(--heat-2); text-decoration-color: currentColor; }
.ref a::after { content: " ↗"; }
.slide[data-theme="dev"] .ref { color: var(--dev-muted); }
.slide[data-theme="dev"] .ref a:hover, .slide[data-theme="dev"] .ref a:focus-visible { color: var(--dev-blue); }
