/*
  You Had to Be There: components, built on design/tokens.css and nothing else.
  Shared by the site and the specimen page (system/), so the two can't drift.
  Every state in design/README.md section 5 is reachable two ways: by the real pseudo-class
  (:hover, :focus-visible, :active, :checked) and, for the specimen, forced with
  data-state="hover|focus|pressed|on|…". "Inverted" swaps ground and ink.
*/
@layer tokens, base, components, app;

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

  :root {
    color-scheme: light;
    font: var(--font-body);
    color: var(--now-ink);
    background: var(--now-ground);
    -webkit-font-smoothing: antialiased;
  }

  body {
    margin: 0;
  }

  button,
  input {
    font: inherit;
    color: inherit;
  }

  .visually-hidden {
    position: absolute;
    inline-size: var(--line);
    block-size: var(--line);
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* text whose box should end at its letters, so insets measure true */
  .trim {
    text-box: trim-both cap alphabetic;
  }
}

@layer components {
  /* ── Icon ─────────────────────────────────────────────────────────────── */
  .icon {
    display: inline-grid;
    place-items: center;
    inline-size: var(--icon-box);
    block-size: var(--icon-box);
    flex: none;
  }

  .icon svg {
    inline-size: var(--icon);
    block-size: var(--icon);
    fill: none;
    stroke: currentColor;
    stroke-width: var(--line-strong);
    stroke-linecap: square;
    stroke-linejoin: miter;
  }

  /* ── Button (and the parts every control shares) ──────────────────────── */
  .button,
  .icon-button,
  .switch {
    --c-ground: var(--btn-ground, var(--now-ground));
    --c-ink: var(--btn-ink, var(--now-ink));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-block-size: var(--control);
    padding: 0 var(--space-3);
    margin: 0;
    font: var(--font-control);
    letter-spacing: var(--track-none);
    white-space: nowrap;
    color: var(--c-ink);
    background: var(--c-ground);
    border: var(--line) solid var(--c-ink);
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition:
      color var(--t-press) var(--ease-press),
      background-color var(--t-press) var(--ease-press),
      translate var(--t-press) var(--ease-press);
  }

  .button > .label,
  .switch .words {
    text-box: trim-both cap alphabetic;
  }

  .icon-button {
    inline-size: var(--control);
    padding: 0;
  }

  /* hover and pressed invert; pressed also sinks by a line */
  :is(.button, .icon-button):not([aria-pressed]):is(:hover, [data-state~="hover"]):not([aria-disabled="true"]),
  :is(.button, .icon-button):is(:active, [data-state~="pressed"]):not([aria-disabled="true"]),
  .switch:is(:active, [data-state~="pressed"]) {
    color: var(--c-ground);
    background: var(--c-ink);
  }

  :is(.button, .icon-button):is(:active, [data-state~="pressed"]):not([aria-disabled="true"]),
  .switch:is(:active, [data-state~="pressed"]) {
    translate: 0 var(--line);
  }

  /*
    a switch or a toggle under the pointer: a --line-strong border instead of inversion, so an
    inverted control always means "on"; the padding gives back what the border takes, so nothing moves
  */
  .switch:is(:hover, [data-state~="hover"]),
  :is(.button, .icon-button)[aria-pressed]:is(:hover, [data-state~="hover"]):not([aria-disabled="true"]) {
    border-width: var(--line-strong);
    padding-inline: calc(var(--space-3) - var(--line-strong) + var(--line));
  }

  .icon-button[aria-pressed]:is(:hover, [data-state~="hover"]) {
    padding-inline: 0;
  }

  :is(.button, .icon-button):is(:focus-visible, [data-state~="focus"]),
  .switch:is(:has(input:focus-visible), [data-state~="focus"]) {
    outline: var(--line-strong) solid var(--c-ink);
    outline-offset: var(--focus-offset);
  }

  :is(.button, .icon-button)[aria-disabled="true"] {
    color: var(--now-ink-disabled);
    border-color: var(--now-ink-disabled);
    border-style: dashed;
    cursor: default;
  }

  /* a toggle that is on stays inverted; its words say the state */
  :is(.button, .icon-button)[aria-pressed="true"] {
    color: var(--c-ground);
    background: var(--c-ink);
  }

  /* on a sheet, a control takes the sheet's pair */
  .sheet .button,
  .sheet .icon-button,
  .open-sheet .button {
    --btn-ground: var(--ground);
    --btn-ink: var(--ink);
  }

  /* ── Sound switch: says plainly whether sound is on ─────────────────────── */
  .switch input {
    position: absolute;
    inline-size: var(--line);
    block-size: var(--line);
    margin: 0;
    opacity: 0;
    pointer-events: none;
  }

  .switch {
    position: relative;
  }

  .switch .icon-on {
    display: none;
  }

  /* one width, on or off: both words share one place and the bars keep theirs, so the bar never shifts */
  .switch .words {
    display: inline-grid;
  }

  .switch .words > :is(.on, .off) {
    grid-area: 1 / 1;
  }

  .switch .on,
  .switch .bars {
    visibility: hidden;
  }

  .switch:is(:has(input:checked), [data-state~="on"]) {
    color: var(--c-ground);
    background: var(--c-ink);
  }

  .switch:is(:has(input:checked), [data-state~="on"]) :is(.on, .bars) {
    visibility: visible;
  }

  .switch:is(:has(input:checked), [data-state~="on"]) .icon-on {
    display: inline-grid;
  }

  .switch:is(:has(input:checked), [data-state~="on"]) .icon-off {
    display: none;
  }

  .switch:is(:has(input:checked), [data-state~="on"]) .off {
    visibility: hidden;
  }

  /* three small level bars that move only while something is audible */
  .switch .bars {
    display: inline-flex;
    align-items: flex-end;
    gap: var(--line);
    block-size: var(--icon);
  }

  .switch .bars i {
    display: block;
    inline-size: var(--switch-bar);
    block-size: var(--icon);
    background: currentColor;
    scale: 1 0.3;
    transform-origin: 50% 100%;
  }

  .switch:is([data-audible], [data-state~="audible"]) .bars i {
    animation: level var(--t-paste) var(--ease-press) infinite alternate;
  }

  .switch .bars i:nth-child(2) {
    animation-delay: calc(var(--t-press) * -1);
  }

  .switch .bars i:nth-child(3) {
    animation-delay: calc(var(--t-quick) * -1);
  }

  @keyframes level {
    from { scale: 1 0.3; }
    to { scale: 1 1; }
  }

  /* on a phone the words shorten; they are never dropped */
  .switch .short {
    display: none;
  }

  @media (max-width: 599px) {
    .switch .long {
      display: none;
    }

    .switch .short {
      display: inline;
    }
  }

  .switch[data-state~="short"] .long {
    display: none;
  }

  .switch[data-state~="short"] .short {
    display: inline;
  }

  /* ── Bar ───────────────────────────────────────────────────────────────── */
  .bar {
    position: relative;
    z-index: var(--z-bar);
    display: flex;
    /* the controls sit --space-2 from the top, on the grid; the rule under them takes a line of the last --space-2 */
    align-items: flex-start;
    block-size: var(--bar);
    gap: var(--space-2);
    padding: var(--space-2) var(--margin) 0;
    color: var(--now-ink);
    background: var(--now-ground);
    border-block-end: var(--line) solid var(--now-ink);
  }

  .bar-title,
  .bar-name {
    align-self: center;
  }

  .bar-title {
    flex: 1;
    min-inline-size: 0;
    margin: 0 0 0 var(--space-2);
    overflow: hidden;
    font: var(--font-bar-title);
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .bar-name {
    flex: 1;
    margin: 0;
    font: var(--font-bar-title);
  }

  .bar nav {
    display: flex;
    gap: var(--space-2);
  }

  /* where the bar is too narrow for words: icons, named; Sound keeps its word; three controls move to the wall's end */
  @media (max-width: 599px) {
    .bar .bar-more {
      display: none;
    }

    .bar .button > .label {
      position: absolute;
      inline-size: var(--line);
      block-size: var(--line);
      overflow: hidden;
      clip-path: inset(50%);
    }

    .bar .button {
      inline-size: var(--control);
      padding: 0;
    }
  }

  .bar[data-state~="narrow"] .bar-more {
    display: none;
  }

  .bar[data-state~="narrow"] .button > .label {
    position: absolute;
    inline-size: var(--line);
    block-size: var(--line);
    overflow: hidden;
    clip-path: inset(50%);
  }

  .bar[data-state~="narrow"] .button {
    inline-size: var(--control);
    padding: 0;
  }

  .bar[data-state~="narrow"] .switch .long {
    display: none;
  }

  .bar[data-state~="narrow"] .switch .short {
    display: inline;
  }

  /* ── The dateline and the wordmark (Round 8) ──────────────────────────── */
  /* without the masthead flag the dateline is only the moment's name, as before */
  .dateline,
  .dateline .cell-title,
  .dateline .cell-label {
    display: contents;
  }

  .dateline .cell-label-text,
  .dateline [data-cell],
  .bar-home .mark,
  .bar-year {
    display: none;
  }

  .dateline dd {
    margin: 0;
  }

  /* ── The masthead (Round 8, flag "masthead") ─────────────────────────── */
  @media (min-width: 600px) {
    :root[data-r8~="masthead"] {
      --bar: var(--bar-mast);
    }
  }

  :root[data-r8~="masthead"] {
    .bar {
      align-items: center;
      gap: 0;
      padding-block: 0;
    }

    .bar-home .mark {
      display: inline;
    }

    .bar-name,
    .bar-home .mark {
      font: var(--font-mark);
      letter-spacing: var(--track-field);
      white-space: nowrap;
    }

    /* the house and the wordmark are one button: Home */
    .bar-home {
      padding-inline: var(--space-2) var(--space-3);
    }

    .bar-home > .label {
      display: none;
    }

    .dateline {
      display: flex;
      flex: 1 1 0;
      align-items: center;
      gap: var(--space-5);
      min-inline-size: 0;
      align-self: stretch;
      margin: 0 0 0 var(--space-3);
      padding-inline: var(--space-4) var(--space-3);
      border-inline-start: var(--line) solid var(--now-ink);
      container-type: inline-size;
    }

    .dateline .cell-title,
    .dateline [data-cell] {
      display: grid;
      align-content: center;
      gap: var(--space-1);
      min-inline-size: 0;
    }

    .dateline .cell-title {
      flex: 0 1 auto;
    }

    /* a cell keeps its own width: when there is no room it gives way whole, never squeezed */
    .dateline [data-cell] {
      flex: none;
    }

    .dateline .cell-label {
      display: block;
      font: var(--font-source);
      letter-spacing: var(--track-small);
      white-space: nowrap;
      color: var(--now-ink-soft);
    }

    .dateline .cell-label-text {
      display: inline;
    }

    /* the building line takes the title's label while it shows */
    .cell-label:has(.building:not([hidden])) .cell-label-text {
      display: none;
    }

    .dateline .building {
      display: inline;
      margin: 0;
      overflow: visible;
    }

    .dateline .cell-answer {
      font: var(--font-cell);
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }

    /* the moment's name, fitted down from --text-5 to --text-3 (paper.js), never cut: at the floor it may take two lines */
    .dateline .bar-title {
      flex: none;
      overflow: visible;
      font: var(--font-mast-title);
      font-size: var(--mast-size, var(--text-5));
      letter-spacing: var(--track-tight);
      white-space: nowrap;
      text-overflow: clip;
    }

    .dateline .bar-title[data-wrap] {
      white-space: normal;
      text-wrap: balance;
    }

    /* a very long name at the floor: its label gives way, so it may take a third line, still inside the bar */
    .dateline .cell-title[data-nolabel] > .cell-label {
      position: absolute;
      inline-size: var(--line);
      block-size: var(--line);
      overflow: hidden;
      clip-path: inset(50%);
    }

    /* cells give way from the end when the name needs the room (paper.js fits it): sources, years ago, the date.
       Gone from sight, not from screen readers */
    .dateline [data-cell][data-dropped] {
      position: absolute;
      inline-size: var(--line);
      block-size: var(--line);
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }

    /* all moments: the name only */
    .dateline[data-archive] [data-cell] {
      display: none;
    }

    /* Earlier and Later, the moment's year between them */
    .bar nav {
      align-items: center;
      gap: 0;
      padding-inline: var(--space-3);
      border-inline-start: var(--line) solid var(--now-ink);
    }

    .bar-year {
      display: inline;
      padding-inline: var(--space-2);
      font: var(--font-cell);
      font-variant-numeric: tabular-nums;
    }

    /* the controls: no outline at rest; hover, press and focus invert; groups parted by a hairline */
    .bar :is(.button, .icon-button, .switch) {
      border-color: transparent;
    }

    .bar :is(.button, .icon-button):is(:focus-visible, [data-state~="focus"]):not([aria-disabled="true"]) {
      color: var(--c-ground);
      background: var(--c-ink);
    }

    .bar [aria-disabled="true"] {
      opacity: 0.4;
      border-style: solid;
    }

    .bar [data-years] {
      margin-inline-start: var(--space-3);
    }

    .bar .switch {
      margin-inline-start: var(--space-3);
      padding-inline-start: var(--space-4);
      border-inline-start: var(--line) solid var(--now-ink);
      border-radius: 0;
    }

    /* a switch under the pointer: a heavy rule under its word, never inversion (inverted means "on") */
    .bar .switch:is(:hover, [data-state~="hover"]) {
      border-width: 0 0 0 var(--line);
      padding-inline: var(--space-4) var(--space-3);
      text-decoration: underline var(--line-strong);
      text-underline-offset: var(--space-1);
    }

    /* below 1024 px on a wall the house alone is Home (the wordmark is on the start screen), and Sound says
       "On" or "Off": the name needs the room */
    @media (min-width: 600px) and (max-width: 1023px) {
      .bar-home .mark {
        display: none;
      }

      .bar-home {
        inline-size: var(--control);
        padding: 0;
      }

      .bar .switch .long {
        display: none;
      }

      .bar .switch .short {
        display: inline;
      }
    }

    /* from 600 to 819 px All moments, Save poster and Share go to the wall's end, as on a phone, and the year
       between Earlier and Later gives way: the longest name in the archive still fits in two lines */
    @media (min-width: 600px) and (max-width: 819px) {
      .bar :is([data-all], [data-poster], .copy),
      .bar-year {
        display: none;
      }

      .wall-end {
        display: grid;
      }
    }

    /* from 820 to 1199 px they are icons, named, with their hint */
    @media (min-width: 820px) and (max-width: 1199px) {
      .bar .bar-more > .label,
      .bar .copy .button > .label {
        position: absolute;
        inline-size: var(--line);
        block-size: var(--line);
        overflow: hidden;
        clip-path: inset(50%);
      }

      .bar :is(.bar-more.button, .copy .button) {
        inline-size: var(--control);
        padding: 0;
      }
    }
  }

  /* ── The phone's two-row bar (Round 8, flag "phoneBar") ──────────────── */
  @media (max-width: 599px) {
    :root[data-r8~="masthead"][data-r8~="phoneBar"] {
      --bar: var(--bar-phone);

      /* the start screen has no second row to show: one row, as before */
      &:has(body[data-phase="ask"]) {
        --bar: calc(var(--control) + 2 * var(--space-2));
      }

      .bar {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto auto;
        grid-template-areas: "home . nav sound" "line line line line";
        align-items: center;
        row-gap: 0;
        padding-block: var(--space-1);
      }

      .bar-home,
      .bar-name {
        grid-area: home;
      }

      .bar-home {
        inline-size: auto;
        padding-inline: var(--space-1) var(--space-2);
      }

      .bar-name,
      .bar-home .mark {
        font-size: var(--text-4);
      }

      .bar nav {
        grid-area: nav;
        border: 0;
        padding: 0;
      }

      .bar .switch {
        grid-area: sound;
        border: 0;
        margin: 0;
        padding-inline: var(--space-2);
      }

      .dateline {
        grid-area: line;
        align-self: stretch;
        margin: 0;
        padding: 0;
        border: 0;
      }

      .dateline :is([data-cell="ago"], [data-cell="sources"]),
      .bar-year,
      .bar .switch .long {
        display: none;
      }

      .bar .switch .short {
        display: inline;
      }
    }
  }

  /* ── Wall's end (phone): All moments, Save poster and Share, worded, in equal columns ── */
  .wall-end {
    display: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
    padding: var(--margin);
    color: var(--now-ink);
    background: var(--now-ground);
  }

  @media (max-width: 599px) {
    .wall-end {
      display: grid;
    }
  }

  .wall-end[data-state~="shown"] {
    display: grid;
  }

  .wall-end .button,
  .wall-end .copy {
    inline-size: 100%;
    min-inline-size: 0;
  }

  .wall-end .copy .button {
    flex: 1;
  }

  /* at the end of the page, Share's bubble opens above it */
  .wall-end .bubble {
    inset: auto 0 calc(100% + var(--space-2)) auto;
  }

  /* ── Field ────────────────────────────────────────────────────────────── */
  .field {
    display: grid;
    gap: var(--space-2);
    inline-size: 100%;
  }

  .field-prompt {
    font: var(--font-prompt);
  }

  .field-input {
    inline-size: 100%;
    margin: 0;
    padding: 0 0 var(--space-2);
    font: var(--font-field);
    letter-spacing: var(--track-field);
    color: var(--now-ink);
    background: transparent;
    border: 0;
    border-block-end: var(--line-strong) solid var(--now-ink);
    border-radius: var(--radius);
    outline: none;
  }

  .field-input::placeholder {
    color: var(--now-ink-soft);
  }

  .field-input:is(:hover, [data-state~="hover"]) {
    cursor: text;
  }

  .field-input:is(:focus-visible, :focus, [data-state~="focus"]) {
    border-block-end-width: var(--line-heavy);
    padding-block-end: calc(var(--space-2) - var(--line-heavy) + var(--line-strong));
  }

  .field-input[readonly] {
    cursor: default;
  }

  .field-note {
    min-block-size: var(--space-5);
    margin: 0;
    font: var(--font-status);
    letter-spacing: var(--track-small);
  }

  /* "Looking for …" shares the note's line, so nothing below moves when one replaces the other (round 7) */
  .field-note + .field-status {
    margin-block-start: calc(var(--space-5) * -1);
  }

  /* several things share the name: the matches to pick from, as links like the decades' moments */
  .choices {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-2) 0 0;
    padding: 0;
    list-style: none;
  }

  .choices li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-1) var(--space-3);
  }

  .choice-note {
    font: var(--font-source);
    letter-spacing: var(--track-small);
    color: var(--now-ink-soft);
  }

  /* ── Decade rail and card ─────────────────────────────────────────────── */
  .rail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-block-end: var(--space-3);
  }

  .rail-title {
    margin: 0;
    font: var(--font-label);
    text-box: trim-both cap alphabetic;
  }

  .rail {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    padding: 0;
    list-style: none;
    border-block-start: var(--line) solid var(--now-ink);
    border-inline-start: var(--line) solid var(--now-ink);
  }

  @media (min-width: 600px) {
    .rail {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }
  }

  @media (min-width: 1024px) {
    .rail {
      grid-template-columns: repeat(8, minmax(0, 1fr));
    }
  }

  .era-card {
    position: relative;
    display: grid;
    align-content: start;
    gap: var(--space-2);
    padding: var(--space-3);
    color: var(--now-ink);
    background: var(--now-ground);
    border-inline-end: var(--line) solid var(--now-ink);
    border-block-end: var(--line) solid var(--now-ink);
    transition:
      color var(--t-quick) var(--ease-arrive),
      background-color var(--t-quick) var(--ease-arrive);
  }

  /* the first colour a visitor sees: pointing at a decade */
  .era-card:is(:hover, :focus-within, [data-state~="hover"], [data-state~="focus"]) {
    color: var(--card-ink);
    background: var(--card-ground);
  }

  /* visited this session: a heavy rule along the top in the decade's ink */
  .era-card:is([data-visited], [data-state~="visited"])::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    block-size: var(--line-heavy);
    background: var(--card-rule);
  }

  /* the decade's photo across the card's top: ink on stock at rest, on the decade's ground when pointed at */
  /*
    A two-tone print: the grey photo multiplied onto the lighter colour, then the darker colour lightened over
    it, so black prints in the darker colour and white in the lighter. At rest that is ink on stock; pointed
    at, the decade's pair (--card-dark and --card-light, which the page sets from the pair).
  */
  .era-card {
    --photo-dark: var(--now-ink);
    --photo-light: var(--now-ground);
  }

  .era-card:is(:hover, :focus-within, [data-state~="hover"], [data-state~="focus"]) {
    --photo-dark: var(--card-dark, var(--card-ink));
    --photo-light: var(--card-light, var(--card-ground));
  }

  .era-photo {
    position: relative;
    aspect-ratio: 4 / 3;
    margin: calc(var(--space-3) * -1) calc(var(--space-3) * -1) var(--space-1);
    overflow: hidden;
    isolation: isolate;
    background: var(--photo-light);
    transition: background-color var(--t-quick) var(--ease-arrive);
  }

  .era-photo::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--photo-dark);
    mix-blend-mode: lighten;
    transition: background-color var(--t-quick) var(--ease-arrive);
  }

  .era-photo img {
    display: block;
    inline-size: 100%;
    block-size: 100%;
    object-fit: cover;
    object-position: 50% 30%;
    filter: grayscale(1) contrast(1.15);
    mix-blend-mode: multiply;
  }

  .era-name {
    margin: 0;
    font: var(--card-weight) var(--decade-size) / 1 var(--card-face);
  }

  .era-card ul {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* ── Round 8: the archive's numbers on the start screen ───────────────── */
  /* label-and-answer pairs in the rail's head, between "Try these" and Surprise me */
  .rail-head {
    flex-wrap: wrap;
  }

  .stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-6);
    margin: 0 auto 0 var(--space-6);
  }

  .stat {
    display: grid;
    gap: var(--space-1);
  }

  .stat-label {
    font: var(--font-source);
    letter-spacing: var(--track-small);
    color: var(--now-ink-soft);
  }

  .stat-answer {
    display: grid;
    justify-items: start;
    gap: var(--space-1);
    margin: 0;
  }

  @media (max-width: 599px) {
    .stats {
      order: 3;
      flex-basis: 100%;
      margin: var(--space-3) 0 0;
    }
  }

  [data-stat="total"] .odometer {
    font: 700 var(--text-6) / 1 var(--now);
    letter-spacing: var(--track-tight, 0);
  }

  .stat-note {
    font: var(--font-source);
    letter-spacing: var(--track-small);
    color: var(--now-ink-soft);
    font-variant-numeric: tabular-nums;
  }

  /* an odometer: one column of digits each, rolled to its place; tabular, so the number never changes width */
  .odometer {
    display: inline-flex;
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }

  .odo {
    display: inline-flex;
  }

  .odo-digit {
    display: inline-block;
    inline-size: 1ch;
    block-size: 1em;
    overflow: hidden;
  }

  .odo-strip {
    display: grid;
    translate: 0 calc(var(--d) * -1em);
  }

  .odo-strip > span {
    block-size: 1em;
    text-align: center;
  }

  @media (prefers-reduced-motion: no-preference) {
    .odometer[data-rolling] .odo-strip {
      transition: translate var(--t-move) var(--ease-travel) calc(var(--k) * var(--stagger-digit));
    }
  }

  .era-count {
    margin: 0;
    font: var(--font-source);
    letter-spacing: var(--track-small);
    font-variant-numeric: tabular-nums;
  }

  /* a decade's ruler along its card's top: ten years, each a bar as tall as its share of the busiest year */
  .ruler {
    position: relative;
    display: grid;
    gap: var(--space-1);
    margin: calc(var(--space-3) * -1) calc(var(--space-3) * -1) 0;
    padding: var(--space-2) var(--space-3) var(--space-1);
    cursor: pointer;
  }

  .ruler {
    margin-block-end: var(--space-2);
  }

  /* one hairline under every card's bars: at desktop the eight read as one ruler from 1950 to now */
  .ruler-bars {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    align-items: end;
    block-size: var(--ruler-bar);
    border-block-end: var(--line) solid currentColor;
  }

  .ruler-slot {
    display: grid;
    justify-items: center;
    align-items: end;
    block-size: 100%;
  }

  .ruler-slot > i {
    inline-size: var(--space-1);
    block-size: max(calc(var(--n) * var(--ruler-bar)), 2px);
    background: currentColor;
  }

  .ruler-slot[data-empty] > i {
    visibility: hidden;
  }

  /* the year under the pointer or the keyboard: its slot inverted */
  .ruler-slot[data-on] {
    color: var(--now-ground);
    background: var(--now-ink);
  }

  .era-card:is(:hover, :focus-within) .ruler-slot[data-on] {
    color: var(--card-ground);
    background: var(--card-ink);
  }

  .ruler-value {
    display: grid;
    margin: 0;
    font: var(--font-source);
    letter-spacing: var(--track-small);
    font-variant-numeric: tabular-nums;
  }

  .ruler-value > * {
    grid-area: 1 / 1;
  }

  /* the value line is the decade's first year at rest and the year shown while one is: never both, same height */
  .ruler[data-previewing] .ruler-start {
    visibility: hidden;
  }

  /* the native slider carries the keyboard and screen readers; the pointer uses the strip under it */
  .ruler-input {
    position: absolute;
    inset: 0;
    inline-size: 100%;
    block-size: 100%;
    margin: 0;
    opacity: 0;
    pointer-events: none;
  }

  .ruler:has(.ruler-input:focus-visible) {
    outline: var(--line-strong) solid currentColor;
    outline-offset: var(--focus-inset);
  }

  @media (pointer: coarse) {
    .ruler {
      cursor: auto;
    }
  }

  /* ── Link (a topic on a card, a source) ───────────────────────────────── */
  @media (pointer: coarse) {
    .era-card .link,
    .page-links .link,
    .choices .link,
    .years-list .link {
      display: inline-flex;
      align-items: center;
      min-block-size: var(--control);
    }
  }

  .link {
    padding: 0;
    font: var(--font-link);
    text-align: start;
    color: inherit;
    background: none;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: underline var(--line);
    text-underline-offset: var(--space-1);
  }

  .link:is(:hover, [data-state~="hover"]) {
    text-decoration-thickness: var(--line-strong);
  }

  .link:is(:focus-visible, [data-state~="focus"]) {
    outline: var(--line-strong) solid currentColor;
    outline-offset: var(--focus-offset);
  }

  .era-card .link:is(:active, [data-state~="pressed"]) {
    color: var(--card-ground);
    background: var(--card-ink);
    text-decoration: none;
  }

  /* ── Cover: the decades' photos drifting behind the field ─────────────────── */
  /*
    Three layers, each two screens wide, drift sideways at three speeds and back. The photos are muted into
    the stock (grey, faint), so the field always reads at full contrast over them. Still under reduced motion.
  */
  .cover {
    overflow: hidden;
    pointer-events: none;
  }

  .cover-layer {
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    inline-size: 200%;
    animation: cover-drift var(--t-drift) var(--ease-travel) infinite alternate;
  }

  .cover-layer[data-depth="1"] {
    animation-duration: calc(var(--t-drift) * 1.4);
    animation-direction: alternate-reverse;
  }

  .cover-layer[data-depth="2"] {
    animation-duration: calc(var(--t-drift) * 1.9);
  }

  .cover img {
    position: absolute;
    inset-inline-start: calc(var(--x) / 2);
    inset-block-start: var(--y);
    inline-size: calc(var(--space-9) * var(--w));
    aspect-ratio: 4 / 5;
    object-fit: cover;
    filter: grayscale(1) contrast(1.1);
    opacity: var(--cover-strength);
  }

  @keyframes cover-drift {
    to {
      translate: -50% 0;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .cover-layer {
      animation: none;
    }
  }

  /* ── Building line: more of a found moment's wall is on its way (round 7) ──────── */
  /* in the bar beside the moment's name, so it never covers a sheet; on a phone it stands in for the name */
  .building {
    flex: 1 1 0;
    align-self: center;
    min-inline-size: 0;
    margin: 0 0 0 var(--space-3);
    overflow: hidden;
    font: var(--font-source);
    letter-spacing: var(--track-small);
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--now-ink-soft);
  }

  /* the name keeps its own width and the line takes the rest */
  .bar:has(.building:not([hidden])) .bar-title {
    flex: 0 1 auto;
  }

  @media (max-width: 599px) {
    .bar:has(.building:not([hidden])) .bar-title {
      display: none;
    }

    .building {
      margin-inline-start: var(--space-2);
    }
  }

  /* ── Another year: a found person, band or series at a different moment (round 7) ── */
  /*
    A panel under its button (anchored by the button that opened it, flipping at the screen's edges): the
    subject's three biggest years, then any year. Not a menu: its links and its field are Tab stops.
  */
  .years {
    inset: auto;
    position-area: block-end span-inline-start;
    position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
    inline-size: min(calc(100vw - var(--margin) * 2), calc(var(--space-9) * 3.5));
    margin: var(--space-2) 0;
    padding: var(--space-4);
    color: var(--now-ink);
    background: var(--now-ground);
    border: var(--line) solid var(--now-ink);
    border-radius: var(--radius);
  }

  .years:popover-open {
    display: grid;
    gap: var(--space-4);
  }

  /* a browser without anchor positioning: the panel sits at the top right, under the bar */
  @supports not (position-area: block-end) {
    .years {
      position: fixed;
      inset: calc(var(--bar) + var(--space-2)) var(--margin) auto auto;
    }
  }

  @media (prefers-reduced-motion: no-preference) {
    .years {
      opacity: 0;
      translate: 0 calc(var(--space-1) * -1);
      transition: opacity, translate, display, overlay;
      transition-duration: var(--t-press);
      transition-behavior: allow-discrete;
    }

    .years:popover-open {
      opacity: 1;
      translate: 0 0;

      @starting-style {
        opacity: 0;
        translate: 0 calc(var(--space-1) * -1);
      }
    }
  }

  .years-title {
    margin: 0;
    font: var(--font-label);
  }

  .years-list {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .years-list .link[aria-current] {
    text-decoration-thickness: var(--line-strong);
  }

  .years-form {
    display: grid;
    gap: var(--space-2);
  }

  .years-label {
    font: var(--font-source);
    letter-spacing: var(--track-small);
  }

  .years-row {
    display: flex;
    gap: var(--space-2);
  }

  .years-input {
    inline-size: calc(var(--space-9) * 1.25);
    min-block-size: var(--control);
    padding: 0 var(--space-3);
    font: var(--font-body);
    color: inherit;
    background: var(--now-ground);
    border: var(--line) solid var(--now-ink);
    border-radius: var(--radius);
  }

  .years-input:focus-visible {
    outline: var(--line-strong) solid currentColor;
    outline-offset: var(--focus-offset);
  }

  /* with Another year the phone's strip holds four: two by two */
  .wall-end:has([data-years]:not([hidden])) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* ── Photo credits: every photo the site shows, once ───────────────────── */
  .credits {
    font: var(--font-source);
    letter-spacing: var(--track-small);
  }

  .credits summary {
    inline-size: fit-content;
    cursor: pointer;
  }

  .credits-note {
    max-inline-size: var(--measure);
    margin: var(--space-3) 0;
  }

  .credits-list {
    margin: 0;
    padding: 0;
    list-style: none;
    columns: calc(var(--space-9) * 3);
    column-gap: var(--space-5);
  }

  .credits-list li {
    margin-block-end: var(--space-2);
    break-inside: avoid;
    overflow-wrap: anywhere;
  }

  /* ── Sheet ─────────────────────────────────────────────────────────────── */
  /*
    A sheet is a stack: its story underneath (the back of the paper, in the under pair), its front
    (the face with label, answer and source), the curl (a button), and when it is peeled, a roll of
    paper along its top edge. While a sheet is dragged, the peel script cuts the front and draws the
    fold over it; at rest everything here is CSS.
  */
  .sheet {
    --c: var(--curl);
    position: relative;
    min-inline-size: 0;
    min-block-size: 0;
    color: var(--ink);
    transition:
      translate var(--t-quick) var(--ease-arrive),
      transform var(--t-quick) var(--ease-arrive);
  }

  .sheet-front {
    position: relative;
    display: flex;
    flex-direction: column;
    block-size: 100%;
    padding: var(--sheet-pad);
    background-color: var(--ground);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%);
  }

  .sheet-under {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--sheet-pad);
    overflow: hidden;
    color: var(--under-ink);
    background-color: var(--under-ground);
  }

  /*
    The paper (Round 8): its tooth over the ground, and a seam shade inside its edge so each sheet reads as a
    piece pasted up. Older paper is folded in four: a light ridge, the valley beside it, the far quarter a shade
    darker. All of it is background, so it sits under the type, moves nothing, and the poster paints it as is.
  */
  :is(.sheet-front, .sheet-under) {
    --seam: color-mix(in oklab, var(--black) calc(var(--shade) * var(--seam-strength)), transparent);
    --seams:
      linear-gradient(to right, var(--seam) var(--seam-width), transparent var(--seam-width) calc(100% - var(--seam-width)), var(--seam) calc(100% - var(--seam-width))),
      linear-gradient(to bottom, var(--seam) var(--seam-width), transparent var(--seam-width) calc(100% - var(--seam-width)), var(--seam) calc(100% - var(--seam-width)));
    background-image: var(--seams), var(--tooth);
    background-size: 100% 100%, 100% 100%, var(--tooth-size);
    background-position: 0 0;
    background-repeat: no-repeat, no-repeat, repeat;

    &[data-folded] {
      --fold-dark: color-mix(in oklab, var(--black) calc(var(--shade) * var(--fold-strength)), transparent);
      --fold-light: color-mix(in oklab, var(--stock) calc(var(--shade) * var(--fold-strength)), transparent);
      background-image:
        linear-gradient(var(--fold-dark), var(--fold-dark)),
        linear-gradient(to bottom, transparent calc(var(--fold-y) - 1px), var(--fold-light) calc(var(--fold-y) - 1px) var(--fold-y), var(--fold-dark) var(--fold-y), transparent calc(var(--fold-y) + var(--fold-valley))),
        linear-gradient(to right, transparent calc(var(--fold-x) - 1px), var(--fold-light) calc(var(--fold-x) - 1px) var(--fold-x), var(--fold-dark) var(--fold-x), transparent calc(var(--fold-x) + var(--fold-valley))),
        var(--seams),
        var(--tooth);
      background-size: calc(100% - var(--fold-x)) calc(100% - var(--fold-y)), 100% 100%, 100% 100%, 100% 100%, 100% 100%, var(--tooth-size);
      background-position: 100% 100%, 0 0, 0 0, 0 0, 0 0, 0 0;
      background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, repeat;
    }
  }

  /* at rest only the curled corner shows what is underneath; peeling, rolling or rolled, all of it */
  .sheet:not([data-peeled], [data-peeling], [data-rolling], [data-state~="peeled"]) .sheet-under {
    clip-path: polygon(100% calc(100% - var(--c)), 100% 100%, calc(100% - var(--c)) 100%);
  }

  .sheet-under p {
    margin: 0;
    max-inline-size: var(--measure);
    font: var(--font-body);
    text-wrap: pretty;
  }

  .sheet-heading {
    display: contents;
    margin: 0;
    font: inherit;
  }

  .sheet-label {
    display: block;
    font: var(--font-label);
    text-box: trim-both cap alphabetic;
  }

  /* a sheet with a follow tab keeps its label clear of the tab (the script measures --tab-room) */
  .sheet:has(.follow) .sheet-label {
    padding-inline-end: var(--tab-room, 0);
  }

  .sheet-answer {
    display: block;
    margin-block: auto var(--space-2);
    padding-block-start: var(--space-3);
    font-family: var(--then-face);
    font-weight: var(--then-weight);
    line-height: var(--then-leading);
    letter-spacing: var(--then-tracking);
    text-wrap: balance;
    overflow-wrap: normal;
    /* its box ends at the face's descent, so a descender never reaches the source below */
    text-box: trim-both cap text;
  }

  .sheet-source {
    margin: 0;
    padding-inline-end: var(--curl-lifted);
    font: var(--font-source);
    letter-spacing: var(--track-small);
    text-box: trim-both cap alphabetic;
  }

  .sheet:is(:focus-within, [data-state~="focus"]) .sheet-front {
    outline: var(--line-strong) solid var(--ink);
    outline-offset: var(--focus-inset);
  }

  .sheet:is(:hover, :focus-within, [data-state~="hover"], [data-state~="focus"], [data-state~="pressed"]) {
    --c: var(--curl-lifted);
  }

  /* the curl: the corner folded back, the back of the paper showing; a button at least --control square */
  .curl {
    position: absolute;
    inset: auto 0 0 auto;
    inline-size: max(var(--control), var(--c));
    block-size: max(var(--control), var(--c));
    padding: 0;
    background: none;
    border: 0;
    border-radius: var(--radius);
    cursor: grab;
    touch-action: none;
    /* on the button, not the flap: a clip-path would cut its own shadow off */
    filter: drop-shadow(var(--shadow-flap));
  }

  /*
    The flap is the back of the sheet's own paper (--paper), darker towards the crease, outlined in
    its ink. Under it, where the corner is gone, the story shows in --under-ground.
  */
  .curl::before,
  .curl::after {
    content: "";
    position: absolute;
    inset: auto 0 0 auto;
    inline-size: var(--c);
    block-size: var(--c);
    transition:
      inline-size var(--t-quick) var(--ease-arrive),
      block-size var(--t-quick) var(--ease-arrive);
  }

  .curl::before {
    background: var(--ink);
    clip-path: polygon(0 0, 100% 0, 0 100%);
  }

  .curl::after {
    background: linear-gradient(to bottom right, var(--flap-ground), color-mix(in srgb, var(--flap-ground), var(--black) var(--shade)) 50%);
    /* the same triangle, a line in from every edge (the long edge needs 1 + √2 lines) */
    clip-path: polygon(
      var(--line) var(--line),
      calc(100% - var(--line) * 2.414) var(--line),
      var(--line) calc(100% - var(--line) * 2.414)
    );
  }

  .curl:focus-visible {
    outline: none;
  }

  /* peeled: rolled up like a poster along its own top edge; its story shows; it never leaves its cell */
  .sheet-roll {
    position: absolute;
    inset: 0 0 auto;
    display: none;
    block-size: var(--roll);
    cursor: pointer;
    background:
      linear-gradient(
        to bottom,
        color-mix(in srgb, var(--flap-ground), var(--black) calc(var(--shade) * 1.5)),
        var(--flap-ground) 38%,
        color-mix(in srgb, var(--flap-ground), var(--black) calc(var(--shade) * 0.75)) 70%,
        color-mix(in srgb, var(--flap-ground), var(--black) calc(var(--shade) * 2))
      );
    border-block: var(--line) solid var(--ink);
    filter: drop-shadow(var(--shadow-roll));
  }

  .sheet:is([data-peeled], [data-state~="peeled"]) .sheet-front {
    clip-path: inset(0 0 100% 0);
  }

  .sheet:is([data-peeled], [data-state~="peeled"]) .sheet-roll {
    display: block;
  }

  .sheet:is([data-peeled], [data-state~="peeled"]) .sheet-under {
    padding-block-start: calc(var(--roll) + var(--sheet-pad));
  }

  .sheet:is([data-peeled], [data-state~="peeled"]) .curl::before,
  .sheet:is([data-peeled], [data-state~="peeled"]) .curl::after {
    display: none;
  }

  /*
    arriving: the whole sheet unrolls downward from its top edge; the roll sits where the paper has
    got to (--unrolled, from 0 to 100%), and the script moves it with translate
  */
  .sheet:is([data-arriving], [data-state~="arriving"]) {
    clip-path: inset(0 0 calc(100% - var(--unrolled, 0%) - var(--roll)) 0);
  }

  .sheet:is([data-arriving], [data-state~="arriving"]) .sheet-roll {
    display: block;
    inset-block-start: var(--unrolled, 0%);
  }

  .sheet[data-state~="arriving"] {
    --unrolled: 45%;
  }

  /*
    The living wall: the sheet under a mouse rises by --lift, leans toward it by up to --tilt
    (--lean-x and --lean-y, set by the script), and a band of light at --sheen follows it (--sx).
    The script sets data-living only with a mouse and without reduced motion.
  */
  .sheet::before {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: var(--shadow-living);
    opacity: 0;
    transition: opacity var(--t-quick) var(--ease-arrive);
    pointer-events: none;
  }

  .sheet-front::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
      105deg,
      transparent calc(var(--sx, 50%) - 25%),
      color-mix(in srgb, var(--stock) var(--sheen), transparent) var(--sx, 50%),
      transparent calc(var(--sx, 50%) + 25%)
    );
    opacity: 0;
    transition: opacity var(--t-quick) var(--ease-arrive);
    pointer-events: none;
  }

  .sheet:is([data-living], [data-state~="living"]) {
    z-index: var(--z-sheet-lifted);
    --c: var(--curl-lifted);
    translate: 0 calc(var(--lift) * -1);
    transform: perspective(var(--perspective)) rotateX(var(--lean-y, 0deg)) rotateY(var(--lean-x, 0deg));
  }

  .sheet:is([data-living], [data-state~="living"])::before,
  .sheet:is([data-living], [data-state~="living"]) .sheet-front::after {
    opacity: 1;
  }

  .sheet[data-state~="living"] {
    --lean-x: var(--tilt);
    --lean-y: calc(var(--tilt) * -0.5);
    --sx: 35%;
  }

  /*
    the follow tab: a labelled tab on the top-right edge, in the sheet's inverted pair; a link. It is
    the sheet's child, not the front's, so the front's clip-path never cuts its focus ring.
  */
  .follow {
    position: absolute;
    inset: 0 var(--sheet-pad) auto auto;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-block-size: var(--control);
    max-inline-size: calc(100% - 2 * var(--sheet-pad));
    padding: 0 var(--space-3);
    font: var(--font-control);
    color: var(--ground);
    background: var(--ink);
    text-decoration: none;
  }

  .follow:is(:hover, [data-state~="hover"]) {
    color: var(--ink);
    background: var(--ground);
    outline: var(--line) solid var(--ink);
    outline-offset: calc(var(--line) * -1);
  }

  .follow:is(:focus-visible, [data-state~="focus"]) {
    outline: var(--line-strong) solid var(--ink);
    outline-offset: var(--focus-offset);
  }

  .sheet:is([data-peeled], [data-state~="peeled"], [data-arriving], [data-state~="arriving"]) .follow {
    display: none;
  }

  /* ── Open sheet: a modal dialog in the sheet's pair ───────────────────── */
  .open-sheet {
    inline-size: 100%;
    max-inline-size: none;
    block-size: 100%;
    max-block-size: none;
    margin: 0;
    padding: 0;
    color: var(--ink);
    background: var(--ground);
    border: 0;
    border-radius: var(--radius);
  }

  .open-sheet::backdrop {
    background: transparent;
  }

  /* the Close button floats over the hero and stays in reach while the page scrolls */
  .open-head {
    position: sticky;
    inset-block-start: 0;
    z-index: var(--z-raised);
    display: flex;
    align-items: start;
    justify-content: end;
    block-size: 0;
    padding: 0 var(--margin);
  }

  .open-head .button {
    position: absolute;
    inset: var(--space-3) var(--margin) auto auto;
  }

  .open-title {
    margin: 0;
    font: var(--font-dialog-title);
    letter-spacing: var(--track-tight);
  }

  /*
    The open sheet as a magazine spread: a full-width hero (the official video, else the subject's first
    free photo) with the label and the answer on a band of the sheet's ground; then the story in short
    blocks with the facts and links beside it; a strip of photos; connections as picture cards.
  */
  .open-body {
    display: grid;
  }

  .spread-hero {
    display: grid;
  }

  .spread-media {
    position: relative;
    block-size: var(--hero);
    overflow: hidden;
    background: color-mix(in srgb, var(--ground), var(--ink) var(--placeholder));
  }

  /* no photo and no video: just the band, at the top */
  .spread-hero.is-plain .spread-media {
    display: none;
  }

  .spread-hero.is-plain .spread-title {
    margin-block-start: 0;
    padding-block-start: var(--bar);
  }

  .spread-media > img {
    position: absolute;
    inset: 0;
    inline-size: 100%;
    block-size: 100%;
    object-fit: cover;
    object-position: 50% 20%;
  }

  /* a portrait: its face is near the top */
  .spread-media > img[data-tall] {
    object-position: 50% 12%;
  }

  .spread-media .play,
  .spread-media .page-frame {
    border-radius: 0;
  }

  /*
    A video keeps its own 16 by 9 under Close's row (so the two controls never overlap), and the band sits
    under it rather than over its foot, so the player's controls are never covered once it plays
  */
  .spread-media:has(> .page-video) {
    block-size: auto;
    padding-block-start: var(--bar);
    background: none;
  }


  .spread-hero:has(.page-video) .spread-title {
    margin-block-start: 0;
  }

  .spread-credit {
    position: absolute;
    inset: var(--space-3) auto auto var(--margin);
    max-inline-size: calc(100% - var(--margin) * 2 - var(--space-9) * 1.5);
    margin: 0;
    padding: var(--space-1) var(--space-2);
    font: var(--font-source);
    letter-spacing: var(--track-small);
    color: var(--ink);
    background: var(--ground);
  }

  /* the label and the answer on a band of the sheet's ground, laid over the foot of the photo */
  .spread-title {
    position: relative;
    display: grid;
    align-content: end;
    gap: var(--space-2);
    margin-block-start: calc(var(--space-8) * -1);
    padding: var(--space-5) var(--margin) var(--space-2);
    color: var(--ink);
    background: var(--ground);
  }

  /*
    On a wide screen the opening is a two-page spread: the answer on the left page, set at the foot; the photo
    or the video filling the right page, so a photo is never blown up past its size
  */
  @media (min-width: 1024px) {
    .spread-hero:not(.is-plain) {
      grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    }

    .spread-hero:not(.is-plain) .spread-media {
      grid-area: 1 / 2;
    }

    .spread-hero:not(.is-plain) .spread-title {
      grid-area: 1 / 1;
      margin-block-start: 0;
      padding-block: var(--bar) var(--space-5);
    }
  }

  .spread-title .open-title {
    margin: 0;
  }

  .spread-title .open-answer {
    max-inline-size: 100%;
  }

  .page {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-7);
    padding: var(--space-6) var(--margin) var(--space-8);
  }

  @media (min-width: 1024px) {
    .page {
      grid-template-columns: minmax(0, var(--measure)) minmax(0, 1fr);
      column-gap: var(--space-8);
    }
  }

  .page-story {
    display: grid;
    align-content: start;
    gap: var(--space-4);
  }

  .page-story p {
    margin: 0;
    font: var(--font-body);
    text-wrap: pretty;
  }

  .page-more {
    display: grid;
    gap: var(--space-4);
  }

  .page-story .page-lede {
    font: var(--font-label);
  }

  .page-aside {
    display: grid;
    align-content: start;
    gap: var(--space-5);
  }

  .page-facts {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: var(--space-2) var(--space-5);
    margin: 0;
    font: var(--font-body);
  }

  .page-facts div {
    display: contents;
  }

  .page-facts dt {
    font: var(--font-label);
  }

  .page-facts dd {
    margin: 0;
  }

  .page-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-5);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* the photos: one row that scrolls sideways and stops on each photo */
  .page-strip {
    grid-column: 1 / -1;
    display: flex;
    gap: var(--space-3);
    margin-inline: calc(var(--margin) * -1);
    padding-inline: var(--margin);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--margin);
  }

  .page-strip:empty {
    display: none;
  }

  .page-strip > * {
    flex: none;
    inline-size: var(--strip-photo);
    scroll-snap-align: start;
  }

  .page-photo,
  .page-video,
  .page-audio {
    display: grid;
    align-content: start;
    gap: var(--space-2);
    margin: 0;
  }

  .page-photo img {
    display: block;
    inline-size: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: color-mix(in srgb, var(--ground), var(--ink) var(--placeholder));
    opacity: 0;
    transition: opacity var(--t-quick) var(--ease-arrive);
  }

  /* a photo shows in its place once it has loaded, never half-drawn */
  .page-photo img[data-loaded] {
    opacity: 1;
  }

  .page-photo figcaption,
  .page-video figcaption,
  .page-audio figcaption {
    font: var(--font-source);
    letter-spacing: var(--track-small);
  }

  /* still loading: the block holds its final size, so nothing below it moves when it fills */
  .page-photo.is-loading {
    aspect-ratio: 4 / 3;
    background: color-mix(in srgb, var(--ground), var(--ink) var(--placeholder));
  }

  .page-video video,
  .page-frame {
    display: block;
    inline-size: 100%;
    aspect-ratio: 16 / 9;
    background: var(--ink);
    border: 0;
  }

  .page-audio audio {
    inline-size: 100%;
  }

  /* an official video: a block in the sheet's inverted pair; pressing it loads the player in its place */
  .play {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: end;
    gap: var(--space-4);
    inline-size: 100%;
    aspect-ratio: 16 / 9;
    padding: var(--space-5);
    color: var(--ground);
    text-align: start;
    background: var(--ink);
    border: var(--line) solid var(--ink);
    border-radius: var(--radius);
    cursor: pointer;
    transition:
      color var(--t-press) var(--ease-press),
      background-color var(--t-press) var(--ease-press);
  }

  .play:is(:hover, [data-state~="hover"]) {
    color: var(--ink);
    background: var(--ground);
  }

  .play:is(:focus-visible, [data-state~="focus"]) {
    outline: var(--line-strong) solid var(--ink);
    outline-offset: var(--focus-offset);
  }

  .play-mark {
    inline-size: var(--space-7);
    block-size: var(--space-7);
    background: currentColor;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
  }

  .play-words {
    display: grid;
    gap: var(--space-1);
  }

  .play-label {
    font: var(--font-control);
  }

  .play-title {
    font: var(--font-label);
    text-wrap: balance;
  }

  .play-source {
    font: var(--font-source);
    letter-spacing: var(--track-small);
  }

  .page-heading {
    margin: 0;
    font: var(--font-label);
  }

  /* connections: other moments that share this article or person; each one falls there */
  .page-connections {
    grid-column: 1 / -1;
    display: grid;
    gap: var(--space-4);
    padding-block-start: var(--space-5);
    border-block-start: var(--line) solid var(--ink);
  }

  .page-connections ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(var(--space-9) * 2.5)), 1fr));
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .connection {
    display: grid;
    gap: var(--space-1);
    block-size: 100%;
    min-block-size: var(--control);
    padding: var(--space-3) var(--space-4);
    color: var(--ink);
    text-decoration: none;
    border: var(--line) solid var(--ink);
    transition:
      color var(--t-press) var(--ease-press),
      background-color var(--t-press) var(--ease-press);
  }

  .connection:is(:hover, [data-state~="hover"]) {
    color: var(--ground);
    background: var(--ink);
  }

  .connection:is(:focus-visible, [data-state~="focus"]) {
    outline: var(--line-strong) solid var(--ink);
    outline-offset: var(--focus-offset);
  }

  .connection-photo {
    display: block;
    inline-size: calc(100% + 2 * var(--space-4));
    margin: calc(var(--space-3) * -1) calc(var(--space-4) * -1) var(--space-2);
    aspect-ratio: 3 / 2;
    object-fit: cover;
    background: color-mix(in srgb, var(--ground), var(--ink) var(--placeholder));
  }

  .connection-name {
    font: var(--font-label);
  }

  .connection-when {
    font: var(--font-source);
    letter-spacing: var(--track-small);
  }

  .open-answer {
    margin: 0;
    font-family: var(--then-face);
    font-weight: var(--then-weight);
    line-height: var(--then-leading);
    letter-spacing: var(--then-tracking);
    font-size: var(--text-field);
    text-wrap: balance;
  }

  /* a credit line is as small as its caption */
  :is(figcaption, .spread-credit) .link {
    font: inherit;
  }

  /* ── The fall's HUD ───────────────────────────────────────────────────── */
  .hud {
    position: fixed;
    inset: var(--margin) auto auto var(--margin);
    z-index: var(--z-hud);
    display: grid;
    justify-items: start;
    gap: var(--space-2);
    max-inline-size: min(var(--measure), calc(100vw - 2 * var(--margin)));
    pointer-events: none;
  }

  .hud-status {
    margin: 0;
    padding: var(--space-2) var(--space-3);
    font: var(--font-status);
    letter-spacing: var(--track-small);
    color: var(--now-ink);
    background: var(--now-ground);
  }

  .hud-narration {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    color: var(--now-inverse-ink);
    background: var(--now-inverse-ground);
  }

  .hud-decade {
    margin: 0;
    font: var(--font-narration-title);
    letter-spacing: var(--track-tight);
  }

  .hud-line {
    margin: 0;
    font: var(--font-narration-line);
    text-wrap: balance;
  }

  .hud-year {
    display: flex;
    margin: 0;
    padding: 0 var(--space-3);
    font-size: var(--counter-size);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--now-inverse-ink);
    background: var(--now-inverse-ground);
  }

  /* Round 8: one quiet line under the rolling year, in the same panel */
  .hud-passed {
    display: flex;
    gap: var(--space-2);
    align-items: baseline;
    margin: 0;
    padding: var(--space-1) var(--space-3) 0;
    font: var(--font-source);
    letter-spacing: var(--track-small);
    font-variant-numeric: tabular-nums;
  }

  .hud-passed[hidden] {
    display: none;
  }

  .hud-passed-n {
    font-weight: 700;
  }

  .hud-year .digit {
    display: block;
    inline-size: var(--counter-digit);
    block-size: 1em;
    overflow: hidden;
  }

  .hud-year .strip {
    display: flex;
    flex-direction: column;
  }

  .hud-year .strip span {
    display: block;
    block-size: 1em;
    text-align: center;
  }

  /* the tunnel behind the controls can be dark, so an inverted control keeps a stock edge */
  .controls :is(.button, .icon-button):is(:hover, :active, [data-state~="hover"], [data-state~="pressed"], [aria-pressed="true"]),
  .controls .switch:is(:hover, :active, :has(input:checked), [data-state~="hover"], [data-state~="pressed"], [data-state~="on"]) {
    border-color: var(--c-ground);
  }

  .controls {
    position: fixed;
    inset: auto 0 calc(var(--space-5) + env(safe-area-inset-bottom)) 0;
    z-index: var(--z-hud);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    inline-size: fit-content;
    max-inline-size: calc(100% - 2 * var(--margin));
    margin: 0 auto;
  }

  /* ── Archive wall: every moment on one wall ────────────────────────────── */
  .archive {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: var(--space-4);
    min-block-size: calc(100dvh - var(--bar));
    padding: var(--space-5) var(--margin);
  }

  .archive-title {
    margin: 0;
    font: var(--font-dialog-title);
    letter-spacing: var(--track-tight);
  }

  /* ARCHIVE in tokens.js: 2 by 8 on a phone, 4 by 4 on a tablet, 8 by 2 on desktop; tiles touch */
  .archive-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(calc(var(--space-9) * 2), 1fr);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  @media (min-width: 600px) {
    .archive-grid {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }
  }

  @media (min-width: 1024px) {
    .archive-grid {
      grid-template-columns: repeat(8, minmax(0, 1fr));
    }
  }

  .tile {
    position: relative;
    min-inline-size: 0;
    transition:
      translate var(--t-quick) var(--ease-arrive),
      transform var(--t-quick) var(--ease-arrive);
  }

  .tile-link {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--space-3);
    block-size: 100%;
    padding: var(--sheet-pad);
    overflow: hidden;
    color: var(--ink);
    background: var(--ground);
    text-decoration: none;
  }

  .tile-label {
    font: var(--font-label);
    text-box: trim-both cap alphabetic;
  }

  .tile-name {
    font-family: var(--then-face);
    font-weight: var(--then-weight);
    font-size: var(--decade-size);
    line-height: var(--then-leading);
    letter-spacing: var(--then-tracking);
    text-wrap: balance;
  }

  .tile-link:is(:focus-visible, [data-state~="focus"]) {
    outline: var(--line-strong) solid var(--ink);
    outline-offset: var(--focus-inset);
  }

  /* hover is the sheet's: the living wall */
  .tile::before {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: var(--shadow-living);
    opacity: 0;
    transition: opacity var(--t-quick) var(--ease-arrive);
    pointer-events: none;
  }

  .tile:is([data-living], [data-state~="living"]) {
    z-index: var(--z-sheet-lifted);
    translate: 0 calc(var(--lift) * -1);
    transform: perspective(var(--perspective)) rotateX(var(--lean-y, 0deg)) rotateY(var(--lean-x, 0deg));
  }

  .tile:is([data-living], [data-state~="living"])::before {
    opacity: 1;
  }

  .tile[data-state~="living"] {
    --lean-x: var(--tilt);
    --lean-y: calc(var(--tilt) * -0.5);
  }

  /* ── Poster: the stock strip under the saved wall ────────────────────── */
  .poster-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 0 var(--margin);
    font: var(--font-label);
    color: var(--now-ink);
    background: var(--now-ground);
  }

  .poster-foot span {
    text-box: trim-both cap alphabetic;
  }

  /* ── Hint and share bubble ─────────────────────────────────────────────── */
  .hint,
  .bubble {
    display: inline-block;
    margin: 0;
    padding: var(--space-2) var(--space-3);
    font: var(--font-hint);
    color: var(--now-inverse-ink);
    background: var(--now-inverse-ground);
  }

  .bubble {
    position: absolute;
    inset: calc(100% + var(--space-2)) 0 auto auto;
    z-index: var(--z-bubble);
    white-space: nowrap;
    opacity: 0;
    translate: 0 calc(var(--space-1) * -1);
    transition:
      opacity var(--t-quick) var(--ease-leave),
      translate var(--t-quick) var(--ease-leave);
    pointer-events: none;
  }

  .bubble:not(:empty),
  .bubble[data-state~="shown"] {
    opacity: 1;
    translate: 0 0;
    transition-timing-function: var(--ease-arrive);
  }

  .copy {
    position: relative;
    display: inline-flex;
  }
}
