/* Layout idea: a fixed network map fills the screen. Four lines, one per topic, cross at
   junctions where the story changes trains. Station signs scroll past on the left while
   the camera follows the train. Light by default; dark follows the system setting or the
   toggle in the top bar (which sets data-theme on <html>). */
:root {
  color-scheme: light;
  --paper: #EDF0F2;
  --ink: #16213E;
  --ink-soft: #55607A;
  --sign: #FFFFFF;
  --p1: #2046E0;
  --g2: #12996B;
  --o3: #E67E00;
  --m4: #C4267A;
  --water: #CBDDEA;
  --park: #D6E6D2;
  --board: #0D1322;
  --amber: #FFC53D;
  --on-ink: #FFFFFF;     /* text on an --ink background */
  --on-line: #FFFFFF;    /* text on a line-colour background */
  --shadow: rgba(22, 33, 62, .14);
  --board-shadow: rgba(13, 19, 34, .32);
  --font: "Overpass", "Helvetica Neue", Arial, sans-serif;
  --bar: 56px;
}
/* Dark tokens, written twice: once for the system setting, once for the explicit toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0F1524;
    --ink: #E4E9F2;
    --ink-soft: #97A2BA;
    --sign: #182033;
    --p1: #6584FF;
    --g2: #2EC08B;
    --o3: #FF9D2E;
    --m4: #EC5CA3;
    --water: #16304A;
    --park: #15291F;
    --board: #070B15;
    --on-ink: #0F1524;
    --on-line: #0B1020;
    --shadow: rgba(0, 0, 0, .45);
    --board-shadow: rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0F1524;
  --ink: #E4E9F2;
  --ink-soft: #97A2BA;
  --sign: #182033;
  --p1: #6584FF;
  --g2: #2EC08B;
  --o3: #FF9D2E;
  --m4: #EC5CA3;
  --water: #16304A;
  --park: #15291F;
  --board: #070B15;
  --on-ink: #0F1524;
  --on-line: #0B1020;
  --shadow: rgba(0, 0, 0, .45);
  --board-shadow: rgba(0, 0, 0, .6);
}
* { box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
[data-l="p1"] { --lc: var(--p1); }
[data-l="g2"] { --lc: var(--g2); }
[data-l="o3"] { --lc: var(--o3); }
[data-l="m4"] { --lc: var(--m4); }

/* ---------- map stage ---------- */
#map {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  background: var(--paper);
  z-index: 0;
}
.line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.hit { fill: none; stroke: transparent; stroke-width: 46; pointer-events: stroke; cursor: pointer; }
.stn { cursor: pointer; }
.lbl {
  font-family: var(--font); font-size: 26px; font-weight: 600; fill: var(--ink-soft);
  paint-order: stroke; stroke: var(--paper); stroke-width: 7px; stroke-linejoin: round;
  pointer-events: none;
}
.lbl.jn { font-weight: 800; fill: var(--ink); }
.lbl.on { fill: var(--ink); font-weight: 800; }
.badge-t { font-family: var(--font); font-weight: 900; font-size: 22px; fill: var(--on-line); text-anchor: middle; pointer-events: none; }

/* ---------- top bar ---------- */
.bar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--bar);
  z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 clamp(12px, 4vw, 56px);
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
}
.mark { background: none; border: 0; padding: 6px 0; font-weight: 900; font-size: 19px; white-space: nowrap; }
.roundel {
  display: inline-grid; place-items: center;
  min-width: 34px; height: 24px; padding: 2px 7px 0;
  background: var(--lc, var(--ink)); color: var(--on-line); border-radius: 5px;
  font-weight: 900; font-size: 14px; line-height: 1; flex: none;
}
.right { display: flex; align-items: center; gap: 10px; }
.tabs { display: flex; gap: 4px; }
.auto {
  display: flex; align-items: center; gap: 8px;
  background: var(--sign); border: 2px solid var(--ink); border-radius: 99px;
  padding: 6px 12px 4px; font-weight: 800; font-size: 14px; white-space: nowrap;
}
.auto svg { flex: none; }
.theme {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; padding: 0;
  background: var(--sign); border: 2px solid var(--ink); border-radius: 50%;
}
.theme .i-sun { display: none; }
.theme[aria-pressed="true"] .i-sun { display: block; }
.theme[aria-pressed="true"] .i-moon { display: none; }
.auto .i-play, .auto[aria-pressed="false"] .i-pause { display: none; }
.auto[aria-pressed="false"] .i-play { display: block; }
.auto[aria-pressed="false"] { color: var(--ink-soft); border-color: var(--ink-soft); }

/* ---------- departure board ---------- */
.board {
  position: fixed; z-index: 4; top: calc(var(--bar) + 14px);
  left: calc(min(470px, 100% - 32px) + clamp(16px, 4vw, 56px) + 24px); right: clamp(16px, 4vw, 56px);
  display: flex; justify-content: center; pointer-events: none;
  visibility: hidden; opacity: 0; transform: translateY(-130%);
  transition: transform .5s cubic-bezier(.2, 1.3, .4, 1), opacity .3s, visibility 0s .5s;
}
.board.show { visibility: visible; opacity: 1; transform: none; transition: transform .5s cubic-bezier(.2, 1.3, .4, 1), opacity .3s; }
.board-in {
  pointer-events: auto;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px;
  background: var(--board); color: #fff; border-radius: 10px;
  padding: 10px 12px 10px 16px;
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 10px 26px var(--board-shadow);
  font-family: "Overpass Mono", ui-monospace, Menlo, monospace; font-size: 15px;
}
.b-dest { color: var(--amber); font-weight: 700; font-size: 18px; perspective: 300px; }
.b-dest span { display: inline-block; }
.b-status { display: flex; align-items: center; gap: 8px; color: #C9D1E3; }
.b-status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #58E08A; animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }
#b-go { font-family: var(--font); font-weight: 800; background: var(--amber); color: #0D1322; border: 0; border-radius: 6px; padding: 8px 14px 6px; }
#b-go:focus-visible { outline-color: #fff; }
@media (prefers-reduced-motion: reduce) { .board, .board.show { transition: none; } .b-status::before { animation: none; } }
.tab {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 0; border-bottom: 4px solid transparent;
  height: var(--bar); padding: 4px 10px 0;
  font-weight: 600; font-size: 15px; color: var(--ink-soft);
}
.tab[aria-pressed="true"] { color: var(--ink); font-weight: 800; border-bottom-color: var(--lc); }

/* ---------- station signs (content) ---------- */
main {
  position: relative; z-index: 2;
  width: min(470px, 100% - 32px);
  margin-left: clamp(16px, 4vw, 56px);
  pointer-events: none;
}
.stop {
  min-height: 100vh; min-height: 100svh;
  display: flex; align-items: center;
  padding: calc(var(--bar) + 24px) 0 24px;
}
.sign {
  width: 100%;
  pointer-events: auto;
  background: var(--sign);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: 6px 6px 0 var(--shadow);
  overflow: hidden;
}
.sign-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px 10px;
  background: var(--ink); color: var(--on-ink);
}
.sign-head h2 { margin: 0; font-size: 22px; font-weight: 800; line-height: 1.2; text-wrap: balance; }
.sign-body { padding: 20px 22px 24px; }
.sign-body > *:first-child { margin-top: 0; }
.sign-body > *:last-child { margin-bottom: 0; }
.sign-body p { margin: 0 0 14px; max-width: 60ch; }
.sign-body ul.plain { margin: 0 0 14px; padding-left: 20px; }
.sign-body ul.plain li { margin-bottom: 6px; }
.hero .sign-body { padding: 28px 24px 26px; }
h1 {
  margin: 0 0 10px; font-weight: 900; line-height: .9; letter-spacing: -.03em;
  font-size: clamp(64px, 11vw, 108px); color: var(--ink);
}
.lede { font-size: 21px; line-height: 1.35; font-weight: 600; text-wrap: balance; }
.when { color: var(--ink-soft); font-weight: 600; font-variant-numeric: tabular-nums; }
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0 0; }
.go {
  display: flex; align-items: center; gap: 10px;
  background: var(--sign); border: 2px solid var(--ink); border-radius: 8px;
  padding: 9px 12px 7px; font-weight: 800; text-align: left;
  transition: background .2s, color .2s;
}
.go:hover { background: var(--ink); color: var(--on-ink); }
.depart { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-weight: 600; margin-top: 16px; }
.status {
  display: inline-block; padding: 3px 10px 1px; border-radius: 99px;
  font-size: 13px; font-weight: 800; border: 2px solid var(--lc); color: var(--lc); margin-bottom: 12px;
}
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 14px 0 0; }
.tags li { background: var(--paper); border-radius: 5px; padding: 3px 9px 1px; font-size: 14px; font-weight: 600; }
.contact-list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; }
.contact-list li { display: flex; gap: 12px; }
.contact-list b { width: 78px; flex: none; font-weight: 800; }
.change { border-top: 2px solid var(--paper); margin-top: 20px; padding-top: 16px; }
.change p { font-weight: 800; margin-bottom: 0; }
.change .roundel { display: inline-grid; vertical-align: 2px; }
.change .pick { margin-top: 10px; }

@media (max-width: 820px) {
  body { font-size: 16px; }
  main { margin: 0 auto; }
  .stop { align-items: flex-start; padding-top: 50vh; padding-top: 50svh; }
  .tab { padding: 4px 6px 0; }
  .tab .name, .auto .name { display: none; }
  .auto { padding: 7px 9px; }
  .theme { width: 32px; height: 32px; }
  .right { gap: 4px; }
  .board { left: 12px; right: 12px; }
  .board-in { font-size: 13px; }
}
@media (max-width: 400px) { .pick { grid-template-columns: 1fr; } }
