/*
  The shared frame for WhatNickThinks, "home recorded".
  Every take is one of Nick's own tapes: it opens on a hand-written cassette
  label (with Fact / Opinion ticked), plays as calm footage, and ends on a
  camcorder STOP screen with the sign-off and a rewind. Analog texture only
  shows up when the reader does something: taps, changes scene, rewinds.
*/

:root {
  color-scheme: light dark;

  --bg: #f1f1ee;
  --ink: #18171a;
  --ink-muted: #545259;
  --line: #cfcec9;
  --pen: #2238a3;
  --rec: #cf2a1d;

  /* Physical things keep their own colours in both modes. */
  --shell: #1c1b1f;
  --shell-edge: #34333a;
  --paper: #ffffff;
  --paper-ink: #18171a;
  --paper-muted: #5a5860;
  --paper-rule: #c9cfe6;
  --paper-pen: #2238a3;
  /* Red for text and buttons on paper, which stays light in dark mode too. */
  --paper-rec: #cf2a1d;
  --screen: #0d0d10;
  --screen-ink: #f2f1ee;
  --screen-muted: #b9b7bd;
  --stamp: #ffb53c;

  /* Each tape gets its own label colour. Takes override this. */
  --tape: #f2b42a;

  --font-sans: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --font-hand: "Nanum Pen Script", "Bradley Hand", cursive;
  --font-osd: "DotGothic16", ui-monospace, monospace;

  --measure: 38rem;
  --wide: 64rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='120' viewBox='0 0 320 120' preserveAspectRatio='none'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.012 0.55' numOctaves='2' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 -2.4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131215;
    --ink: #ecebe7;
    --ink-muted: #aba9b0;
    --line: #38363d;
    --pen: #aab8ff;
    --rec: #ff5d50;
    --shell: #050506;
    --shell-edge: #3a3940;
    --paper: #e7e5df;
    --paper-rule: #b8bdd2;
    --paper-rec: #b82014;
    --screen: #050506;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.125rem;
  line-height: 1.6;
  overflow-wrap: normal;
  hyphens: manual;
}

a {
  color: var(--pen);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 0.16em;
}

:focus-visible {
  outline: 3px solid var(--pen);
  outline-offset: 3px;
}

/* `hidden` always hides, even on elements whose class sets a display, like deck keys. */
[hidden] {
  display: none !important;
}

/* Avoid a single word stranded on the last line. */
p,
figcaption,
.spine__summary {
  text-wrap: pretty;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.hand {
  font-family: var(--font-hand);
  font-weight: 400;
  line-height: 1;
  color: var(--paper-pen);
}

.osd {
  font-family: var(--font-osd);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

/* Wordmark: one word, with a REC light for the dot on Nick's i. */

.wordmark {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 75%;
  font-variation-settings: "opsz" 96;
  line-height: 0.9;
  letter-spacing: -0.01em;
  color: inherit;
  text-decoration: none;
}

.wordmark__i {
  position: relative;
}

.wordmark__i::after {
  content: "";
  position: absolute;
  top: 0.19em;
  left: 50%;
  width: 0.19em;
  height: 0.19em;
  border-radius: 50%;
  background: var(--rec);
  box-shadow: 0 0 0.1em rgb(255 60 40 / 0.5);
  transform: translateX(-50%);
}

/* Masthead: the same bar on every page, so the frame below starts at the same
   height everywhere. The small wordmark sits left and the links right. The
   homepage leaves out the small wordmark, because its frame is the wordmark. */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  max-width: calc(var(--wide) + 2 * var(--gutter));
  /* The top padding plus a 2.75rem row: one line of links at their tap size. */
  min-height: 3.75rem;
  margin: 0 auto;
  padding: 1rem var(--gutter) 0;
}

.masthead .wordmark {
  font-size: 1.75rem;
}

.masthead__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  margin-left: auto;
}

.masthead__nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.masthead__nav a:hover,
.masthead__nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.3em;
}

.masthead__nav a[aria-current="page"] {
  text-decoration-color: var(--rec);
}

/* On phones the bar stays one line at the default text size. */
@media (max-width: 30rem) {
  .masthead {
    column-gap: 1rem;
  }

  .masthead .wordmark {
    font-size: 1.375rem;
  }

  .masthead__nav {
    gap: 0 0.875rem;
  }
}

/* Short pages: every in-flow child spans the width so `margin: 0 auto` still
   centres it in the column, and the footer sits at the bottom of the window. */
body > :not(.counter, .rewind-noise) {
  width: 100%;
}

/* Taps on buttons and controls act at once, without waiting for a double-tap zoom. */
button,
label,
a {
  touch-action: manipulation;
}

/* Viewfinder corners: a frame drawn only at the corners. */

.viewfinder {
  --corner: 1.25rem;
  --corner-weight: 2px;
  --corner-color: var(--ink);
  --corner-inset: 0px;
  /* Top and bottom padding that keeps text out from under the corners. */
  --corner-clearance: calc(var(--corner-inset) + var(--corner) + 0.5rem);
  position: relative;
}

.viewfinder::before {
  content: "";
  position: absolute;
  inset: var(--corner-inset);
  background:
    linear-gradient(var(--corner-color) 0 0) top left / var(--corner) var(--corner-weight),
    linear-gradient(var(--corner-color) 0 0) top left / var(--corner-weight) var(--corner),
    linear-gradient(var(--corner-color) 0 0) top right / var(--corner) var(--corner-weight),
    linear-gradient(var(--corner-color) 0 0) top right / var(--corner-weight) var(--corner),
    linear-gradient(var(--corner-color) 0 0) bottom left / var(--corner) var(--corner-weight),
    linear-gradient(var(--corner-color) 0 0) bottom left / var(--corner-weight) var(--corner),
    linear-gradient(var(--corner-color) 0 0) bottom right / var(--corner) var(--corner-weight),
    linear-gradient(var(--corner-color) 0 0) bottom right / var(--corner-weight) var(--corner);
  background-repeat: no-repeat;
  pointer-events: none;
}

/* Film: the shared "footage" look. A still, warmly lit frame with grain and
   a vignette. Text inside switches to screen colours in both themes.
   Add `film--live` to let the grain move (used at the top and end of a page). */

.film {
  --ink: var(--screen-ink);
  --ink-muted: var(--screen-muted);
  --pen: #aab8ff;
  --corner-color: rgb(255 255 255 / 0.85);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 0.5rem;
  background:
    radial-gradient(60% 75% at 18% 28%, rgb(255 181 60 / 0.3), transparent 70%),
    radial-gradient(45% 60% at 95% 105%, rgb(207 42 29 / 0.22), transparent 70%),
    radial-gradient(120% 100% at 45% 40%, #2b2723 0%, #161417 65%, #0b0a0c 100%);
  box-shadow: inset 0 0 7rem 1rem rgb(0 0 0 / 0.55);
  color: var(--ink);
}

/* Grain sits over the picture but under the content and viewfinder corners.
   It's oversized so it can jump each "frame" without showing an edge, and
   moving it never repaints the picture. */
.film::after {
  content: "";
  position: absolute;
  inset: -50%;
  z-index: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  opacity: 0.55;
  pointer-events: none;
}

.film > * {
  position: relative;
  z-index: 1;
}

.film.viewfinder::before {
  z-index: 1;
}

/* Camcorder readouts look the same in every footage frame: bright, with a slight glow. */
.film .osd {
  color: var(--screen-ink);
  text-shadow: 0 0 0.3em rgb(255 255 255 / 0.4);
}

.film--live::after {
  animation: film-grain 1s steps(1) infinite;
}

/* About ten "frames" a second: the grain jumps, and its strength flickers
   very slightly, like light through a projector gate. */
@keyframes film-grain {
  0% { transform: translate(0, 0); opacity: 0.55; }
  10% { transform: translate(-5%, -8%); opacity: 0.5; }
  20% { transform: translate(-12%, 4%); opacity: 0.58; }
  30% { transform: translate(6%, -14%); opacity: 0.52; }
  40% { transform: translate(-4%, 18%); opacity: 0.56; }
  50% { transform: translate(-15%, 8%); opacity: 0.5; }
  60% { transform: translate(14%, 0); opacity: 0.57; }
  70% { transform: translate(0, 12%); opacity: 0.53; }
  80% { transform: translate(3%, -18%); opacity: 0.58; }
  90% { transform: translate(-10%, 9%); opacity: 0.51; }
}

@media (prefers-reduced-motion: reduce) {
  .film--live::after {
    animation: none;
  }
}

/* Tracking: a band of tape noise rolls through, and the picture slips.
   Only ever added in response to something the reader does. */

.tracking {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.tracking::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  height: 16%;
  background: var(--tracking-color, currentColor);
  /* One band of noise stretched to fit (no tiling seams), with soft edges. */
  mask:
    var(--noise) 0 0 / 100% 100% no-repeat,
    linear-gradient(transparent, #000 35% 65%, transparent);
  mask-composite: intersect;
  opacity: 0;
  pointer-events: none;
}

.tracking.is-tracking::after {
  animation: tracking-roll 460ms steps(7) both;
}

.tracking.is-tracking .tracking__picture {
  animation: tracking-slip 460ms steps(4) both;
}

@keyframes tracking-roll {
  0% { opacity: 0.85; transform: translateY(300%); }
  70% { opacity: 0.6; transform: translateY(40%); }
  100% { opacity: 0; transform: translateY(-120%); }
}

@keyframes tracking-slip {
  0% { transform: translateX(-0.5rem); filter: drop-shadow(3px 0 rgb(255 60 40 / 0.55)) drop-shadow(-3px 0 rgb(60 120 255 / 0.55)); }
  40% { transform: translateX(0.375rem) skewX(-3deg); }
  70% { transform: translateX(-0.125rem); filter: none; }
  100% { transform: none; filter: none; }
}

/* The opening: title, opinion note and the tape's label. */

.opening {
  max-width: calc(var(--wide) + 2 * var(--gutter));
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) var(--gutter) clamp(2rem, 5vw, 3.5rem);
}

.opening__frame {
  --corner: 1.75rem;
  --corner-weight: 3px;
  --corner-inset: clamp(0.75rem, 2vw, 1.125rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  align-items: center;
  gap: clamp(2.5rem, 6vw, 5rem);
  /* Side padding follows the screen width, not the text size, so large text keeps its room. */
  padding: max(clamp(2.5rem, 6vw, 4.5rem), var(--corner-clearance)) min(clamp(1.75rem, 5vw, 3.75rem), 7.5vw);
}

@media (max-width: 52rem) {
  .opening__frame {
    grid-template-columns: minmax(0, 1fr);
  }

  .opening .tape {
    transform: none;
  }
}

.opening__title {
  margin: 0;
  font-family: var(--font-display);
  /* Capped by the screen width, so the longest word fits a phone at large text sizes. */
  font-size: min(clamp(2.75rem, 1.5rem + 5vw, 5.75rem), 11.5vw);
  font-stretch: 80%;
  font-weight: 800;
  font-variation-settings: "opsz" 96;
  line-height: 0.92;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.opening__title:focus {
  outline: none;
}

.opening__dek {
  max-width: var(--measure);
  margin: 1.5rem 0 0;
  font-size: clamp(1.25rem, 1.05rem + 0.6vw, 1.5rem);
  line-height: 1.45;
}

.opening__note {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  max-width: var(--measure);
  margin: 2rem 0 0;
  font-size: 1rem;
  color: var(--ink-muted);
}

.opening__note svg {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.05rem;
}

/* The cassette: a black shell, a hand-written label, two reels. */

.tape {
  justify-self: center;
  width: min(100%, 32rem);
  container-type: inline-size;
  padding: min(0.9rem, 2.5vw) min(0.9rem, 2.5vw) 0;
  border-radius: 0.9rem;
  background: var(--shell);
  box-shadow:
    inset 0 0 0 1px var(--shell-edge),
    0 1.5rem 3rem -1.5rem rgb(0 0 0 / 0.45);
  transform: rotate(1.5deg);
}

.tape__label {
  position: relative;
  /* Padding and the printed wordmark follow the tape's width, so large text keeps its room. */
  --label-pad: min(1.1rem, 4.5cqi);
  padding: 0 var(--label-pad) var(--label-pad);
  border-radius: 0.3rem;
  background: var(--paper);
  color: var(--paper-ink);
  font-size: 0.9375rem;
  line-height: 1.3;
}

.tape__band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin: 0 calc(-1 * var(--label-pad)) 0.75rem;
  padding: 0.55rem var(--label-pad) 0.45rem;
  border-radius: 0.3rem 0.3rem 0 0;
  background: var(--tape);
  color: var(--shell);
}

.tape__band .wordmark {
  font-size: min(1.25rem, 8.5cqi);
}

.tape__band .wordmark__i::after {
  box-shadow: none;
}

/* Printed on the label, not glowing on a screen: ink colour, no glow. */
.tape__band .osd {
  color: inherit;
  text-shadow: none;
  font-size: 0.9375rem;
}

.tape__field {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.75rem;
  padding-block: 0.3rem 0.15rem;
  border-bottom: 1px solid var(--paper-rule);
}

.tape__field-name {
  flex: none;
  min-width: 4.75rem;
  font-size: 0.875rem;
  color: var(--paper-muted);
}

/* The Title's long words need the width cap; the short Take and date don't. */
.tape__field .hand {
  font-size: min(1.75rem, 13cqi);
}

.tape__row .hand {
  font-size: 1.75rem;
}

.tape__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
}

.tape__row .tape__field {
  flex: 1 1 9rem;
}

.tape__row .tape__field-name {
  min-width: 0;
}

.tape__kind {
  /* Sit at the top of its grid row so the boxes (and the tick) don't stretch. */
  align-self: start;
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 0.85rem 0 0;
  font-size: 0.9375rem;
}

.tape__box {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.tape__box::before {
  content: "";
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  border: 1.5px solid var(--paper-muted);
  border-radius: 2px;
}

.tape__box--ticked {
  position: relative;
}

.tape__box--ticked svg {
  position: absolute;
  left: -0.2rem;
  top: -0.55rem;
  width: 1.8rem;
  height: 1.8rem;
  color: var(--paper-pen);
}

/* With room, the label lays out like a real one: details left, contents right. */
@container (min-width: 24rem) {
  .tape__label {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    grid-template-rows: auto auto auto 1fr;
    column-gap: 1.5rem;
  }

  .tape__band {
    grid-column: 1 / -1;
  }

  .tape__label > nav {
    grid-column: 2;
    grid-row: 2 / span 3;
  }

  .tape__label > nav .tape__index-name {
    margin-top: 0.3rem;
  }
}

.tape__index-name {
  margin: 1rem 0 0.25rem;
  font-size: 0.875rem;
  color: var(--paper-muted);
}

.tape__index {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tape__index a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.75rem;
  padding-block: 0.2rem 0.1rem;
  border-bottom: 1px solid var(--paper-rule);
  color: var(--paper-pen);
  font-family: var(--font-hand);
  font-size: 1.45rem;
  line-height: 1.05;
  text-decoration: none;
}

.tape__index a:hover span:last-child {
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.12em;
}

.tape__index a:focus-visible {
  outline: 3px solid var(--paper-pen);
  outline-offset: 2px;
}

/* Time and scene name share a line; they only wrap when text is large. */
.tape__index a span:last-child {
  flex: 1 1 5rem;
}

.tape__time {
  min-width: 2.2em;
  font-variant-numeric: tabular-nums;
}

/* The window: smoked plastic with a sheen, two reels, and tape running along the bottom. */
.tape__window {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 4.75rem;
  margin: 0.8rem 12% 0;
  padding-inline: 0.75rem;
  overflow: hidden;
  border-radius: 0.4rem 0.4rem 0 0;
  background:
    linear-gradient(115deg, transparent 30%, rgb(255 255 255 / 0.07) 42%, transparent 54%),
    #201f24;
  box-shadow: inset 0 0 0 1px #3c3b42, inset 0 0.5rem 1rem rgb(0 0 0 / 0.5);
}

.tape__window::after {
  content: "";
  position: absolute;
  inset: auto 1.5rem 0.4rem;
  height: 2px;
  background: #4a3a30;
}

.reel {
  flex: none;
  width: min(4.25rem, 40%);
  aspect-ratio: 1;
}

.reel__pack { fill: #4a3a30; }
.reel__wind { fill: none; stroke: rgb(0 0 0 / 0.22); stroke-width: 0.75; }
.reel__hub { fill: #e4e2db; }
.reel__hole { fill: #201f24; }
.reel__teeth { fill: #e4e2db; }

/* Rewinding: the full reel turns slowly and the near-empty one spins fast, like real tape. */
.is-rewinding .reel {
  animation: reel-spin 800ms linear infinite reverse;
}

.is-rewinding .reel--empty {
  animation-duration: 420ms;
}

@keyframes reel-spin {
  to { transform: rotate(1turn); }
}

/* Scenes: the body of a take. Calm, left-aligned and readable. */

.scene {
  padding: clamp(2.25rem, 5.5vw, 4.25rem) var(--gutter);
}

.scene > * {
  max-width: var(--wide);
  margin-inline: auto;
}

.prose > * {
  max-width: var(--measure);
}

.scene__counter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25em;
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
  color: var(--ink-muted);
}

/* In the rant, each scene is a piece of evidence: EXHIBIT A, B, C. */
.scene__exhibit {
  color: var(--rec);
}

.prose h2 {
  margin: 0 0 1.25rem;
  font-family: var(--font-display);
  /* On phones with large text, headings stay above body text but below the page title. */
  font-size: min(clamp(2rem, 1.3rem + 2.6vw, 3.25rem), max(9vw, 1.25rem));
  font-stretch: 85%;
  font-weight: 750;
  font-variation-settings: "opsz" 72;
  line-height: 1.02;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.prose p {
  margin: 0 0 1em;
}

.prose p:last-child {
  margin-bottom: 0;
}

/* Footage: a still from the tape, with the date burned in. */

.nowrap {
  white-space: nowrap;
}

.footage {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1.5rem;
  min-width: 0;
  margin: 0;
  /* Padding follows the screen width, not the text size, so large text keeps its room. */
  padding: min(clamp(1.25rem, 4vw, 2.25rem), 6vw);
}

.footage__osd {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  font-size: 1.125rem;
  color: var(--screen-ink);
  text-shadow: 0 0 0.3em rgb(255 255 255 / 0.4);
}

.footage__body {
  align-self: center;
}

.footage__stamp {
  justify-self: end;
  font-family: var(--font-osd);
  font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--stamp);
  text-shadow: 0 0 0.35em rgb(255 170 50 / 0.55);
}

/* Then and now: two stills from the same tape, years apart, with a fast-forward between. */

.cuts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 1rem;
}

.cuts__skip {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.25rem;
  max-width: 7rem;
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
  text-align: center;
  color: var(--ink-muted);
}

.cuts__skip .osd {
  font-size: 1.75rem;
  color: var(--ink);
}

@media (max-width: 56rem) {
  .cuts {
    grid-template-columns: minmax(0, 1fr);
  }

  .cuts__skip {
    max-width: none;
    grid-auto-flow: column;
    justify-content: start;
    align-items: center;
    gap: 0.75rem;
    padding-left: 1rem;
  }
}

@media (min-width: 56.01rem) {
  .cuts .footage {
    min-height: 22rem;
  }
}

/* Text inside footage frames: quotes, captions and single lines set large. */

.footage__quote {
  margin: 0;
}

.footage__quote p,
.footage__line {
  margin: 0;
  max-width: 28ch;
  font-size: clamp(1.25rem, 1rem + 0.9vw, 1.75rem);
  line-height: 1.35;
  text-wrap: pretty;
}

.footage__line {
  font-family: var(--font-display);
  /* Capped by the screen width, so long words fit a phone at large text sizes. */
  font-size: min(clamp(1.75rem, 1.2rem + 1.8vw, 2.75rem), 9vw);
  font-stretch: 85%;
  font-weight: 700;
  line-height: 1.08;
}

.footage figcaption {
  margin-top: 1rem;
  font-size: 1rem;
  color: var(--screen-muted);
}

.prose .aside {
  margin-top: 3rem;
  font-family: var(--font-display);
  font-size: min(clamp(1.75rem, 1.3rem + 1.6vw, 2.75rem), max(9vw, 1.25rem));
  font-stretch: 85%;
  font-weight: 750;
  line-height: 1.1;
}

/* "Now, the rant.": the beat in every take where the argument starts.
   A REC light comes on, and the line is set large. */

.rant {
  padding: clamp(1.5rem, 4vw, 3rem) var(--gutter);
}

.rant__inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding-block: clamp(1.25rem, 3vw, 2rem);
  border-block: 2px solid var(--ink);
}

.rant__osd {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  color: var(--ink-muted);
}

.rant__osd::before {
  content: "";
  width: 0.65em;
  height: 0.65em;
  border-radius: 50%;
  background: var(--rec);
}

.rant__title {
  margin: 0;
  font-family: var(--font-display);
  /* Stays below the page title on phones with large text. */
  font-size: min(clamp(2.5rem, 1.5rem + 4.5vw, 5rem), 11vw);
  font-stretch: 80%;
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.015em;
}

/* Interactive pieces sit inside viewfinder corners, straight on the page. */

.stage {
  margin-block: 2.5rem;
  padding: max(clamp(1.25rem, 3.5vw, 2.5rem), var(--corner-clearance)) clamp(1.25rem, 3.5vw, 2.5rem);
}

/* A scene that ends on its stage already has the scene padding below it. */
.stage:last-child {
  margin-bottom: 0;
}

@media (max-width: 30rem) {
  .stage {
    padding-inline: 0.75rem;
  }
}

.stage figcaption {
  margin-top: 1rem;
  font-size: 1rem;
  color: var(--ink-muted);
}

/* Deck keys: the buttons on a tape deck, with a light that comes on. */

.deck-key {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
  padding: 0.5rem 1.1rem;
  border: 0;
  border-radius: 0.375rem;
  background: linear-gradient(to bottom, #2e2d33, var(--shell));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.12),
    0 2px 0 #000;
  color: #f2f1ee;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

@media (prefers-color-scheme: dark) {
  .deck-key {
    background: linear-gradient(to bottom, #4a4950, #2f2e34);
    box-shadow:
      inset 0 1px 0 rgb(255 255 255 / 0.18),
      0 2px 0 #000;
  }

  /* Keep the film vignette and add a faint edge, so frames don't melt into the page. */
  .film {
    box-shadow:
      inset 0 0 0 1px rgb(255 255 255 / 0.14),
      inset 0 0 7rem 1rem rgb(0 0 0 / 0.55);
  }
}

.deck-key:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.08);
}

.deck-key__light {
  flex: none;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: #4a4950;
}

.deck-key:focus-visible {
  outline-color: var(--pen);
}

/* A key that's latched down sits lower, shaded inside, with its light on.
   A disabled key is busy (sending, say), so its light is on too. */
.deck-key.is-down,
.deck-key:has(input:checked) {
  background: linear-gradient(to bottom, var(--shell), #2e2d33);
  box-shadow: inset 0 2px 4px rgb(0 0 0 / 0.6);
  transform: translateY(2px);
}

.deck-key.is-down .deck-key__light,
.deck-key:has(input:checked) .deck-key__light,
.deck-key:disabled .deck-key__light {
  background: var(--rec);
  box-shadow: 0 0 0.5rem rgb(255 70 50 / 0.8);
}

/* The ending: the camcorder's STOP screen, the sign-off, and a rewind. */

.ending {
  padding: clamp(1rem, 3vw, 2rem) var(--gutter);
}

.ending__screen {
  --corner-color: rgb(255 255 255 / 0.7);
  --corner: 1.75rem;
  --corner-inset: 0.875rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  gap: 2.5rem;
  max-width: var(--wide);
  min-height: min(44rem, 90svh);
  margin: 0 auto;
  padding: max(clamp(1.5rem, 5vw, 3.5rem), var(--corner-clearance)) min(clamp(1.5rem, 5vw, 3.5rem), 6.5vw);
}

.ending__osd {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin: 0;
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.5rem);
  text-shadow: 0 0 0.3em rgb(255 255 255 / 0.4);
}

.ending__stop {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
}

.ending__stop::before {
  content: "";
  width: 0.7em;
  height: 0.7em;
  background: currentColor;
}

.ending__body {
  align-self: center;
}

.ending__title {
  margin: 0;
  max-width: 14ch;
  font-family: var(--font-display);
  font-size: min(clamp(2.5rem, 1.25rem + 5vw, 5.5rem), 11.5vw);
  font-stretch: 80%;
  font-weight: 800;
  font-variation-settings: "opsz" 96;
  line-height: 0.92;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.ending__dek {
  margin: 1.25rem 0 0;
  font-size: clamp(1.25rem, 1.05rem + 0.8vw, 1.75rem);
  color: var(--screen-ink);
}

.ending__foot .footage__stamp {
  margin-inline-start: auto;
}

.ending__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
}

.signoff {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 1.1rem + 1vw, 2rem);
  font-stretch: 85%;
  font-weight: 600;
  line-height: 1.15;
}

.signoff .wordmark {
  font-size: 1.15em;
}

.rewind {
  display: flex;
  justify-content: center;
  margin: 2rem 0 0;
}

/* Like every deck key, the Rewind light is only on while it's working. */
.is-rewinding .rewind__button .deck-key__light {
  background: var(--rec);
  box-shadow: 0 0 0.5rem rgb(255 70 50 / 0.8);
}

/* End credits: the inside of the sleeve. */

.credits {
  max-width: calc(var(--wide) + 2 * var(--gutter));
  margin: 0 auto;
  padding: clamp(3rem, 7vw, 5rem) var(--gutter) clamp(3rem, 7vw, 5rem);
}

.credits__inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 2.5rem 4rem;
}

.credits h2 {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: min(1.5rem, max(9vw, 1.25rem));
  font-stretch: 85%;
  font-weight: 700;
}

.credits__sleeve {
  justify-self: start;
  width: min(100%, 26rem);
  padding: 1.25rem 1.5rem 1.5rem;
  border-top: 0.6rem solid var(--tape);
  border-radius: 0.3rem;
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow: 0 1rem 2rem -1.25rem rgb(0 0 0 / 0.4);
  transform: rotate(-1deg);
}

@media (max-width: 30rem) {
  .credits__sleeve {
    transform: none;
  }
}

.credits__roll {
  display: grid;
  gap: 0.5rem;
  margin: 0;
}

.credits__roll div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 1rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--paper-rule);
}

.credits__roll dt {
  min-width: 6rem;
  font-size: 0.9375rem;
  color: var(--paper-muted);
}

.credits__roll dd {
  margin: 0;
  font-size: 1.75rem;
}

.credits__sources {
  margin: 0;
  padding: 0;
  list-style: none;
}

.credits__sources li + li {
  margin-top: 0.75rem;
}

.credits__home {
  margin: 3rem 0 0;
  font-size: 1rem;
  color: var(--ink-muted);
}

/* Site footer: links to every page, on every page. */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  max-width: calc(var(--wide) + 2 * var(--gutter));
  /* Auto top margin: on a short page, the footer sits at the bottom of the window. */
  margin: auto auto 0;
  font-family: var(--font-display);
  padding: 2rem var(--gutter) 3rem;
  font-size: 1rem;
  color: var(--ink-muted);
}

.site-footer__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.site-footer p {
  margin: 0;
}

/* Leave room under the footer for the tape counter, which shows on wide screens. */
@media (min-width: 85rem) {
  body:has(.counter) .site-footer {
    padding-bottom: 6.5rem;
  }
}

/* Copy that's still a placeholder: Nick's own words replace it before launch.
   `pnpm build` lists every page that still has some. */

[data-placeholder] {
  text-decoration: underline dashed var(--rec);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

/* The tape counter: a small camcorder readout while you read. Wide screens only. */

.counter {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 10;
  display: none;
  gap: 0.15rem;
  padding: 0.55rem 0.8rem 0.5rem;
  border-radius: 0.375rem;
  background: rgb(13 13 16 / 0.9);
  color: var(--screen-ink);
  font-size: 1rem;
  text-shadow: 0 0 0.3em rgb(255 255 255 / 0.35);
  --tracking-color: #fff;
}

.counter[data-ready] {
  display: grid;
}

@media (max-width: 84.99rem) {
  .counter[data-ready] {
    display: none;
  }
}

.counter__time {
  font-size: 1.375rem;
  font-variant-numeric: tabular-nums;
}

/* Rewind: tape noise over everything while the page winds back. */

.rewind-noise {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  background: var(--ink);
  mask: var(--noise) 0 0 / 100% 14rem repeat-y;
}

.is-rewinding .rewind-noise {
  animation: rewind-noise 280ms steps(3) infinite;
}

@keyframes rewind-noise {
  0% { opacity: 0.18; mask-position: 0 0; }
  50% { opacity: 0.1; mask-position: 0 5rem; }
  100% { opacity: 0.16; mask-position: 0 -3rem; }
}

@media (prefers-reduced-motion: reduce) {
  .tracking.is-tracking::after,
  .tracking.is-tracking .tracking__picture,
  .is-rewinding .rewind-noise,
  .is-rewinding .reel {
    animation: none;
  }
}

/* Changing pages: putting a tape in. The page slips out, a blip of tape noise,
   and the next one rolls in. Opening a take, the label of the tape you picked
   grows into its cassette label (the homepage names it, in home.ts), and shrinks
   back onto the shelf on the way out. Browsers without cross-page transitions,
   and readers who prefer less motion, get an ordinary page load. */

@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}

/* The bar at the top holds still while the page changes under it. */
.masthead {
  view-transition-name: masthead;
}

.tape__label {
  view-transition-name: tape;
}

/* Faint tape noise behind both pages: it shows in the gap between one leaving
   and the next arriving. The page colour over it keeps it to a blip. */
::view-transition-image-pair(root) {
  background:
    linear-gradient(color-mix(in srgb, var(--bg) 78%, transparent) 0 0),
    var(--noise) 0 0 / 100% 14rem repeat-y,
    var(--bg);
}

::view-transition-old(root) {
  animation: tape-out 150ms ease-in both;
}

::view-transition-new(root) {
  animation: tape-in 280ms steps(5, end) 110ms both;
}

/* The label travels as blank paper while its words swap, so it never vanishes mid-flight. */
::view-transition-group(tape) {
  border-radius: 0.3rem;
  background: var(--paper);
  animation-duration: 420ms;
  animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
}

/* The label's words swap rather than blend: the old ones go first, the new
   ones arrive as it settles, so two sets of text never overlap. */
::view-transition-old(tape) {
  animation: label-out 120ms ease-out both;
}

::view-transition-new(tape) {
  animation: label-in 180ms ease-in 220ms both;
}

@keyframes label-out {
  to { opacity: 0; }
}

@keyframes label-in {
  from { opacity: 0; }
}

@keyframes tape-out {
  to {
    opacity: 0;
    transform: translateY(-0.5rem);
    filter: brightness(1.25) contrast(1.15);
  }
}

@keyframes tape-in {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
    filter: brightness(1.4) contrast(1.25);
  }

  50% {
    opacity: 1;
    transform: translateY(-0.2rem);
  }
}
