:root {
  --ink: #111111;
  --ink-soft: #555550;
  --ink-mute: #6b6b66;
  --panel: #101010;
  --lane: rgba(255, 255, 255, 0.045);
  --human: #f2f2f2;
  --ours: #ffa94d;
  /* `.blk` hardcodes this colour's RGB triplet as rgba(127, 147, 171, …) for its
     translucent background and border. color-mix() is not available to us here,
     so the two must be kept in sync by hand. */
  --deep: #7f93ab;
  --dotted: rgba(255, 255, 255, 0.18);
  --sweep: 6s;
}

/* style.css pins html/body to height:100% for the single-screen homepage and
   makes body a column flexbox. This page is long, so release the height
   constraint or the flex children can be squeezed. */
body {
  height: auto;
  background: var(--paper);
  color: var(--ink);
}

.navbar a.wordmark {
  text-decoration: none;
  color: inherit;
}

.page {
  padding: clamp(68px, 10vh, 112px) 24px 0;
}

.col {
  max-width: 680px;
  margin: 0 auto;
}

.wide {
  max-width: 920px;
  margin: 0 auto;
}

.eyebrow-r {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 2.2em;
}

.title {
  font-family: 'Iowan Old Style', 'Baskerville', 'Times New Roman', serif;
  font-size: clamp(3.8rem, 7vw, 6.5rem);
  font-weight: 400;
  line-height: 0.96;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.deck {
  font-size: 20px;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 600px;
  margin-top: 2rem;
}

.page h2 {
  font-family: 'Iowan Old Style', 'Baskerville', 'Times New Roman', serif;
  font-size: 2.35rem;
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin-top: 6.5rem;
}

.page h3 {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 3.5rem;
}

.page p + p {
  margin-top: 1.4em;
}

.page h2 + p,
.page h3 + p {
  margin-top: 1.2em;
}

/* Two class names, not one: `.page p + p` below scores (0,1,2) and would
   otherwise beat a bare `.close` at (0,1,0) and eat this margin. */
.page .close {
  margin-top: 6.5rem;
  padding-top: 3rem;
  border-top: 1px solid var(--line);
  font-family: 'Iowan Old Style', 'Baskerville', 'Times New Roman', serif;
  font-size: 2rem;
  line-height: 1.3;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 880px;
  margin: 6rem auto 0;
  padding: 24px 0 40px;
  border-top: 1px solid var(--line);
}

.foot a {
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
}

.foot a:hover {
  text-decoration: underline;
}

/* ---- diagram system ---- */

.tape {
  margin: 3rem auto 0;
}

.panel {
  position: relative;
  background: var(--panel);
  border-radius: 10px;
  padding: 22px 24px 26px;
}

.panel__title {
  font-size: 14px;
  color: #e8e8e8;
  text-align: center;
}

.panel__sub {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  margin-top: 4px;
}

.lanes {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lane {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lane__label {
  flex: 0 0 96px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

.lane__plot {
  position: relative;
  flex: 1;
  height: 40px;
  background: var(--lane);
  border-radius: 6px;
  overflow: hidden;
}

.lane__layer {
  position: absolute;
  inset: 0;
}

/* Full strength by default so the diagrams are legible without JavaScript.
   The dim baseline is a progressive enhancement: it only applies once the
   script has confirmed it can actually run the sweep. */
.lane__layer--base {
  opacity: 1;
}

.js .lane__layer--base {
  opacity: 0.28;
}

.lane__layer--lit {
  clip-path: inset(0 100% 0 0);
}

.lane__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 40px;
  display: block;
}

.bar--human { fill: var(--human); }
.bar--ours  { fill: var(--ours); }
.bar--faint { opacity: 0.4; }
.sil        { stroke: var(--dotted); }

.blk {
  position: absolute;
  top: 7px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  letter-spacing: 0.06em;
  border-radius: 4px;
  background: rgba(127, 147, 171, 0.22);
  border: 1px solid rgba(127, 147, 171, 0.55);
  color: #cfd9e4;
  white-space: nowrap;
  overflow: hidden;
}

.blk--deep {
  border-style: dashed;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.55);
  opacity: 0;
  pointer-events: none;
}

.notes {
  position: relative;
  height: 15px;
}

.lanes--labelled .notes {
  margin-left: 108px;
}

.note {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.55);
}

/* Hidden by default: without JavaScript the button is inert, so it must not be
   focusable. The script's `js` class reveals it. */
.replay {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 44px;
  height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.js .replay {
  display: flex;
}

.replay:hover {
  color: rgba(255, 255, 255, 0.9);
}

.replay:focus-visible {
  outline: 2px solid var(--ours);
  outline-offset: -2px;
}

.tape figcaption,
.fan figcaption {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-mute);
  text-align: center;
  max-width: 620px;
  margin: 1.1rem auto 0;
}

/* ---- animation ---- */

@keyframes sweep {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}

@keyframes playhead-run {
  from { left: 0%; }
  to   { left: 100%; }
}

.is-playing .lane__layer--lit {
  animation: sweep var(--sweep) linear forwards;
}

.is-playing .playhead {
  opacity: 1;
  animation: playhead-run var(--sweep) linear forwards;
}

@media (prefers-reduced-motion: reduce) {
  .lane__layer--lit,
  .is-playing .lane__layer--lit {
    clip-path: inset(0);
    animation: none;
  }

  .playhead,
  .is-playing .playhead {
    display: none;
    animation: none;
  }

  /* `.js .replay` above scores (0,2,0) and a media query adds no specificity,
     so a bare `.replay` here would lose and the button would stay visible. */
  .replay,
  .js .replay {
    display: none;
  }
}

/* ---- one-to-many fan ---- */

.fan {
  margin: 3rem auto 0;
}

.fan__body {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-top: 22px;
}

.fan__text {
  flex: 0 0 auto;
  font-size: 15px;
  color: #e8e8e8;
  border-right: 1px solid rgba(255, 255, 255, 0.16);
  padding-right: 28px;
}

.fan__stubs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fan__stub {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  /* Full strength without JavaScript, mirroring .lane__layer--base on the
     tapes. The dim baseline below is a progressive enhancement. */
  opacity: 1;
}

.js .fan__stub {
  opacity: 0.28;
}

.fan__stub svg {
  flex: 0 0 130px;
  height: 22px;
  display: block;
}

.fan__stub span {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.5);
}

.fan__stub--fit span {
  color: var(--ours);
}

@keyframes fan-in {
  to { opacity: 1; }
}

@keyframes fan-outline {
  to { border-color: rgba(255, 169, 77, 0.65); }
}

.is-playing .fan__stub:nth-child(1) { animation: fan-in 0.4s ease-out 0.05s forwards; }
.is-playing .fan__stub:nth-child(2) { animation: fan-in 0.4s ease-out 0.20s forwards; }
.is-playing .fan__stub:nth-child(3) { animation: fan-in 0.4s ease-out 0.35s forwards; }
.is-playing .fan__stub:nth-child(4) {
  animation: fan-in 0.4s ease-out 0.50s forwards,
             fan-outline 0.4s ease-out 0.90s forwards;
}

@media (prefers-reduced-motion: reduce) {
  /* The :nth-child selectors must be repeated here. The animation rules above
     score (0,3,0) and a media query adds no specificity, so a bare
     `.is-playing .fan__stub` at (0,2,0) loses the cascade and the animations
     keep running. `.js .fan__stub` is listed for the same reason: at (0,2,0) it
     would otherwise beat a bare `.fan__stub` and leave the stubs dim. */
  .fan__stub,
  .js .fan__stub,
  .is-playing .fan__stub,
  .is-playing .fan__stub:nth-child(1),
  .is-playing .fan__stub:nth-child(2),
  .is-playing .fan__stub:nth-child(3),
  .is-playing .fan__stub:nth-child(4) {
    opacity: 1;
    animation: none;
  }

  .fan__stub--fit {
    border-color: rgba(255, 169, 77, 0.65);
  }
}

@media (max-width: 700px) {
  .fan__body {
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
  }

  .fan__text {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    padding: 0 0 14px;
  }

  .fan__stubs {
    width: 100%;
  }
}

@media (max-width: 700px) {
  /* style.css drops to 16px only at 600px; the spec sets this page's
     breakpoint at 700px, so restate it here. */
  body {
    font-size: 16px;
  }

  .page {
    padding: 58px 20px 0;
  }

  .title {
    font-size: clamp(3.35rem, 14vw, 4.5rem);
  }

  .deck {
    font-size: 18px;
  }

  .page h2 {
    font-size: 2rem;
    margin-top: 4.75rem;
  }

  /* Matches base rule's `.page .close` (0,2,0) — see specificity note above;
     a bare `.close` here would lose and never apply. */
  .page .close {
    font-size: 1.65rem;
  }

  /* Panels scroll rather than compressing below legibility. */
  .tape .panel,
  .fan .panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tape .lanes {
    min-width: 560px;
  }

  .lane__label {
    flex: 0 0 86px;
    font-size: 10px;
  }

  .lanes--labelled .notes {
    margin-left: 98px;
  }

  .foot {
    padding-left: 20px;
    padding-right: 20px;
  }
}
