/* Shuttle — Space Shuttle mission archive (final build).
   Layout of the mission modules is computed by grid.js (the law);
   this file only styles the pieces and gives a plain fallback without JS. */

/* ---------- Font: ABC Areal Semi Mono (Dinamo), Regular only ------------- */

@font-face { font-family: "ABC Areal Semi Mono"; src: url("fonts/ABCArealSemiMono-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }

/* ---------- Tokens ------------------------------------------------------- */

:root {
  --gutter: 20px;

  --fs-xs: 0.75rem;     /* 12 — captions, meta, panel */
  --fs-ui: 0.875rem;    /* 14 — UI */
  --fs-name: 1rem;      /* 16 — mission name in the notch */
  --fs-name-big: 1rem;  /* 16 — same as regular modules (Dan, 28.10) */
  --fs-intro: 1rem;     /* 16 — intro (Dan, 28.10) */
  --lh-ui: 1.4286;

  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  --font: "ABC Areal Semi Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111111;
  --fg: #f2f2f2;
  --muted: #8e8e8e;                 /* 5.9:1 on bg */
  --rule: #5c5c5c;
  --ph-bg: #232323;                 /* photo placeholder while loading */
  --img-line: oklch(1 0 0 / 0.1);
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f2f2;
  --fg: #111111;
  --muted: #6e6e6e;                 /* 5.1:1 on bg */
  --rule: #b4b4b4;
  --ph-bg: #ececec;
  --img-line: oklch(0 0 0 / 0.1);
}

/* ---------- Base --------------------------------------------------------- */

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

html {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  /* Areal Semi Mono alternates: lowercase a, t, u, y (ss01–ss04) and capital R (ss06) */
  font-feature-settings: "ss01", "ss02", "ss03", "ss04", "ss06";
  font-size: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--fg);
  font-size: var(--fs-ui);
  line-height: var(--lh-ui);
  min-height: 100dvh;
  overflow-x: clip;
}

button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
p, h1, h2, h3 { margin: 0; padding: 0; font-weight: inherit; font-size: inherit; }
svg { display: block; }
img { display: block; }

/* No focus rings anywhere (Dan, 28.10): focus is never drawn, after a click or after Tab. */
:focus, :focus-visible { outline: none; }
button::-moz-focus-inner { border: 0; }
html { -webkit-tap-highlight-color: transparent; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.nw { white-space: nowrap; }

.skip {
  position: absolute; z-index: 50; left: var(--gutter); top: 8px;
  padding: 6px 10px; background: var(--fg); color: var(--bg);
  border-radius: 4px; text-decoration: none; transform: translateY(-200%);
}
.skip:focus { transform: none; }

/* Theme swap: no colour transitions while the palette flips */
.no-transitions *, .no-transitions *::before, .no-transitions *::after { transition: none !important; }

/* ---------- Scene (the page, full width) --------------------------------- */

.scene {
  position: relative;
  width: 100%;
  margin-inline: auto;
  background: var(--bg);
  min-height: 100dvh;
}

/* ---------- Masthead ----------------------------------------------------- */

.masthead {
  position: relative;
  padding: var(--gutter) var(--gutter) 0;
}

.wordmark { color: var(--fg); line-height: 0; }
.wordmark svg { display: block; width: 100%; height: auto; }

.theme-dot {
  position: absolute; z-index: 2;
  left: var(--gutter); top: var(--gutter);
  width: 20px; height: 20px; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--fg);
  cursor: pointer;
  transition: scale 150ms ease-out;
}
.theme-dot::before { content: ""; position: absolute; inset: -12px; border-radius: 50%; }
@media (hover: hover) { .theme-dot:hover { scale: 1.2; } }
.theme-dot:active { scale: 0.96; }

/* ---------- Intro -------------------------------------------------------- */

/* Fixed (Dan, 28.10): 84px under the logo, 16px text in a 750px box, centred.
   Phones: the same 16px text, the gap scaled like the old defaults (40 → 28). */
.intro {
  padding: 84px var(--gutter) 0;
  text-align: center;
}
.intro__text {
  max-width: 750px;
  margin-inline: auto;
  font-size: var(--fs-intro);
  line-height: 1.4;
  text-wrap: pretty;
}
.intro__meta {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 24px;
  margin-top: 20px;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
  :root { --gutter: 16px; }
  .intro { padding-top: 56px; }
  /* the theme dot gets its own line above the wordmark */
  .masthead { padding-top: calc(var(--gutter) + 20px + 16px); }
}

/* ---------- Grid --------------------------------------------------------- */

.grid {
  position: relative;
  margin-top: 96px;
}
@media (max-width: 600px) { .grid { margin-top: 64px; } }

/* Fallback without JS (or before the first layout): a plain wrapping row. */
.grid:not(.is-laid) {
  display: flex; flex-wrap: wrap; gap: 40px var(--gutter);
  padding: 0 var(--gutter);
}
.js .grid:not(.is-laid) { visibility: hidden; }
.grid:not(.is-laid) .mod { position: relative; width: 240px; }
.grid:not(.is-laid) .mod__ph { position: relative; width: 240px; aspect-ratio: 1; }
.grid:not(.is-laid) .mod__cap { position: relative; }
.grid:not(.is-laid) .era { width: 100%; }

/* Era label: sits above the big module that opens a season. */
.era {
  position: absolute;
  font-size: var(--fs-xs);
  line-height: 1.4;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.era b { font-weight: 400; color: var(--fg); }

/* A module is one button: photo (with the name notched into its corner) + caption. */
.mod {
  position: absolute;
  display: block;
  margin: 0; padding: 0;
  border: 0; background: none;
  text-align: start;
  cursor: pointer;
}

.mod__ph {
  position: absolute;
  display: block;
  overflow: hidden;
  background: var(--ph-bg);
}
.mod__ph::after {                   /* image outline, pure black/white at 10% */
  content: ""; position: absolute; inset: 0;
  outline: 1px solid var(--img-line); outline-offset: -1px;
  pointer-events: none;
}
.mod__ph img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: scale 600ms var(--ease);
}

/* Name notched into the bottom-left corner: a tab of page colour. */
.mod__name {
  position: absolute; left: 0; bottom: 0; z-index: 1;
  padding: 6px 10px 0 0;
  background: var(--bg);
  color: var(--fg);
  font-size: var(--fs-name);
  line-height: 1.2;
  white-space: nowrap;
  transition-property: color, background-color;
  transition-duration: 150ms;
}
.mod--big .mod__name { font-size: var(--fs-name-big); }
.mod--bleed .mod__name { padding-inline-start: var(--gutter); }

.mod__cap {
  position: absolute;
  display: flex; flex-direction: column; gap: 2px;
  padding-top: 8px;
  font-size: var(--fs-xs);
  line-height: 1.4;
  color: var(--muted);
}
.mod__meta, .mod__title { display: block; text-wrap: pretty; }
.mod__meta { font-variant-numeric: tabular-nums; }
.mod__title { transition: color 150ms; }

@media (hover: hover) {
  .mod:hover .mod__title { color: var(--fg); }
  .mod:hover .mod__ph img { scale: 1.035; }
}

@media (prefers-reduced-motion: reduce) {
  .mod__ph img { transition: none; }
  .mod:hover .mod__ph img { scale: 1; }
}

/* ---------- Footer ------------------------------------------------------- */

.footer {
  margin-top: 120px;
  padding: 0 var(--gutter) var(--gutter);
  font-size: var(--fs-xs);
  color: var(--muted);
}
.footer p { padding-top: 12px; border-top: 1px solid var(--rule); }

/* ---------- Photo reveal (reveal.js, Downlink) --------------------------- */
/* Photos wait hidden until their effect plays; the canvas exists only while it does. */
.rv-boot .mod__ph:not([data-rv-skip]) img,
.mod__ph[data-rv="wait"] img,
.mod__ph[data-rv="hide"] img { opacity: 0; }
.rv-canvas {
  position: absolute; inset: 0;
  display: block; width: 100%; height: 100%;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .rv-boot .mod__ph img, .mod__ph[data-rv] img { opacity: 1; }
  .rv-canvas { display: none; }
}

/* ---------- Player dock (player.js) -------------------------------------- */
/* Always visible, bottom centre. Logo colour (--fg) as the surface, page colour
   as ink, so it inverts with the theme. Corners after the wordmark: straight
   stems and ~45° chamfers (clip-path), never round pills. "Signal": a capsule
   with a live meter that unfolds into the playlist. */

.pl {
  --pl-bg: var(--fg);
  --pl-ink: var(--bg);
  --pl-dim: color-mix(in oklab, var(--pl-ink) 62%, var(--pl-bg));
  --pl-wash: color-mix(in oklab, var(--pl-ink) 7%, var(--pl-bg));
  --pl-wash-2: color-mix(in oklab, var(--pl-ink) 12%, var(--pl-bg));
  --pl-rule: color-mix(in oklab, var(--pl-ink) 16%, var(--pl-bg));
  --pl-h: 48px;
  --pl-w: 300px;                /* collapsed (Dan, 28.10: was 360) */
  --pl-w-open: 440px;           /* playlist open (was 480) */
  --pl-t: 420ms;
  --pl-ease: cubic-bezier(0.2, 0, 0, 1);
  position: fixed; z-index: 58;
  left: 50%; bottom: max(16px, env(safe-area-inset-bottom));
  translate: -50% 0;
  width: min(var(--pl-w), calc(100vw - 32px));
  color: var(--pl-ink);
  font-size: var(--fs-xs); line-height: 16px;
  font-variant-numeric: tabular-nums;
  filter: drop-shadow(0 6px 18px rgb(0 0 0 / 0.22));
  transition: width var(--pl-t) var(--pl-ease);
}
.pl.is-open { width: min(var(--pl-w-open), calc(100vw - 32px)); }
.pl--static, .pl--static * { transition: none !important; }
.pl-audio { display: none; }
.pl button { -webkit-tap-highlight-color: transparent; }

/* chamfered corners: --c (all) or --c1..--c4 (tl, tr, br, bl) */
.pl-cf {
  --c1: var(--c); --c2: var(--c); --c3: var(--c); --c4: var(--c);
  clip-path: polygon(var(--c1) 0, calc(100% - var(--c2)) 0, 100% var(--c2), 100% calc(100% - var(--c3)),
                     calc(100% - var(--c3)) 100%, var(--c4) 100%, 0 calc(100% - var(--c4)), 0 var(--c1));
}
/* small controls take their own even chamfer (~1/10 of their height) instead of
   inheriting the surface's big diagonal --c1..--c4, so the cut never crowds the text */
.pl :is(.pl-ib, .pl-rates button, .pl-row) {
  --c1: var(--c); --c2: var(--c); --c3: var(--c); --c4: var(--c);
}

/* page room: the footer and focused things never hide under the dock */
html { scroll-padding-bottom: 96px; }
.footer { padding-bottom: calc(var(--gutter) + 80px); }

/* scrim: phones only, while the sheet is open */
.pl-scrim {
  position: fixed; inset: 0; z-index: 57;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  opacity: 0; pointer-events: none;
  transition: opacity 240ms ease-out;
}

/* ---- shared controls ---- */

.pl-play {
  position: relative; flex: none;
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; background: var(--pl-ink); color: var(--pl-bg);
  cursor: pointer;
  --c: 9px;
  transition: scale 150ms ease-out;
}
.pl-play:active { scale: 0.96; }
.pl-ic, .pl-load { grid-area: 1 / 1; }
.pl-ic svg { width: 16px; height: 16px; fill: currentColor; }
.pl-ic {
  opacity: 0; scale: 0.25; filter: blur(4px);
  transition-property: opacity, scale, filter;
  transition-duration: 300ms; transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}
.pl[data-status="idle"] .pl-ic--play, .pl[data-status="paused"] .pl-ic--play,
.pl[data-status="playing"] .pl-ic--pause, .pl[data-status="error"] .pl-ic--retry { opacity: 1; scale: 1; filter: none; }

/* dot-ring loader (after the reference's dot spinner) */
.pl-load { position: relative; width: 20px; height: 20px; opacity: 0; transition: opacity 150ms ease-out; }
.pl[data-status="loading"] .pl-load, .pl[data-status="buffering"] .pl-load { opacity: 1; }
.pl-load i {
  position: absolute; left: 50%; top: 50%;
  width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px; border-radius: 50%;
  background: currentColor;
  transform: rotate(calc(var(--i) * 45deg)) translateY(-7px);
  opacity: 0.2;
  animation: pl-dot 960ms linear infinite;
  animation-delay: calc(var(--i) * 120ms - 960ms);
}
.pl-load i:nth-child(1) { --i: 0; } .pl-load i:nth-child(2) { --i: 1; } .pl-load i:nth-child(3) { --i: 2; } .pl-load i:nth-child(4) { --i: 3; }
.pl-load i:nth-child(5) { --i: 4; } .pl-load i:nth-child(6) { --i: 5; } .pl-load i:nth-child(7) { --i: 6; } .pl-load i:nth-child(8) { --i: 7; }
@keyframes pl-dot { 0% { opacity: 1; } 70%, 100% { opacity: 0.2; } }

.pl-toggle {
  display: flex; align-items: center;
  min-width: 0; padding: 0;
  border: 0; background: none; color: inherit;
  text-align: start; cursor: pointer;
}
.pl-led { display: block; min-width: 0; color: var(--pl-ink); }

.pl-sheet {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows var(--pl-t) var(--pl-ease);
}
.pl-sheet__in {
  min-height: 0; overflow: hidden;
  display: flex; flex-direction: column;
  opacity: 0;
  transition: opacity 160ms ease-out;
}
.pl.is-open .pl-sheet { grid-template-rows: 1fr; }
.pl.is-open .pl-sheet__in { opacity: 1; transition: opacity 260ms ease-out 110ms; }

.pl-head { display: flex; flex-direction: column; gap: 6px; padding: 14px 14px 8px; }
.pl-head__meta { color: var(--pl-dim); }

.pl-seek { display: flex; align-items: center; gap: 10px; color: var(--pl-dim); }
.pl-seek__t { flex: none; min-width: 5ch; }
.pl-seek__t:last-child { text-align: end; }
.pl-seek__in {
  -webkit-appearance: none; appearance: none;
  flex: 1; min-width: 0; height: 24px; margin: 0; padding: 0;
  background:
    linear-gradient(var(--pl-ink), var(--pl-ink)) 0 50% / calc(var(--pct, 0) * 100%) 2px no-repeat,
    linear-gradient(var(--pl-rule), var(--pl-rule)) 0 50% / 100% 2px no-repeat;
  cursor: pointer;
}
.pl-seek__in::-webkit-slider-runnable-track { height: 24px; background: none; border: 0; }
.pl-seek__in::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 4px; height: 14px; margin-top: 5px; border: 0; border-radius: 1px; background: var(--pl-ink); }
.pl-seek__in::-moz-range-track { height: 24px; background: none; border: 0; }
.pl-seek__in::-moz-range-thumb { width: 4px; height: 14px; border: 0; border-radius: 1px; background: var(--pl-ink); }

.pl-tr { display: flex; align-items: center; gap: 2px; margin-inline: -6px; }
.pl-ib {
  position: relative; display: grid; place-items: center;
  width: 32px; height: 32px; padding: 0;
  border: 0; background: none; color: inherit; cursor: pointer;
  --c: 4px;
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
  transition-property: background-color, scale; transition-duration: 150ms; transition-timing-function: ease-out;
}
.pl-ib svg { width: 16px; height: 16px; fill: currentColor; }
.pl-ib:active:not(:disabled) { scale: 0.96; }
.pl-ib:disabled { opacity: 0.35; cursor: default; }
@media (hover: hover) { .pl-ib:hover:not(:disabled) { background: var(--pl-wash-2); } }
.pl-rates { display: flex; gap: 2px; margin-inline-start: auto; }
.pl-rates button {
  --c: 3px;
  height: 28px; min-width: 40px; padding: 0 9px;
  border: 0; background: none; color: var(--pl-dim);
  font-size: 11px; cursor: pointer;
  clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px);
  transition-property: background-color, color; transition-duration: 150ms; transition-timing-function: ease-out;
}
@media (hover: hover) { .pl-rates button:hover { background: var(--pl-wash-2); color: var(--pl-ink); } }
.pl-rates button[aria-pressed="true"] { background: var(--pl-ink); color: var(--pl-bg); }

.pl-list {
  position: relative;
  max-height: min(400px, calc(100dvh - 300px));
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--pl-rule) transparent;
  padding: 0 6px 6px;
}
.pl-era__h {
  position: sticky; top: 0; z-index: 1;
  display: flex; gap: 10px;
  padding: 10px 8px 6px;
  background: var(--pl-bg); color: var(--pl-dim);
  font-size: 11px; line-height: 14px; text-transform: uppercase; letter-spacing: 0.04em;
}
.pl-era__y { margin-inline-start: auto; }
.pl-era__h > :first-child { color: var(--pl-ink); }
.pl-era__list { list-style: none; margin: 0; padding: 0; }
/* seasons read as separate groups: a hairline and more room above a season than below its header */
.pl-era + .pl-era { margin-top: 10px; }
.pl-era + .pl-era .pl-era__h { padding-top: 14px; box-shadow: inset 0 1px var(--pl-rule); }

.pl-row {
  display: grid; grid-template-columns: 22px 62px minmax(0, 1fr) auto;
  align-items: center; column-gap: 10px;
  width: 100%; min-height: 36px; padding: 0 8px;
  border: 0; background: none; color: inherit;
  font-size: var(--fs-xs); text-align: start;
  cursor: pointer;
  --c: 4px;
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
  transition: background-color 150ms ease-out;
}
@media (hover: hover) { .pl-row:hover { background: var(--pl-wash-2); } }
.pl-row__ep { position: relative; display: grid; color: var(--pl-dim); }
.pl-row__ep > * { grid-area: 1 / 1; }
.pl-row__title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pl-row__d { color: var(--pl-dim); }
.pl-row[aria-current="true"] { background: var(--pl-ink); color: var(--pl-bg); }
.pl-row[aria-current="true"] .pl-row__ep, .pl-row[aria-current="true"] .pl-row__d { color: color-mix(in oklab, var(--pl-bg) 62%, var(--pl-ink)); }

/* state mark on the loaded item (replaces the episode number), same shapes as the
   grid module's notch mark: rounded triangle while playing, two bars when paused;
   loading / buffering keeps the triangle and breathes */
.pl-mark {
  display: none; flex: none;
  width: 10px; height: 10px;
  background: currentColor;
  -webkit-mask: var(--mark) left center / contain no-repeat; mask: var(--mark) left center / contain no-repeat;
  --mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 12'%3E%3Cpath d='M1 1.2v9.6a.6.6 0 0 0 .9.5l7.6-4.8a.6.6 0 0 0 0-1L1.9.7a.6.6 0 0 0-.9.5z'/%3E%3C/svg%3E");
}
.pl:is([data-status="playing"], [data-status="loading"], [data-status="buffering"]) .pl-mark {
  --mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 12'%3E%3Crect x='1' y='1' width='3' height='10' rx='.5'/%3E%3Crect x='6' y='1' width='3' height='10' rx='.5'/%3E%3C/svg%3E");
}
.pl-item[aria-current="true"] .pl-mark { display: block; }
.pl-row[aria-current="true"] .pl-mark { align-self: center; background: var(--pl-bg); }
.pl-row[aria-current="true"] .pl-row__n { visibility: hidden; }
.pl:is([data-status="loading"], [data-status="buffering"]) .pl-mark { animation: pl-mark 1.2s ease-in-out infinite alternate; }
@keyframes pl-mark { to { opacity: 0.35; } }

/* ---- Signal: capsule with a live meter; rows carry dot graphs ---- */

.pl .pl-surface {
  --c1: 16px; --c2: 4px; --c3: 16px; --c4: 4px;     /* the wordmark's S: chamfers on one diagonal */
  display: flex; flex-direction: column-reverse;
  background: var(--pl-bg);
}
.pl .pl-bar { display: flex; align-items: center; height: var(--pl-h); padding: 4px; }
/* concentric with the surface: inner chamfer = outer − inset·(2−√2), so the 4px inset holds along the diagonals too
   (16 − 2.34 ≈ 13.7 top-left, 4 − 2.34 ≈ 1.7 bottom-left) */
.pl .pl-play { --c1: 13.7px; --c2: 3px; --c3: 3px; --c4: 1.7px; }
/* rhythm: 4 · play · 12 · meter · 12 · text · 12 · 4 */
.pl .pl-toggle { flex: 1; align-self: stretch; gap: 12px; padding: 0 12px; }
.pl-meter { flex: 1; height: 100%; }
.pl.is-open .pl-bar { box-shadow: inset 0 1px var(--pl-rule); }
.pl-stack { flex: none; display: flex; flex-direction: column; align-items: flex-end; line-height: 15px; padding-top: 2px; }   /* caps vs. digits: 2px centres the ink */
.pl-stack__c { font-size: var(--fs-xs); }
.pl-stack__t { font-size: 11px; color: var(--pl-dim); }
.pl .pl-row { grid-template-columns: 22px 62px minmax(0, 1fr) 84px auto; }
.pl-row__g { display: block; width: 84px; height: 14px; color: inherit; cursor: crosshair; }

/* ---- phones: full width inside the 16px gutters; the open state is a bottom sheet ---- */

@media (max-width: 600px) {
  .pl, .pl.is-open { width: calc(100vw - 32px); }
  .pl-list { max-height: calc(100dvh - 290px); }
  .pl-row { min-height: 44px; }
  html.pl-open .pl-scrim { opacity: 1; pointer-events: auto; }
  .pl .pl-row { grid-template-columns: 10px 54px minmax(0, 1fr) 56px auto; column-gap: 8px; }
  .pl .pl-row__n { display: none; }     /* the narrow first column keeps only the state mark */
  .pl .pl-era__h { padding-inline-start: 26px; }   /* season code lines up with the mission codes, past the mark gutter */
  .pl-row__g { width: 56px; }
}

/* ---- grid: the module whose recording is loaded shows its state in the notch:
   play triangle while playing, pause bars when paused ---- */

.mod:is([data-playing="on"], [data-playing="loaded"]) .mod__name::after {
  content: ""; display: inline-block;
  width: 0.55em; height: 0.6em; margin-inline-start: 0.45em; vertical-align: 0.02em;
  background: currentColor;
  -webkit-mask: var(--mark) center / contain no-repeat; mask: var(--mark) center / contain no-repeat;
}
.mod[data-playing="on"] {
  --mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 12'%3E%3Crect x='1' y='1' width='3' height='10' rx='.5'/%3E%3Crect x='6' y='1' width='3' height='10' rx='.5'/%3E%3C/svg%3E");
}
.mod[data-playing="loaded"] {
  --mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 12'%3E%3Cpath d='M1 1.2v9.6a.6.6 0 0 0 .9.5l7.6-4.8a.6.6 0 0 0 0-1L1.9.7a.6.6 0 0 0-.9.5z'/%3E%3C/svg%3E");
}

@media (prefers-reduced-motion: reduce) {
  .pl, .pl-sheet, .pl-ic { transition-property: opacity; }
  .pl-ic { scale: 1; filter: none; }
  .pl-load i { animation: none; opacity: 0.55; }
  .pl-mark { animation: none !important; }
}


/* ---------- Mission overlay (overlay.js) --------------------------------- */
/* Full-screen sheet from the right: minimap · gallery · text on desktop,
   text over photos below 900px. One scroller; the minimap and the text are
   sticky. The player dock (z 58) floats above it (z 56). */

/* scroll lock without a shift: the gutter stays reserved while overflow is
   hidden, so the page (and fixed things like the player) keep their x */
html { scrollbar-gutter: stable; }
html.ov-open { overflow: hidden; }
html.ov-open body { padding-right: var(--sbw, 0px); }               /* fallback, 0 when the gutter holds */
html.ov-open .pl { margin-left: calc(var(--sbw, 0px) / -2); }        /* centred dock: half of it */

.ov {
  --ov-gap: 40px;
  --ov-map-w: 84px;
  --ov-text-w: clamp(300px, 26vw, 400px);
  --ov-top: var(--gutter);
  --ov-bottom: 148px;                       /* last photo clears the player dock */
  --ov-photo-max: calc(100dvh - 200px);     /* a photo + its caption fit one screen */
  --ov-fig-gap: clamp(40px, 7vh, 80px);
  --ov-in: 760ms;
  --ov-out: 460ms;
  position: fixed; inset: 0; z-index: 56;
}
.ov[hidden] { display: none; }

/* the page recedes under a veil of page colour; it never moves */
.ov__veil {
  position: absolute; inset: 0;
  background: var(--bg);
  opacity: 0;
  transition: opacity var(--ov-out) ease-out;
}
.ov.is-in .ov__veil { opacity: 0.72; transition-duration: var(--ov-in); }

.ov__panel {
  position: absolute; inset: 0;
  background: var(--bg);
  box-shadow: -1px 0 0 var(--rule);          /* the leading edge reads against the page while it slides */
  translate: 100% 0;
  transition: translate var(--ov-out) cubic-bezier(0.4, 0, 0.2, 1);
}
.ov.is-in .ov__panel { translate: 0 0; transition: translate var(--ov-in) var(--ease); }
.ov.is-out { pointer-events: none; }

/* text arrives after the sheet, in four short steps */
.ov .ov-st {
  opacity: 0; translate: 0 12px; filter: blur(4px);
}
.ov.is-in .ov-st {
  opacity: 1; translate: 0 0; filter: blur(0);
  transition-property: opacity, translate, filter;
  transition-duration: 300ms; transition-timing-function: ease-out;
  transition-delay: calc(300ms + var(--i, 0) * 100ms);
}
.ov-st:nth-child(1) { --i: 0; } .ov-st:nth-child(2) { --i: 1; } .ov-st:nth-child(3) { --i: 1; }
.ov-st:nth-child(4) { --i: 2; } .ov-st:nth-child(5) { --i: 3; } .ov-st:nth-child(6) { --i: 3; }
.ov .ov-map { opacity: 0; }
.ov.is-in .ov-map { opacity: 1; transition: opacity 400ms ease-out 480ms; }

.ov.is-instant, .ov.is-instant *, html.ov-instant .scene { transition: none !important; }

/* ---- scroller + columns ---- */

.ov__scroll {
  position: absolute; inset: 0;
  overflow-x: hidden; overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: calc(var(--ov-top) + 8px) var(--ov-bottom);
}

.ov__layout {
  position: relative;
  display: grid;
  grid-template-columns: var(--ov-map-w) minmax(0, 1fr) var(--ov-text-w);
  grid-template-areas: "map gal text";
  column-gap: var(--ov-gap);
  align-items: start;
  padding-inline: var(--gutter);
}

/* ---- text column ---- */

.ov-text {
  grid-area: text;
  position: sticky; top: 0;
  height: 100dvh;
}
.ov-text__in {
  display: flex; flex-direction: column;
  height: 100%;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  padding: var(--ov-top) 0 var(--gutter);
}
.ov-text__in::-webkit-scrollbar { display: none; }

.ov-era {
  min-height: 20px;
  padding-inline-end: 96px;                  /* room for Close */
  font-size: var(--fs-xs); line-height: 20px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ov-era b { font-weight: 400; color: var(--fg); }

.ov-title {
  display: flex; flex-direction: column; align-items: flex-start; gap: 14px;
  margin-top: clamp(32px, 8vh, 72px);
}
.ov-code {
  --c1: 8px; --c2: 2px; --c3: 8px; --c4: 2px;   /* one diagonal, like the wordmark's S and the player */
  padding: 5px 12px 4px;
  background: var(--fg); color: var(--bg);
  font-size: var(--fs-name); line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.ov-name {
  font-size: 2rem; line-height: 1.1;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.ov-meta {
  margin-top: 12px;
  font-size: var(--fs-xs); line-height: 1.4;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ov-about {
  margin-top: 28px;
  max-width: 46ch;
  font-size: var(--fs-ui); line-height: 1.6;
  text-wrap: pretty;
}
.ov-about p + p { margin-top: 0.8em; }

/* mission switcher: ← previous · next → (replaces the old listen block; the dock plays) */
.ov-nav {
  --ov-wash: color-mix(in oklab, var(--fg) 7%, var(--bg));
  --ov-wash-2: color-mix(in oklab, var(--fg) 13%, var(--bg));
  margin-top: auto; padding-top: 12px;       /* pinned to the bottom of the column */
  border-top: 1px solid var(--rule);
  font-size: var(--fs-xs); line-height: 1.4;
}
.ov-nav__pos { color: var(--muted); font-variant-numeric: tabular-nums; }
.ov-nav__n { color: var(--fg); }
.ov-nav__row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px; margin-top: 10px; }
.ov-nav__a {
  --c1: 3px; --c2: 3px; --c3: 3px; --c4: 3px;  /* small chamfers: the text stays clear of the cut */
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-width: 0; min-height: 52px;
  padding: 9px 12px;
  background: var(--ov-wash); color: var(--fg);
  text-decoration: none;
  cursor: pointer;
  transition-property: background-color, scale; transition-duration: 150ms; transition-timing-function: ease-out;
}
.ov-nav__a--next { align-items: flex-end; text-align: end; }
.ov-nav__k { display: flex; gap: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ov-nav__ar { color: var(--muted); }
.ov-nav__t { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }
@media (hover: hover) { .ov-nav__a[href]:hover { background: var(--ov-wash-2); } }
.ov-nav__a[href]:active { scale: 0.96; }
.ov-nav__a.is-off { background: none; color: var(--muted); cursor: default; }
.ov-nav__a.is-off .ov-nav__t { color: color-mix(in oklab, var(--muted) 70%, var(--bg)); }

/* switching missions: the content steps aside, swaps, glides back in */
.ov__layout { transition: opacity 280ms ease-out, translate 280ms var(--ease); }
.ov.is-swap .ov__layout {
  opacity: 0; translate: var(--swap-dx, 0px) 0;
  transition-duration: 140ms; transition-timing-function: ease-out;
}
.ov.is-swap-jump .ov__layout { transition: none; }

.ov-foot {
  margin-top: 28px; margin-bottom: 32px;     /* photo count + credit, right under the text */
  font-size: var(--fs-xs); line-height: 1.4;
  color: var(--muted);
}
.ov-count { font-variant-numeric: tabular-nums; padding-top: 12px; border-top: 1px solid var(--rule); }
.ov-count__n { color: var(--fg); }
.ov-count.is-single .ov-count__n, .ov-count.is-single .ov-count__sep { display: none; }
.ov-credit { margin-top: 2px; }

/* ---- close ---- */

.ov-close {
  position: absolute; z-index: 3;
  top: calc(var(--ov-top) - 10px); right: calc(var(--gutter) - 10px);
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 10px;
  border: 0; background: none;
  color: var(--muted);
  font-size: var(--fs-xs); line-height: 1;
  cursor: pointer;
  transition-property: color, scale; transition-duration: 150ms; transition-timing-function: ease-out;
}
.ov-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
@media (hover: hover) { .ov-close:hover { color: var(--fg); } }
.ov-close:active { scale: 0.96; }

/* chamfers (bevel.js softens the joints, like the player) */
.ov-cf {
  clip-path: polygon(var(--c1) 0, calc(100% - var(--c2)) 0, 100% var(--c2), 100% calc(100% - var(--c3)),
                     calc(100% - var(--c3)) 100%, var(--c4) 100%, 0 calc(100% - var(--c4)), 0 var(--c1));
}

/* ---- gallery: one column of large photos ---- */

.ov-gal {
  grid-area: gal;
  display: flex; flex-direction: column; gap: var(--ov-fig-gap);
  min-width: 0;
  padding: calc(var(--ov-top) + 8px) 0 var(--ov-bottom);
}
.ov-fig { margin: 0; }
.ov-ph {
  position: relative;
  width: min(100%, calc(var(--ov-photo-max) * var(--ar, 1.5)));
  aspect-ratio: var(--ar, 1.5);
  overflow: hidden;
  background: var(--ph-bg);
}
.ov-ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ov-ph::after {                              /* image outline, pure black/white at 10% */
  content: ""; position: absolute; inset: 0; z-index: 2;
  outline: 1px solid var(--img-line); outline-offset: -1px;
  pointer-events: none;
}
.ov-num {                                    /* index notched into the corner, as on the grid */
  position: absolute; left: 0; bottom: 0; z-index: 1;
  padding: 5px 10px 0 0;
  background: var(--bg); color: var(--fg);
  font-size: var(--fs-xs); line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.ov-cap {
  display: flex; flex-direction: column; gap: 2px;
  max-width: 64ch;
  padding-top: 8px;
  font-size: var(--fs-xs); line-height: 1.4;
  color: var(--muted);
}
.ov-cap__t { color: var(--fg); text-wrap: pretty; }
.ov-cap__m { font-variant-numeric: tabular-nums; }
.ov-cap__id {
  color: inherit;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: var(--rule);
  transition-property: color, text-decoration-color; transition-duration: 150ms;
}
@media (hover: hover) { a.ov-cap__id:hover { color: var(--fg); text-decoration-color: currentColor; } }

/* reveal (reveal.js, Downlink): the photo waits hidden until its effect plays */
.ov-ph[data-rv="wait"] img, .ov-ph[data-rv="hide"] img { opacity: 0; }

/* ---- minimap ---- */

.ov-map {
  grid-area: map;
  position: sticky; top: 0;
  height: 100dvh;
  padding: calc(var(--ov-top) + 8px) 0 var(--gutter);
}
.ov-map__in {
  position: relative;
  height: 100%;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.ov-map.is-drag .ov-map__in { cursor: grabbing; }
.ov-map__track { position: absolute; left: 0; top: 0; width: 100%; will-change: transform; }
.ov-map__ph { position: absolute; overflow: hidden; background: var(--ph-bg); }
.ov-map__ph img { display: block; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; }
.ov-map__cap { position: absolute; height: 1px; background: var(--muted); opacity: 0.7; }
.ov-map__frame {
  position: absolute; left: 0; top: 0; width: 100%;
  border: 1px solid var(--fg);
  box-shadow: 0 0 0 100vh color-mix(in srgb, var(--bg) 55%, transparent);   /* dims what is off screen */
  pointer-events: none;
  will-change: transform;
}

/* ---- the minimap stands in for the scrollbar on desktop ---- */

@media (min-width: 901px) {
  .ov__scroll { scrollbar-width: none; }
  .ov__scroll::-webkit-scrollbar { display: none; }
}

/* ---- up to 900px: no minimap; text on top, photos below ---- */

@media (max-width: 900px) {
  .ov { --ov-bottom: 120px; --ov-fig-gap: 40px; }
  .ov__layout { display: block; padding-inline: 0; }
  .ov-map { display: none; }
  .ov-text { position: static; height: auto; }
  .ov-text__in {
    height: auto; overflow: visible;
    max-width: 720px; margin-inline: auto;
    padding: var(--ov-top) var(--gutter) 40px;
  }
  .ov-title { margin-top: 40px; }
  .ov-name { font-size: 1.75rem; }
  .ov-about { max-width: none; }
  .ov-nav { margin-top: 0; }
  .ov-count__n, .ov-count__sep { display: none; }
  .ov-gal { max-width: 720px; margin-inline: auto; padding: 0 var(--gutter) var(--ov-bottom); }
  .ov-ph { width: 100%; }
  /* Close floats over the photos as you scroll: give it a tab of page colour */
  .ov-close {
    top: max(8px, env(safe-area-inset-top)); right: 8px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  }
}
@media (max-width: 600px) {
  .ov-gal { padding-inline: 0; }             /* photos bleed to the edges, captions stay in the gutter */
  .ov-cap { padding-inline: var(--gutter); }
  .ov-name { font-size: 1.625rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ov__panel, .ov.is-in .ov__panel { translate: none; opacity: 0; transition: opacity 220ms ease-out; }
  .ov.is-in .ov__panel { opacity: 1; }
  .ov.is-out .ov__panel { opacity: 0; }
  .ov .ov-st, .ov.is-in .ov-st { translate: none; filter: none; transition-delay: 0ms; }
  .ov.is-in .ov-map { transition-delay: 0ms; }
  .ov.is-swap .ov__layout { translate: none; }
  .ov-ph[data-rv] img { opacity: 1; }
}
