/* ============================================================================
   MAIN.CSS — component styles
   You normally edit tokens.css, not this file. Sections: RESET / SHELL / RAIL
   / TEXTURE / TYPE / MODULES / LISTS / TABLE / BUTTONS / TUTORIAL / MEDIA
   / EMPTY / MOTION / RESPONSIVE / PRINT
   ========================================================================= */

/* ------------------------------------------------------------- RESET ----- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}

img, svg, video, iframe { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { padding: 0; list-style: none; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: var(--lh-snug);
  letter-spacing: var(--track-tight);
  text-wrap: balance;
}
p { text-wrap: pretty; }

:focus-visible { outline: 2px solid var(--hue); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--hue); color: var(--hue-ink); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link {
  position: fixed; top: var(--space-3); left: var(--space-3); z-index: 300;
  padding: var(--space-3) var(--space-4);
  background: var(--invert-bg); color: var(--invert-fg);
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700;
  text-transform: uppercase; letter-spacing: var(--track-label);
  transform: translateY(-250%);
  transition: transform var(--dur-mid) var(--ease);
}
.skip-link:focus { transform: translateY(0); }

/* ------------------------------------------------------------- SHELL ----- */
.main { margin-left: var(--rail-w); position: relative; z-index: 1; }
.wrap { width: 100%; max-width: var(--max-w); margin-inline: auto; padding-inline: var(--gutter); }
.block { padding-block: var(--section-y); }
.block--tight { padding-block: var(--space-6); }
.block + .block { border-top: var(--hairline); }

/* ----------------------------------------------------------- TEXTURE ---- */
.backdrop { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.backdrop::before {
  content: ''; position: absolute; inset: -1px;
  background-image:
    linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  opacity: var(--grid-opacity);
}
.backdrop::after {
  content: ''; position: absolute; inset: 0; opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* -------------------------------------------------------------- RAIL ----- */
.rail {
  position: fixed; inset: 0 auto 0 0; z-index: 200;
  width: var(--rail-w);
  display: flex; flex-direction: column;
  background: var(--bg-alt);
  border-right: var(--hairline);
}
.rail__head { padding: var(--space-5) var(--space-4) var(--space-4); border-bottom: var(--hairline); }
.rail__mark {
  display: flex; align-items: center; gap: var(--space-3);
}
.rail__glyph {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center;
  background: var(--invert-bg); color: var(--invert-fg);
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: 0.02em;
}
.rail__logo { width: 30px; height: 30px; flex: none; object-fit: contain; }
.rail__name {
  font-family: var(--font-display); font-weight: 900; font-size: 0.95rem;
  letter-spacing: 0.02em; text-transform: uppercase; line-height: 1;
}
.rail__sub {
  margin-top: var(--space-3);
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: var(--track-label); text-transform: uppercase;
  color: var(--text-mute);
}

.rail__body { flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-3); }
.rail__group + .rail__group { margin-top: var(--space-5); }
.rail__title {
  padding: 0 var(--space-3) var(--space-3);
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: var(--track-label); text-transform: uppercase;
  color: var(--text-mute);
}

.rail__link {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 44px; padding: var(--space-2) var(--space-3);
  border-left: 2px solid transparent;
  font-family: var(--font-mono); font-size: var(--fs-small);
  color: var(--text-soft); cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.rail__link:hover { background: var(--surface); color: var(--text); }
.rail__link[aria-current='page'] {
  background: var(--surface); color: var(--text);
  border-left-color: var(--hue);
}
.rail__link svg { flex: none; color: var(--hue); }
.rail__link-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail__count { font-size: var(--fs-label); color: var(--text-mute); font-variant-numeric: tabular-nums; }

.rail__foot {
  padding: var(--space-3); border-top: var(--hairline);
  display: flex; align-items: center; gap: var(--space-2);
}
.rail__foot .meta { flex: 1; }

/* Search field */
.search { position: relative; margin-bottom: var(--space-4); }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-mute); }
.search input {
  width: 100%; min-height: 44px; padding: 0 var(--space-3) 0 34px;
  background: var(--surface); color: var(--text);
  border: var(--hairline); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: var(--fs-small);
}
.search input::placeholder { color: var(--text-mute); }
.search input:focus { border-color: var(--line-strong); outline-offset: 1px; }
.search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  padding: 2px 5px; border: var(--hairline); border-radius: 2px;
  font-family: var(--font-mono); font-size: 10px; color: var(--text-mute);
}

/* Mobile top bar — only shown when the rail collapses */
.topbar {
  display: none; position: sticky; top: 0; z-index: 210;
  align-items: center; gap: var(--space-3);
  min-height: 56px; padding-inline: var(--gutter);
  background: var(--bg-alt); border-bottom: var(--hairline);
}

/* --------------------------------------------------------------- TYPE ---- */
/* Mono eyebrow with a numeric stamp — the signature detail */
.meta {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 500;
  letter-spacing: var(--track-label); text-transform: uppercase;
  color: var(--text-mute);
}
.meta--hue { color: var(--hue); }
.meta-row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); align-items: baseline; }
.meta-row > * { display: inline-flex; align-items: center; gap: var(--space-2); }

.stamp {
  display: inline-flex; align-items: center; gap: var(--space-3);
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700;
  letter-spacing: var(--track-label); text-transform: uppercase;
  color: var(--text-mute);
}
.stamp b { color: var(--hue); font-weight: 700; }
.stamp::after { content: ''; flex: 1; height: 1px; min-width: 24px; background: var(--line); }

.display {
  font-size: var(--fs-display); line-height: var(--lh-tight);
  letter-spacing: -0.045em; text-transform: uppercase; font-weight: 900;
}
/* Hollow outline word. The stroke colour must be named explicitly —
   `currentColor` would resolve to the transparent fill and vanish. */
.display em {
  font-style: normal; color: transparent;
  -webkit-text-stroke: 1.5px var(--hue);
}
h1.title { font-size: var(--fs-h1); text-transform: uppercase; letter-spacing: -0.035em; }
h2.title { font-size: var(--fs-h2); text-transform: uppercase; letter-spacing: -0.03em; }
.lede { font-size: var(--fs-lede); color: var(--text-soft); max-width: 62ch; }
.prose { color: var(--text-soft); max-width: var(--max-w-text); }
.prose p + p { margin-top: var(--space-4); }

/* ------------------------------------------------------------ MODULES --- */
/* The console panel: a bordered block with a mono header strip. */
.mod { border: var(--hairline); background: var(--surface); }
.mod__bar {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 40px; padding: 0 var(--space-4);
  border-bottom: var(--hairline); background: var(--bg-alt);
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: var(--track-label); text-transform: uppercase;
  color: var(--text-soft);
}
.mod__bar b { color: var(--hue); font-weight: 700; }
.mod__bar .spacer { flex: 1; }
.mod__bar .dim { color: var(--text-mute); font-weight: 400; }
.mod__body { padding: var(--space-5); }
.mod__body--flush { padding: 0; }

.cols { display: grid; gap: var(--space-5); }
.cols--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cols--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.cols--split { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }

/* --------------------------------------------------------------- HERO ---- */
/* Sits on top of a pinned scene. Text stays put while the machine animates. */
.scene__pin .wrap { position: relative; z-index: 2; }
.hero-cap { padding-bottom: var(--space-5); }
.hero-cap .display { max-width: 22ch; }
.hero-cap .lede { margin-top: var(--space-4); }
.scene__stage { margin-top: calc(-1 * var(--space-4)); }

.scroll-cue {
  position: absolute; left: 50%; bottom: var(--space-5); z-index: 3;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: var(--track-label); text-transform: uppercase;
  color: var(--text-mute); pointer-events: none;
}
.scroll-cue::after {
  content: ''; width: 1px; height: 26px;
  background: linear-gradient(to bottom, var(--hue), transparent);
  animation: cue 1.8s var(--ease) infinite;
}
@keyframes cue { 0%,100% { opacity: 0.25; transform: scaleY(0.5); } 50% { opacity: 1; transform: scaleY(1); } }

/* --------------------------------------------------------------- LISTS -- */
/* Machine rows on the index page */
.machine {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  align-items: stretch; gap: 0;
  border: var(--hairline); background: var(--surface);
  transition: border-color var(--dur-mid) var(--ease), background var(--dur-mid) var(--ease);
}
.machine:hover { border-color: color-mix(in srgb, var(--hue) 50%, transparent); }
.machine__info { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.machine__code {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 46px; height: 26px; padding: 0 var(--space-2);
  background: var(--hue); color: var(--hue-ink);
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700;
  letter-spacing: 0.1em;
}
.machine__name { font-size: var(--fs-h2); text-transform: uppercase; letter-spacing: -0.03em; }
.machine__foot { margin-top: auto; padding-top: var(--space-4); border-top: var(--hairline); }
.machine__scene {
  border-left: var(--hairline); background: var(--bg-alt);
  overflow: hidden; min-height: 240px;
  display: grid; place-items: center;
}

/* Definition rows — specs, details */
.rows { display: grid; }
.rows > div {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: var(--space-4); padding: var(--space-3) var(--space-5);
}
.rows > div + div { border-top: var(--hairline); }
.rows dt {
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-mute);
}
.rows dd {
  font-family: var(--font-mono); font-size: var(--fs-small); font-weight: 500;
  text-align: right; font-variant-numeric: tabular-nums;
}

/* Numbered rule list — safety */
.rules { counter-reset: rule; }
.rules li {
  counter-increment: rule; position: relative;
  padding: var(--space-4) var(--space-5) var(--space-4) 60px;
  font-size: var(--fs-small); color: var(--text-soft);
}
.rules li + li { border-top: var(--hairline); }
.rules li::before {
  content: counter(rule, decimal-leading-zero);
  position: absolute; left: var(--space-5); top: var(--space-4);
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700;
  color: var(--hue);
}

/* --------------------------------------------------------------- TABLE -- */
/* The tutorial index. Reads like a directory listing, on purpose. */
.tbl { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: var(--fs-small); }
.tbl thead th {
  text-align: left; padding: var(--space-3) var(--space-4);
  border-bottom: var(--hairline); background: var(--bg-alt);
  font-size: var(--fs-label); font-weight: 600;
  letter-spacing: var(--track-label); text-transform: uppercase; color: var(--text-mute);
  white-space: nowrap;
}
.tbl tbody tr { border-bottom: var(--hairline); transition: background var(--dur-fast) var(--ease); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl td { padding: var(--space-3) var(--space-4); vertical-align: middle; }
.tbl td a { display: block; font-weight: 500; }
.tbl tbody tr:hover td a { color: var(--hue); }
.tbl .num { color: var(--text-mute); font-variant-numeric: tabular-nums; width: 1%; white-space: nowrap; }
.tbl .shrink { width: 1%; white-space: nowrap; }
.tbl-scroll { overflow-x: auto; }

/* Machine tag used in tables and cards */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px var(--space-2); border: 1px solid color-mix(in srgb, var(--hue) 40%, transparent);
  background: var(--hue-tint); color: var(--hue);
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
}
.tag--plain {
  border-color: var(--line); background: transparent; color: var(--text-mute);
}
.tag-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ------------------------------------------------------------- BUTTONS -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-3); min-height: 44px; padding: 0 var(--space-5);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700;
  letter-spacing: var(--track-label); text-transform: uppercase;
  cursor: pointer; text-align: center;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn svg { flex: none; }
.btn--solid { background: var(--invert-bg); color: var(--invert-fg); }
.btn--solid:hover { background: var(--hue); color: var(--hue-ink); }
.btn--line { border-color: var(--line-strong); color: var(--text); }
.btn--line:hover { border-color: var(--hue); color: var(--hue); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.iconbtn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border: var(--hairline); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-soft); cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.iconbtn:hover { color: var(--text); border-color: var(--line-strong); }

.filter {
  min-height: 36px; padding: 0 var(--space-4);
  border: var(--hairline); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-mute); cursor: pointer;
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  transition: all var(--dur-fast) var(--ease);
}
.filter:hover { color: var(--text); border-color: var(--line-strong); }
.filter[aria-pressed='true'] { background: var(--invert-bg); color: var(--invert-fg); border-color: var(--invert-bg); }

/* Inline link with a sliding underline */
.tlink {
  display: inline-flex; align-items: center; gap: var(--space-2);
  color: var(--hue); cursor: pointer;
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700;
  letter-spacing: var(--track-label); text-transform: uppercase;
}
.tlink span { position: relative; }
.tlink span::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -3px; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: left;
  transition: transform var(--dur-mid) var(--ease);
}
.tlink:hover span::after { transform: scaleX(1); }
.tlink svg { transition: transform var(--dur-mid) var(--ease); }
.tlink:hover svg { transform: translateX(4px); }

/* ------------------------------------------------------------ TUTORIAL -- */
.steps { counter-reset: step; }
.step { counter-increment: step; position: relative; padding: var(--space-6) 0 var(--space-6) 74px; }
.step + .step { border-top: var(--hairline); }
.step::before {
  content: counter(step, decimal-leading-zero);
  position: absolute; left: 0; top: var(--space-6);
  width: 46px; height: 32px; display: grid; place-items: center;
  border: 1px solid color-mix(in srgb, var(--hue) 40%, transparent);
  background: var(--hue-tint); color: var(--hue);
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700;
}
.step h3 { font-size: var(--fs-h3); text-transform: none; letter-spacing: -0.01em; }
.step p { margin-top: var(--space-3); color: var(--text-soft); max-width: var(--max-w-text); }
.step__extra { margin-top: var(--space-4); display: grid; gap: var(--space-4); }

.note {
  display: flex; gap: var(--space-4); padding: var(--space-4);
  border: var(--hairline); border-left: 2px solid var(--c, var(--hue));
  background: var(--bg-alt);
}
.note__icon { color: var(--c, var(--hue)); flex: none; margin-top: 2px; }
.note__title {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700;
  letter-spacing: var(--track-label); text-transform: uppercase; color: var(--c, var(--hue));
}
.note p { margin-top: var(--space-2); font-size: var(--fs-small); color: var(--text-soft); }
.note--warn { --c: var(--danger); }
.note--tip  { --c: var(--safe); }

/* Lead-in above a block (not sticky — that treatment is only for steps) */
.section-lead { margin-bottom: var(--space-6); }
.section-lead .title { font-size: var(--fs-h2); }
.section-lead .lede { font-size: var(--fs-small); }

/* ------------------------------------------------ THE TWO VIDEOS -------- */
/* Side by side under the big animation; stacked on narrow screens. */
.vids { display: grid; gap: var(--space-5); grid-template-columns: 1fr 1fr; }
.vid { border: var(--hairline); background: var(--surface); display: flex; flex-direction: column; }
.vid__head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--hairline); background: var(--bg-alt);
}
.vid__icon { width: 34px; height: 34px; flex: none; }
.vid__titles { flex: 1; min-width: 0; }
.vid__kind {
  display: block;
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: var(--track-label); text-transform: uppercase; color: var(--hue);
}
.vid__name {
  font-family: var(--font-display); font-weight: 800; font-size: 1.05rem;
  text-transform: uppercase; letter-spacing: -0.02em; line-height: 1.2;
}
.vid__body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.vid__hint { font-size: var(--fs-small); color: var(--text-mute); }

/* ------------------------------------------------- THE SAFETY BAND ------ */
/* This one is meant to stop you. Hazard stripes and warning red rather than
   the machine accent — danger should look the same on every page. */
/* The stripes advance with the scroll wheel, not on a timer — scenes.js sets
   --hz from scroll position. They sit still when you do. */
.hazard {
  --stripe: 14.142px;   /* a 40px shift is exactly one repeat at 45° */
  height: 16px;
  background-image: repeating-linear-gradient(45deg,
    var(--caution) 0 var(--stripe),
    var(--caution-dark) var(--stripe) calc(var(--stripe) * 2));
  background-position: calc(var(--hz, 0) * 1px) 0;
}

/* Full-bleed, tinted, and it breaks the page's rhythm on purpose. */
.warnband {
  background: color-mix(in srgb, var(--danger) 7%, var(--bg));
  padding-block: var(--space-6) var(--space-7);
}
.warnband__head {
  display: flex; align-items: center; gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.warnband__icon {
  width: 52px; height: 52px; flex: none; display: grid; place-items: center;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  padding: 4px;
}
.warnband__titles h2 {
  font-size: var(--fs-h2); text-transform: uppercase; letter-spacing: -0.03em;
  color: var(--danger);
}
.warnband__sub {
  display: block; margin-top: 3px;
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700;
  letter-spacing: var(--track-label); text-transform: uppercase; color: var(--text-soft);
}

.warnlist {
  counter-reset: warn;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  background: var(--surface);
}
.warnlist li {
  counter-increment: warn;
  display: flex; align-items: flex-start; gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  font-size: var(--fs-lede); color: var(--text);
}
.warnlist li + li { border-top: var(--hairline); }
.warnlist li::before {
  content: counter(warn, decimal-leading-zero);
  flex: none; margin-top: 3px;
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700;
  letter-spacing: 0.06em; color: var(--danger);
}
.warnlist svg { flex: none; margin-top: 3px; color: var(--danger); }

/* ------------------------------------------------- STICKY SECTIONS ------ */
/* Each section's heading sticks to the top while you read that section, then
   is pushed out by the next one. A sticky element cannot leave its own
   container, so the hand-off happens on its own — no JavaScript involved.
   The animated icon beside it is driven by scroll progress through the
   section (see the 'section' mode in assets/js/scenes.js). */
.sect { position: relative; scroll-margin-top: 0; }

.sect__head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4) 0;
  /* Opaque, so the text of the section above scrolls away behind it */
  background: var(--bg);
  border-bottom: var(--hairline);
}

.sect__icon {
  width: 54px; height: 54px; flex: none;
  display: grid; place-items: center;
  border: var(--hairline); background: var(--surface);
  padding: 5px;
}
.sect__titles { min-width: 0; }
.sect__titles h2 {
  font-size: var(--fs-h3); text-transform: uppercase;
  letter-spacing: -0.015em; line-height: 1.15;
}
.sect__num {
  display: block; margin-bottom: 3px;
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700;
  letter-spacing: var(--track-label); color: var(--hue);
}
.sect__body { padding-block: var(--space-6) var(--space-8); }

/* Step layout: instructions on the left, the clip on the right */
.sect__split {
  display: grid; gap: var(--space-6);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: start;
}
.sect__text { font-size: var(--fs-lede); color: var(--text-soft); max-width: 52ch; }
.sect__text strong { color: var(--text); font-weight: 600; }
.sect__text + .sect__text { margin-top: var(--space-4); }

/* Animated clip (GIF or short video) */
.clip { position: relative; aspect-ratio: 16 / 10; border: var(--hairline); background: var(--surface); overflow: hidden; }
.clip video, .clip img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.clip__cap {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: var(--space-2) var(--space-3);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-top: var(--hairline);
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-mute);
}

/* Section jump chips at the top of a tutorial. Wraps on desktop; scrolls
   sideways on narrow screens (see the responsive block). */
.jump { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.jump a {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 36px; padding: 0 var(--space-3);
  border: var(--hairline); white-space: nowrap;
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-mute);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.jump a:hover { color: var(--hue); border-color: var(--hue); }
.jump a b { color: var(--hue); font-weight: 700; }

/* Sticky in-page index */
.toc { position: sticky; top: var(--space-5); align-self: start; }
.toc a {
  display: flex; gap: var(--space-3); padding: var(--space-3);
  border-left: 2px solid transparent;
  font-family: var(--font-mono); font-size: var(--fs-small); color: var(--text-soft);
  transition: all var(--dur-fast) var(--ease);
}
.toc a:hover { background: var(--surface); color: var(--text); }
.toc a.is-active { border-left-color: var(--hue); color: var(--hue); background: var(--hue-tint); }
.toc a b { color: var(--text-mute); font-weight: 500; }

.split-toc { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: var(--space-7); align-items: start; }

/* --------------------------------------------------------------- MEDIA -- */
/* Image placeholder: looks deliberate until a real file is dropped in. */
.slot {
  position: absolute; inset: 0; display: grid; place-content: center;
  gap: var(--space-3); padding: var(--space-5); text-align: center;
  background: var(--surface-2);
}
.slot::before {
  content: ''; position: absolute; inset: 8px;
  border: 1px dashed var(--line-strong);
}
.slot__icon { color: var(--hue); opacity: 0.8; justify-self: center; }
.slot__hint {
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-mute);
  max-width: 34ch;
}
.slot__hint code {
  display: inline-block; margin-top: var(--space-2); padding: 2px 6px;
  background: var(--bg); color: var(--hue); text-transform: none; letter-spacing: 0;
}
.slot__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.frame { position: relative; border: var(--hairline); overflow: hidden; background: var(--surface); }
.frame--wide { aspect-ratio: 16 / 9; }
.frame--sq { aspect-ratio: 1 / 1; }

/* YouTube facade — the iframe loads only after a click */
.video {
  position: relative; aspect-ratio: 16 / 9; width: 100%; padding: 0;
  border: var(--hairline); background: var(--surface-2);
  overflow: hidden; cursor: pointer; display: block;
}
.video__thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video__scrim {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.75), rgba(0,0,0,0.1) 60%, rgba(0,0,0,0.25));
  transition: opacity var(--dur-mid) var(--ease);
}
.video:hover .video__scrim { opacity: 0.8; }
.video__play {
  position: absolute; inset: 0; margin: auto;
  width: 64px; height: 64px; display: grid; place-items: center;
  background: var(--hue); color: var(--hue-ink);
  transition: transform var(--dur-mid) var(--ease-back);
}
.video:hover .video__play { transform: scale(1.1); }
.video__cap {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: var(--space-4); text-align: left; color: #fff;
  font-family: var(--font-mono); font-size: var(--fs-label);
  letter-spacing: var(--track-label); text-transform: uppercase;
}
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video--empty { cursor: default; }

/* --------------------------------------------------------------- EMPTY -- */
.empty {
  padding: var(--space-8) var(--space-5); text-align: center;
  border: 1px dashed var(--line-strong); background: var(--bg-alt);
}
.empty__icon { color: var(--hue); opacity: 0.7; margin: 0 auto var(--space-4); }
.empty h3 {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700;
  letter-spacing: var(--track-label); text-transform: uppercase; color: var(--text-soft);
}
.empty p { margin: var(--space-3) auto 0; max-width: 46ch; font-size: var(--fs-small); color: var(--text-mute); }
.empty code {
  font-family: var(--font-mono); font-size: 0.8rem;
  padding: 2px 6px; background: var(--surface); color: var(--hue);
}

/* -------------------------------------------------------------- FOOTER -- */
.foot {
  border-top: var(--hairline); background: var(--bg-alt);
  padding: var(--space-5) 0;
}
.foot__in {
  display: flex; flex-wrap: wrap; gap: var(--space-4);
  justify-content: space-between; align-items: center;
}

/* ------------------------------------------------------------- MOTION --- */
.reveal {
  opacity: 0; transform: translateY(14px);
  transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
  transition-delay: var(--d, 0ms);
}
.reveal.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .scroll-cue { display: none; }
}

/* --------------------------------------------------------- RESPONSIVE --- */
@media (max-width: 1080px) {
  .cols--split { grid-template-columns: 1fr; }
  .split-toc { grid-template-columns: 1fr; }
  .toc { position: static; display: flex; overflow-x: auto; gap: 2px; }
  .toc a { border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; }
  .toc a.is-active { border-left: 0; border-bottom-color: var(--hue); }
}

@media (max-width: 900px) {
  :root { --rail-w: 0px; }
  .main { margin-left: 0; }
  .topbar { display: flex; }
  .rail {
    inset: 56px 0 auto 0; width: 100%; height: auto; max-height: calc(100vh - 56px);
    border-right: 0; border-bottom: var(--hairline);
    transform: translateY(-100%); opacity: 0; pointer-events: none;
    transition: transform var(--dur-mid) var(--ease), opacity var(--dur-mid) var(--ease);
  }
  .rail.is-open { transform: none; opacity: 1; pointer-events: auto; }
  .rail__head { display: none; }
  .machine { grid-template-columns: 1fr; }
  .machine__scene { border-left: 0; border-top: var(--hairline); min-height: 190px; }
  /* Touch targets go up to 44px once there is no mouse */
  .filter, .jump a { min-height: 44px; }
  /* Section headings park below the mobile top bar, not under it */
  .sect__head { top: 56px; }
  .sect__split { grid-template-columns: 1fr; }
  .sect__icon { width: 46px; height: 46px; }
  /* Too many chips to wrap comfortably on a phone — scroll them instead */
  .jump { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .jump::-webkit-scrollbar { display: none; }
  /* The two videos stack rather than squeeze */
  .vids { grid-template-columns: 1fr; }
  .warnband__head { padding: var(--space-4); }
  .warnband__icon { width: 44px; height: 44px; }
  .warnlist li { padding: var(--space-4); font-size: var(--fs-body); }
}

@media (max-width: 560px) {
  .btn { width: 100%; }
  .btn-row { flex-direction: column; }
  .step { padding-left: 0; padding-top: var(--space-8); }
  .step::before { top: var(--space-5); }
}

/* -------------------------------------------------------------- PRINT --- */
@media print {
  .rail, .topbar, .backdrop, .foot, .scene, .toc, .video__play { display: none !important; }
  .main { margin-left: 0; }
  body { background: #fff; color: #000; }
  .mod { break-inside: avoid; }
}
