:root {
  --ocean: #0f0f0e;
  --paper: #ffffff;
  --ink: #111110;
  --ink-muted: #6c6b66;
  --rule: #ebebe8;
  --on-dark: #efeee9;
  --on-dark-muted: rgba(239, 238, 233, 0.62);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --gutter: 24px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--ocean);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body {
  font: 16px/1.5 "Instrument Sans", system-ui, sans-serif; letter-spacing: -0.005em;
  color: var(--on-dark);
}
button { font: inherit; letter-spacing: inherit; }

#stage {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 1;
  touch-action: none; opacity: 0; transition: opacity 0.9s var(--ease);
}
#stage.is-ready { opacity: 1; }
.videos video {
  position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0;
  pointer-events: none;
}
/* Without WebGL the videos are shown directly above the 2D map. */
.no-gl .videos video { z-index: 2; opacity: 0; transition: opacity 0.6s var(--ease); }
.no-gl .videos video.is-on { opacity: 1; }

/* Captions carry each film's lines, so the scrim is weighted to the bottom-left
   where they sit, and stays light across the rest of the picture. */
.scrim {
  position: fixed; left: 0; right: 0; bottom: 0; height: 56vh; z-index: 3; pointer-events: none;
  background:
    radial-gradient(ellipse 62% 78% at 0% 100%, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.22) 55%, transparent 80%),
    linear-gradient(to top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.16) 40%, transparent 75%);
  opacity: 0; transition: opacity 0.6s var(--ease);
}
.is-playing .scrim { opacity: 1; }

/* Card */
.card {
  position: fixed; z-index: 6; left: 50%; top: 50%;
  width: min(384px, calc(100vw - 32px));
  padding: 32px;
  background: var(--paper); color: var(--ink);
  border-radius: 16px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25), 0 24px 64px -24px rgba(0, 0, 0, 0.7);
  transform: translate(-50%, -50%);
  transition: opacity 0.4s var(--ease), transform 0.5s var(--ease), visibility 0s;
  outline: none;
}
.card.is-min {
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translate(-50%, calc(-50% + 8px)) scale(0.97);
  transition: opacity 0.25s var(--ease), transform 0.35s var(--ease), visibility 0s 0.35s;
}
.card p { margin: 0; }
.intro { font-size: 17px; line-height: 1.45; letter-spacing: -0.012em; }
.now {
  margin-top: 24px !important; padding: 16px 0;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-size: 15px;
}
.prev { margin-top: 24px; font-size: 15px; line-height: 1.6; }
.label { display: block; font-size: 13px; color: var(--ink-muted); margin-bottom: 4px; }
.card .credits { display: grid; grid-template-columns: max-content max-content; column-gap: 32px; row-gap: 2px; margin: 0; }
.card .credits dt { color: inherit; }
.card .credits dd { margin: 0; color: #6b6a65; }
.card nav { display: flex; gap: 24px; margin-top: 24px; font-size: 15px; }
.card a {
  color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px;
  text-underline-offset: 3px; text-decoration-color: rgba(17, 17, 16, 0.28);
  transition: text-decoration-color 0.2s;
}
.card a:hover { text-decoration-color: rgba(17, 17, 16, 0.9); }
.card a:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; border-radius: 2px; }

/* Note: the card folded into a wall label, bottom-right */
.note {
  position: fixed; z-index: 6; right: var(--gutter); bottom: var(--gutter);
  width: 244px; padding: 12px 14px 11px;
  background: var(--paper); color: var(--ink); border-radius: 8px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25), 0 12px 32px -16px rgba(0, 0, 0, 0.75);
  font-size: 12.5px; line-height: 1.45; cursor: pointer;
  opacity: 0; visibility: hidden; transition: opacity 0.2s var(--ease), visibility 0s 0.2s;
}
.note.is-on { opacity: 1; visibility: visible; transition-delay: 0s; }
.note p { margin: 0; }
.n-open {
  display: block; width: 100%; margin: 0; padding: 0; border: 0; background: none; color: inherit;
  text-align: left; font-size: inherit; line-height: inherit; cursor: pointer;
}
.n-open .n-short { display: none; }
.n-now { margin-top: 6px !important; color: var(--ink-muted); }
.n-links { margin-top: 2px !important; color: #b3b2ad; }
.note a {
  color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px;
  text-underline-offset: 2px; text-decoration-color: rgba(17, 17, 16, 0.28);
}
.note a:hover { text-decoration-color: rgba(17, 17, 16, 0.9); }
.note:hover { background: #fbfbfa; }
.n-open:focus-visible, .note a:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; border-radius: 2px; }
.fold {
  position: fixed; z-index: 7; left: 0; top: 0; width: 0; height: 0; pointer-events: none;
  background: var(--paper); border-radius: 16px; display: none;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25), 0 24px 64px -24px rgba(0, 0, 0, 0.7);
}
/* Narrow screens: the caption owns the bottom, so the note moves top-left and
   collapses to one line; a tap expands it, a second tap opens the card. */
@media (max-width: 899px) {
  .note { right: auto; left: var(--gutter); top: var(--gutter); bottom: auto; width: auto; max-width: calc(100vw - 2 * var(--gutter) - 176px); }
  .note.is-compact { display: flex; align-items: baseline; gap: 8px; padding: 7px 12px; border-radius: 10px; white-space: nowrap; }
  .note.is-compact .n-open { width: auto; font-weight: 500; }
  .note.is-compact .n-full, .note.is-compact .n-links { display: none; }
  .note.is-compact .n-short { display: inline; }
  .note.is-compact .n-now { margin: 0 !important; }
  .note:not(.is-compact) { width: min(244px, calc(100vw - 2 * var(--gutter))); max-width: none; }
}

/* Video controls */
.controls {
  position: fixed; z-index: 5; top: var(--gutter); right: var(--gutter);
  display: flex; gap: 8px;
  opacity: 0; visibility: hidden; transition: opacity 0.4s var(--ease), visibility 0s 0.4s;
}
.is-playing .controls { opacity: 1; visibility: visible; transition-delay: 0s; }
.ctl {
  padding: 7px 12px; border-radius: 10px; cursor: pointer;
  font-size: 13px; line-height: 1.2; color: var(--on-dark);
  background: rgba(15, 15, 14, 0.42); border: 1px solid rgba(239, 238, 233, 0.16);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  transition: background 0.2s, border-color 0.2s;
}
.ctl:hover { background: rgba(15, 15, 14, 0.62); border-color: rgba(239, 238, 233, 0.32); }

/* Caption panel */
.panel {
  position: fixed; z-index: 4; left: var(--gutter); bottom: var(--gutter);
  width: min(560px, calc(100vw - 2 * var(--gutter)));
  pointer-events: none; opacity: 0; transform: translateY(6px);
  transition: opacity 0.5s var(--ease), transform 0.6s var(--ease);
}
.is-playing .panel { opacity: 1; transform: none; }
/* A soft local shade behind the caption block: feathered to nothing, so there is no box,
   but dark enough behind the text for AA contrast over a bright frame. */
.panel { isolation: isolate; }
.panel::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  left: -120px; right: -140px; top: -90px; bottom: -80px;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.5) 45%, rgba(0, 0, 0, 0.22) 75%, transparent);
}
.panel a { pointer-events: auto; }
.p-name, .p-asof, .p-sources, .p-music, .nav { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6), 0 0 12px rgba(0, 0, 0, 0.45); }
.p-name { margin: 0; font-size: 20px; line-height: 1.2; font-weight: 500; letter-spacing: -0.015em; }
.p-asof { margin: 4px 0 0; font-size: 13px; color: var(--on-dark-muted); }
.p-line {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7), 0 0 10px rgba(0, 0, 0, 0.55), 0 0 24px rgba(0, 0, 0, 0.45);
  margin: 16px 0 0; font-size: 16px; line-height: 1.45; min-height: 2.9em; max-width: 44ch;
  text-wrap: pretty; transition: opacity 0.25s;
}
.p-line.is-swap { opacity: 0; transition-duration: 0.16s; }
.p-sources { margin: 8px 0 0; font-size: 12px; color: var(--on-dark-muted); display: flex; flex-wrap: wrap; gap: 4px 16px; }
.p-sources:empty { display: none; }
.p-sources a {
  color: var(--on-dark-muted); text-decoration: underline; text-decoration-thickness: 1px;
  text-underline-offset: 3px; text-decoration-color: rgba(239, 238, 233, 0.25);
}
.p-sources a:hover { color: var(--on-dark); }
.p-music { margin: 4px 0 0; font-size: 11px; color: rgba(239, 238, 233, 0.5); }
.p-music:empty { display: none; }

.p-nav { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 16px; pointer-events: auto; }
.p-nav:empty { display: none; }
.nav {
  padding: 4px 0; border: 0; background: none; cursor: pointer;
  font-size: 13px; line-height: 1.3; color: var(--on-dark-muted); transition: color 0.2s;
}
.nav:hover { color: var(--on-dark); }
.nav:focus-visible { outline: 1px solid var(--on-dark); outline-offset: 3px; border-radius: 2px; }
.nav[hidden] { display: none; }
.thread {
  padding: 3px 8px; border: 1px solid rgba(239, 238, 233, 0.18); border-radius: 6px; font-size: 12px;
}
.thread:hover { border-color: rgba(239, 238, 233, 0.4); }

/* The call: offered only while its shot plays. */
.call { opacity: 0; pointer-events: none; transition: opacity 0.9s var(--ease); }
.call.is-on { opacity: 1; pointer-events: auto; }
.is-finale .panel { display: none; }
/* The ending: one feather at the end of the route. */
.glint {
  position: fixed; z-index: 4; left: 0; top: 0; width: 36px; height: 36px; margin: -27px 0 0 -11px; padding: 7px;
  border: 0; background: none; color: #f4f1e8; cursor: pointer;
  filter: drop-shadow(0 0 6px rgba(244, 241, 232, 0.55));
  opacity: 0; visibility: hidden; transition: opacity 1.8s var(--ease), visibility 0s 1.8s;
}
.glint.is-on { opacity: 1; visibility: visible; transition-delay: 0s; animation: glint 3.2s ease-in-out infinite 1.8s; }
.glint:focus-visible { outline: 1px solid var(--on-dark); outline-offset: 2px; border-radius: 4px; }
@keyframes glint { 50% { opacity: 0.55; filter: drop-shadow(0 0 2px rgba(244, 241, 232, 0.3)); } }

/* Map hint + lens label */
.hint {
  position: fixed; z-index: 4; left: var(--gutter); bottom: var(--gutter); margin: 0;
  font-size: 13px; color: #7c7b75; pointer-events: none;
  opacity: 0; transition: opacity 0.6s var(--ease);
}
.hint.is-on { opacity: 1; transition-delay: 0.4s; }
.tip {
  position: fixed; z-index: 4; left: 0; top: 0; pointer-events: none; white-space: nowrap;
  font-size: 12px; line-height: 1; color: var(--on-dark); text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
  opacity: 0; transition: opacity 0.2s;
}
.tip.is-on { opacity: 1; }
.tip span { display: inline-block; transform: translateX(-50%); }
.tip small { color: var(--on-dark-muted); font-size: 12px; margin-left: 8px; font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
  :root { --gutter: 16px; }
  .card { padding: 24px; }
  .intro { font-size: 16px; }
  .p-name { font-size: 18px; }
  .p-line { font-size: 15px; }
}
/* Small phones (iPhone SE/mini, 320-379px): the compact note can't fit beside the film
   controls, so it keeps just "eliot" (a tap still opens it), and the Previously list tightens. */
@media (max-width: 379px) {
  .note.is-compact .n-now { display: none; }
  .card { padding: 20px; }
  .card .credits { grid-template-columns: max-content minmax(0, 1fr); column-gap: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .glint.is-on { animation: none; }
  .card, .card.is-min, .panel, #stage { transition-property: opacity, visibility; transform: translate(-50%, -50%); }
  .panel, #stage { transform: none; }
}
.nw { white-space: nowrap; }
