/* Transfer: a magazine drawn as a transit line.
   Shape rule: panels, inputs and buttons are square; only line bullets and station nodes are circles.
   Colour rule: chrome is ink and paper, the five line colours are data, amber is only the departure sign. */

@font-face { font-family: "Oswald"; src: url("assets/oswald.ttf") format("truetype"); font-weight: 200 700; font-display: swap; }
@font-face { font-family: "Work Sans"; src: url("assets/work-sans.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Literata"; src: url("assets/literata.ttf") format("truetype"); font-weight: 200 900; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("assets/ibm-plex-mono.ttf") format("truetype"); font-weight: 400; font-display: swap; }

:root {
  color-scheme: light dark;
  --paper: #e6eaee;
  --panel: #f6f8fa;
  --ink: #10151b;
  --ink-2: #394551;
  --tile: rgb(16 21 27 / 0.06);
  --hover: rgb(16 21 27 / 0.05);
  --sign-bg: #0b0d10;
  --sign-fg: #ffc233;
  --c1: #b02a7e;
  --c2: #b8480a;
  --c3: #1f5fd0;
  --c4: #c2282d;
  --c5: #167a45;
  --on-line: #ffffff;

  --display: "Oswald", "Arial Narrow", sans-serif;
  --ui: "Work Sans", system-ui, sans-serif;
  --read: "Literata", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --z-sign: 10;
  --z-detail: 50;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1318;
    --panel: #171c23;
    --ink: #eef1f4;
    --ink-2: #b5c0cb;
    --tile: rgb(238 241 244 / 0.05);
    --hover: rgb(238 241 244 / 0.06);
    --c1: #ee6fbc;
    --c2: #ff9a4d;
    --c3: #7aa9ff;
    --c4: #ff7373;
    --c5: #4cd08a;
    --on-line: #0b0e12;
  }
}

[data-cat="Culture"] { --lc: var(--c1); }
[data-cat="Food"] { --lc: var(--c2); }
[data-cat="Movement"] { --lc: var(--c3); }
[data-cat="People"] { --lc: var(--c4); }
[data-cat="Places"] { --lc: var(--c5); }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--tile) 1px, transparent 1px),
    linear-gradient(90deg, var(--tile) 1px, transparent 1px);
  background-size: 48px 24px;
  color: var(--ink);
  font: 400 1rem/1.5 var(--ui);
}
body.locked { overflow: hidden; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.skip {
  position: absolute; left: 12px; top: -80px; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 10px 14px; font-weight: 600;
}
.skip:focus { top: 12px; }

/* ---------- shell ---------- */
#app { display: grid; grid-template-columns: 400px minmax(0, 1fr); min-height: 100dvh; }

.panel {
  position: sticky; top: 0; align-self: start;
  height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 24px;
  padding: 32px 28px 28px;
  background: var(--panel);
  border-right: 3px solid var(--ink);
}

.wordmark {
  font: 700 clamp(3.4rem, 5.4vw, 5rem)/0.95 var(--display);
  text-transform: uppercase; letter-spacing: 0.01em;
}
.stripes { display: flex; height: 12px; margin: 14px 0 16px; }
.stripes i { flex: 1; }
.stripes i:nth-child(1) { background: var(--c1); }
.stripes i:nth-child(2) { background: var(--c2); }
.stripes i:nth-child(3) { background: var(--c3); }
.stripes i:nth-child(4) { background: var(--c4); }
.stripes i:nth-child(5) { background: var(--c5); }
.tagline { color: var(--ink-2); max-width: 32ch; }

/* departure sign: the only amber on the page */
.sign {
  display: grid; gap: 4px;
  background: var(--sign-bg); color: var(--sign-fg);
  font-family: var(--mono); text-transform: uppercase;
  padding: 12px 14px; border: 2px solid var(--ink);
  min-height: 78px;
}
.sign-label { font-size: 0.75rem; letter-spacing: 0.12em; opacity: 0.8; }
.sign-text {
  font-size: 0.95rem; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* controls */
.controls { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 0.9rem; }
input[type="search"], select {
  width: 100%; height: 48px; padding: 0 12px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 0;
  appearance: none; -webkit-appearance: none;
}
select {
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px;
  background-size: 6px 6px; background-repeat: no-repeat;
}
input::placeholder { color: var(--ink-2); opacity: 1; }

.saved-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 14px;
  background: transparent; border: 2px solid var(--ink); border-radius: 0; font-weight: 600; text-align: left;
  transition: transform 0.12s ease, background-color 0.15s ease;
}
.saved-toggle:active, .btn:active, .chip:active { transform: translateY(1px) scale(0.99); }
.saved-toggle[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.saved-label { flex: 1; }
.saved-count {
  font: 400 0.85rem/1 var(--mono); min-width: 28px; text-align: center; padding: 6px 6px;
  border: 2px solid currentColor;
}

/* bookmark glyph built from CSS, not an icon font */
.ticket-icon {
  width: 14px; height: 18px; flex: none; border: 2px solid currentColor; border-bottom: 0;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
  background: transparent; position: relative;
}
[aria-pressed="true"] > .ticket-icon { background: currentColor; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px 0 6px;
  background: transparent; border: 2px solid var(--ink); border-radius: 0; font-weight: 500; font-size: 0.92rem;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chip .bullet { width: 24px; height: 24px; font-size: 0.85rem; }

.bullet {
  display: inline-grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--lc); color: var(--on-line);
  font: 700 0.95rem/1 var(--display);
}
.bullet-lg { width: 44px; height: 44px; font-size: 1.5rem; border: 2px solid var(--paper); }

/* ---------- route ---------- */
.route-wrap { padding: 44px clamp(24px, 4vw, 64px) 40px; max-width: 1080px; outline: none; }
.route-head { margin-bottom: 36px; display: grid; gap: 8px; }
.route-head h2 { font: 600 clamp(1.6rem, 2.4vw, 2.1rem)/1.1 var(--display); text-transform: uppercase; letter-spacing: 0.02em; }
.route-key { color: var(--ink-2); max-width: 56ch; }
.count { font: 400 0.85rem/1.4 var(--mono); color: var(--ink-2); }

.route { list-style: none; margin: 0; padding: 0; }

.stop {
  --m: 5;
  --gap: calc(var(--m) * 11px + 28px);
  position: relative;
  display: grid; grid-template-columns: 100px minmax(0, 1fr) 220px; column-gap: 0;
}
.stop:last-child { --gap: 44px; }
.stop:hover { background: linear-gradient(90deg, transparent 100px, var(--hover) 100px); }

.rail { position: relative; grid-row: 1 / span 2; }
.rail::before {
  content: ""; position: absolute; left: 28px; top: 25px; bottom: -25px; width: 12px; margin-left: -6px;
  background: var(--lc);
}
.stop:last-child .rail::before { bottom: 0; }
.stop:last-child .rail::after {
  content: ""; position: absolute; left: 28px; bottom: -4px; width: 40px; height: 8px; margin-left: -20px; background: var(--ink);
}
.node {
  position: absolute; left: 28px; top: 12px; width: 26px; height: 26px; margin-left: -13px;
  border-radius: 50%; background: var(--paper); border: 6px solid var(--lc); z-index: 1;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.stop.interchange .node { box-shadow: 0 0 0 4px var(--paper), 0 0 0 7px var(--ink); }
.stop:hover .node, .stop:focus-within .node { transform: scale(1.25); }
.ride {
  position: absolute; left: 48px; top: calc(50% + 6px); transform: translateY(-50%);
  font: 400 0.78rem/1 var(--mono); color: var(--ink-2); background: var(--paper); padding: 4px 6px; white-space: nowrap;
  border: 1px solid var(--ink-2);
}
.stop:last-child .ride { top: 70px; transform: none; }

.stop-body { padding: 2px 0 var(--gap); display: grid; gap: 10px; align-content: start; grid-row: 1; }
.line-tag { display: flex; align-items: center; gap: 10px; font: 600 0.82rem/1 var(--ui); letter-spacing: 0.08em; text-transform: uppercase; }
.stop-title { font: 600 clamp(1.75rem, 2.7vw, 2.5rem)/1.06 var(--display); text-transform: uppercase; letter-spacing: 0.01em; }
.open {
  all: unset; box-sizing: border-box; cursor: pointer; display: block;
}
.open::after { content: ""; position: absolute; inset: 0; }
.open:focus-visible { outline: none; }
.open:focus-visible::after { outline: 3px solid var(--ink); outline-offset: -3px; }
.stop:hover .open { text-decoration: underline; text-decoration-thickness: 4px; text-underline-offset: 6px; text-decoration-color: var(--lc); }
.sum { color: var(--ink-2); max-width: 52ch; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font: 400 0.82rem/1.4 var(--mono); color: var(--ink-2); }
.saved-tag { color: var(--ink); border: 2px dashed var(--ink); padding: 1px 8px; font-weight: 400; }

.thumb {
  grid-column: 3; grid-row: 1; align-self: start; margin: 4px 0 0 28px;
  width: 192px; max-width: none; aspect-ratio: 3 / 2; object-fit: cover; display: block;
  border: 2px solid var(--ink); filter: grayscale(1) contrast(1.05);
  transition: filter 0.3s ease;
}
.stop:hover .thumb, .stop:focus-within .thumb { filter: none; }

.empty {
  border: 3px solid var(--ink); background: var(--panel); padding: 28px; max-width: 560px; display: grid; gap: 12px; justify-items: start;
}
.empty h3 { font: 600 2rem/1.1 var(--display); text-transform: uppercase; }
.empty p { color: var(--ink-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 0 18px;
  background: var(--ink); color: var(--paper); border: 2px solid var(--ink); border-radius: 0; font-weight: 600; white-space: nowrap;
  transition: transform 0.12s ease;
}

.end-of-line { margin-top: 12px; padding-left: 100px; font: 600 1.3rem/1.2 var(--display); text-transform: uppercase; }
.colophon { margin-top: 56px; padding-top: 18px; border-top: 2px solid var(--ink); color: var(--ink-2); font-size: 0.88rem; max-width: 60ch; }

/* ---------- detail ---------- */
.detail {
  position: fixed; inset: 0; z-index: var(--z-detail);
  background: var(--paper); overflow-y: auto; overscroll-behavior: contain;
  border-left: 16px solid var(--lc); outline: none;
}
.detail-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px clamp(14px, 3vw, 40px);
  background: var(--ink); color: var(--paper);
}
.detail-line { display: flex; align-items: center; gap: 12px; min-width: 0; }
.detail-cat { font: 600 1.2rem/1 var(--display); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-actions { display: flex; gap: 10px; }
.detail-bar .btn { background: transparent; color: var(--paper); border-color: var(--paper); }
.detail-bar .btn-save[aria-pressed="true"] { background: var(--paper); color: var(--ink); }
.detail-bar :focus-visible { outline-color: var(--paper); }

.detail-grid {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(28px, 5vw, 88px);
  max-width: 1360px; margin: 0 auto; padding: clamp(24px, 4vw, 64px) clamp(18px, 4vw, 64px) 72px;
}
.detail-lead { display: grid; gap: 18px; align-content: start; }
.detail-title { font: 700 clamp(2.4rem, 5vw, 4.6rem)/1.02 var(--display); text-transform: uppercase; letter-spacing: 0.005em; text-wrap: balance; }
.detail-summary { font-size: 1.2rem; line-height: 1.45; max-width: 40ch; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font: 400 0.88rem/1.4 var(--mono); color: var(--ink-2); }
.detail-photo { margin: 12px 0 0; display: grid; gap: 8px; }
.detail-photo img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border: 3px solid var(--ink); display: block; }
.detail-photo figcaption { font-size: 0.82rem; color: var(--ink-2); }

.detail-body { font: 400 1.2rem/1.75 var(--read); max-width: 62ch; }
.detail-body p { margin: 0 0 1.25em; }
.detail-body p:first-child { font-size: 1.36rem; line-height: 1.55; }
.detail-body p:first-child::first-letter {
  float: left; font: 700 4.6em/0.82 var(--display); padding: 0.06em 0.1em 0 0; color: var(--lc);
}

.stops-nav { margin-top: 48px; display: grid; gap: 14px; max-width: 62ch; }
.next, .prev {
  display: grid; gap: 6px; text-align: left; width: 100%; padding: 16px 18px; border-radius: 0;
  border: 2px solid var(--ink); background: transparent; transition: transform 0.15s ease;
}
.next { background: var(--ink); color: var(--paper); border-left: 14px solid var(--lc); }
.next:hover, .prev:hover { transform: translateX(4px); }
.next:focus-visible { outline-color: var(--ink); }
.next-label { font: 400 0.78rem/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
.next-title { font: 600 1.7rem/1.1 var(--display); text-transform: uppercase; }
.prev-title { font: 600 1.1rem/1.2 var(--display); text-transform: uppercase; }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .list-enter .stop { animation: board 0.55s cubic-bezier(0.16, 1, 0.3, 1) both; animation-delay: calc(var(--i) * 70ms); }
  .detail.arriving { animation: arrive 0.32s cubic-bezier(0.16, 1, 0.3, 1) both; }
  .sign-text.tick { animation: tick 0.25s steps(4) both; }
}
@keyframes board { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes arrive { from { opacity: 0; transform: translateX(6%); } to { opacity: 1; transform: none; } }
@keyframes tick { from { opacity: 0.2; } to { opacity: 1; } }

/* ---------- tablet and mobile ---------- */
@media (max-width: 1100px) {
  #app { grid-template-columns: 340px minmax(0, 1fr); }
  .stop { grid-template-columns: 100px minmax(0, 1fr); }
  .stop-body { padding-bottom: 0; }
  .thumb { grid-column: 2; grid-row: 2; margin: 14px 0 var(--gap); width: min(100%, 320px); }
  .stop:hover { background: linear-gradient(90deg, transparent 100px, var(--hover) 100px); }
}

@media (max-width: 860px) {
  #app { display: block; padding-bottom: 76px; }
  .panel { position: static; height: auto; overflow: visible; border-right: 0; border-bottom: 3px solid var(--ink); padding: 22px 16px 20px; gap: 18px; }
  .wordmark { font-size: 3.6rem; }
  .legend { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; scroll-snap-type: x proximity; }
  .chip { flex: none; scroll-snap-align: start; }

  /* sign becomes a bottom departure board on small screens */
  .sign {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sign);
    min-height: 0; padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); border-width: 3px 0 0; gap: 2px;
  }
  .sign-text { -webkit-line-clamp: 1; font-size: 0.85rem; }

  .route-wrap { padding: 28px 16px 32px; }
  .route-head { margin-bottom: 24px; }
  .stop { grid-template-columns: 72px minmax(0, 1fr); --gap: calc(var(--m) * 8px + 24px); }
  .stop:last-child { --gap: 36px; }
  .stop:hover { background: none; }
  .rail::before, .stop:last-child .rail::after { left: 22px; }
  .node { left: 22px; }
  .ride { left: 36px; }
  .stop-title { font-size: 1.75rem; }
  .thumb { width: 100%; }
  .end-of-line { padding-left: 72px; }

  .detail { border-left-width: 8px; }
  .detail-bar { padding: 8px 12px; }
  .detail-cat { display: none; }
  .detail-actions { width: 100%; justify-content: space-between; }
  .detail-actions .btn { flex: 1; padding: 0 10px; }
  .detail-line { display: none; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 22px; }
  .detail-body { font-size: 1.1rem; }
  .detail-body p:first-child { font-size: 1.2rem; }
  .next-title { font-size: 1.4rem; }
}

@media (forced-colors: active) {
  .node, .bullet { border: 2px solid CanvasText; }
}
