/* ============================================================
   BETWEEN STOPS — night-service transit network
   Ground: tunnel navy · Line colors: five districts
   Voices: Oswald (signage) · Work Sans (UI) · Literata (reading)
           IBM Plex Mono (timetable data)
   ============================================================ */

@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 {
  --ground: #0d1322;
  --ground-2: #141b33;
  --ground-3: #1c2540;
  --line-edge: #2a3554;
  --ink: #e9edf5;
  --ink-2: #a8b3cb;
  --amber: #ffc233;
  --amber-deep: #b88000;
  --amber-ink: #1d1502;

  --line-culture: #f0539e;
  --line-food: #ff6247;
  --line-movement: #3fc5ff;
  --line-people: #a78bfa;
  --line-places: #46d17e;

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

  --radius: 10px;
}

* { box-sizing: border-box; }

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(120% 90% at 50% -20%, #131c36 0%, var(--ground) 55%),
    var(--ground);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

::selection { background: var(--amber); color: var(--amber-ink); }
input, textarea { caret-color: var(--amber); }

* { scrollbar-width: thin; scrollbar-color: var(--line-edge) transparent; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-edge); border-radius: 6px; border: 3px solid var(--ground); }
::-webkit-scrollbar-thumb:hover { background: #3a4a75; }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 4px;
}

.hidden { display: none !important; }

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  background: var(--amber);
  color: var(--amber-ink);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 6px;
  text-decoration: none;
  transform: translateY(-64px);
}
.skip-link:focus { transform: none; }

/* ---------------- Split-flap board ---------------- */

.board {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3em;
  perspective: 600px;
}
.board-row { display: flex; gap: 0.16em; }

.cell {
  width: 1.12em;
  height: 1.58em;
  display: grid;
  place-items: center;
  font-family: var(--font-sign);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--amber);
  background: linear-gradient(180deg, var(--ground-3) 0%, var(--ground-2) 48%, #101728 52%, var(--ground-2) 100%);
  border: 1px solid #2c3a66;
  border-radius: 0.14em;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
}
.cell.blank { border-color: #223051; background: #111a30; }
.cell.blank::before { content: none; }
.cell::before {
  /* the flap split */
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 2px;
  background: rgba(0, 0, 0, 0.55);
  box-shadow: 0 1px 0 rgba(255, 210, 120, 0.08);
  pointer-events: none;
}
.cell::after {
  /* glass glare on the top half */
  content: "";
  position: absolute;
  inset: 0 0 52% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent);
  pointer-events: none;
}
.cell.tick { animation: flap-tick 70ms ease-out; }
@keyframes flap-tick {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(72deg); filter: brightness(0.62); }
  100% { transform: rotateX(0); }
}

/* ---------------- Masthead ---------------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px 36px;
  padding: clamp(28px, 5vh, 52px) clamp(18px, 4.5vw, 56px) 22px;
  max-width: 1440px;
  margin: 0 auto;
}

.masthead-board { font-size: clamp(17px, 4.6vw, 44px); }

.masthead-side { text-align: right; padding-bottom: 0.6em; }
.tagline {
  margin: 0 0 10px;
  font-family: var(--font-sign);
  font-weight: 500;
  font-size: clamp(15px, 1.4vw, 19px);
  letter-spacing: 0.045em;
  color: var(--ink);
  text-transform: uppercase;
}
.service-note {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 0 rgba(255, 194, 51, 0.5);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 194, 51, 0.45); }
  70% { box-shadow: 0 0 0 9px rgba(255, 194, 51, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 194, 51, 0); }
}

/* ---------------- Route planner ---------------- */

.planner {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(13, 19, 34, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line-edge);
  border-bottom: 1px solid var(--line-edge);
}
.planner-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px clamp(18px, 4.5vw, 56px) 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 22px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.input {
  font-family: var(--font-ui);
  font-size: 16px;
  color: var(--ink);
  background: #10182c;
  border: 1px solid var(--line-edge);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.input::placeholder { color: #76829f; }
.input:hover { border-color: #3a4a75; }
.input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(255, 194, 51, 0.16); outline: none; }
.input:focus-visible { outline: none; }
#stopSearch { width: clamp(220px, 26vw, 320px); }

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  cursor: pointer;
  width: 190px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23a8b3cb' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px;
}

.toggle, .strip-btn {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 14.5px;
  color: var(--ink);
  background: #10182c;
  border: 1px solid var(--line-edge);
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}
.toggle:hover, .strip-btn:hover { border-color: #4a5c8f; }
.toggle[aria-pressed="true"] {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--amber-ink);
}
.toggle[aria-pressed="true"] .pin-icon { color: var(--amber-ink); }
.pin-icon { color: var(--amber); flex: none; }
.toggle[aria-pressed="true"]:hover { background: #ffd269; }

.planner-status {
  margin: 0 0 0 auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-2);
  align-self: center;
  padding-bottom: 6px;
  white-space: nowrap;
}

/* ---------------- The route (line diagram) ---------------- */

.route-wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px clamp(18px, 4.5vw, 56px) 30px;
}
.route {
  list-style: none;
  margin: 0;
  padding: 0;
}

.terminus {
  display: flex;
  align-items: center;
  gap: 16px;
}
.terminus-bar {
  flex: none;
  width: 14px;
  height: 40px;
  border-radius: 5px;
  background: linear-gradient(180deg, #3a4a75, var(--line-edge));
  margin-left: calc(50% - 7px);
}
.terminus-text {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.terminus-origin { padding-bottom: 0; }
.terminus-origin .terminus-bar { border-radius: 5px 5px 2px 2px; }
.terminus-end { padding-top: 4px; }
.terminus-end .terminus-bar {
  margin-left: calc(50% - 7px);
  border-radius: 2px 2px 5px 5px;
  background: linear-gradient(180deg, var(--line-edge), #3a4a75);
}

.stop {
  display: grid;
  grid-template-columns: 1fr 96px 1fr;
  padding: 34px 0 0;
}
.stop.last-visible { padding-bottom: 34px; }
.stop.first-visible .segment { top: -34px; }

.spine { position: relative; grid-column: 2; }
.segment {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  bottom: -34px; /* bridge the row gap; the last row's bridge is covered below */
  width: 10px;
  border-radius: 5px;
  background: linear-gradient(180deg, var(--c), var(--cnext, var(--c)));
  opacity: 0.9;
}
.stop.last-visible .segment { bottom: 0; }

.node {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--c);
  border: 5px solid var(--ground);
  display: grid;
  place-items: center;
  z-index: 2;
}
.node::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
}
.stop.pinned .node {
  border: 5px solid var(--ground);
  box-shadow: 0 0 0 2px var(--amber), 0 0 14px rgba(255, 194, 51, 0.35);
}

/* Stop plates */
.plate { display: flex; min-width: 0; }
.stop:nth-child(odd) .plate { grid-column: 1; justify-content: flex-end; }
.stop:nth-child(even) .plate { grid-column: 3; justify-content: flex-start; }

.open-btn {
  font-family: var(--font-ui);
  text-align: start;
  max-width: 470px;
  width: 100%;
  background: linear-gradient(180deg, var(--ground-3), var(--ground-2));
  border: 1px solid #2c3a66;
  border-radius: var(--radius);
  padding: 18px 22px 16px;
  cursor: pointer;
  color: var(--ink);
  box-shadow: 0 16px 34px rgba(2, 5, 14, 0.42);
  transition: transform 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}
.open-btn:hover {
  transform: translateY(-3px);
  border-color: var(--c);
  box-shadow: 0 22px 40px rgba(2, 5, 14, 0.5), 0 0 0 1px var(--c);
}
.plate-top {
  display: flex;
  gap: 10px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c);
  margin-bottom: 9px;
}
.stop:nth-child(odd) .plate-top { justify-content: flex-end; }
.station {
  display: block;
  font-family: var(--font-sign);
  font-weight: 500;
  font-size: clamp(20px, 1.55vw, 25px);
  line-height: 1.16;
  letter-spacing: 0.012em;
  color: var(--ink);
}
.stop:nth-child(odd) .station { text-align: end; }
.summary {
  display: block;
  margin-top: 7px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.stop:nth-child(odd) .summary { text-align: end; }
.plate-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 13px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.stop:nth-child(odd) .plate-foot { justify-content: flex-end; }
.line-chip {
  border: 1px solid var(--c);
  color: var(--c);
  border-radius: 999px;
  padding: 3px 10px;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.pin-flag { color: var(--amber); border: 1px solid rgba(255, 194, 51, 0.45); border-radius: 999px; padding: 3px 10px; letter-spacing: 0.12em; }

/* ---------------- Advisory / empty state ---------------- */

.advisory {
  max-width: 580px;
  margin: 44px auto 20px;
  background: var(--ground-2);
  border: 1px solid #2c3a66;
  border-top: 3px solid var(--amber);
  border-radius: var(--radius);
  padding: 26px 30px 28px;
}
.advisory-kind {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--amber);
}
.advisory-title {
  margin: 0 0 10px;
  font-family: var(--font-sign);
  font-weight: 500;
  font-size: 26px;
  letter-spacing: 0.015em;
  color: var(--ink);
}
.advisory-body { margin: 0 0 20px; font-size: 15px; line-height: 1.55; color: var(--ink-2); }
.advisory-action {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--amber-ink);
  background: var(--amber);
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  cursor: pointer;
  transition: background-color 150ms ease;
}
.advisory-action:hover { background: #ffd269; }

/* ---------------- Colophon ---------------- */

.colophon {
  border-top: 1px solid var(--line-edge);
  margin-top: 40px;
  padding: 26px clamp(18px, 4.5vw, 56px) 34px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 30px;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.colophon p { margin: 0; }

/* ============================================================
   DETAIL VIEW — alighting
   ============================================================ */

.detail { min-height: 100vh; }

body.detail-open .masthead,
body.detail-open .planner,
body.detail-open .route-wrap,
body.detail-open .colophon { display: none; }

.detail-strip {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 36px);
  background: rgba(13, 19, 34, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-edge);
}
.strip-btn { flex: none; background: transparent; }
.back-btn .arrow { transition: transform 180ms ease; }
.back-btn:hover .arrow { transform: translateX(-3px); }

.pin-btn[aria-pressed="true"] {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--amber-ink);
}
.pin-btn[aria-pressed="true"] .pin-icon { color: var(--amber-ink); }
.pin-btn[aria-pressed="true"]:hover { background: #ffd269; }

.route-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 120px;
}
.progress-endpoint {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  flex: none;
}
.progress-track {
  flex: 1;
  position: relative;
  height: 3px;
  border-radius: 3px;
  background: var(--line-edge);
}
.progress-train {
  position: absolute;
  top: 50%;
  left: 0;
  width: 30px;
  height: 17px;
  transform: translate(0, -50%);
  background: var(--amber);
  border-radius: 5px 9px 9px 5px;
  box-shadow: 0 0 0 2px var(--ground), 0 3px 10px rgba(255, 194, 51, 0.28);
  transition: left 120ms linear;
}
.progress-train::before {
  content: "";
  position: absolute;
  top: 4px; left: 6px; right: 6px;
  height: 4px;
  border-radius: 2px;
  background: var(--ground);
  box-shadow: 0 5px 0 var(--ground);
}

/* Article */
.detail-article {
  max-width: 900px;
  margin: 0 auto;
  padding: 36px clamp(18px, 4vw, 40px) 90px;
}

.detail-head { text-align: center; margin-bottom: 8px; }
.board-caption {
  margin: 4px 0 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.detail-board {
  font-size: clamp(14px, 2.1vw, 22px);
  align-items: center;
  margin: 0 auto;
  width: fit-content;
  max-width: 100%;
}
.board-row { flex-wrap: wrap; justify-content: center; }

.detail-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 24px 0 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.detail-meta .line-chip { font-family: var(--font-mono); font-size: 10.5px; }

/* Duotone illustration */
.duo { margin: 36px 0 0; border-radius: 14px; overflow: hidden; border: 1px solid #2c3a66; background: var(--line-c); }
.duo img {
  display: block;
  width: 100%;
  filter: grayscale(1) contrast(1.1) brightness(1.05);
  mix-blend-mode: multiply;
}
.duo figcaption {
  padding: 11px 16px;
  background: var(--ground-2);
  border-top: 1px solid #2c3a66;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* Reading body */
.detail-body {
  max-width: 66ch;
  margin: 40px auto 0;
  font-family: var(--font-read);
  font-size: 1.14rem;
  line-height: 1.8;
  color: #dde3ef;
}
.detail-body p { margin: 0 0 1.4em; }
.detail-body p:first-child::first-letter {
  font-family: var(--font-sign);
  font-weight: 600;
  font-size: 3.1em;
  float: left;
  line-height: 0.78;
  padding: 0.08em 0.14em 0 0;
  color: var(--line-c);
}

/* End of the line */
.detail-end { margin-top: 30px; text-align: center; }
.endline .terminus-bar { margin: 0 auto; border-radius: 5px; background: linear-gradient(180deg, var(--line-c), #3a4a75); }
.end-note {
  margin: 14px 0 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.end-back { margin-top: 22px; }

.transfers { margin-top: 52px; text-align: left; }
.transfers h2 {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 14px;
  text-align: center;
}
.transfers-list { display: flex; flex-direction: column; gap: 10px; max-width: 520px; margin: 0 auto; }
.transfer-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--font-ui);
  text-align: start;
  background: var(--ground-2);
  border: 1px solid #2c3a66;
  border-radius: 8px;
  padding: 14px 18px;
  cursor: pointer;
  color: var(--ink);
  transition: border-color 160ms ease, background-color 160ms ease;
}
.transfer-btn:hover { border-color: var(--tc); background: var(--ground-3); }
.transfer-name { font-family: var(--font-sign); font-weight: 500; font-size: 17px; letter-spacing: 0.012em; }
.transfer-arrow { color: var(--tc); font-family: var(--font-mono); flex: none; }

/* ---------------- Responsive ---------------- */

@media (max-width: 719px) {
  .masthead { padding-top: 24px; justify-content: flex-start; }
  .masthead-side { text-align: left; padding-bottom: 0; order: 2; }
  .masthead-board { order: 1; }

  .planner-inner { padding: 12px 18px 14px; gap: 12px 16px; }
  #stopSearch { width: 100%; }
  .field { flex: 1 1 100%; }
  .field:nth-of-type(2) { flex: 1 1 auto; }
  .planner-status { flex-basis: 100%; margin-left: 0; padding-bottom: 0; }

  .stop { grid-template-columns: 56px 1fr; padding-top: 26px; }
  .stop.last-visible { padding-bottom: 26px; }
  .stop.first-visible .segment { top: -26px; }
  .stop .segment { bottom: -26px; }
  .spine { grid-column: 1; }
  .segment { left: 50%; width: 10px; }
  .stop:nth-child(odd) .plate,
  .stop:nth-child(even) .plate { grid-column: 2; justify-content: flex-start; }
  .open-btn { max-width: none; }
  .stop:nth-child(odd) .plate-top,
  .stop:nth-child(odd) .station,
  .stop:nth-child(odd) .summary,
  .stop:nth-child(odd) .plate-foot { text-align: start; justify-content: flex-start; }
  .terminus-bar { margin-left: 21px; }
  .terminus-origin { gap: 12px; }

  .detail-strip { flex-wrap: wrap; row-gap: 10px; }
  .route-progress { order: 3; flex-basis: 100%; }
  .detail-strip .pin-btn { margin-left: auto; }

  .detail-body { font-size: 1.08rem; }
}

/* ---------------- Reduced motion ---------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .pulse-dot { animation: none; }
}
