/* Slideware engine: layout, steps, components. Colours, fonts and the brand mark come from a theme (themes/<name>/theme.css). Static HTML first; slides.js upgrades it to a deck. */
:root {
  --ease: cubic-bezier(.2, .7, .1, 1);
  /* a light spring: overshoots about 5% and settles */
  --spring: linear(0, .06, .25 9%, .62 20%, .9 33%, 1.03 45%, 1.05 52%, 1.02 65%, 1);
  /* one design unit = 1% of slide width; set per mode below */
  --u: 1cqw;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--paper); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--accent); }
a:hover { color: var(--accent-deep); }

/* ---------- slide box ---------- */
.slide {
  position: relative;
  container-type: inline-size;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.slide > .in {
  position: absolute; inset: 0;
  padding: calc(var(--u) * 5.5) calc(var(--u) * 6.5) calc(var(--u) * 5);
  display: flex; flex-direction: column;
  font-size: calc(var(--u) * 1.9);
  line-height: 1.35;
}
.slide.dark { background: var(--ink); color: var(--paper); }
.slide.dark .kicker, .slide.dark .mute { color: var(--mute); }
.slide.green { background: var(--green); color: var(--paper); }
.slide.wash { background: var(--wash); }

/* ---------- type ---------- */
.sl { color: var(--accent); font-weight: 600; margin-right: .25em; letter-spacing: -.05em; }
.note { color: var(--orange-ink); font-family: var(--mono); font-size: calc(var(--u) * 1.05); letter-spacing: .04em; text-transform: uppercase; }
.kicker { font-family: var(--mono); font-size: calc(var(--u) * 1.15); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: calc(var(--u) * 2); }
.kicker b { color: var(--accent); font-weight: 600; }
h1 { font-size: calc(var(--u) * 6.4); font-weight: 800; letter-spacing: -.035em; line-height: 1; }
h2 { font-size: calc(var(--u) * 4); font-weight: 700; letter-spacing: -.03em; line-height: 1.05; max-width: 30ch; }
h3 { font-size: calc(var(--u) * 2.1); font-weight: 700; letter-spacing: -.01em; margin-bottom: calc(var(--u) * .8); }
p + p { margin-top: calc(var(--u) * 1); }
.big { font-size: calc(var(--u) * 2.8); line-height: 1.2; font-weight: 500; letter-spacing: -.015em; max-width: 34ch; }
.mute { color: var(--ink-2); }
.g { color: var(--green); }
em { font-style: normal; color: var(--green-deep); }
.slide.dark em, .slide.green em { color: inherit; border-bottom: .12em solid currentColor; }
.foot { margin-top: auto; font-size: calc(var(--u) * 1.1); color: var(--mute); font-family: var(--mono); }
ul.list { list-style: none; display: grid; gap: calc(var(--u) * 1.1); }
ul.list li { padding-left: calc(var(--u) * 2.2); position: relative; }
ul.list li::before { content: ''; position: absolute; left: 0; top: .55em; width: calc(var(--u) * 1.1); height: 2px; background: var(--accent); }

/* ---------- layout helpers ---------- */
.grow { flex: 1; min-height: 0; }
/* wide: a diagram slide; the title sits higher and the diagram sits in a light framed panel reaching into the side margins */
.slide.wide > .in { padding-top: calc(var(--u) * 5); }
.slide.wide .grow { margin: calc(var(--u) * 1.6) calc(var(--u) * -4.5) 0; }
/* panel: the light frame a diagram sits in; every wide slide's .grow is one, and a diagram beside other content takes the class */
.panel, .slide.wide .grow { padding: calc(var(--u) * 1.4) calc(var(--u) * 1.8); border: 1px solid var(--line); background: color-mix(in srgb, var(--wash) 50%, var(--paper)); }
.center { justify-content: center; }
.row { display: flex; gap: calc(var(--u) * 4); }
.cols { display: grid; grid-template-columns: repeat(var(--n, 2), 1fr); gap: calc(var(--u) * 3); }
.cell { border-top: 2px solid var(--ink); padding-top: calc(var(--u) * 1.2); }
.cell.g2 { border-color: var(--green); }
.stat { font-size: calc(var(--u) * 5); font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.tag { display: inline-block; font-family: var(--mono); font-size: .62em; padding: .15em .5em; border: 1px solid currentColor; text-transform: uppercase; letter-spacing: .06em; }
.logo { width: calc(var(--u) * 3); height: calc(var(--u) * 3); }
figure { margin: 0; }
figure img, figure video { width: 100%; height: 100%; object-fit: contain; display: block; border: 1px solid var(--line); }

/* ---------- code ---------- */
pre {
  position: relative;
  font-family: var(--mono); font-size: calc(var(--u) * 1.3); line-height: 1.55;
  background: var(--dark); color: var(--dark-fg);
  padding: calc(var(--u) * 1.6) calc(var(--u) * 2);
  overflow: auto; white-space: pre;
}
pre .c { color: var(--dark-mute); }
pre .k { color: var(--dark-green); }
pre .s { color: var(--dark-orange); }
pre .p { color: var(--mute); user-select: none; }
pre.scene-tip { position: absolute; top: 12%; z-index: 3; font-size: calc(var(--u) * 1.05); pointer-events: none; opacity: 0; transition: opacity .15s; }
pre.scene-tip.on { opacity: 1; }
code { font-family: var(--mono); font-size: .9em; background: var(--wash); padding: .05em .3em; }
pre code { background: none; padding: 0; font-size: 1em; }
.copy {
  position: absolute; top: calc(var(--u) * .7); right: calc(var(--u) * .7);
  font: 600 calc(var(--u) * .9) var(--mono); text-transform: uppercase; letter-spacing: .06em;
  background: transparent; color: var(--mute); border: 1px solid var(--dark-line); padding: .3em .7em; cursor: pointer;
}
.copy:hover { color: var(--paper); border-color: var(--paper); }
.copy.done { color: var(--green); border-color: var(--green); }
/* code pop: [data-pop] opens its template in a dialog, sized like the slide */
[data-pop] { cursor: zoom-in; }
dialog.pop { --u: min(1vw, 1.778vh); margin: auto; padding: 0; border: 0; background: none; max-width: 90vw; max-height: 88vh; overflow: visible; }
dialog.pop::backdrop { background: color-mix(in srgb, var(--stage) 70%, transparent); }
dialog.pop .term { font-size: calc(var(--u) * 1.5); max-height: 88vh; }
dialog.pop .term .body { overflow: auto; padding-right: calc(var(--u) * 7); }

/* ---------- diagrams ---------- */
/* fill is inherited from the root, so a fill attribute on a text or group wins */
svg.dia { width: 100%; height: 100%; overflow: visible; font-family: var(--sans); fill: var(--ink); }
svg.dia text { font-size: 14px; }
svg.dia .lbl { font-family: var(--mono); font-size: 11px; fill: var(--ink-2); letter-spacing: .06em; text-transform: uppercase; }
svg.dia .box { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; }
svg.dia .box.g { fill: var(--green-wash); stroke: var(--green-deep); }
svg.dia .box.k { fill: var(--ink); }
svg.dia .box.k + text, svg.dia text.w { fill: var(--paper); }
svg.dia .wire { fill: none; stroke: var(--ink); stroke-width: 1.5; }
svg.dia .wire.g { stroke: var(--green); stroke-width: 2.5; }
svg.dia .note { fill: var(--orange-ink); font-family: var(--mono); font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
svg.dia .band { fill: var(--band); stroke: var(--orange); stroke-dasharray: 3 4; }
/* tables: a hairline between rows, every other row washed (slides.js draws them into every g.tb; HTML tables get them here) */
svg.dia .tb .row-wash { fill: var(--wash); }
svg.dia .tb .row-line { fill: none; stroke: var(--line); stroke-width: .75; }
:where(.slide table) :where(td, th) { border-bottom: 1px solid var(--line); }
:where(.slide table tbody tr:nth-child(even)) > :where(td) { background: var(--wash); }
svg.dia .dash { fill: none; stroke: var(--ink); stroke-dasharray: 4 3; }
svg.dia .cell { fill: var(--paper); stroke: var(--line); }
svg.dia .hl { fill: var(--green-wash); stroke: none; }
svg.dia .mono, svg.dia .mono text { font-family: var(--mono); font-size: var(--fs, 12px); }
/* a flow is a dashed wire; the packets riding it show the motion */
svg.dia .flow { stroke-dasharray: 6 6; }
/* icons: <use class="ico" href="../../engine/icons.svg#i-user" x y width height/>, ink by default, s-<token> recolours */
:where(svg .ico) { stroke: var(--ink); }
:where(.slide.dark svg .ico) { stroke: var(--paper); }
/* paint: f-<token> fills, s-<token> strokes, from the theme palette. :where() keeps them at the zero specificity
   of a fill/stroke attribute, so .box, .wire, .lbl and the rest still win */
:where(.f-ink) { fill: var(--ink); } :where(.s-ink) { stroke: var(--ink); }
:where(.f-ink-2) { fill: var(--ink-2); } :where(.s-ink-2) { stroke: var(--ink-2); }
:where(.f-mute) { fill: var(--mute); } :where(.s-mute) { stroke: var(--mute); }
:where(.f-line) { fill: var(--line); } :where(.s-line) { stroke: var(--line); }
:where(.f-paper) { fill: var(--paper); } :where(.s-paper) { stroke: var(--paper); }
:where(.f-wash) { fill: var(--wash); } :where(.s-wash) { stroke: var(--wash); }
:where(.f-green) { fill: var(--green); } :where(.s-green) { stroke: var(--green); }
:where(.f-green-deep) { fill: var(--green-deep); } :where(.s-green-deep) { stroke: var(--green-deep); }
:where(.f-green-wash) { fill: var(--green-wash); } :where(.s-green-wash) { stroke: var(--green-wash); }
:where(.f-blue) { fill: var(--blue); } :where(.s-blue) { stroke: var(--blue); }
:where(.f-orange) { fill: var(--orange); } :where(.s-orange) { stroke: var(--orange); }
:where(.f-orange-ink) { fill: var(--orange-ink); } :where(.s-orange-ink) { stroke: var(--orange-ink); }
:where(.f-band) { fill: var(--band); } :where(.s-band) { stroke: var(--band); }
:where(.f-red) { fill: var(--red); } :where(.s-red) { stroke: var(--red); }
:where(.f-red-ink) { fill: var(--red-ink); } :where(.s-red-ink) { stroke: var(--red-ink); }
:where(.f-red-wash) { fill: var(--red-wash); } :where(.s-red-wash) { stroke: var(--red-wash); }
:where(.f-accent) { fill: var(--accent); } :where(.s-accent) { stroke: var(--accent); }
:where(.f-accent-deep) { fill: var(--accent-deep); } :where(.s-accent-deep) { stroke: var(--accent-deep); }
:where(.f-dark) { fill: var(--dark); } :where(.s-dark) { stroke: var(--dark); }
:where(.f-dark-fg) { fill: var(--dark-fg); } :where(.s-dark-fg) { stroke: var(--dark-fg); }
:where(.f-dark-out) { fill: var(--dark-out); } :where(.s-dark-out) { stroke: var(--dark-out); }
:where(.f-dark-orange) { fill: var(--dark-orange); } :where(.s-dark-orange) { stroke: var(--dark-orange); }
:where(.f-dark-green) { fill: var(--dark-green); } :where(.s-dark-green) { stroke: var(--dark-green); }
:where(.f-dark-2) { fill: var(--dark-2); } :where(.s-dark-2) { stroke: var(--dark-2); }
:where(.f-dark-mute) { fill: var(--dark-mute); } :where(.s-dark-mute) { stroke: var(--dark-mute); }
:where(.f-dark-line) { fill: var(--dark-line); } :where(.s-dark-line) { stroke: var(--dark-line); }
:where(.f-dark-edge) { fill: var(--dark-edge); } :where(.s-dark-edge) { stroke: var(--dark-edge); }
:where(.f-accent-wash) { fill: var(--accent-wash); } :where(.s-accent-wash) { stroke: var(--accent-wash); }
:where(.f-stage) { fill: var(--stage); } :where(.s-stage) { stroke: var(--stage); }
:where(.f-stage-line) { fill: var(--stage-line); } :where(.s-stage-line) { stroke: var(--stage-line); }

/* ---------- steps: things settle in with a spring, from blurred to sharp ---------- */
[data-step] { transition: opacity .3s var(--ease), transform .7s var(--spring), filter .55s var(--ease); }
.deck [data-step]:not(.on):not(.keep) { opacity: 0; transform: translateY(14px) scale(.985); filter: blur(6px); pointer-events: none; }
.deck [data-step].dim:not(.on):not(.keep) { opacity: .12; transform: none; filter: none; }
/* in diagrams the parts move, not the group: wires draw their length, boxes grow from their centre */
.deck svg [data-step]:not(.on) { transform: none; filter: none; }
.deck svg g[data-step] rect { transform-box: fill-box; transform-origin: center; transition: transform .7s var(--spring); }
.deck svg g[data-step]:not(.keep):not(.on) rect { transform: scale(.88); }
.deck .auto-draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); transition: stroke-dashoffset .9s var(--ease) .08s; }
.deck .on .auto-draw, .deck .auto-draw.on { stroke-dashoffset: 0; }
/* packets ride the green wires (data flows) once they are drawn */
.deck .pkt { offset-rotate: 0deg; animation: travel var(--dur, 2s) linear infinite; animation-delay: var(--delay, 0s); opacity: 0; transition: opacity .4s var(--ease) .9s; }
.deck .here .pkt { opacity: 1; }
.deck [data-step]:not(.on) > .pkt { opacity: 0; transition: none; }
.stat { font-variant-numeric: tabular-nums; }
/* a live scene (engine/scene.js) draws over the slide; its static diagram stays for ?doc, print and reduced motion */
.deck .live svg.dia { visibility: hidden; }

/* ---------- scene helpers: captions that swap per step, strokes that draw, parts that fly in ---------- */
.swapset { position: relative; }
/* every child shares one grid cell, so the set is as tall as its tallest child and nothing around it moves;
   captions roll: the old one leaves upward, the next one arrives from below */
.deck .swapset { display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.deck .swapset > * { grid-area: 1 / 1; min-height: 0; transition: opacity .35s var(--ease), transform .65s var(--spring), filter .5s var(--ease), visibility 0s; }
.deck .swapset > *:not(.cur) { opacity: 0; visibility: hidden; transform: translateY(.6em); filter: blur(4px); transition: opacity .25s var(--ease), transform .4s var(--ease), filter .3s var(--ease), visibility 0s linear .4s; }
.deck .swapset > .before:not(.cur) { transform: translateY(-.6em); }
html:not(.deck) svg .swapset > :not(:last-child) { display: none; } /* doc and print show every step: an SVG swapset keeps its final state */
.caption { font-size: calc(var(--u) * 2.3); line-height: 1.25; font-weight: 500; letter-spacing: -.01em; max-width: 46ch; }
.caption b { font-weight: 700; }
.deck .draw { stroke-dasharray: var(--len, 1200); stroke-dashoffset: var(--len, 1200); }
.deck .on .draw, .deck .draw.on, .deck .here .draw.always { transition: stroke-dashoffset 1.4s var(--ease); stroke-dashoffset: 0; }
.deck .keep:not(.on) .draw:not(.always):not([data-step]), .deck .draw.keep:not(.on) { visibility: hidden; }
.deck .fly { transition: transform 1s var(--ease), opacity .6s var(--ease); }
.deck .fly:not(.on) { transform: translate(var(--fx, 0), var(--fy, 0)); opacity: 0; }
.deck .pulse.on { animation: pulse 1.8s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.deck .travel.on { animation: travel var(--dur, 2.4s) linear infinite; offset-rotate: 0deg; }
@keyframes travel { from { offset-distance: 0%; } to { offset-distance: 100%; } }

/* zoom through: the context scales up and fades while the detail grows out of one point */
.deck .zoomin, .deck .outgoing { transform-box: view-box; transition: transform 1.1s var(--ease), opacity .6s var(--ease); }
.deck .zoomin:not(.on) { transform: scale(.16); opacity: 0; }
.deck .outgoing.on { transform: scale(4); opacity: 0; pointer-events: none; }
html:not(.deck) .outgoing { display: none; } /* doc and print show the final state of a zoom */

/* ---------- terminal replay: real captured sessions, typed on slide entry ---------- */
.term { align-self: start;
  background: var(--dark); color: var(--dark-fg); font: calc(var(--u) * 1.15)/1.6 var(--mono);
  border: 1px solid var(--dark-edge); display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.term > header {
  display: flex; align-items: center; gap: .5em; padding: .45em .9em; background: var(--dark-2); color: var(--dark-mute);
  font-size: .85em; border-bottom: 1px solid var(--dark-edge);
}
.term > header i { width: .75em; height: .75em; background: var(--dark-line); display: inline-block; }
.term > header i:first-child { background: var(--green); }
.term .body { padding: .8em 1.1em; overflow: hidden; white-space: pre; flex: 1; }
.term .cmd::before { content: '$ '; color: var(--green); }
.term .cmd { color: var(--paper); }
.term .out { color: var(--dark-out); }
.term .ok { color: var(--dark-green); }
.term .dim { color: var(--dark-mute); }
.deck .term.play .tl { visibility: hidden; }
.deck .term.play .tl.shown { visibility: visible; }
.term .caret { display: inline-block; width: .55em; height: 1.1em; background: var(--green); vertical-align: -.15em; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* light code: C or the HUD switches every code block of the deck (pre, .term, an svg g.code-panel) to the light palette.
   Only the code tokens change, and only inside code, so --dark-* elsewhere (labels on ink boxes) stays as it is. */
html.code-light :is(pre, .term, .code-panel) {
  --dark: var(--paper); --dark-2: var(--wash); --dark-edge: var(--line); --dark-line: var(--line);
  --dark-fg: var(--ink); --dark-out: var(--ink-2); --dark-mute: var(--mute);
  --dark-green: var(--green-deep); --dark-orange: var(--orange-ink); --dark-red: var(--red-ink); --dark-blue: var(--blue);
}
html.code-light :not(.term) > pre { box-shadow: inset 0 0 0 1px var(--line); }
html.code-light .code-panel > rect.f-dark { stroke: var(--line); }
html.code-light .term .cmd, html.code-light .copy:hover { color: var(--ink); }
html.code-light .copy:hover { border-color: var(--ink); }

/* ---------- product screenshots in a plain browser frame ---------- */
.shot { border: 1px solid var(--ink); background: var(--paper); display: flex; flex-direction: column; min-height: 0; }
.shot > header { display: flex; align-items: center; gap: .6em; padding: .4em .8em; border-bottom: 1px solid var(--line); font: calc(var(--u) * .95) var(--mono); color: var(--ink-2); background: var(--wash); }
.shot > header i { width: .7em; height: .7em; border: 1px solid var(--mute); display: inline-block; }
.shot > header span { margin-left: .6em; }
.shot img, .shot video { display: block; width: 100%; height: 100%; object-fit: contain; object-position: top; min-height: 0; flex: 1; border: 0; }
/* deck: the figure is only the slot; header and capture are sized together to the capture's ratio (--ar, set by slides.js) */
html.deck .shot { --hh: calc(var(--u) * 2.1); container-type: size; border: 0; background: none; align-items: center; justify-content: center; }
html.deck .shot > header, html.deck .shot > img, html.deck .shot > video { flex: none; width: min(100cqw, (100cqh - var(--hh)) * var(--ar, 1.6)); border: 1px solid var(--ink); }
html.deck .shot > header { height: var(--hh); border-bottom-color: var(--line); }
html.deck .shot > img, html.deck .shot > video { height: auto; aspect-ratio: var(--ar, 1.6); border-top: 0; object-fit: cover; }

/* ---------- logo wall ---------- */
.logos { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: calc(var(--u) * 1.2); align-items: stretch; }
.logos a { border: 1px solid var(--line); display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; padding: calc(var(--u) * 1.2); aspect-ratio: 5 / 2; min-width: 0; }
.logos a:hover { border-color: var(--ink); }
.logos img { height: calc(var(--u) * var(--la, 6.2) / sqrt(var(--ar, 4))); width: auto; max-width: 100%; max-height: 100%; object-fit: contain; } /* equal area; --ar set by slides.js */
.logos.mini { --la: 3.4; display: flex; flex-wrap: wrap; align-items: center; gap: calc(var(--u) * 3.5); }
.logos.mini a { border: 0; padding: 0; aspect-ratio: auto; height: calc(var(--u) * 3.6); }
.logos a { position: relative; }
.logos img.flag { position: absolute; bottom: calc(var(--u) * .6); right: calc(var(--u) * .6); width: calc(var(--u) * 1.7); height: auto; aspect-ratio: 1; max-height: none; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--line); }

/* ---------- 3D exploded stack: layers lift apart one step at a time ---------- */
.stack3d { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: calc(var(--u) * 3); align-items: center; min-height: 0; }
.stack3d .scene3d { position: relative; height: 100%; min-height: 0; perspective: calc(var(--u) * 180); display: flex; align-items: center; justify-content: center; }
.stack3d .plane { position: relative; flex: 0 0 64%; aspect-ratio: 2 / 1; transform-style: preserve-3d; transform: translateY(26%) rotateX(60deg) rotateZ(-38deg); }
.stack3d .layer {
  position: absolute; inset: 0; border: 1.5px solid var(--ink); background: color-mix(in srgb, var(--paper) 95%, transparent);
  display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 5%; padding: 5%;
  transform: translateZ(calc((var(--i, 0) * 3.3 + 14) * var(--u))); opacity: 0;
  transition: transform 1s var(--ease), opacity .6s var(--ease), box-shadow .4s;
}
.deck .stack3d .layer.on, html:not(.deck) .stack3d .layer { transform: translateZ(calc(var(--i, 0) * 3.3 * var(--u))); opacity: 1; }
.stack3d .layer.cur { box-shadow: 0 0 0 3px var(--green); }
.deck .stack3d .layer.on:not(.cur) { opacity: .5; }
.stack3d .layer b { font: 700 calc(var(--u) * .92) var(--sans); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3em; text-align: center; border: 1px solid var(--ink); background: var(--paper); overflow: hidden; }
.stack3d .layer b img { max-width: 72%; max-height: 52%; object-fit: contain; }
.stack3d .layer.g { background: color-mix(in srgb, var(--green-wash) 96%, transparent); border-color: var(--green-deep); }
.stack3d .layer.k { background: color-mix(in srgb, var(--ink) 96%, transparent); }
.stack3d .layer.k b { background: var(--dark-2); color: var(--paper); border-color: var(--dark-line); }
.stack3d ol { list-style: none; display: grid; gap: calc(var(--u) * .5); font-size: calc(var(--u) * 1.2); }
.stack3d ol li { border-left: 3px solid var(--line); padding: calc(var(--u) * .25) 0 calc(var(--u) * .25) calc(var(--u) * 1.2); transition: border-color .4s, color .4s; color: var(--mute); }
.stack3d ol li b { display: block; color: var(--ink); font-size: calc(var(--u) * 1.4); }
.stack3d ol li.on { color: var(--ink-2); border-color: var(--ink); }
.stack3d ol li.cur { border-color: var(--green); }

/* ---------- deck mode (slides.js adds .deck to <html>) ---------- */
html.deck, html.deck body { height: 100%; overflow: hidden; background: var(--stage); }
html.deck .stage { position: fixed; inset: 0; display: grid; place-items: center; }
html.deck .slide {
  position: absolute;
  width: min(100vw, 177.78vh);
  border: 0;
  opacity: 0; visibility: hidden;
  transition: opacity .45s var(--ease), visibility 0s linear .45s;
}
html.deck .slide.here { opacity: 1; visibility: visible; transition: opacity .45s var(--ease); }
html.deck.vt .slide, html.deck.vt .slide.here { transition: none; }
::view-transition-group(*) { animation-duration: .7s; animation-timing-function: var(--ease); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .45s; }
/* a diagram whose parts travel by hand (data-morph inside an svg) stays at full strength; its own parts fade in */
::view-transition-new(*.carry) { animation: none; }
/* a panel folding into its carried parts, or unfolding from them, keeps its proportions inside its moving box */
::view-transition-old(m-panel), ::view-transition-new(m-panel) { height: 100%; object-fit: contain; }

/* chrome */
.bar { display: none; }
html.deck .bar {
  display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 3px; z-index: 10;
}
html.deck .bar i { display: block; height: 100%; background: var(--accent); transition: width .5s var(--ease); }
.hud { display: none; }
html.deck .hud {
  display: flex; gap: 1em; align-items: center;
  position: fixed; right: 14px; bottom: 12px; z-index: 11;
  font: 500 12px var(--mono); color: var(--mute); opacity: 0; transition: opacity .3s;
}
html.deck.show-hud .hud, html.deck .hud:hover { opacity: 1; }
.hud button { font: inherit; color: inherit; background: none; border: 1px solid var(--stage-line); padding: 3px 8px; cursor: pointer; }
.hud button:hover { color: var(--paper); border-color: var(--paper); }
.hud .media { display: none; gap: inherit; margin-right: 1.2em; }
.hud.has-media .media { display: inline-flex; }

/* presenter ink: A pointer, W pen (slides.js draws it in a 1600x900 overlay of the slide) */
.ink { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; overflow: visible; transition: opacity .3s var(--ease); }
.ink.gone { opacity: 0; }
.ink .stroke { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.ink .tail { fill: var(--green); opacity: .5; }
.ink .dot { fill: var(--green); opacity: 0; filter: drop-shadow(0 0 5px var(--green)) drop-shadow(0 0 14px var(--green)); transition: opacity .2s; }
html.deck[data-tool="laser"] .ink.aim .dot { opacity: 1; }
html.deck[data-tool="laser"] .stage, html.deck[data-tool="laser"] .stage * { cursor: none; }
html.deck[data-tool="pen"] .stage, html.deck[data-tool="pen"] .stage * { cursor: crosshair; }
html.deck[data-tool="pen"] .stage { touch-action: none; user-select: none; }
.hud button.on { color: var(--paper); border-color: var(--accent); }
.hud [data-k]::after { content: attr(data-k); margin-left: .6em; padding: 0 .35em; border: 1px solid var(--stage-line); border-radius: 2px; font-size: .9em; opacity: .75; }
.hud .cog { display: inline-flex; padding: 3px 5px; }
.hud .cog .ico { width: 14px; height: 14px; stroke: currentColor; fill: none; }
/* the cog's menu: every control with its key, settings flip in place */
.hud .menu { inset: auto 14px 44px auto; margin: 0; padding: 10px; min-width: 280px; background: var(--stage); color: var(--mute); border: 1px solid var(--stage-line); font: inherit; }
.hud .menu:popover-open { display: grid; gap: 1px; }
.hud .menu b { margin: 10px 8px 4px; font-weight: 500; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--paper); opacity: .45; }
.hud .menu b:first-child { margin-top: 0; }
.hud .menu :is(button, span) { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; border: 1px solid transparent; text-align: left; }
.hud .menu button:hover { border-color: var(--stage-line); }
.hud:has(.menu:popover-open) { opacity: 1; }

/* overview: press O */
html.deck.overview, html.deck.overview body { overflow: auto; }
html.deck.overview .stage { position: static; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; padding: 16px; }
html.deck.overview .slide { position: relative; width: 100%; opacity: 1; visibility: visible; transform: none; cursor: pointer; outline: 1px solid var(--stage-line); transition: none; }
html.deck.overview .slide.here { outline: 3px solid var(--accent); }
html.deck.overview [data-step] { opacity: 1 !important; transform: none !important; }

/* ---------- doc mode (no JS, ?doc, print, phones) ---------- */
@media (max-width: 720px) {
  html:not(.deck) .slide { aspect-ratio: auto; min-height: 60vh; --u: 2.6vw; }
  html:not(.deck) .slide > .in { position: relative; font-size: 15px; padding: 32px 16px; }
  html:not(.deck) .cols, html:not(.deck) .code2, html:not(.deck) .split { grid-template-columns: 1fr; }
  html:not(.deck) .slide { overflow: visible; }
  html:not(.deck) h1 { font-size: 40px; }
  html:not(.deck) h2 { font-size: 28px; }
  html:not(.deck) .big { font-size: 19px; }
  html:not(.deck) pre { font-size: 12px; }
}
/* Z zoom: the chart grows to the slide over a paper veil; the chart and its ancestors are lifted above the rest of the slide */
html.deck .slide :is([data-zoom], svg.dia, figure.shot, .panel) { transition: translate .8s cubic-bezier(.65, 0, .35, 1), scale .8s cubic-bezier(.65, 0, .35, 1); }
html.deck .zoom-on { position: relative; z-index: 10; }
html.deck .zoom-path { position: relative; z-index: 10; }
html.deck .zoom-unclip { overflow: visible !important; min-width: 0; min-height: 0; }
html.deck .zoom-veil { position: absolute; inset: -200vmax; z-index: 9; background: color-mix(in srgb, var(--paper) 85%, transparent); backdrop-filter: blur(10px); animation: zoom-veil .5s var(--ease) both; pointer-events: none; }
@keyframes zoom-veil { from { opacity: 0; } }
html.deck .zoom-veil.out { animation: zoom-veil-out .6s var(--ease) both; }
@keyframes zoom-veil-out { to { opacity: 0; } }
/* reduced motion: every state is shown as it ends, nothing travels */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .deck .pkt { display: none; }
}
@media print {
  @page { size: 1600px 900px; margin: 0; }
  .slide { width: 1600px; break-after: page; border: 0; }
  .copy, .hud, .bar { display: none !important; }
}
