/* Naarad design system: tokens, shell, and the primitives every page shares.
   Page-specific sheets (home, route, story, studio, journey, explore) are
   loaded by the view that needs them. */

@import url('./tokens.css');

/* Subset to the characters the site sets; scripts/build-fonts.py rebuilds them.
   Indic language names in the interface fall back to the reader's system
   fonts, which carry those scripts properly. */
@font-face { font-family: 'DM Sans'; src: url('/app/fonts/DMSans.woff2') format('woff2'); font-style: normal; font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'Playfair Display'; src: url('/app/fonts/PlayfairDisplay.woff2') format('woff2'); font-style: normal; font-weight: 500 800; font-display: swap; }
@font-face { font-family: 'Caveat'; src: url('/app/fonts/Caveat-latin.woff2') format('woff2'); font-style: normal; font-weight: 600; font-display: swap; unicode-range: U+0000-00FF, U+2010-2027, U+2030-205E; }

/* Shell defaults - tokens are defined in tokens.css */
:root {
  color-scheme: light;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; min-height: 100svh; background: var(--paper); padding-bottom: var(--player-h); }
a, button, summary, [role="button"], label { -webkit-tap-highlight-color: transparent; }
a, button, summary, [role="button"], input, select, textarea, label { touch-action: manipulation; }
button, summary, [role="button"] { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* Every control answers a press; the buttons with their own pressed look below override this. */
button:not(:disabled):active, [role="button"]:active, summary:active { opacity: .82; }
button, input, select, textarea { font: inherit; color: inherit; }
/* iOS zooms the page when a focused field is under 16px. The header and catalogue search set their own size, below. */
@media (pointer: coarse) { input, select, textarea { font-size: var(--text-base); } }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg, video { display: block; max-width: 100%; }
html, body { overflow-x: clip; }
h1, h2, h3, h4 { margin: 0; font-family: var(--serif); font-weight: 700; letter-spacing: -.015em; line-height: 1.05; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { color: var(--white); background: var(--orange); }
:focus-visible { outline: 3px solid var(--orange-bright); outline-offset: 3px; border-radius: 3px; }
/* A heading takes focus after a page is drawn in place (main.js); it is not a control, so it shows no ring. */
h1[tabindex='-1']:focus, h2[tabindex='-1']:focus, h3[tabindex='-1']:focus { outline: none; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 2000; padding: 10px 16px; background: var(--ink); color: var(--white); border-radius: 4px; transform: translateY(-160%); }
.skip-link:focus { transform: none; }
.wrap { width: min(100% - 64px, var(--wrap)); margin-inline: auto; }

/* ── Paper texture ─────────────────────────────────────────────── */
/* A column, so the footer sits at the bottom of a page shorter than the window (the 404, an empty journey). */
.site-shell { position: relative; display: flex; flex-direction: column; min-height: 100svh; overflow-x: clip; }
.site-shell > main { flex: 1 0 auto; }
.site-shell > * { position: relative; z-index: 1; }

/* ── Typography primitives ─────────────────────────────────────── */
.eyebrow {
  margin: 0; font-size: 14px; font-weight: 600;
  color: var(--orange-text); font-family: var(--sans);
}
.eyebrow-mark { display: inline-flex; align-items: center; gap: 9px; }
.eyebrow-mark::before { content: ''; width: 8px; height: 8px; background: var(--orange); }
.eyebrow-ink { color: var(--ink-muted); }
.script { font-family: var(--script); font-weight: 600; line-height: 1.15; letter-spacing: .01em; }
.display { font-family: var(--serif); font-size: clamp(42px, 5vw, 68px); line-height: 1.02; }
.display .accent { color: var(--orange-text); }
.section-title { font-size: clamp(30px, 3.1vw, 46px); }
.lede { font-size: 17.5px; line-height: 1.62; color: var(--ink); }
.data-note { margin: 0; font-size: var(--text-xs); line-height: 1.55; color: var(--ink-muted); }

/* ── Buttons and chips ─────────────────────────────────────────── */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 46px; padding: 0 22px; border-radius: 999px; border: 1px solid var(--line-strong);
  font-size: var(--text-sm); font-weight: 600; color: var(--ink); background: var(--paper-bright);
  transition: background .18s, color .18s, border-color .18s, transform .18s;
}
.button { white-space: nowrap; }
.primary-nav a { white-space: nowrap; }
@media (hover: hover) { .button:hover { border-color: var(--ink); transform: translateY(-1px); } }
.button-primary { background: var(--orange); border-color: var(--orange-text); color: var(--white); }
@media (hover: hover) { .button-primary:hover { background: var(--orange-deep); border-color: var(--orange-deep); color: var(--white); } }
.button-ghost { background: transparent; border-color: rgb(var(--white-rgb) / 45%); color: var(--white); }
@media (hover: hover) { .button-ghost:hover { background: rgb(var(--white-rgb) / 12%); border-color: var(--white); } }
.button-sm { min-height: 38px; padding: 0 16px; font-size: var(--text-xs); }
.button[disabled], .button[aria-disabled='true'] { opacity: .5; cursor: not-allowed; transform: none; }
.icon-button {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: var(--paper-bright); color: var(--ink);
}
@media (hover: hover) { .icon-button:hover { border-color: var(--ink); } }
.text-link { display: inline-flex; align-items: center; gap: 7px; font-size: var(--text-sm); font-weight: 600; color: var(--orange-text); }
@media (hover: hover) { .text-link:hover { color: var(--orange-deep); text-decoration: underline; text-underline-offset: 4px; } }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--paper-bright);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: .02em; color: var(--ink-soft);
}
.chip-list { display: flex; flex-wrap: wrap; gap: 7px; }
.pin-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px;
  background: rgba(253, 250, 244, .95); color: var(--ink); font-size: var(--text-xs); font-weight: 600;
  box-shadow: var(--shadow-sm); backdrop-filter: blur(6px);
}

/* ── Form fields (the studio and the journal) ──────────────────── */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.field select, .field input[type='text'], .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--ink-muted); border-radius: 8px;
  background: var(--paper); font-size: var(--text-base); color: var(--ink);
}
.field textarea { resize: vertical; line-height: 1.6; font-family: var(--sans); }

/* Small line icons used across metric rows */
.ico { width: 19px; height: 19px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ico-orange { color: var(--orange-text); }
.ico-sage { color: var(--sage); }

/* ── Metric rows ───────────────────────────────────────────────── */
.metric-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 26px; }
.metric {
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.metric .ico { color: var(--orange-text); }
.metric-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.metric-text b { font-size: var(--text-sm); font-weight: 700; color: var(--ink); }
.metric-text span { font-size: var(--text-xs); color: var(--ink-muted); }

/* ── Torn paper edges ──────────────────────────────────────────── */
/* A deckled edge between a photograph and the paper it sits on. */
.torn-left {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none' viewBox='0 0 100 1000'%3E%3Cpath d='M1.6 0 C.6 34 2.4 62 1.2 96 C.3 128 2.2 156 1 188 C.2 220 2.4 250 1.3 282 C.4 314 2.1 344 .9 376 C.2 408 2.3 438 1.1 470 C.3 502 2.2 532 1 564 C.2 596 2.4 626 1.2 658 C.4 690 2.1 720 .9 752 C.2 784 2.3 814 1.1 846 C.3 878 2.2 908 1 940 C.3 968 1.8 986 1.4 1000 L100 1000 L100 0 Z' fill='%23fff'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none' viewBox='0 0 100 1000'%3E%3Cpath d='M1.6 0 C.6 34 2.4 62 1.2 96 C.3 128 2.2 156 1 188 C.2 220 2.4 250 1.3 282 C.4 314 2.1 344 .9 376 C.2 408 2.3 438 1.1 470 C.3 502 2.2 532 1 564 C.2 596 2.4 626 1.2 658 C.4 690 2.1 720 .9 752 C.2 784 2.3 814 1.1 846 C.3 878 2.2 908 1 940 C.3 968 1.8 986 1.4 1000 L100 1000 L100 0 Z' fill='%23fff'/%3E%3C/svg%3E");
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.torn-bottom {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none' viewBox='0 0 1000 100'%3E%3Cpath d='M0 0 L1000 0 L1000 94 C940 98 890 92 830 96 C770 99 720 93 660 97 C600 99 550 93 490 97 C430 99 380 94 320 97 C260 99 210 94 150 97 C90 99 50 95 0 98 Z' fill='%23fff'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none' viewBox='0 0 1000 100'%3E%3Cpath d='M0 0 L1000 0 L1000 94 C940 98 890 92 830 96 C770 99 720 93 660 97 C600 99 550 93 490 97 C430 99 380 94 320 97 C260 99 210 94 150 97 C90 99 50 95 0 98 Z' fill='%23fff'/%3E%3C/svg%3E");
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}

/* ── Photographs ───────────────────────────────────────────────── */
.photo { position: relative; overflow: hidden; background: var(--paper-deep); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-credit {
  position: absolute; right: 10px; bottom: 9px; z-index: 2; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px; border-radius: 4px; background: rgba(12, 28, 51, .62); color: rgb(var(--white-rgb) / 93%);
  font-size: var(--text-xs); line-height: 1.35; max-width: min(90%, 380px);
}
.photo-credit a { text-decoration: underline; text-underline-offset: 2px; }
.caption { display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; font-size: var(--text-xs); color: var(--ink-muted); line-height: 1.45; }
.caption .ico { width: 15px; height: 15px; margin-top: 2px; }

/* ── Handwritten notes ─────────────────────────────────────────── */
.note-card {
  display: inline-block; padding: 18px 24px 20px; border-radius: 6px;
  background: var(--ink-deep); color: var(--paper); box-shadow: var(--shadow-md);
}
.note-card .script { font-size: 23px; color: #f3e7d2; }
.note-card::after { content: ''; display: block; width: 46px; height: 2px; margin-top: 12px; background: var(--orange); }
.note-plain { font-family: var(--script); font-weight: 600; font-size: 24px; color: var(--ink-soft); line-height: 1.2; }
/* A handwritten note laid over a photograph needs its own ground to stay readable. */
.note-over-photo {
  padding: 12px 18px 14px; border-radius: 6px; color: #fdfaf4;
  background: rgba(12, 28, 51, .58);
}

/* ── Header ────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 900; display: grid; align-items: center;
  grid-template-columns: auto 1fr auto auto auto; gap: 22px;
  padding: 11px max(clamp(16px, 2.4vw, 34px), env(safe-area-inset-right)) 11px max(clamp(16px, 2.4vw, 34px), env(safe-area-inset-left)); min-height: var(--header-h);
  background: rgba(248, 243, 233, .93); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand img { width: 52px; height: 52px; object-fit: contain; }
.brand-name { display: block; font-family: var(--serif); font-size: 25px; font-weight: 800; letter-spacing: .055em; line-height: 1; color: var(--ink); }
.brand-motto { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--orange-text); }
.primary-nav { display: flex; justify-content: center; gap: clamp(14px, 2vw, 32px); }
.primary-nav a { display: inline-flex; align-items: center; gap: 5px; padding: 8px 2px; font-size: var(--text-sm); font-weight: 500; color: var(--ink-soft); border-bottom: 2px solid transparent; }
@media (hover: hover) { .primary-nav a:hover { color: var(--ink); } }
.primary-nav a.is-current { color: var(--orange-text); font-weight: 600; border-bottom-color: var(--orange-text); }
.header-search { display: flex; align-items: center; gap: 8px; width: min(270px, 22vw); padding: 0 14px; height: 42px; border: 1px solid var(--ink-muted); border-radius: 999px; background: var(--paper-bright); }
.header-search input { flex: 1; min-width: 0; border: 0; background: none; font-size: var(--text-xs); }
@media (pointer: coarse) { .header-search input { font-size: var(--text-base); } }
.header-search input::placeholder { color: var(--ink-muted); }
/* The ring is on the pill, not the bare input inside it. */
.header-search input:focus { outline: none; }
.header-search:focus-within { outline: 3px solid var(--orange-bright); outline-offset: 3px; }
.header-search button { display: grid; place-items: center; color: var(--ink-soft); }
.header-cta { height: 44px; }
.header-avatar { display: flex; align-items: center; gap: 9px; font-size: var(--text-sm); font-weight: 600; }
.header-avatar .avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--orange); color: var(--white); font-weight: 700; }
.menu-toggle { display: none; }

/* ── Dithered bands (app/dither.js) ───────────────────────────── */
.dither-band { position: relative; isolation: isolate; background: linear-gradient(135deg, var(--band-back), var(--band-front)); }
.dither-band[data-dither="sand"] { --band-back: #f8f3e9; --band-front: #efe6d4; --band-wash: rgb(248 243 233 / .6); }
.dither-band[data-dither="navy"] { --band-back: #0c1c33; --band-front: #0b1d3a; --band-wash: rgb(12 28 51 / .74); }
.dither-band[data-dither="forest"] { --band-back: #1e5b46; --band-front: #0c1c33; --band-wash: rgb(12 28 51 / .6); }
.dither-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; image-rendering: pixelated; pointer-events: none; }
/* The wash keeps text over the pattern at its designed contrast. */
.dither-band::after { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--band-wash); pointer-events: none; }

/* ── Footer ────────────────────────────────────────────────────── */
.site-footer {
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px 34px;
  padding: 26px clamp(18px, 3vw, 44px); background: var(--ink-deep); color: rgba(247, 242, 232, .85);
}
.site-footer .footer-brand { display: flex; align-items: center; gap: 11px; color: var(--paper); }
.site-footer .footer-brand img { width: 40px; height: 40px; object-fit: contain; }
.site-footer .footer-brand b { font-family: var(--serif); font-size: 19px; letter-spacing: .06em; display: block; }
.site-footer .footer-brand small { font-size: 9.5px; letter-spacing: .14em; color: var(--orange-on-dark); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 22px; font-size: var(--text-sm); }
@media (hover: hover) { .site-footer nav a:hover { color: var(--white); text-decoration: underline; text-underline-offset: 4px; } }
.footer-script { margin-left: auto; font-family: var(--script); font-size: 21px; color: rgba(247, 242, 232, .8); }
.footer-social { display: flex; gap: 14px; }
.footer-social a { display: grid; place-items: center; width: 30px; height: 30px; color: rgba(247, 242, 232, .72); }
@media (hover: hover) { .footer-social a:hover { color: var(--white); } }

/* ── Notices, empty states, loaders ────────────────────────────── */
.site-notice {
  position: fixed; left: 50%; bottom: calc(22px + var(--player-h)); transform: translateX(-50%);
  z-index: 1200; max-width: min(92vw, 520px); padding: 13px 20px; border-radius: 999px;
  background: var(--ink-deep); color: var(--paper); font-size: var(--text-xs); box-shadow: var(--shadow-lg);
}
.empty-state {
  display: flex; gap: 14px; align-items: flex-start; padding: 20px 22px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: rgba(253, 250, 244, .7);
}
.empty-state .ico { width: 22px; height: 22px; color: var(--orange-text); }
.empty-state strong { display: block; font-family: var(--serif); font-size: 17px; margin-bottom: 5px; }
.empty-state p { font-size: var(--text-xs); line-height: 1.55; color: var(--ink-soft); }
.load-error { display: grid; gap: 14px; place-content: center; min-height: 60vh; text-align: center; padding: 40px; }


/* ── Photo Mosaic (Airbnb-style) ───────────────────────────────── */
/* One large, four small. The first photo spans two columns and two rows. */
.photo-mosaic {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 2px;
  background: var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.photo-mosaic > *:first-child {
  grid-column: 1 / -1;
  grid-row: 1 / 3;
}
.photo-mosaic > * {
  position: relative;
  overflow: hidden;
  background: var(--paper-deep);
}
.photo-mosaic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--move) var(--ease-out);
}
@media (hover: hover) { .photo-mosaic > *:hover img { transform: scale(1.03); } }
.photo-mosaic .photo-credit { bottom: 10px; right: 10px; }

@media (max-width: 639px) {
  .photo-mosaic {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 10px;
  }
  .photo-mosaic > *:first-child {
    grid-column: 1;
    grid-row: 1;
    aspect-ratio: 16 / 9;
  }
  .photo-mosaic > * + * { aspect-ratio: 4 / 3; }
}

/* ── Dithered Hero Bands (Framer dither style) ─────────────────── */
/* Animated dither background for hero sections. */
.dither-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  image-rendering: pixelated;
  pointer-events: none;
}
.dither-band { position: relative; isolation: isolate; }
.dither-band::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--band-wash);
  pointer-events: none;
}
.dither-band[data-dither="sand"] { --band-back: #f8f3e9; --band-front: #efe6d4; --band-wash: rgb(248 243 233 / .6); }
.dither-band[data-dither="navy"] { --band-back: #0c1c33; --band-front: #0b1d3a; --band-wash: rgb(12 28 51 / .74); }
.dither-band[data-dither="forest"] { --band-back: #1e5b46; --band-front: #0c1c33; --band-wash: rgb(12 28 51 / .6); }

/* ── Route Map Fullscreen Dialog ───────────────────────────────── */
.route-map-dialog {
  width: min(1480px, calc(100% - 32px));
  max-width: none;
  height: min(920px, calc(100svh - 32px));
  max-height: none;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-bright);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.route-map-dialog[open] [data-map="fullscreen"] { display: none; }
.route-map-dialog::backdrop { background: rgb(12 28 51 / 78%); }
.route-map-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; margin-bottom: 14px; }
.route-map-dialog-head h2 { margin: 0; font-family: var(--serif); font-size: var(--text-md); }
.route-map-dialog-content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); gap: 16px; height: calc(100% - 58px); min-height: 0; }
.route-map-dialog-content > .map-frame { height: 100%; min-height: 0; aspect-ratio: auto; }
.route-map-dialog-content > .stop-rail { position: static; height: 100%; max-height: none; min-height: 0; }
.route-map-dialog-content > [data-map-dialog-empty] { align-self: start; margin: 0; padding: 14px; }

@media (max-width: 639px) {
  .route-map-dialog { width: calc(100% - 12px); height: calc(100svh - 12px); padding: 10px; border-radius: 12px; }
  .route-map-dialog-head { margin-bottom: 10px; }
  .route-map-dialog-content { grid-template-columns: 1fr; grid-template-rows: minmax(250px, 52svh) minmax(0, 1fr); gap: 10px; height: calc(100% - 54px); }
  .route-map-dialog-content > .map-frame { border-radius: 8px; }
  .route-map-dialog-content > .stop-rail { padding: 12px; }
}

/* ── Section Header Variants ───────────────────────────────────── */
.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 42%);
  gap: 20px 40px;
  align-items: end;
  margin-bottom: 34px;
}
.section-head .eyebrow { margin-bottom: 14px; }
.section-head-aside { display: flex; align-items: center; justify-content: flex-end; gap: 26px; }
.section-head-aside p { max-width: 46ch; font-size: var(--text-base); line-height: 1.6; color: var(--ink); text-align: right; }
.section-head-aside .button { flex: none; }

@media (max-width: 1023px) {
  .section-head { grid-template-columns: 1fr; }
  .section-head-aside { justify-content: space-between; }
  .section-head-aside p { text-align: left; }
}

/* ── Route Card Grid ───────────────────────────────────────────── */
.route-card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px; }

@media (max-width: 1240px) { .route-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 639px) { .route-card-grid { grid-template-columns: 1fr; } }

/* ── Responsive shell ──────────────────────────────────────────── */
@media (max-width: 1240px) {
  .header-search { width: 190px; }
  .primary-nav { gap: 16px; }
}
@media (max-width: 1023px) {
  :root { --header-h: 66px; }
  .site-header { grid-template-columns: auto 1fr auto; gap: 12px; }
  .primary-nav {
    position: absolute; top: 100%; left: 0; right: 0; display: none; flex-direction: column; gap: 0;
    padding: 8px 20px 18px; background: var(--paper-bright); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-md);
  }
  .site-header.nav-open .primary-nav { display: flex; }
  .primary-nav a { padding: 13px 0; border-bottom: 1px solid var(--line); }
  .primary-nav a.is-current { border-bottom-color: var(--line); }
  .header-search, .header-cta { display: none; }
  .menu-toggle { display: inline-grid; place-items: center; width: 44px; height: 44px; }
  .menu-toggle span { display: block; width: 19px; height: 2px; background: var(--ink); }
  .menu-toggle span + span { margin-top: 5px; }
  .brand img { width: 42px; height: 42px; }
  .brand-name { font-size: 20px; }
  .wrap { width: calc(100% - 32px); }
  .site-footer { flex-direction: column; align-items: flex-start; }
  .footer-script { margin-left: 0; }
}

/* A phone is used with a thumb: what can be tapped is 44px each way. */
@media (max-width: 639px) {
  .button-sm { min-height: 44px; }
  .icon-button { width: 44px; height: 44px; }
  a.text-link { min-height: 44px; }
  .site-footer nav { gap: 0 22px; }
  .site-footer nav a, .breadcrumb a { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
  .site-footer .footer-brand { min-height: 44px; }
  .breadcrumb { margin-bottom: 4px; }
}

/* ── Listening bar ─────────────────────────────────────────────── */
.listen-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
  display: grid; grid-template-columns: 56px minmax(0, 1.1fr) auto minmax(0, 1.6fr) auto;
  align-items: center; gap: 16px; padding: 10px clamp(14px, 2vw, 26px);
  /* Clear the home indicator and the landscape notch. --player-h is this bar's offsetHeight, so it includes the inset. */
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  padding-left: max(clamp(14px, 2vw, 26px), env(safe-area-inset-left));
  padding-right: max(clamp(14px, 2vw, 26px), env(safe-area-inset-right));
  background: var(--ink-deep); color: var(--paper); box-shadow: 0 -6px 24px rgba(12, 28, 51, .24);
}
.listen-art { width: 56px; height: 56px; border-radius: 6px; overflow: hidden; background: rgba(247, 242, 232, .1); }
.listen-art img { width: 100%; height: 100%; object-fit: cover; }
.listen-meta { min-width: 0; }
.listen-meta strong { display: block; font-size: var(--text-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.listen-meta span { display: block; font-size: var(--text-xs); color: rgba(247, 242, 232, .62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.listen-controls { display: flex; align-items: center; gap: 10px; }
/* On phones the source label sits under the title, because the aside that holds the full label is hidden there. */
.listen-meta .listen-source-inline { display: none; font-size: 12px; color: rgba(247, 242, 232, .75); }
.listen-bar [hidden] { display: none; }
.listen-skip { position: relative; display: grid; place-items: center; width: 44px; height: 44px; color: rgba(247, 242, 232, .85); }
.listen-skip .ico { width: 23px; height: 23px; }
.listen-skip span { position: absolute; font-size: 8.5px; font-weight: 700; top: 53%; left: 50%; transform: translate(-50%, -50%); }
@media (hover: hover) { .listen-skip:hover { color: var(--white); } }
.listen-play { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--orange); color: var(--white); }
@media (hover: hover) { .listen-play:hover { background: var(--orange-bright); } }
.listen-play .ico { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.listen-progress { display: flex; align-items: center; gap: 12px; min-width: 0; }
.listen-progress input[type='range'] { flex: 1; min-width: 60px; accent-color: var(--orange-text); height: 4px; }
.listen-progress input[disabled] { opacity: .55; }
.listen-time { font-size: var(--text-xs); font-variant-numeric: tabular-nums; color: rgba(247, 242, 232, .7); white-space: nowrap; }
.listen-aside { display: flex; align-items: center; gap: 14px; }
.listen-source { font-size: var(--text-xs); letter-spacing: .02em; color: rgba(247, 242, 232, .75); white-space: nowrap; }
.listen-rate { min-width: 40px; padding: 5px 9px; border-radius: 6px; border: 1px solid rgba(247, 242, 232, .25); font-size: var(--text-xs); font-weight: 600; color: rgba(247, 242, 232, .9); }
@media (hover: hover) { .listen-rate:hover { border-color: var(--paper); } }
.listen-next { display: flex; align-items: center; gap: 9px; max-width: 210px; }
.listen-next .ico { width: 17px; height: 17px; color: rgba(247, 242, 232, .6); }
.listen-next small { display: block; font-size: 12px; color: rgba(247, 242, 232, .72); }
.listen-next b { display: block; font-size: var(--text-xs); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.listen-close { width: 44px; height: 44px; border-color: rgba(247, 242, 232, .25); background: transparent; color: rgba(247, 242, 232, .8); }
@media (hover: hover) { .listen-close:hover { border-color: var(--paper); color: var(--white); } }
.listen-close .ico { width: 15px; height: 15px; }

@media (max-width: 1023px) {
  .listen-bar {
    /* One row: art, title block, the three controls, and the close button as its own column. It used to wrap onto a
       second row, which made the bar 118px tall. */
    grid-template-columns: 46px minmax(0, 1fr) auto auto; gap: 12px;
    padding: 8px max(14px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
  .listen-art { width: 46px; height: 46px; }
  .listen-progress, .listen-source, .listen-next, .listen-rate { display: none; }
  .listen-meta .listen-source-inline { display: block; }
  .listen-controls { gap: 4px; }
}
/* Narrow phones have no room for the thumbnail beside a readable title; the stop's photo is on the page. */
@media (max-width: 429px) {
  .listen-bar { grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
  .listen-art { display: none; }
}

/* Map fallback text */
.map-unavailable {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  max-width: 80%; padding: 12px 16px; border-radius: 8px; text-align: center;
  background: rgba(253, 250, 244, .94); font-size: var(--text-xs); color: var(--ink-soft);
}
.photo-missing { display: block; min-height: 90px; background: var(--paper-deep); }

/* ── Breadcrumbs and bylines (route, story, journey) ───────────── */
.breadcrumb { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; font-size: var(--text-xs); color: var(--ink-muted); }
.breadcrumb .ico { width: 13px; height: 13px; stroke-width: 2; }
@media (hover: hover) { .breadcrumb a:hover { color: var(--orange-text); } }
.breadcrumb b { color: var(--ink); font-weight: 600; }
.route-byline { display: flex; align-items: center; gap: 13px; margin-top: 26px; }
.byline-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--paper-bright); }
.byline-mark img { width: 34px; height: 34px; object-fit: contain; }
.byline-copy small { display: block; font-size: var(--text-xs); color: var(--ink-muted); }
.byline-copy b { display: block; font-size: 15px; margin: 2px 0 1px; }
.byline-copy > span { font-size: var(--text-xs); color: var(--ink-muted); }
.byline-mark { flex: none; }
.byline-copy { min-width: 0; }

/* Numbered stop badge (route rail, studio picker) */
.stop-index {
  display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%;
  background: var(--ink); color: var(--white); font-size: var(--text-xs); font-weight: 700;
}

/* ── Motion ────────────────────────────────────────────────────── */
/* Everything here is scoped to html[data-motion='on'], which app/motion.js
   sets only when the observer is running and the reader has not asked for
   reduced motion. Without script, or with reduced motion, nothing hides. */

:root { --ease-out: cubic-bezier(.22, .61, .36, 1); --move: 460ms; }

[data-motion='on'] [data-reveal='out'] { opacity: 0; transform: translateY(18px); }
[data-motion='on'] [data-reveal] {
  transition: opacity var(--move) var(--ease-out), transform var(--move) var(--ease-out);
}
[data-motion='on'] [data-reveal='in'] { opacity: 1; transform: none; }

/* Once GSAP has loaded it drives the reveal, so the CSS transitions step aside. */
html[data-gsap='on'][data-motion='on'] [data-reveal],
html[data-gsap='on'][data-motion='on'] [data-reveal] > * { transition: none; }

/* The parts of a surface arrive one after another. */
[data-motion='on'] [data-reveal='out'] > .eyebrow,
[data-motion='on'] [data-reveal='out'] > h1,
[data-motion='on'] [data-reveal='out'] > h2,
[data-motion='on'] [data-reveal='out'] > h3,
[data-motion='on'] [data-reveal='out'] > p,
[data-motion='on'] [data-reveal='out'] > .lede,
[data-motion='on'] [data-reveal='out'] > .button,
[data-motion='on'] [data-reveal='out'] > .text-link,
[data-motion='on'] [data-reveal='out'] > picture,
[data-motion='on'] [data-reveal='out'] > .chip-list,
[data-motion='on'] [data-reveal='out'] > ul,
[data-motion='on'] [data-reveal='out'] > ol,
[data-motion='on'] [data-reveal='out'] > .metric-row { opacity: 0; transform: translateY(14px); }

[data-motion='on'] [data-reveal] > .eyebrow,
[data-motion='on'] [data-reveal] > h1,
[data-motion='on'] [data-reveal] > h2,
[data-motion='on'] [data-reveal] > h3,
[data-motion='on'] [data-reveal] > p,
[data-motion='on'] [data-reveal] > .lede,
[data-motion='on'] [data-reveal] > .button,
[data-motion='on'] [data-reveal] > .text-link,
[data-motion='on'] [data-reveal] > picture,
[data-motion='on'] [data-reveal] > .chip-list,
[data-motion='on'] [data-reveal] > ul,
[data-motion='on'] [data-reveal] > ol,
[data-motion='on'] [data-reveal] > .metric-row {
  transition: opacity 520ms var(--ease-out), transform 520ms var(--ease-out);
}

[data-motion='on'] [data-reveal='in'] > .eyebrow,
[data-motion='on'] [data-reveal='in'] > h1,
[data-motion='on'] [data-reveal='in'] > h2,
[data-motion='on'] [data-reveal='in'] > h3,
[data-motion='on'] [data-reveal='in'] > p,
[data-motion='on'] [data-reveal='in'] > .lede,
[data-motion='on'] [data-reveal='in'] > .button,
[data-motion='on'] [data-reveal='in'] > .text-link,
[data-motion='on'] [data-reveal='in'] > picture,
[data-motion='on'] [data-reveal='in'] > .chip-list,
[data-motion='on'] [data-reveal='in'] > ul,
[data-motion='on'] [data-reveal='in'] > ol,
[data-motion='on'] [data-reveal='in'] > .metric-row { opacity: 1; transform: none; }

/* The signature move: a photograph is uncovered rather than faded in. */
[data-motion='on'] [data-reveal='out'] .photo img,
[data-motion='on'] [data-reveal='out'] .route-preview { clip-path: inset(0 0 100% 0); transform: scale(1.04); }
[data-motion='on'] [data-reveal] .photo img,
[data-motion='on'] [data-reveal] .route-preview {
  transition: clip-path 760ms var(--ease-out), transform 900ms var(--ease-out);
}
[data-motion='on'] [data-reveal='in'] .photo img,
[data-motion='on'] [data-reveal='in'] .route-preview { clip-path: inset(0 0 0 0); transform: none; }

/* The one moving picture: the hero drifts while it is on screen. */
@keyframes hero-drift { from { transform: scale(1.015) translate3d(0, 0, 0); } to { transform: scale(1.075) translate3d(0, -1.1%, 0); } }
[data-motion='on'] .home-hero-photo img,
[data-motion='on'] .story-hero-photo img { animation: hero-drift 28s var(--ease-out) alternate infinite; }

/* Feedback on the things you press. */
.button, .icon-button, .chip, .map-control, .stop-item, .route-card, .journey-card,
.story-card, .collection-card, .magazine-page, .language-list li, .filter-chips button, .quick-links a {
  transition: transform .18s var(--ease-out), background-color .18s, border-color .18s, color .18s, box-shadow .18s;
}
.button:active, .icon-button:active, .map-control:active, .filter-chips button:active { transform: translateY(1px) scale(.985); }
.stop-item:active, .route-card:active, .journey-card:active, .story-card:active, .collection-card:active { transform: scale(.994); }
@media (hover: hover) { .language-list li:hover { background: var(--paper-deep); border-color: var(--line-strong); } }
@media (hover: hover) { .quick-links a:hover .ico { transform: translateY(-2px); } }
.quick-links .ico { transition: transform .2s var(--ease-out); }
.text-link .ico { transition: transform .2s var(--ease-out); }
@media (hover: hover) { .text-link:hover .ico, .button:hover .ico { transform: translateX(3px); } }

@media (prefers-reduced-motion: reduce) {
  [data-motion='on'] .home-hero-photo img,
  [data-motion='on'] .story-hero-photo img { animation: none; }
  .button, .icon-button, .chip, .map-control, .stop-item, .route-card, .journey-card,
  .story-card, .collection-card, .magazine-page, .language-list li, .filter-chips button, .quick-links a { transition: none; }
}

/* Offline bar and unsaved-route marks (behind the offline-bundles flag; see app/offline-ui.js). */
.offline-bar { padding: 10px 16px; text-align: center; font-weight: 600; background: var(--ink); color: var(--white); }
a[data-unsaved-offline] { opacity: .6; cursor: not-allowed; }
.unsaved-note { display: block; margin-top: 4px; font-size: .8125rem; font-weight: 600; }

/* Phone in landscape: the header scrolls away rather than sitting over a sixth of a 390px-tall screen. */
@media (orientation: landscape) and (max-height: 500px) {
  .site-header { position: static; }
}
