/* =============================================================
   case.css
   Long-form case-study pages (/work/<slug>/).

   Archetype: Tactical Telemetry / CRT terminal.
   Applied directives:
     - Visible compartmentalization: every content unit is a sealed
       cell, never floating prose.
     - Grid determinism: `display:grid; gap:1px` over a --line ground
       generates the razor-thin dividers; no per-child borders.
     - Extreme scale contrast: macro section numerals against fixed
       micro telemetry type.
     - Syntax decoration: [ ] bracket framing, // and >>> markers.
     - Bimodal density: an open hero, then tightly packed data cells.
   Deviation: the archetype's hazard-red accent is dropped — this
   site is monochrome, so emphasis is carried by the ink hierarchy.

   Inherits every token, overlay and HUD rule from style.css.
   ============================================================= */

.case-hero,
.case {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- nav: breadcrumb back-link ---------- */
.nav__item--back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.8;
}
.nav__item--back:hover { opacity: 1; color: var(--ink); }
.nav__item--back::before,
.nav__item--back::after { content: none; }
/* breadcrumb trail: HOME / WORK / <this page> */
.crumbs { display: flex; align-items: center; gap: 0.7rem; margin: 0; padding: 0; list-style: none; font-size: var(--fs-micro); }
.crumbs li { display: flex; align-items: center; gap: 0.7rem; }
.crumbs li + li::before { content: "/"; color: var(--ink-faint); }
.crumbs__here { opacity: 1; color: var(--ink); }

/* =============================================================
   HERO — the negative-space half of the bimodal rhythm
   ============================================================= */
.case-hero {
  padding-block: clamp(6.5rem, 14vh, 10rem) clamp(2.5rem, 6vw, 4rem);
}

/* telemetry strip: fixed micro type, uppercase, generously tracked */
.case-hero__rev {
  display: flex;
  flex-wrap: wrap;
  gap: 0 clamp(1rem, 3vw, 2.5rem);
  padding-block: var(--space-sm);
  border-block: 1px solid var(--line);
  margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
  font-size: var(--fs-micro);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.case-hero__rev span { white-space: nowrap; }
.case-hero__rev b { font-weight: 400; color: var(--ink-dim); }

.case-hero__title {
  font-family: var(--font-display);
  font-weight: 400;
  /* macro scale — the long line is CONVERSATIONAL (14 glyphs), so the
     min is pinned low enough to clear a 375px viewport */
  font-size: clamp(1.05rem, 5vw, 4.4rem);
  line-height: 1.16;
  letter-spacing: var(--track-tight);
  margin-block: var(--space-lg) var(--space-xl);
}
.case-hero__line { display: block; }
.case-hero__line--outline {
  color: transparent;
  -webkit-text-stroke: 1.5px var(--ink);
  text-stroke: 1.5px var(--ink);
}

.case-hero__lede {
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  line-height: 1.7;
  color: var(--ink);
  max-width: 58ch;
  margin-bottom: clamp(2rem, 4vw, 3rem);
}

/* ---------- meta + metrics: grid determinism, 1px gap as the rule ---------- */
.case-hero__meta,
.metrics {
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
/* Both blocks hold exactly four cells. auto-fit would happily make three
   tracks at mid widths, leaving a dead --line cell beside the orphan on
   row two — so the count is pinned to 2 or 4, never 3. */
.case-hero__meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 1px;
}
.metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: clamp(2rem, 5vw, 3.5rem);
}
@media (min-width: 860px) {
  .case-hero__meta,
  .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.case-hero__meta > div,
.metric {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: clamp(1.1rem, 2.2vw, 1.6rem);
  background: var(--bg);
}
.case-hero__meta dt,
.metric__label {
  font-size: var(--fs-micro);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--ink-faint);
}
.case-hero__meta dd { font-size: 0.82rem; color: var(--ink); }

.metric__value {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.6vw, 1.9rem);
  line-height: 1.15;
  letter-spacing: var(--track-tight);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.metric__unit { font-size: 0.5em; color: var(--ink-dim); margin-left: 0.15em; }
.metric__label { color: var(--ink-dim); }

/* =============================================================
   MEDIA SLOTS
   ============================================================= */
/* A 16:9 frame at full column width is ~740px tall on a 1440 viewport —
   taller than the 818px the nav leaves usable, and well past it on a
   1366x768 laptop. Cap the height against the viewport so a figure and its
   caption always sit inside one screen.
   `width:100%` is load-bearing: without it aspect-ratio honours the cap by
   shrinking the WIDTH instead, leaving the frame stranded to the left of a
   dead gap. Held at full width it simply letterboxes — and since the frame
   background is exactly page-black, those bars are invisible, so this reads
   as the same dissolve-into-black treatment as the rest of the site. */
.slot__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 58vh;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg);
  isolation: isolate;
}
.slot__frame--16-10 { aspect-ratio: 16 / 10; max-height: 50vh; }

.slot__field {
  position: absolute;
  inset: -10%;
  z-index: 1;
  pointer-events: none;      /* decoration: opacity 0 still hit-tests */
  opacity: 0.34;
  -webkit-mask-image: radial-gradient(ellipse 72% 70% at 50% 50%, #000 14%, transparent 84%);
  mask-image: radial-gradient(ellipse 72% 70% at 50% 50%, #000 14%, transparent 84%);
}
.slot__field--dots {
  background-image: radial-gradient(circle at center,
    rgba(242, 242, 239, 0.5) 0.9px, transparent 1px);
  background-size: 15px 15px;
}
.slot__field--grid {
  background-image:
    linear-gradient(rgba(242, 242, 239, 0.26) 1px, transparent 1px),
    linear-gradient(90deg, rgba(242, 242, 239, 0.26) 1px, transparent 1px);
  background-size: 30px 30px;
}
.slot__field--wave {
  background-image: repeating-linear-gradient(0deg,
    rgba(242, 242, 239, 0.28) 0 1px, transparent 1px 10px);
}

.slot__scan {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(0deg,
    rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 4px);
  mix-blend-mode: overlay;
}
.slot__frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse 70% 66% at 50% 50%,
    transparent 52%, rgba(5, 5, 5, 0.55) 76%, var(--bg) 95%);
}
.slot__frame .vp-corner { z-index: 4; opacity: 0.55; pointer-events: none; }

.slot__status,
.slot__spec {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
}
.slot__status {
  top: 50%;
  margin-top: -1.1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-dim);
}
.slot__spec {
  top: 50%;
  margin-top: 0.5rem;
  font-size: 0.5rem;
  letter-spacing: 0.12em;
  text-transform: none;
  color: var(--ink-faint);
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slot__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-dim);
  animation: sys-pulse 2.6s ease-in-out infinite;
}
/* =============================================================
   HERO EXPLAINER PLAYER
   Three states on .slot__frame:
     (none)      awaiting asset — the procedural field + status label
     .is-ready   metadata loaded — poster and the play affordance
     .is-playing native controls, overlays pulled back for legibility
   95 seconds of narration is not wallpaper: nothing autoplays, nothing
   loops, and audio is on when the viewer asks for it.
   ============================================================= */
.slot__media,
.slot__play {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.slot__frame.is-ready .slot__media { opacity: 1; pointer-events: auto; }
.slot__frame.is-ready .slot__play { opacity: 1; pointer-events: auto; }
.slot__frame.is-ready .slot__field,
.slot__frame.is-ready .slot__status,
.slot__frame.is-ready .slot__spec { opacity: 0; }
.slot__frame.is-engaged .slot__play { opacity: 0; pointer-events: none; }

/* overlays ease off while playing — scanlines over moving text are noise */
.slot__scan { transition: opacity var(--dur) var(--ease); }
.slot__frame::after { transition: opacity var(--dur) var(--ease); }
.slot__frame.is-engaged .slot__scan { opacity: 0.2; }
.slot__frame.is-engaged::after { opacity: 0.25; }

.slot__play {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  width: 100%;
  height: 100%;
  font: inherit;
  color: inherit;
  cursor: inherit;
  background: rgba(5, 5, 5, 0.38);
  transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease);
}
.slot__play:hover { background: rgba(5, 5, 5, 0.14); }

.slot__play-mark {
  display: grid;
  place-items: center;
  width: clamp(48px, 5vw, 66px);
  aspect-ratio: 1;
  border: 1px solid var(--line-strong);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.slot__play:hover .slot__play-mark {
  border-color: var(--ink);
  box-shadow: var(--glow);
}
.slot__play-mark::before {
  content: "";
  width: 0; height: 0;
  margin-left: 0.28em;
  border-left: 0.9em solid var(--ink);
  border-block: 0.58em solid transparent;
}
.slot__play-label {
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--ink);
}
.slot__play-time {
  font-size: 0.5rem;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* =============================================================
   TRANSPORT — the explainer's control surface
   Native controls are a rounded, translucent, consumer-iconography
   bar; on this page they read as a different product. This is built
   to the same rules as everything else: grid-determinism dividers
   (gap:1px over --line), 90-degree geometry throughout, fixed micro
   mono in caps, bracket/slash syntax, zero translucency — it sits
   BELOW the frame as its own compartment rather than floating over
   the picture, so nothing has to be seen through.
   ============================================================= */
.vp {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-top: 0;                      /* the frame's bottom edge serves */
}
.vp[hidden] { display: none; }

.vp__cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 38px;
  padding: 0 clamp(0.7rem, 1.4vw, 1.1rem);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.vp__btn { cursor: inherit; font: inherit; letter-spacing: 0.18em; }
.vp__btn:hover { background: var(--surface); color: var(--ink); }
/* every control cell is a fixed square-ish module: the grid's `auto` tracks
   must not resize when a label or glyph swaps, or the whole transport
   twitches sideways mid-playback */
.vp__btn--icon { position: relative; min-width: 46px; }

/* play / pause, drawn in CSS — crisp at any size, no icon dependency.
   Both states occupy the SAME 10x12 box (clip-path swaps the shape, not the
   geometry); a border-triangle changes its own border-box width and dragged
   the column — and the rest of the row — with it on every play/pause. */
.vp__glyph {
  width: 10px;
  height: 12px;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.vp.is-playing .vp__glyph {
  clip-path: none;
  background:
    linear-gradient(currentColor 0 0) left  / 3px 100% no-repeat,
    linear-gradient(currentColor 0 0) right / 3px 100% no-repeat;
}
[data-vp-play] { color: var(--ink); }

/* ---- icon cells ---- */
.vp__ico {
  display: block;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.vp__ico-solid { fill: currentColor; stroke: none; }
/* one state group paints at a time */
.vp__ico-off,
.vp__ico-exit,
.is-muted .vp__ico-on,
.is-full .vp__ico-in { display: none; }
.is-muted .vp__ico-off,
.is-full .vp__ico-exit { display: block; }
/* sound off also drops the cone to dim, so the state reads at a glance */
.is-muted .vp__ico { opacity: 0.55; }

/* label kept for AT fallback and CSS-off, never measured */
.vp__sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.vp__time {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.vp__slash { color: var(--ink-faint); margin: 0 0.45rem; }

/* ---- scrub ---- */
.vp__track { position: relative; padding-inline: clamp(0.8rem, 1.6vw, 1.25rem); }
.vp__rail {
  position: relative;
  display: block;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.10);
}
.vp__buf, .vp__fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
}
.vp__buf  { background: rgba(255, 255, 255, 0.18); }
.vp__fill { background: var(--ink); }
/* a square head, never a pill */
.vp__head {
  position: absolute;
  top: 50%;
  left: 0;
  width: 2px;
  height: 13px;
  margin-top: -6.5px;
  background: var(--ink);
  box-shadow: var(--glow);
}
/* the real input sits on top: free keyboard access and ARIA, invisible */
.vp__scrub {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}
.vp__scrub:focus-visible + .vp__rail,
.vp__track:focus-within .vp__rail { outline: 1px solid var(--ink); outline-offset: 4px; }

@media (max-width: 620px) {
  /* two rows: transport controls, then the scrub spanning full width */
  .vp { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .vp__track { grid-column: 1 / -1; order: 2; padding-block: 0.6rem; }
  .vp__btn--icon { min-width: 40px; }
}

/* ---- fullscreen ----
   Fullscreen is requested on the FIGURE, not the frame, so the transport
   travels with the picture instead of being left behind on the page. The
   figure becomes a two-row grid: picture takes whatever is left, transport
   pinned beneath it — the same compartment, same 1px divider, just taller.
   Driven by a class rather than :fullscreen so the prefixed selectors and
   their specificity quirks never come into it. */
.slot.is-fs {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;                /* the compartment's own padding would inset it */
  background: var(--bg);
  opacity: 1;                /* never inherit a half-finished reveal */
  transform: none;
}
.slot.is-fs .slot__frame {
  height: 100%;
  max-height: none;
  aspect-ratio: auto;        /* the row decides the height now */
  border: 0;
}
.slot.is-fs .vp {
  border: 0;
  border-top: 1px solid var(--line);
}
.slot.is-fs .slot__caption { display: none; }
/* a 38px bar reads fine in a column, less so across a 27" display */
.slot.is-fs .vp__cell { min-height: 46px; }
.slot.is-fs .vp__ico { width: 17px; height: 17px; }
.slot.is-fs .vp__glyph { width: 12px; height: 14px; }
.slot.is-fs:focus { outline: none; }   /* focused only to receive keys */

.slot__caption {
  margin-top: 0.85rem;
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
/* `contain`, not `cover`: once the frame is height-capped it is wider than
   16:9, and cropping a blueprint graph or a UI capture loses the content.
   The frame background is exactly page-black, so the letterboxing is
   invisible. The hero recording is the one place cover is right. */
.slot__media {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: grayscale(1) contrast(1.06);
  transition: opacity var(--dur) var(--ease), filter 0.6s var(--ease);
}
/* grey at rest keeps the page monochrome; the footage comes back to colour
   while it plays (paused or ended, it settles back to grey) */
.slot__frame.is-playing .slot__media { filter: grayscale(0) contrast(1); }
/* cover would crop the recording top and bottom now the frame is wider
   than 16:9 — contain everywhere, letterboxed invisibly on page-black */

/* =============================================================
   DOCUMENT LAYOUT — sticky index + body
   ============================================================= */
.case {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: start;
  padding-bottom: clamp(4rem, 9vw, 7rem);
  border-top: 1px solid var(--line);
  padding-top: clamp(2.5rem, 6vw, 4.5rem);
}

.case__toc {
  position: sticky;
  top: 108px;
  padding-left: 1rem;      /* lane for the rail + sliding marker */
}
/* the rail the marker travels along */
.case__toc-list { position: relative; }
.case__toc-list::before {
  content: "";
  position: absolute;
  left: -1rem;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--line);
}
/* the same rail, lit from the top in proportion to how far you have read.
   --p is written by case.js off the same read-line the marker uses, so the
   fill and the selector can never disagree. */
.case__toc-list::after {
  content: "";
  position: absolute;
  left: -1rem;
  top: 0;
  width: 1px;
  height: 100%;
  background: var(--ink-dim);
  transform: scaleY(var(--p, 0));
  transform-origin: top;
  transition: transform 0.25s linear;
}
/* HUD selector: slides to whichever entry is being read */
.case__toc-marker {
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 0;
  background: var(--ink);
  opacity: 0;
  box-shadow: var(--glow);
  transition: transform 0.42s var(--ease),
              height 0.42s var(--ease),
              opacity 0.3s var(--ease);
  will-change: transform;
}
.case__toc-title {
  font-size: var(--fs-micro);
  letter-spacing: var(--track-eyebrow);
  color: var(--ink-faint);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-sm);
}
.case__toc-link {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0 0.45rem 0.85rem;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
  transition: color var(--dur-fast) var(--ease);
}
/* terminal cursor marks the active unit */
.case__toc-link::before {
  content: ">";
  position: absolute;
  left: 0;
  opacity: 0;
  color: var(--ink);
  transition: opacity var(--dur-fast) var(--ease);
}
.case__toc-link span {
  font-family: var(--font-display);
  font-size: 0.5rem;
  font-variant-numeric: tabular-nums;
}
.case__toc-link:hover { color: var(--ink-dim); }
.case__toc-link.is-active { color: var(--ink); }
.case__toc-link.is-active::before {
  opacity: 1;
  animation: toc-caret 1.1s steps(1) infinite;
}
.case__toc-link.is-active span { color: var(--ink); }
@keyframes toc-caret {
  0%, 60%  { opacity: 1; }
  61%, 100% { opacity: 0.25; }
}

.case__body { min-width: 0; }

/* -------------------------------------------------------------
   THE COMPARTMENT SYSTEM
   Each section is a sealed unit. The 1px grid gap over a --line
   ground draws every internal divider — no child owns a border,
   so the rules are always exactly 1px and always aligned.
   ------------------------------------------------------------- */
.case__section {
  display: grid;
  /* minmax(0,1fr), never a bare auto track: cells like .diagram wrap a
     `white-space:pre` block whose min-content is ~480px, and overflow-x on
     that inner block does not zero the wrapper's min-content contribution.
     An auto track would grow to it and blow past the viewport. */
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: clamp(2rem, 4vw, 3.25rem);
  scroll-margin-top: 96px;
}
.case__section > * {
  background: var(--bg);
  padding: clamp(1.35rem, 2.8vw, 2.25rem);
  margin: 0;
  min-width: 0;      /* let every cell shrink; inner blocks scroll instead */
  transition: background var(--dur) var(--ease);
}
.case__section > *:hover { background: #0a0a0c; }
.case__section > .case__head:hover { background: #131316; }

/* ---- secondary motion ----
   The cell itself never animates — it would carry its background out and
   open a hole in the 1px divider grid. Its CONTENTS arrive just behind it,
   staggered by the --d that case.js stamps on each child. */
/* An animation, not a transition: cells like .case__no declare their own
   `transition` and would silently win the cascade at equal specificity,
   dropping that child out of the stagger entirely. `both` holds the from-
   state through the delay. case.js never adds .cell-in under reduced
   motion, so the blanket `animation:none` there can't strand it hidden. */
.cell-in { opacity: 0; }
.case__section.is-visible .cell-in {
  animation: cell-in 0.55s var(--ease) var(--d, 0ms) both;
}
@keyframes cell-in {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: none; }
}
/* case.js skips .cell-in when reduced motion is on at load — but if it is
   turned on afterwards, animations.css kills the animation and the from-
   state would strand this content invisible. Never let that happen. */
@media (prefers-reduced-motion: reduce) {
  .cell-in { opacity: 1 !important; transform: none !important; }
}

/* ---------- the section being read ---------- */
.case__section {
  transition: border-color var(--dur) var(--ease);
}
.case__section.is-current { border-color: var(--line-strong); }
.case__section.is-current > .case__head { background: #101013; }
.case__section.is-current .case__no { -webkit-text-stroke-color: var(--ink); }
.case__section.is-current .case__ref { color: var(--ink-dim); }
.case__section.is-current .case__ref::after {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  margin-left: 0.55rem;
  background: var(--ink);
  animation: sys-pulse 2.6s ease-in-out infinite;
}
/* one-shot scan across the header the moment a section becomes current */
.case__section.is-current > .case__head::after {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--ink), transparent);
  animation: head-sweep 1.05s var(--ease) 1;
}
@keyframes head-sweep {
  from { transform: translateX(-100%); opacity: 0; }
  35%  { opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

/* ---------- section header bar: macro numeral vs micro telemetry ---------- */
.case__section > .case__head { background: var(--surface); }
.case__head {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(0.9rem, 2vw, 1.6rem);
}
.case__no {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.2vw, 2.5rem);
  line-height: 1;
  letter-spacing: var(--track-tight);
  color: transparent;
  -webkit-text-stroke: 1.5px var(--ink-dim);
  text-stroke: 1.5px var(--ink-dim);
  font-variant-numeric: tabular-nums;
  transition: -webkit-text-stroke-color var(--dur) var(--ease);
}
.case__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(0.72rem, 1.5vw, 1.05rem);
  line-height: 1.45;
  letter-spacing: var(--track-tight);
  text-transform: uppercase;
  color: var(--ink);
}
.case__ref {
  font-size: var(--fs-micro);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* =============================================================
   PROSE
   ============================================================= */
.prose { display: flex; flex-direction: column; gap: var(--space-lg); }
.prose p {
  font-size: var(--fs-body);
  line-height: 1.75;
  color: var(--ink-dim);
  max-width: 68ch;
}
.prose strong { color: var(--ink); font-weight: 700; }

/* sub-heads carry the >>> directional marker */
.prose__h {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--ink);
  padding-top: var(--space-sm);
  margin-bottom: calc(var(--space-lg) * -0.5);
}
.prose__h::before {
  content: ">>>";
  color: var(--ink-faint);
  letter-spacing: 0;
}
.prose__note {
  font-size: 0.8rem !important;
  color: var(--ink-faint) !important;
  border-left: 1px solid var(--line-strong);
  padding-left: var(--space-md);
}
.prose__list { display: flex; flex-direction: column; max-width: 68ch; }
.prose__list li {
  position: relative;
  padding: 0.75rem 0 0.75rem 1.6rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--ink-dim);
}
.prose__list li::before {
  content: "";
  position: absolute;
  left: 0.15rem;
  top: 1.35rem;
  width: 5px; height: 5px;
  background: var(--ink-faint);
}
.prose__list li:last-child { border-bottom: 0; }

.case-hero code,
.case__body code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 0.05em 0.32em;
  white-space: nowrap;
}

/* =============================================================
   SPEC TABLES — high-density tabular telemetry
   ============================================================= */
.table-wrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); }

.spec {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  line-height: 1.55;
  text-align: left;
}
.spec--num { font-variant-numeric: tabular-nums; }

.spec__cap {
  caption-side: top;
  text-align: left;
  font-size: var(--fs-micro);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: var(--space-sm);
}
.spec thead th {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--ink-dim);
  padding: 0 1rem 0.6rem 0;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.spec tbody th {
  font-weight: 400;
  color: var(--ink);
  padding: 0.7rem 1rem 0.7rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.spec tbody td {
  color: var(--ink-dim);
  padding: 0.7rem 1rem 0.7rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.spec tbody tr:last-child th,
.spec tbody tr:last-child td { border-bottom: 0; }
.spec tbody th:last-child,
.spec tbody td:last-child { padding-right: 0; }

.spec tbody tr.is-key th,
.spec tbody tr.is-key td { color: var(--ink); }
.spec tbody tr.is-key th { position: relative; }
.spec tbody tr.is-key th::before {
  content: "";
  position: absolute;
  left: -0.7rem;
  top: 1.05rem;
  width: 4px; height: 4px;
  background: var(--ink);
}

/* =============================================================
   TERMINAL DIAGRAMS
   The compartment supplies the outer rule; the block only needs
   its raised substrate.
   ============================================================= */
.diagram__pre {
  overflow: auto;
  max-height: 70vh;
  /* x-only containment: stops a horizontal swipe triggering back-navigation
     while still letting a vertical wheel chain on to the page once the
     diagram bottoms out. Containing both axes traps the wheel here. */
  overscroll-behavior-x: contain;
  padding: clamp(1rem, 2.2vw, 1.5rem);
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.diagram__pre::-webkit-scrollbar { height: 8px; }
.diagram__pre::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); }
.diagram__pre code {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  line-height: 1.55;
  letter-spacing: 0;
  color: var(--ink-dim);
  white-space: pre;
  border: 0;
  padding: 0;
}
.diagram__pre--inline { margin-block: var(--space-md); }
.diagram__cap {
  margin-top: 0.85rem;
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* =============================================================
   CALLOUT — a flagged cell, marked by its label not a box
   ============================================================= */
.case__section > .callout { background: var(--surface); }
.callout__label {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: var(--space-md);
}
.callout__label::before { content: "///"; color: var(--ink-faint); letter-spacing: 0; }
.callout p:not(.callout__label) {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--ink-dim);
  max-width: 66ch;
}
.callout strong { color: var(--ink); }

/* =============================================================
   DEFECT BLOCKS — bracketed keys, hairline-ruled rows
   ============================================================= */
.defect__title {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin-bottom: var(--space-lg);
}
.defect__no {
  font-family: var(--font-display);
  font-size: 0.55rem;
  font-weight: 400;
  color: var(--ink-faint);
  flex: none;
  font-variant-numeric: tabular-nums;
}

.defect__row {
  display: grid;
  grid-template-columns: 124px minmax(0, 1fr);
  gap: var(--space-lg);
  padding-block: var(--space-md);
  border-top: 1px solid var(--line);
}
.defect__key {
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  padding-top: 0.25rem;
  white-space: nowrap;
}
.defect__key::before { content: "[ "; }
.defect__key::after  { content: " ]"; }
.defect__val { display: flex; flex-direction: column; gap: var(--space-md); min-width: 0; }
.defect__val p {
  font-size: 0.85rem;
  line-height: 1.75;
  color: var(--ink-dim);
  max-width: 64ch;
}
.defect__val strong { color: var(--ink); font-weight: 700; }
.defect__val .prose__list { max-width: none; }
.defect__val .diagram__pre { border: 1px solid var(--line); }

/* =============================================================
   PRINCIPLES
   ============================================================= */
.principles { display: flex; flex-direction: column; }
.principle {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: var(--space-lg);
  padding-block: clamp(1.4rem, 2.8vw, 1.85rem);
  border-top: 1px solid var(--line);
}
.principle:first-child { border-top: 0; padding-top: 0; }
.principle:last-child { padding-bottom: 0; }
/* three children, two columns: pin the number to col 1 and stack the
   title and body in col 2, or the paragraph reflows into the gutter */
.principle__no {
  grid-column: 1;
  grid-row: 1;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: transparent;
  -webkit-text-stroke: 1px var(--ink-dim);
  text-stroke: 1px var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
.principle__title,
.principle p { grid-column: 2; }
.principle__title {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: var(--space-sm);
}
.principle p {
  font-size: 0.85rem;
  line-height: 1.75;
  color: var(--ink-dim);
  max-width: 66ch;
}

/* =============================================================
   END NAV
   ============================================================= */
.case__end {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-top: clamp(2.5rem, 5vw, 4rem);
}
.case__end-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: clamp(1.2rem, 2.4vw, 1.75rem);
  background: var(--bg);
  transition: background var(--dur-fast) var(--ease);
}
.case__end-link:hover { background: var(--surface); }
.case__end-link--cta { justify-content: space-between; }
.case__end-body { display: flex; flex-direction: column; gap: 0.35rem; }
.case__end-key {
  font-size: var(--fs-micro);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--ink-faint);
}
.case__end-val {
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--ink);
}

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 980px) {
  .case { grid-template-columns: 1fr; gap: 2rem; }
  .case__toc {
    position: sticky;
    top: 56px;
    z-index: 30;
    /* the grid item must be allowed to shrink: the inner flex row of eight
       nowrap links gives it a ~980px min-content, and overflow-x on the list
       does not zero that out for a plain block. Without this the whole
       column blows past the viewport and gets clipped by overflow-x:hidden. */
    min-width: 0;
    background: var(--bg);
    padding-block: 0.75rem;
    border-bottom: 1px solid var(--line);
  }
  .case__toc-title { display: none; }
  .case__toc-list {
    display: flex;
    gap: 1.1rem;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .case__toc-list::-webkit-scrollbar { display: none; }
  .case__toc {
    padding-left: 0;
    transition: transform 0.32s var(--ease);
  }
  /* reading downward tucks the strip behind the nav; any upward scroll,
     or tapping an entry, brings it straight back */
  .case__toc.is-tucked { transform: translateY(-130%); }
  .case__toc-list::before,
  .case__toc-list::after { content: none; }
  .case__toc-marker { display: none; }
  .case__toc-link { padding: 0.15rem 0; white-space: nowrap; }
  .case__toc-link::before { content: none; }
  /* the active entry underlines itself instead */
  .case__toc-link::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 1px;
    background: var(--ink);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--dur) var(--ease);
  }
  .case__toc-link.is-active::after { transform: scaleX(1); }
}

@media (max-width: 620px) {
  .case-hero { padding-block: 5.5rem 2rem; }
  .case__head { grid-template-columns: auto minmax(0, 1fr); }
  .case__ref { display: none; }
  .defect__row { grid-template-columns: 1fr; gap: var(--space-sm); }
  .principle { grid-template-columns: 1fr; gap: var(--space-sm); }
  /* on touch, a box that scrolls both ways steals the page scroll — let it
     take the height it needs and keep only the horizontal pan */
  .diagram__pre { max-height: none; }

  /* A three-column spec table squeezed into 335px wraps every cell to four
     lines and runs past 850px tall. Give those a floor so .table-wrap pans
     horizontally instead — rows stay one or two lines. Two-column tables
     already fit, so :has() keeps them alone. */
  .spec:has(thead th:nth-child(3)) { min-width: 30rem; }
  .diagram__pre code { font-size: 0.6rem; }
  .slot__spec { display: none; }
}

/* Standard-density screens: Space Mono Bold fills in W, N and M at label
   sizes (9-12px) on a 1x pixel grid. Retina screens keep the bold. */
@media (-webkit-max-device-pixel-ratio: 1.49), (max-resolution: 1.49dppx) {
  .slot__play-label, .prose__h, .spec thead th, .callout__label,
  .defect__key { font-weight: 400; }
}
