:root {
  --bg: #0a0e14;
  --fg: #e8edf2;
  --muted: #6b7685;
  --sub: #9aa7b5;
  --dest: #cdd6df;
  --accent: #3ddc6f;
  --live: #0a8f3c;
  --alert: #ffa726;   /* yellow-orange: non-line UI accents (LIVE, picker, arriving tag) */
}

/* Dot-matrix LED face for the on-train destination blind. Self-hosted so the
   kiosk never falls back to a system font on a flaky connection. */
@font-face {
  font-family: "Micro 5";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./micro5.ttf") format("truetype");
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.board {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: clamp(22px, 3.5vw, 48px) clamp(30px, 4.5vw, 64px) 0;
}

/* ---- header ---- */
.top { display: flex; justify-content: space-between; align-items: center; }
.brand {
  font-size: clamp(13px, 1.6vw, 20px);
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.status { display: inline-flex; align-items: center; gap: 14px; }
.ln { display: inline-flex; align-items: center; gap: 8px; font-size: clamp(11px, 1.2vw, 15px); color: var(--muted); }
.dot {
  width: 13px; height: 13px; border-radius: 50%; background: var(--alert);
  display: inline-block; animation: pulse 2s infinite;
}
.live.off .dot { animation: none; background: var(--muted); }
.live.off { color: var(--muted); opacity: .6; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,167,38,.5); }
  70% { box-shadow: 0 0 0 9px rgba(255,167,38,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,167,38,0); }
}
.stale-hint { font-size: clamp(10px, 1.1vw, 13px); color: #c98a2b; letter-spacing: .04em; }

/* ---- two columns ---- */
.dual {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: clamp(48px, 8vw, 140px); margin-top: clamp(12px, 2vw, 28px);
}
.col h4 {
  margin: 0 0 10px; font-size: clamp(13px, 1.5vw, 19px); color: var(--sub);
  font-weight: 600; letter-spacing: .03em;
}
.row {
  display: flex; justify-content: space-between; align-items: center;
  padding: clamp(6px, 1vw, 12px) 0; border-bottom: 1px solid rgba(255,255,255,.06);
}
.row .dest { font-size: clamp(13px, 1.5vw, 20px); color: var(--dest); margin-right: auto; }
.row .min {
  font-size: clamp(21px, 2.6vw, 38px); color: #fff;
  font-variant-numeric: tabular-nums; font-weight: 700;
}
.row.first .min { color: var(--accent); font-size: clamp(26px, 3.4vw, 50px); }
.row.first.incoming .min { animation: blink 1s steps(2, start) infinite; }
.row .min small { font-size: .5em; color: var(--sub); font-weight: 600; }
.row.empty .dest { color: var(--muted); font-style: italic; }
.row .badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.6em; height: 1.6em; margin-right: .6em; border-radius: 5px;
  color: #fff; font-weight: 800; font-size: clamp(15px, 1.7vw, 22px); flex: 0 0 auto;
}
@keyframes blink { 50% { opacity: .45; } }

/* ---- track + train ---- */
.track-wrap {
  position: relative; flex: 1; min-height: 130px;
  margin: auto calc(-1 * clamp(30px, 4.5vw, 64px)) 0;
  overflow: hidden;
}
.rail {
  position: absolute; bottom: 22px; left: 0; right: 0; height: 3px;
  background: repeating-linear-gradient(90deg, #2a3340 0 20px, transparent 20px 32px);
}

.train {
  position: absolute; bottom: 25px; left: 0;
  display: none;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.5));
  will-change: transform;
}
.train.nb.running { display: block; animation: drive-nb 8s linear infinite; }
.train.sb.running { display: block; animation: drive-sb 8s linear infinite; }

/* The car graphic. Drawn nose-right; the container animation only translates. */
.train-svg { display: block; width: 300px; height: auto; }

/* Destination blind: the Line numeral and destination both in dot-matrix Micro 5. */
.blind-num {
  font-family: "Micro 5", ui-monospace, monospace;
  font-size: 18px;
}
.blind-dest {
  font-family: "Micro 5", ui-monospace, monospace;
  font-size: 22px;
  fill: var(--alert);
  text-transform: uppercase;
  animation: blind-flash 1.6s ease-in-out infinite;
}
@keyframes blind-flash { 50% { opacity: .45; } }

/* SB: mirror the whole graphic so the cab leads on the left... */
.train.sb .train-svg { transform: scaleX(-1); }
/* ...then re-flip the logo + blind (.cf) around their own centers so text reads. */
.train.sb .train-svg .cf {
  transform: scaleX(-1); transform-box: fill-box; transform-origin: center;
}

/* NB: travels left -> right, cab (drawn on the right) leads. */
@keyframes drive-nb {
  from { transform: translateX(-340px); }
  to   { transform: translateX(100vw); }
}
/* SB: travels right -> left. Mirroring lives on .train-svg, not in the keyframe. */
@keyframes drive-sb {
  from { transform: translateX(100vw); }
  to   { transform: translateX(-340px); }
}

/* ---- station picker (hero control + custom dropdown) ---- */
.hero-wrap { position: relative; }
.hero-eyebrow {
  text-transform: uppercase; letter-spacing: .14em; color: var(--muted);
  font-size: clamp(11px, 1.2vw, 15px); font-weight: 600;
  margin-bottom: 8px; padding-left: 2px;
}
.hero {
  display: inline-flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.16);
  margin: 0; padding: 8px 16px;
  color: var(--fg); font-family: inherit; cursor: pointer; line-height: 1;
  font-size: clamp(18px, 2.4vw, 30px); font-weight: 700; letter-spacing: .01em;
  border-radius: 12px;
}
.hero:hover { color: #fff; border-color: rgba(255,255,255,.32); }
.hero:focus-visible { outline: 2px solid var(--alert); outline-offset: 3px; }
.chev { color: var(--alert); font-size: .82em; transition: transform .15s ease; }
.hero[aria-expanded="true"] .chev { transform: rotate(180deg); }

.picker-panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  min-width: max(260px, 22vw); max-height: min(70vh, 520px); overflow-y: auto;
  background: #0e141d; border: 1px solid rgba(255,255,255,.10); border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0,0,0,.55); padding: 6px;
}
.picker-panel[hidden] { display: none; }
.picker-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; color: var(--dest);
  font-size: clamp(14px, 1.4vw, 18px);
}
.picker-item:hover { background: rgba(255,255,255,.06); color: var(--fg); }
.picker-item.sel { background: rgba(255,167,38,.14); color: var(--alert); font-weight: 700; }
.term-tag {
  font-size: .62em; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  border: 1px solid rgba(255,255,255,.16); border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.picker-item.sel .term-tag { color: var(--alert); border-color: rgba(255,167,38,.4); }

/* ---- terminus placeholder (dead direction) ---- */
.terminus-note {
  display: flex; flex-direction: column; gap: 6px;
  padding: clamp(14px, 2vw, 22px);
  border: 1px dashed rgba(255,255,255,.14); border-radius: 12px; color: var(--muted);
}
.term-end { font-size: clamp(16px, 1.8vw, 24px); color: var(--sub); font-weight: 700; letter-spacing: .02em; }
.term-sub { font-size: clamp(12px, 1.3vw, 16px); color: var(--muted); }

/* ---- welcome screen (first run) ---- */
.board[hidden] { display: none; }
.welcome {
  position: fixed; inset: 0; overflow: hidden;
  background: radial-gradient(120% 120% at 20% 0%, #0d141d 0%, var(--bg) 60%);
  display: flex; flex-direction: column;
  padding: clamp(28px, 6vw, 90px);
  /* Reserve a band at the bottom for the rolling train so the centered content
     can never collide with it, regardless of viewport height (kiosk = short + wide). */
  padding-bottom: clamp(168px, 30vh, 264px);
}
.welcome[hidden] { display: none; }
/* Capped spacers center the content in the area above the train band, but stop it
   from drifting to dead-center on tall screens (the void Stefano flagged). */
.welcome::before { content: ""; flex: 1 1 auto; max-height: clamp(24px, 10vh, 120px); }
.welcome::after { content: ""; flex: 2 1 auto; }
.welcome-inner { flex: 0 0 auto; max-width: 760px; position: relative; z-index: 2; }
.welcome-eyebrow {
  text-transform: uppercase; letter-spacing: .16em; color: var(--muted);
  font-size: clamp(11px, 1.2vw, 15px); margin-bottom: clamp(14px, 2vw, 22px);
}
.welcome-head {
  margin: 0 0 clamp(26px, 4vw, 44px); color: var(--fg); font-weight: 800;
  font-size: clamp(34px, 6vw, 76px); line-height: 1.02; letter-spacing: -.01em;
}
.welcome-cta {
  font-size: clamp(18px, 2.2vw, 28px); padding: 14px 22px;
  border: 1px solid rgba(255,255,255,.16); border-radius: 14px; background: rgba(255,255,255,.02);
}
.welcome-cta:hover { border-color: var(--alert); }

.welcome-rail {
  position: absolute; left: 0; right: 0; bottom: clamp(60px, 12vh, 140px); height: 3px;
  background: repeating-linear-gradient(90deg, #2a3340 0 20px, transparent 20px 32px);
}
.welcome-train { position: absolute; left: 0; bottom: calc(clamp(60px, 12vh, 140px) + 3px); z-index: 1; }
.welcome-train .train.welcome-roll {
  position: relative; left: auto; bottom: auto; display: block;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.5));
  animation: welcome-roll-in 2.2s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes welcome-roll-in {
  from { transform: translateX(-440px); }
  to   { transform: translateX(clamp(40px, 12vw, 220px)); }
}
