/* Lines: a strip-map homepage preview. Tokens first, then layout, rail,
   strip, all-stops list, preview bar. Line colors are tuned per theme so the
   track and dots keep >= 3:1 against the page. */

:root {
  --paper: #f6f3ea;
  --paper-2: #ece7da;
  --ink: #1c1c1a;
  --ink-2: #4e4b44;
  --ink-3: #625d53;
  --rule: #d8d1c0;
  --dot-fill: #ffffff;
  --focus: #1f63c6;
  --badge-ink: #ffffff;

  --line-red: #c8312a;
  --line-orange: #c35a0c;
  --line-ochre: #a87a00;
  --line-green: #2a8540;
  --line-teal: #0a7f74;
  --line-blue: #1f63c6;
  --line-indigo: #4a4fc0;
  --line-purple: #7f42b0;
  --line-magenta: #bb2b80;
  --line-brown: #82522f;
  --line-slate: #5b6675;

  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --rail-w: 15.5rem;
  --track: 10px;
  --gutter: clamp(16px, 4vw, 48px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141619;
    --paper-2: #1d2024;
    --ink: #ece8de;
    --ink-2: #c3beb2;
    --ink-3: #9a958a;
    --rule: #33373d;
    --dot-fill: #141619;
    --focus: #7fb0ff;
    --badge-ink: #141619;
    --line-red: #ff6a5c;
    --line-orange: #ff9746;
    --line-ochre: #e5b72f;
    --line-green: #4cc76a;
    --line-teal: #2fc3b1;
    --line-blue: #62a0ff;
    --line-indigo: #9095ff;
    --line-purple: #bd88f0;
    --line-magenta: #f06ab4;
    --line-brown: #c99264;
    --line-slate: #a0abba;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141619; --paper-2: #1d2024; --ink: #ece8de; --ink-2: #c3beb2;
  --ink-3: #9a958a; --rule: #33373d; --dot-fill: #141619; --focus: #7fb0ff; --badge-ink: #141619;
  --line-red: #ff6a5c; --line-orange: #ff9746; --line-ochre: #e5b72f;
  --line-green: #4cc76a; --line-teal: #2fc3b1; --line-blue: #62a0ff;
  --line-indigo: #9095ff; --line-purple: #bd88f0; --line-magenta: #f06ab4;
  --line-brown: #c99264; --line-slate: #a0abba;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 10;
  background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 6px;
}
.skip:focus { top: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- masthead */
.masthead {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  padding: 28px var(--gutter) 22px;
  border-bottom: 2px solid var(--ink);
}
.wordmark {
  font-weight: 700; font-size: clamp(1.6rem, 3.2vw, 2.25rem); letter-spacing: -0.01em;
  text-decoration: none; line-height: 1.1;
}
.bio { margin: 6px 0 0; color: var(--ink-2); max-width: 46rem; }
.top-links { display: flex; gap: 6px 18px; flex-wrap: wrap; justify-content: flex-end; }
.top-links a {
  font-weight: 700; font-size: 0.95rem; text-decoration: none;
  border-bottom: 2px solid transparent; padding: 2px 0;
}
.top-links a:hover { border-bottom-color: currentColor; }

/* ------------------------------------------------------------------ layout */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  gap: 0 clamp(20px, 4vw, 56px);
  padding: 0 var(--gutter);
  max-width: 1180px; width: 100%; margin: 0 auto;
}

/* -------------------------------------------------------------------- rail */
.rail {
  position: sticky; top: 0; align-self: start;
  padding: 26px 0 32px;
  max-height: 100vh; overflow-y: auto;
}
.rail-title {
  margin: 0 0 10px 4px; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3);
}
#stations { display: flex; flex-direction: column; gap: 2px; }
.station, .all-btn {
  --c: var(--ink-3);
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px 9px 8px; margin: 0;
  background: none; border: 0; border-radius: 8px;
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  position: relative;
}
.station:hover, .all-btn:hover { background: var(--paper-2); }
.station .roundel {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 5px var(--c), inset 0 0 0 9px var(--dot-fill);
  transition: box-shadow 160ms ease;
}
.station .name, .all-btn .name { font-weight: 700; font-size: 1.04rem; line-height: 1.2; }
.station .count, .all-btn .count { font-size: 0.85rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.station[aria-selected="true"], .all-btn[aria-selected="true"] { background: var(--paper-2); }
.station[aria-selected="true"]::before, .all-btn[aria-selected="true"]::before {
  content: ""; position: absolute; left: -6px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 2px; background: var(--c);
}
.station[aria-selected="true"] .roundel { box-shadow: inset 0 0 0 13px var(--c); }
.all-btn { margin-top: 14px; border-top: 1px solid var(--rule); border-radius: 0 0 8px 8px; padding-top: 14px; }
.all-btn .all-glyph {
  width: 26px; height: 26px; border-radius: 6px;
  background:
    linear-gradient(var(--ink) 0 0) 6px 7px / 14px 2px no-repeat,
    linear-gradient(var(--ink) 0 0) 6px 12px / 14px 2px no-repeat,
    linear-gradient(var(--ink) 0 0) 6px 17px / 10px 2px no-repeat;
  border: 2px solid var(--ink);
}
.all-btn[aria-selected="true"] { --c: var(--ink); }

/* ------------------------------------------------------------------- panel */
.panel-wrap { min-width: 0; }
.panel { padding: 26px 0 64px; min-width: 0; }
.panel:focus { outline: none; }
.line-head { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: center; margin-bottom: 18px; }
.line-head .badge {
  grid-row: span 2;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--c); color: var(--badge-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 1.35rem; letter-spacing: -0.02em;
}
.line-head h1 { margin: 0; font-size: clamp(1.7rem, 3.4vw, 2.3rem); line-height: 1.1; letter-spacing: -0.01em; }
.line-head .blurb { margin: 0; color: var(--ink-2); max-width: 40rem; }
.line-meta { margin: 0 0 18px; color: var(--ink-3); font-size: 0.9rem; }

/* ------------------------------------------------------------------- strip */
.strip { list-style: none; margin: 0; padding: 6px 0 0; --x: 26px; }
.stop {
  --d: 16px; --ring: 4px; --row: 30px;
  position: relative;
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 0 14px;
  padding: 10px 0 12px;
}
/* track segment behind every stop; first/last are trimmed to the dot centre */
.stop::before {
  content: ""; position: absolute; left: calc(var(--x) - var(--track) / 2);
  top: 0; bottom: 0; width: var(--track); background: var(--c);
}
.stop:first-child::before { top: calc(10px + var(--row) / 2); border-radius: 0; }
.stop:last-child::before { bottom: calc(100% - 10px - var(--row) / 2); }
.strip-cap {
  position: absolute; left: calc(var(--x) - 15px); width: 30px; height: var(--track);
  background: var(--c); border-radius: 2px;
}
.stop:first-child > .strip-cap { top: calc(10px + var(--row) / 2 - var(--track) / 2); }
.stop:last-child > .strip-cap.end { top: calc(10px + var(--row) / 2 - var(--track) / 2); }

.dot {
  grid-column: 1; grid-row: 1;
  position: relative; z-index: 1;
  width: var(--d); height: var(--d);
  margin: calc((var(--row) - var(--d)) / 2) 0 0 calc(var(--x) - var(--d) / 2);
  border-radius: 50%;
  background: var(--dot-fill);
  box-shadow: 0 0 0 var(--ring) var(--c) inset;
}
.stop.s2 { --d: 22px; --ring: 5px; --row: 32px; }
.stop.s3 { --d: 32px; --ring: 6px; --row: 38px; }
.stop.xchange .dot { box-shadow: 0 0 0 var(--ring) var(--ink) inset; }
.stop.s3 .dot::after {
  content: ""; position: absolute; inset: calc(var(--ring) + 4px); border-radius: 50%; background: var(--c);
}
.stop.xchange.s3 .dot::after { background: var(--ink); }

.stop-body { grid-column: 2; min-width: 0; }
.stop-title {
  display: inline-flex; align-items: center; min-height: var(--row);
  font-weight: 700; font-size: 1.08rem; line-height: 1.2;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.stop.s2 .stop-title { font-size: 1.25rem; }
.stop.s3 .stop-title { font-size: 1.55rem; letter-spacing: -0.01em; }
.stop-title:hover { border-bottom-color: var(--c); }
.stop-title .ext { font-size: 0.8em; margin-left: 6px; color: var(--ink-3); font-weight: 400; }
.note { margin: 2px 0 0; color: var(--ink-2); max-width: 38rem; }
.stop.s1 .note { font-size: 0.95rem; }
.where { margin: 3px 0 0; font-size: 0.82rem; color: var(--ink-3); }
.xfer { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 0; font-size: 0.85rem; color: var(--ink-3); }
.xchip {
  --x: var(--ink-3);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 4px; border-radius: 999px;
  border: 1.5px solid var(--rule); background: var(--paper);
  font: 700 0.85rem/1.2 var(--font); color: var(--ink); cursor: pointer;
}
.xchip::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--x); }
.xchip:hover { border-color: var(--x); }
.thumb {
  grid-column: 3; grid-row: 1 / span 2;
  width: 148px; aspect-ratio: 16 / 10; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--rule); background: var(--paper-2);
  align-self: start; margin-top: 4px;
}
.stop.arrive .dot { animation: arrive 1.3s ease-out 2; }
@keyframes arrive {
  0% { box-shadow: 0 0 0 var(--ring) var(--ink) inset, 0 0 0 0 var(--c); }
  100% { box-shadow: 0 0 0 var(--ring) var(--ink) inset, 0 0 0 16px transparent; }
}
.terminus { margin: 22px 0 0 56px; padding-left: 14px; color: var(--ink-3); font-size: 0.9rem; }
.terminus button { font: inherit; color: var(--ink); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

.panel.enter { animation: enter 220ms ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* -------------------------------------------------------------- all stops */
.all-controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin: 0 0 14px; }
.all-controls input[type="search"] {
  flex: 1 1 16rem; min-width: 0;
  font: inherit; color: var(--ink); background: var(--paper);
  border: 2px solid var(--rule); border-radius: 8px; padding: 9px 12px;
}
.all-controls input[type="search"]:focus { border-color: var(--ink); outline: none; }
.sorts { display: flex; gap: 4px; flex-wrap: wrap; }
.sorts button {
  font: 700 0.88rem/1 var(--font); color: var(--ink-2);
  background: none; border: 1.5px solid var(--rule); border-radius: 999px; padding: 8px 12px; cursor: pointer;
}
.sorts button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.all-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.all-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px;
  padding: 10px 2px; border-bottom: 1px solid var(--rule);
}
.all-row a { font-weight: 700; text-decoration: none; }
.all-row a:hover { text-decoration: underline; }
.all-row .note { grid-column: 1; font-size: 0.92rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.all-row .row-meta { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.all-row .host { font-size: 0.8rem; color: var(--ink-3); }
.dots { display: flex; gap: 4px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); display: block; }
.all-empty { color: var(--ink-3); padding: 20px 0; }

/* ------------------------------------------------------------- preview bar */
.preview-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  padding: 12px var(--gutter);
  border-top: 2px solid var(--ink);
  background: var(--paper-2);
  font-size: 0.9rem;
}
.preview-tag {
  margin: 0; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.72rem;
  background: var(--ink); color: var(--paper); padding: 4px 8px; border-radius: 4px;
}
.concept-pick { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.concept-pick select {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--ink-3); border-radius: 6px; padding: 6px 8px;
}
.tagline { margin: 0; color: var(--ink-2); flex: 1 1 18rem; }
.candidate-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 18px; margin-left: auto; }
.candidate-links a { font-weight: 700; }
.why summary { cursor: pointer; font-weight: 700; }
.why p { margin: 6px 0 0; max-width: 46rem; color: var(--ink-2); }
.noscript { padding: 24px var(--gutter); }

/* ------------------------------------------------------------------ phone */
@media (max-width: 820px) {
  .masthead { flex-direction: column; align-items: flex-start; gap: 10px; padding-top: 20px; padding-bottom: 14px; }
  .top-links { justify-content: flex-start; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0; }
  .rail {
    position: sticky; top: 0; z-index: 5;
    max-height: none; background: var(--paper);
    border-bottom: 1px solid var(--rule);
  }
  .rail-title { display: none; }
  #stations { flex-direction: row; gap: 6px; }
  .rail {
    display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
    padding: 10px var(--gutter);
    scroll-padding-inline: var(--gutter);
  }
  .rail::-webkit-scrollbar { display: none; }
  .station, .all-btn {
    width: auto; flex: none; grid-template-columns: 20px auto; gap: 8px;
    padding: 7px 12px 7px 8px; border: 1.5px solid var(--rule); border-radius: 999px;
    margin: 0;
  }
  .station .count, .all-btn .count { display: none; }
  .station .roundel, .all-btn .all-glyph { width: 20px; height: 20px; }
  .station .roundel { box-shadow: inset 0 0 0 4px var(--c), inset 0 0 0 7px var(--dot-fill); }
  .station[aria-selected="true"] .roundel { box-shadow: inset 0 0 0 10px var(--c); }
  .all-btn .all-glyph { background-size: 10px 2px; background-position: 3px 4px, 3px 8px, 3px 12px; border-width: 1.5px; }
  .station[aria-selected="true"], .all-btn[aria-selected="true"] { border-color: var(--c); }
  .station[aria-selected="true"]::before, .all-btn[aria-selected="true"]::before { display: none; }
  .all-btn { border-top: 1.5px solid var(--rule); }
  .panel { padding: 20px var(--gutter) 48px; }
  .stop { grid-template-columns: 44px minmax(0, 1fr); }
  .strip { --x: 20px; }
  .terminus { margin-left: 44px; }
  .thumb { grid-column: 2; grid-row: auto; width: 100%; max-width: 320px; margin-top: 10px; }
  .line-head .badge { width: 42px; height: 42px; font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
