/* ============================================================
   THE LOCAL STOP
   Night-transit identity for a city-life journal.

   Shape system: cards and panels 16px, form inputs 10px,
   buttons and chips are full pills. No mixing.
   Theme: locked dark (the board after dusk).
   Accent: one signal yellow. Category colors are line colors,
   used as data encoding only (metro-line legend).
   ============================================================ */

@font-face {
  font-family: 'Space Grotesk';
  src: url('assets/space-grotesk.ttf') format('truetype');
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: 'Literata';
  src: url('assets/literata.ttf') format('truetype');
  font-weight: 300 800;
  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 {
  --bg: #14161b;            /* asphalt */
  --bg-raised: #1b1e25;     /* platform */
  --bg-sink: #101217;       /* sign box */
  --ink: #eceee8;            /* off-white */
  --ink-dim: #a9b0ab;
  --ink-faint: #7d8480;
  --hair: #2b2f38;
  --accent: #ffc61a;         /* signal yellow */
  --accent-ink: #1d1702;    /* text on yellow */
  --line-places: #59b7d5;
  --line-movement: #7ed087;
  --line-food: #e8925a;
  --line-people: #e36588;
  --line-culture: #b9a0e8;
  --font-ui: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
  --font-read: 'Literata', Georgia, serif;
  --radius-card: 16px;
  --radius-input: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100dvh;
}

body.detail-open { overflow: hidden; }

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 32px;
}

img { display: block; max-width: 100%; }

button { font: inherit; color: inherit; cursor: pointer; }

::selection { background: var(--accent); color: var(--accent-ink); }

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

.skip {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  border-radius: 999px;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip:focus-visible { transform: none; }

/* ---------- masthead ---------- */

.masthead { padding: 44px 0 8px; }

.masthead-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: 48px;
  align-items: center;
}

.masthead-brand { display: flex; gap: 22px; align-items: flex-start; }

.roundel {
  flex: none;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 4px solid var(--accent);
  position: relative;
  margin-top: 14px;
}
.roundel-bar {
  position: absolute;
  left: 6px; right: 6px; top: 50%;
  transform: translateY(-50%);
  height: 10px;
  background: var(--accent);
  border-radius: 2px;
}
.roundel-small { width: 26px; height: 26px; border-width: 3px; margin: 0 0 18px; }
.roundel-small .roundel-bar { height: 5px; border-radius: 1px; left: 3px; right: 3px; }

.masthead-time {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 6px;
}
.masthead-time span { color: var(--ink); }

.wordmark {
  font-size: clamp(2.7rem, 6vw, 5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0 0 14px;
}
.wordmark em { font-style: italic; color: var(--accent); }

.tagline {
  font-size: 1.1rem;
  color: var(--ink-dim);
  max-width: 36ch;
}

.masthead-photo { margin: 0; }
.masthead-photo figcaption,
.detail-photo figcaption {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 8px;
  letter-spacing: 0.04em;
}

.duotone {
  display: block;
  position: relative;
  border-radius: var(--radius-card);
  overflow: hidden;
  border: 1px solid var(--hair);
}
.duotone img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.05) brightness(0.82);
}
.duotone::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  opacity: 0.16;
  mix-blend-mode: multiply;
  pointer-events: none;
}
.masthead-photo .duotone { aspect-ratio: 4 / 3; }
.detail-photo .duotone { aspect-ratio: 21 / 9; }

/* ---------- destination blind ---------- */

.blind {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  margin-top: 34px;
  padding: 15px 22px;
  background: var(--bg-sink);
  border: 1px solid var(--hair);
  border-radius: 12px;
  text-align: left;
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.blind:hover { border-color: var(--accent); transform: translateY(-1px); }
.blind:active { transform: translateY(0) scale(0.995); }

.blind-tag {
  flex: none;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 400;
}

.blind-title {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.blind-go { color: var(--accent); font-size: 18px; }

/* ---------- minimap ---------- */

.minimap { margin-top: 20px; }
.minimap-track {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
}
.minimap-track::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 2px;
  transform: translateY(-50%);
  background: var(--hair);
}
.minimap-dot {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid var(--dot, var(--ink-dim));
  background: var(--bg);
  padding: 0;
  transition: transform 0.25s var(--ease);
}
.minimap-dot:hover { transform: scale(1.35); }
.minimap-dot.is-saved { box-shadow: 0 0 0 3px rgba(255, 198, 26, 0.45); }

/* ---------- controls band ---------- */

.controls {
  position: sticky;
  top: 0;
  z-index: 30;
  margin-top: 34px;
  background: var(--bg);
  border-top: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
  padding: 14px 0;
}

.controls-row {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field > label, .field > .field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.field-search { flex: 1 1 260px; }

input[type="search"], select {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--hair);
  border-radius: var(--radius-input);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  padding: 11px 14px;
  transition: border-color 0.2s var(--ease);
}
input[type="search"]:hover, select:hover { border-color: #3a3f4a; }
input[type="search"]:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}
input[type="search"]::placeholder { color: var(--ink-faint); }

.select-wrap { position: relative; }
.select-wrap::after {
  content: "\25BE";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-dim);
  font-size: 12px;
  pointer-events: none;
}
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  min-width: 150px;
}

.saved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--hair);
  background: var(--bg-raised);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.saved-toggle:hover { border-color: #3a3f4a; transform: translateY(-1px); }
.saved-toggle:active { transform: translateY(0) scale(0.98); }
.saved-toggle .count {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-sink);
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 2px 8px;
}
.saved-toggle[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.saved-toggle[aria-pressed="true"] .count {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
  color: var(--accent);
}

.status {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-dim);
  align-self: center;
  padding-bottom: 10px;
}

/* ---------- board ---------- */

.board { padding: 46px 0 30px; }

.board-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 26px;
}

.route { position: relative; padding-left: 60px; }

.rail {
  position: absolute;
  left: 18px;
  top: 26px;
  bottom: 26px;
  width: 4px;
  border-radius: 2px;
  background: var(--hair);
}

.bus {
  position: absolute;
  left: 6px;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 4px 14px rgba(255, 198, 26, 0.25);
  display: grid;
  place-items: center;
  transition: transform 0.7s var(--ease);
}
.bus-bar {
  width: 20px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent-ink);
}

.stops { list-style: none; display: flex; flex-direction: column; gap: 18px; }

.stop {
  position: relative;
  animation: stop-in 0.55s var(--ease) both;
  animation-delay: calc(var(--i) * 60ms);
}
.stop.instant { animation: none; }

.stop-dot {
  position: absolute;
  left: -46px;
  top: 30px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 3px solid var(--dot, var(--ink-dim));
  background: var(--bg);
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), transform 0.3s var(--ease);
}
.stop.is-current .stop-dot {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.25);
}
.stop.is-passed .stop-dot { background: #4a5058; border-color: #4a5058; }

.stop-card {
  background: var(--bg-raised);
  border: 1px solid var(--hair);
  border-radius: var(--radius-card);
  padding: 22px 26px 20px;
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.stop-card:hover { border-color: #3a3f4a; transform: translateY(-2px); }

.stop-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 10px;
}

.stop-code {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.line-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 4px 12px;
}
.line-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dot, var(--ink-dim));
  flex: none;
}

.punched-label {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  display: none;
}
.stop.is-saved .punched-label { display: inline; }

.stop-title {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin-bottom: 8px;
}

.stop-summary { color: var(--ink-dim); max-width: 62ch; margin-bottom: 14px; }

.stop-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-dim);
  margin-bottom: 16px;
}
.stop-meta .sep { color: var(--ink-faint); margin: 0 8px; }

/* buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--hair);
  background: var(--bg-raised);
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-ghost { background: transparent; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { border-color: #ffd44d; background: #ffd44d; }

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

.empty {
  border: 1px dashed var(--hair);
  border-radius: var(--radius-card);
  padding: 64px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty[hidden] { display: none; }
.empty-sign {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 6px 14px;
  margin-bottom: 8px;
}
.empty h3 { font-size: 1.5rem; }
.empty p { color: var(--ink-dim); max-width: 40ch; margin-bottom: 12px; }

/* ---------- detail overlay ---------- */

.detail {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}
.detail[hidden] { display: none; }

.detail-scrim {
  position: absolute;
  inset: 0;
  background: rgba(10, 11, 14, 0.72);
  animation: scrim-in 0.3s var(--ease) both;
}

.detail-panel {
  position: relative;
  width: min(820px, 100%);
  max-height: min(92dvh, 100%);
  background: var(--bg-raised);
  border: 1px solid var(--hair);
  border-radius: var(--radius-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: panel-in 0.4s var(--ease) both;
}

.detail-topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--hair);
  background: var(--bg-sink);
}
.detail-stopmeta { display: flex; align-items: center; gap: 12px; }
#closeDetail { margin-left: auto; }

.detail-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 40px 44px 48px;
  scrollbar-width: thin;
  scrollbar-color: var(--hair) transparent;
}

.detail-title {
  font-size: clamp(1.9rem, 4.2vw, 2.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 18px;
}

.detail-byline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 26px;
}
.detail-byline span { display: inline-flex; align-items: center; }
.detail-byline span + span::before {
  content: "";
  width: 1px;
  height: 14px;
  background: var(--hair);
  margin: 0 16px;
}

.detail-standfirst {
  font-family: var(--font-read);
  font-style: italic;
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 30px;
  max-width: 60ch;
}

.detail-photo { margin-bottom: 34px; }

.detail-body { max-width: 66ch; }
.detail-body p {
  font-family: var(--font-read);
  font-size: 1.16rem;
  line-height: 1.8;
  color: #e2e4de;
  margin-bottom: 1.35em;
}

.save-row {
  margin-top: 42px;
  padding-top: 30px;
  border-top: 1px dashed var(--hair);
}

.save-ticket {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-radius: 999px;
  border: 1px dashed var(--hair);
  background: var(--bg-sink);
  font-weight: 600;
  font-size: 15px;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease), color 0.25s var(--ease), transform 0.25s var(--ease);
}
.save-ticket:hover { border-color: var(--accent); transform: translateY(-1px); }
.save-ticket:active { transform: translateY(0) scale(0.98); }

.punch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px dashed var(--ink-dim);
  flex: none;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.save-ticket[aria-pressed="true"] {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--accent-ink);
}
.save-ticket[aria-pressed="true"] .punch {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
}

.detail-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
}
.detail-position {
  margin: 0 auto;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-dim);
}

/* ---------- footer ---------- */

.footer {
  border-top: 1px solid var(--hair);
  margin-top: 26px;
  padding: 40px 0 48px;
}
.footer-note {
  font-size: 14px;
  color: var(--ink-dim);
  max-width: 78ch;
  margin-bottom: 8px;
}

/* ---------- animations ---------- */

@keyframes stop-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scrim-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(26px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes blind-flip {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}
.blind-title.is-flipping { animation: blind-flip 0.45s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  .stop { animation: none; }
  .bus, .stop-dot, .minimap-dot, .stop-card, .blind, .btn, .saved-toggle, .save-ticket { transition: none; }
  .detail-scrim, .detail-panel, .blind-title.is-flipping { animation: none; }
  .blind:hover, .stop-card:hover, .btn:hover, .saved-toggle:hover, .save-ticket:hover { transform: none; }
}

/* ---------- mobile ---------- */

@media (max-width: 900px) {
  .shell { padding: 0 20px; }
  .masthead { padding-top: 30px; }
  .masthead-grid { grid-template-columns: 1fr; gap: 24px; }
  .masthead-photo .duotone { aspect-ratio: 16 / 9; }
  .blind { margin-top: 24px; }
  .blind-title { font-size: 12px; letter-spacing: 0.06em; }

  .controls { margin-top: 26px; padding: 12px 0; }
  .controls-row { gap: 12px; }
  .field-search { flex-basis: 100%; }
  .field-line { flex: 1 1 130px; }
  .field-saved { flex: 1 1 auto; }
  .status { flex-basis: 100%; margin-left: 0; padding-bottom: 2px; }

  .board { padding-top: 34px; }
  .route { padding-left: 42px; }
  .rail { left: 10px; width: 3px; }
  .bus { width: 24px; height: 24px; left: 0; }
  .bus-bar { width: 16px; height: 6px; }
  .stop-dot { left: -36px; width: 11px; height: 11px; border-width: 3px; top: 28px; }

  .stop-card { padding: 18px 18px 16px; }
  .stop-title { font-size: 1.22rem; }

  .detail { padding: 0; }
  .detail-panel {
    width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }
  .detail-scroll { padding: 28px 20px 40px; }
  .detail-title { margin-bottom: 14px; }
  .detail-standfirst { font-size: 1.12rem; margin-bottom: 22px; }
  .detail-photo .duotone { aspect-ratio: 16 / 9; }
  .detail-body p { font-size: 1.06rem; }
  .save-row { margin-top: 30px; padding-top: 22px; }
  .detail-nav { flex-wrap: wrap; }
  .detail-position { flex-basis: 100%; text-align: center; margin: 4px 0; order: 3; }
  #prevStop, #nextStop { flex: 1; justify-content: center; }
}
