/*
 * The scene layout every deck shares (talk-engine v1.9, #5897; v2 since #5899): the rules both decks' talk.css
 * carried word for word, for structure the engine itself emits. Pages load this file after
 * engine.css and before the deck's talk.css, so a deck rule still wins.
 *
 * The rule for a move. A rule lives here only if (a) its text appeared verbatim, exactly once, in
 * both decks' talk.css; (b) every selector targets engine-emitted structure: the HUD and header
 * band, the progress path, the body lattice, the step-through exit, the generic scene padding, and
 * the case-grid view; (c) no selector names a scene layout (.layout-<name>), a scene or object id,
 * or an object class authored in objects.json; (d) it loads nothing by a relative path (only data:
 * images), because a relative path resolves against this file, not the deck; and (e) the
 * before/after render comparison (scripts/talks/compare-deck-renders-v2.mjs) shows no difference.
 * A deck rule that used to come before one of these rules now comes after it; none sets the same
 * property on the same selector.
 *
 * Moved from (line ranges in closing-the-loop / closing-the-loop-ese5180 talk.css at f6fb314c7):
 *   path (round 8)                                       1950-2191 / 1948-2189
 *   round 9 HUD                                          3279-3320 / 3296-3337
 *   round 9 HUD row (after the relay chip)               3395-3441 / 3412-3458
 *   lattice                                              3592-3610 / 3609-3627
 *   header band, wordmark slot, step-through exit (r10)  3637-3711 / 3654-3728
 *   round 11 case grid                                   4105-4369 / 4122-4386
 * The two rules on the HUD's relay chip (.hud .relay-chip at 18 px, and the .ctr beside it) stay in
 * each deck: an earlier deck rule on the same selector sets the 24 px dish, and only order made the
 * 18 px one win.
 *
 * The 37 colour literals that moved here are --t-* theme tokens since #5899 (Sub-Issue C).
 */

/* ── The path. The talk's sections as stops under the HUD; a thin grey line joins each pair of stops and
   every dot is opaque, so no line shows through one. Moving forward a section, the stop we leave beats,
   a pulse runs the line toward the next stop and leaves it mint behind it, and the stop we reach ripples
   and takes the glow. Engine v1.6 sets the one-shot classes (leave, run, arrive); every timing is here. */
.progress {
  --dot: 15px;
  --gap: 3px;
  --beat: 440ms;
  --lead: 180ms;
  --run: 720ms;
  --ripple: 950ms;
  --arrive: calc(var(--lead) + var(--steps, 1) * var(--run));
  position: fixed;
  z-index: 19;
  left: var(--pad);
  right: var(--pad);
  top: calc(22px + clamp(22px, 2.2vw, 30px) + clamp(8px, 1.4vh, 16px));
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  pointer-events: none;
  transition: opacity 900ms var(--ease);
}
.progress.none {
  opacity: 0;
  visibility: hidden;
}
.progress .seg {
  position: absolute;
  top: calc(var(--dot) / 2 - 1px);
  left: calc((var(--k) + 0.5) * 100% / var(--n) + var(--dot) / 2 + var(--gap));
  width: calc(100% / var(--n) - var(--dot) - 2 * var(--gap));
  height: 2px;
  border-radius: 1px;
  background: rgba(var(--t-ink-rgb), 0.16);
}
.progress .seg .fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: 1px;
  background: var(--t-accent);
}
.progress .seg.lit .fill {
  width: 100%;
}
.progress .seg.run .fill {
  transition: width var(--run) cubic-bezier(0.45, 0, 0.25, 1)
    calc(var(--lead) + var(--i, 0) * var(--run));
}
.progress .seg .fill::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--t-accent-tint);
  box-shadow:
    0 0 10px 3px rgba(var(--t-accent-rgb), 0.9),
    0 0 24px 8px rgba(var(--t-accent-rgb), 0.4);
  opacity: 0;
}
.progress .seg.run .fill::after {
  animation: path-head var(--run) linear
    calc(var(--lead) + var(--i, 0) * var(--run)) both;
}
@keyframes path-head {
  0% {
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
.progress .stop {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 7px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  pointer-events: auto;
}
.progress .dot {
  position: relative;
  z-index: 1;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  box-sizing: border-box;
  background: var(--t-line-solid);
  transition:
    background 300ms var(--ease),
    box-shadow 300ms var(--ease);
}
.progress .past .dot {
  background: var(
    --t-accent-muted
  ); /* the mint at 55 percent over the stage, opaque */
}
.progress .cur .dot {
  background: var(--t-accent);
  box-shadow:
    0 0 0 5px rgba(var(--t-accent-rgb), 0.18),
    0 0 20px var(--t-accent);
}
.progress .ring {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 0;
  width: var(--dot);
  height: var(--dot);
  margin-left: calc(var(--dot) / -2);
  border-radius: 50%;
  border: 2px solid var(--t-accent);
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
}
.progress .name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 600 clamp(11px, 0.78vw, 15px) / 1.1 var(--t-font);
  color: var(--t-muted);
  transition:
    color 300ms var(--ease),
    font-weight 300ms var(--ease);
}
.progress .past .name {
  color: rgba(var(--t-accent-rgb), 0.6);
}
.progress .cur .name {
  color: var(--t-text);
  font-weight: 800;
}
.progress .stop:hover .name {
  color: var(--t-text);
}
/* r14: no focus box on a path stop, by mouse, keys, or the phone (Matt, 2026-10-21) */
.progress .stop:focus,
.progress .stop:focus-visible,
.progress .stop:focus-visible .dot {
  outline: none;
}
.progress .stop.leave .dot {
  animation: path-beat var(--beat) ease-out both;
}
@keyframes path-beat {
  0% {
    transform: scale(1);
    background: var(--t-accent);
    box-shadow:
      0 0 0 5px rgba(var(--t-accent-rgb), 0.18),
      0 0 20px var(--t-accent);
  }
  40% {
    transform: scale(1.5);
    background: var(--t-accent-tint);
    box-shadow:
      0 0 0 7px rgba(var(--t-accent-rgb), 0.25),
      0 0 28px var(--t-accent);
  }
  100% {
    transform: scale(1);
    background: var(--t-accent-muted);
    box-shadow: none;
  }
}
.progress .stop.arrive .dot {
  animation: path-arrive 440ms ease-out var(--arrive) both;
}
@keyframes path-arrive {
  0% {
    transform: scale(1);
    background: var(--t-line-solid);
    box-shadow: none;
  }
  45% {
    transform: scale(1.55);
    background: var(--t-accent-tint);
    box-shadow:
      0 0 0 7px rgba(var(--t-accent-rgb), 0.25),
      0 0 30px var(--t-accent);
  }
  100% {
    transform: scale(1);
    background: var(--t-accent);
    box-shadow:
      0 0 0 5px rgba(var(--t-accent-rgb), 0.18),
      0 0 20px var(--t-accent);
  }
}
.progress .stop.arrive .ring {
  animation: path-ripple var(--ripple) ease-out var(--arrive) both;
}
@keyframes path-ripple {
  0% {
    transform: scale(1);
    opacity: 0.9;
  }
  100% {
    transform: scale(3.6);
    opacity: 0;
  }
}
.progress .stop.arrive .name {
  transition-delay: var(--arrive);
}
@media (max-height: 820px) {
  .progress {
    --dot: 13px;
    top: 52px;
  }
  .progress .stop {
    gap: 4px;
  }
  .progress .name {
    font-size: 10px;
  }
}
@media (max-width: 760px) {
  .progress {
    display: none; /* the path needs a projector's width */
  }
}

/* ═══ Round 9 (Matt, 2026-10-20 15:24Z): no node graph; the path on the logo's line; the controls as
   icons under the count; every slide gets the room back ═══ */
:root {
  --r9-logo-h: clamp(22px, 2.2vw, 30px);
  --r9-logo-w: calc(
    var(--r9-logo-h) * var(--t-logo-aspect)
  ); /* the header cut's proportions (viewBox 10028 x 2410, r10) */
  --r9-ctr-w: 88px;
  --r9-gap: clamp(28px, 3vw, 64px);
  --r9-top: calc(
    22px + var(--r9-logo-h) + clamp(48px, 3.2vw, 64px)
  ); /* the first line under the HUD */
  --r9-bot: 2vh; /* ROOM-B (Matt's pick): a slim foot */
  --r9-grow: 1.3; /* ROOM-B: the pictures and charts about 30 percent larger */
}
/* the node graph at the foot of every slide is gone */
#ambient {
  display: none;
}
/* the HUD row: the count with the controls under it, at the logo's height */
.hud {
  align-items: flex-start;
}
.hud-right {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: var(--r9-logo-h) auto;
  justify-items: end;
  align-items: center;
  column-gap: 8px;
  row-gap: 8px;
}
.hud-right .ctr {
  grid-row: 1;
  grid-column: 1 / span 9;
  justify-self: end;
}
.hud-right .step,
.hud-right .relay-chip,
.hud-right #talk-identity {
  grid-row: 2;
}

/* step through: a fast-forward mark (the words stay for a screen reader) */
.hud .step {
  width: 34px;
  height: 28px;
  padding: 0;
  font-size: 0;
  justify-content: center;
  background: var(--t-accent) var(--t-icon-play) center / 18px no-repeat;
}
/* account: a silhouette */
.hud #talk-identity .ti-toggle {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 0;
  border-radius: 50%;
  background: var(--t-icon-account) center / 16px no-repeat;
}
@media (min-width: 761px) {
  /* the path between the logo and the count, its dots on the logo's centre line */
  .progress {
    top: calc(22px + var(--r9-logo-h) / 2 - var(--dot) / 2);
    left: calc(var(--pad) + var(--r9-logo-w) + var(--r9-gap));
    right: calc(var(--pad) + var(--r9-ctr-w) + var(--r9-gap));
  }
  .progress .name {
    max-width: 92%;
    white-space: normal;
    text-wrap: balance;
    text-align: center;
    overflow: visible;
    line-height: 1.15;
  }
  /* every slide starts under the HUD and runs to the foot */
  html .scene.scene {
    padding-top: var(--r9-top);
    padding-bottom: var(--r9-bot);
  }
}
@media (max-height: 820px) and (min-width: 761px) {
  .progress {
    top: calc(22px + var(--r9-logo-h) / 2 - var(--dot) / 2);
  }
}

/* the isometric lattice behind every slide, restored (Matt, 2026-10-20 18:09Z). It was drawn on the
   same canvas as the node graph (mesh.js lattice(): two families of 1 px lines at 30 degrees either
   side of horizontal, every 64 px along a row, white at 3.5 percent), so hiding that canvas took it
   too. The lines are drawn here instead, fixed to the screen as the canvas was: 32 px apart measured
   square to the lines (64 px along a row times sin 30). */
body {
  background-image:
    repeating-linear-gradient(
      150deg,
      rgba(var(--t-ink-rgb), 0.035) 0 1px,
      transparent 1px 32px
    ),
    repeating-linear-gradient(
      210deg,
      rgba(var(--t-ink-rgb), 0.035) 0 1px,
      transparent 1px 32px
    );
  background-attachment: fixed;
}

/* r10 H1/H2: the header wordmark is the app's title-bar mark and a link to hapimatic.com */
.hud a.brand {
  pointer-events: auto;
  display: inline-block;
  line-height: 0;
  height: var(--r9-logo-h);
}
.hud a.brand img {
  display: block;
  height: var(--r9-logo-h);
  width: auto;
}
.hud a.brand:focus-visible {
  outline: 2px solid var(--t-accent);
  outline-offset: 4px;
  border-radius: 4px;
}
/* r10 H4: the header band. Content scrolling up under it fades out over the band's last 48 px,
   so the wordmark, the path and the count never sit on top of a slide. The band repeats the
   page's own lattice (same layers as body, fixed), so it reads as the background, not a bar. */
body::before {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: var(--r9-top);
  z-index: 2; /* over the deck (1), under the path and the header (20) */
  pointer-events: none;
  background-color: var(--t-bg);
  background-image:
    repeating-linear-gradient(
      150deg,
      rgba(var(--t-ink-rgb), 0.035) 0 1px,
      transparent 1px 32px
    ),
    repeating-linear-gradient(
      210deg,
      rgba(var(--t-ink-rgb), 0.035) 0 1px,
      transparent 1px 32px
    );
  background-attachment: fixed;
  -webkit-mask-image: linear-gradient(
    to bottom,
    #000 calc(100% - 48px),
    transparent
  );
  mask-image: linear-gradient(to bottom, #000 calc(100% - 48px), transparent);
}
@media (max-width: 760px) {
  body::before {
    height: calc(118px + env(safe-area-inset-top, 0px));
    -webkit-mask-image: linear-gradient(
      to bottom,
      #000 calc(100% - 36px),
      transparent
    );
    mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent);
  }
}
/* r10 H3: the way out of step-through on a phone */
.stepper-exit {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: 12px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font: 400 30px/1 var(--t-font);
  color: var(--t-text);
  background: rgba(var(--t-ink-rgb), 0.1);
  border: 1px solid var(--t-line-strong);
  cursor: pointer;
}

/* ── round 11: the bench as a flat 2x3 grid of case panels (view "grid") and one page per case:
   the icon top-left, the title across the top, then one block per step (picture + caption). The
   grid sits left of the scene's object at the overview; a panel flies to the icon box as its
   page takes over, and flies back when the page leaves. (Variant A.) ── */
.scene-map.view-grid {
  --u: min(1vw, 1.7778vh);
  --case-icon: calc(var(--u) * 7);
}
.scene-map.view-grid .map-layout.case-layout {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  align-items: center;
  gap: calc(var(--u) * 3);
  margin-top: calc(var(--u) * 2.2);
}
.scene-map.view-grid.in-case .map-layout.case-layout {
  opacity: 0;
  visibility: hidden;
}
.scene-map.view-grid .map-layout.case-layout {
  will-change: transform, opacity;
}
.case-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  pointer-events: none;
  transform-origin: 0 0;
  will-change: transform;
  object-fit: contain;
}
.case-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr; /* every card the height of the tallest (Matt, 2026-10-21) */
  gap: calc(var(--u) * 1.4);
}
.case-panel {
  position: relative;
  container-type: inline-size;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  align-items: center;
  gap: calc(var(--u) * 0.6);
  padding: calc(var(--u) * 0.9) calc(var(--u) * 0.6);
  border-radius: calc(var(--u) * 1.2);
  background: rgba(var(--t-surface-rgb), 0.72);
  border: 1px solid rgba(var(--t-ink-rgb), 0.16);
  aspect-ratio: 1.12;
  box-sizing: border-box;
  min-height: 0;
  transition:
    border-color 300ms var(--ease),
    background-color 300ms var(--ease);
}
.case-panel .case-icon {
  width: 58%;
  max-height: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  align-self: center;
}
/* The label is exactly its authored lines (one or two): no wrapping inside a line, the type
   sized from the card's own width so the longest line fits at every stage size, and a two-line
   box on every card so the icons sit level across the row. */
.case-panel .case-label {
  margin: 0;
  text-align: center;
  white-space: nowrap;
  font: 700 clamp(9px, 7.4cqw, 26px) / 1.18 var(--t-font);
  min-height: 2.36em;
  display: grid;
  align-content: center;
  color: var(--t-text);
}
.case-panel.done {
  border-color: rgba(var(--t-line-art-rgb), 0.4);
  background: rgba(var(--t-second-rgb), 0.45);
}
.case-panel.now,
.case-panel.zoom {
  border-color: var(--t-accent);
  background: rgba(var(--t-accent-rgb), 0.1);
  z-index: 3;
}
.case-stage {
  display: grid;
}
.case-stage > .case-layout,
.case-stage > .case-pages {
  grid-area: 1 / 1;
}
.case-pages {
  display: grid;
  align-content: start;
  margin-top: calc(var(--u) * 2.2);
  pointer-events: none;
  min-height: 0;
}
.case-page {
  grid-area: 1 / 1;
  align-self: start;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: calc(var(--u) * 1.8);
  opacity: 0;
  visibility: hidden;
  will-change: transform, opacity;
}
.case-page.shown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.case-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: calc(var(--u) * 2);
}
.case-head .case-icon {
  width: var(--case-icon);
  height: var(--case-icon);
  object-fit: contain;
  border-radius: calc(var(--u) * 1.2);
  background: rgba(var(--t-surface-rgb), 0.72);
  border: 1px solid rgba(var(--t-ink-rgb), 0.16);
  padding: calc(var(--u) * 0.9);
  box-sizing: border-box;
}
.case-title {
  margin: 0;
  font: 800 calc(var(--u) * 3) / 1.05 var(--t-font);
  letter-spacing: -0.02em;
  color: var(--t-text);
}
.case-blocks {
  display: grid;
  grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr));
  gap: calc(var(--u) * 1.4);
  align-content: start;
}
.case-blocks.n-6 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: calc(var(--u) * 1.4) calc(var(--u) * 1.8);
}
.case-block {
  margin: 0;
  display: grid;
  grid-template-rows: auto auto;
  align-content: start; /* every caption starts right under its picture: tops level across the row */
  gap: calc(var(--u) * 1);
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 320ms var(--ease),
    transform 320ms var(--ease);
}
.case-block.on {
  opacity: 1;
  transform: none;
}
.case-media {
  aspect-ratio: 4 / 3;
  border-radius: calc(var(--u) * 1);
  background: rgba(var(--t-bg-rgb), 0.9);
  border: 1px solid rgba(var(--t-ink-rgb), 0.12);
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: calc(var(--u) * 0.5);
  box-sizing: border-box;
}
.case-blocks.n-6 .case-media {
  aspect-ratio: 16 / 9;
}
.case-media > .object,
.case-media > .object-group {
  width: 100%;
  height: 100%;
  margin: 0;
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
/* The picture is sized to the box on both axes and fitted inside it (a picture taller than 4:3
   used to take the box's width, overrun its height, and get clipped: the board render, the cell). */
.case-media .object img,
.case-media .object svg,
.case-media .object video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  margin: 0;
}
.case-media .object-group {
  grid-auto-flow: column;
  gap: calc(var(--u) * 0.6);
}
.case-media .object-group > .object {
  min-width: 0;
  min-height: 0;
  margin: 0;
}
.case-media .credit,
.case-media figcaption.credit {
  display: none;
}
.case-caption {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: calc(var(--u) * 0.6);
  margin: 0;
  font: 500 calc(var(--u) * 1.05) / 1.35 var(--t-font);
  color: var(--t-text);
}
.case-num {
  display: inline-grid;
  place-items: center;
  min-width: 1.9em;
  height: 1.9em;
  border-radius: 999px;
  background: rgba(var(--t-accent-rgb), 0.14);
  font: 700 calc(var(--u) * 0.8) / 1 var(--t-mono);
  color: var(--t-accent);
  letter-spacing: 0.04em;
}
.case-blocks.n-6 .case-caption {
  font-size: calc(var(--u) * 1.02);
}
.case-blocks.n-5 .case-caption {
  font-size: calc(var(--u) * 1.08);
}
/* the phone reading page: the grid stays, static; the pages are the unrolled cards below it */
@media (max-width: 760px) {
  html:not(.is-stage) .scene-map.view-grid .map-layout.case-layout {
    display: grid;
  }
  html:not(.is-stage) .scene-map.view-grid .case-pages {
    display: none;
  }
  html:not(.is-stage) .case-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  html:not(.is-stage) .case-panel {
    padding: 12px 8px;
    gap: 8px;
    aspect-ratio: auto;
    transition: none;
  }
  html:not(.is-stage) .case-panel .case-label {
    font-size: clamp(9px, 7.4cqw, 15px);
    line-height: 1.15;
  }
  html:not(.is-stage) .case-panel .case-icon {
    width: 52%;
  }
}
