/* ABOUTME: Styles for the departure board: black board, split-flap cells, punctuality and network views. */
/* ABOUTME: Generic railway look only; flap size scales with the viewport so phones get a two-line row. */
:root {
  --bg: #0b0b0c;
  --board: #111113;
  --flap: #1d1d20;
  --flap-hi: #26262a;
  --seam: #050506;
  --ink: #f4f4f0;
  --yellow: #f5c518;
  --red: #ff3b30;
  --dim: #8a8a8f;
  --amber: #ff9f0a;
  --cyan: #5ac8fa;
  --cols: 64;
  --cell: min(calc((100vw - 48px) / var(--cols)), 24px);
  --cell-h: calc(var(--cell) * 1.45);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  min-height: 100vh;
  padding: 0 16px env(safe-area-inset-bottom);
  max-width: 1500px;
  margin: 0 auto;
}
a { color: var(--yellow); }

.masthead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding: 20px 0 12px; border-bottom: 3px solid var(--yellow); }
h1 { margin: 0; font-size: clamp(28px, 5vw, 54px); font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
h1 .de { color: var(--dim); font-weight: 400; font-size: 0.55em; margin-left: 0.3em; }
.sub { margin: 6px 0 0; color: var(--dim); font-size: 15px; }
.clock { display: flex; gap: 2px; --cell: clamp(18px, 3.2vw, 34px); }

.tabs { display: flex; gap: 4px; margin: 14px 0; }
.tabs button {
  flex: 1 1 0; background: var(--board); color: var(--dim); border: 1px solid #2a2a2e;
  padding: 10px 8px; font: 600 14px/1 inherit; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--yellow); color: #000; border-color: var(--yellow); }

.view { display: none; }
.view.active { display: block; }

/* Departure board */
.board-head, .row { display: grid; column-gap: calc(var(--cell) * 0.6); align-items: center;
  grid-template-columns: auto auto auto auto auto; grid-template-areas: "time dest plat train status";
  justify-content: start; }
.board-head { color: var(--yellow); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; padding: 0 11px 6px; }
.board-head span { display: block; }
.h-time { width: calc(var(--cell) * 5 + 4px); }
.h-dest { width: calc(var(--cell) * 18 + 17px); }
.h-plat { width: calc(var(--cell) * 10 + 9px); }
.h-train { width: calc(var(--cell) * 6 + 5px); }
.board { background: var(--board); border: 1px solid #222; border-radius: 6px; padding: 8px 10px; }
.row { padding: 5px 0; border-bottom: 1px solid #1a1a1d; position: relative; }
.row:last-child { border-bottom: 0; }
.f-time { grid-area: time; } .f-dest { grid-area: dest; } .f-plat { grid-area: plat; }
.f-train { grid-area: train; } .f-status { grid-area: status; }
.field { display: inline-flex; gap: 1px; }

.cell {
  position: relative; width: var(--cell); height: var(--cell-h); perspective: 300px;
  font: 700 calc(var(--cell-h) * 0.78) / var(--cell-h) "Helvetica Neue", Helvetica, Arial, sans-serif;
  text-align: center; color: var(--ink);
}
.half, .leaf { position: absolute; left: 0; right: 0; height: 50%; overflow: hidden; background: var(--flap); }
.half.top, .leaf.top { top: 0; border-radius: 2px 2px 0 0; background: var(--flap-hi); transform-origin: 50% 100%; }
.half.bot, .leaf.bot { bottom: 0; border-radius: 0 0 2px 2px; transform-origin: 50% 0; }
.half i, .leaf i { position: absolute; left: 0; right: 0; height: var(--cell-h); font-style: normal; }
.half.top i, .leaf.top i { top: 0; }
.half.bot i, .leaf.bot i { bottom: 0; }
.cell::after { content: ""; position: absolute; left: 0; right: 0; top: calc(50% - 0.5px); height: 1px; background: var(--seam); z-index: 3; }
.leaf { z-index: 2; backface-visibility: hidden; }

.f-time .cell, .clock .cell { color: var(--yellow); }
.row.s-cancelled .f-status .cell { color: var(--red); }
.row.s-delayed .f-status .cell { color: var(--yellow); }
.row.s-missed .f-status .cell { color: var(--amber); }
.row.s-station .f-status .cell { color: var(--cyan); }
.row.s-departed .cell { color: var(--dim); }
.row.s-departed .f-time .cell { color: #b39a2e; }
.row.s-cancelled .f-dest .cell { color: var(--red); }
.row.suspended .cell { color: var(--red); }
.row::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 4px; border-radius: 2px; background: var(--line, transparent); }

/* Phone: two lines per row, platform shown as the colored bar */
@media (max-width: 760px) {
  :root { --cols: 29; --cell: calc((100vw - 40px) / var(--cols)); }
  .board-head { display: none; }
  .board { padding: 6px 8px 6px 12px; }
  .row { display: flex; flex-wrap: wrap; row-gap: 3px; column-gap: calc(var(--cell) * 0.6); padding: 7px 0; }
  .row::after { content: ""; flex-basis: 100%; order: 2; }
  .f-time, .f-dest { order: 1; }
  .f-status { order: 3; }
  .f-train { order: 4; margin-left: auto; }
  .f-plat { display: none; }
  .row::before { left: -8px; }
  .tabs button { font-size: 12px; letter-spacing: 0.04em; padding: 10px 4px; }
  .masthead { flex-wrap: wrap; }
}

/* Punctuality */
.punct { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card { background: var(--board); border: 1px solid #222; border-radius: 6px; padding: 18px; }
.card h2 { margin: 0 0 4px; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--yellow); }
.card .note { color: var(--dim); font-size: 13px; margin: 2px 0 12px; }
.big { font-size: clamp(56px, 10vw, 96px); font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.big small { font-size: 0.4em; color: var(--dim); font-weight: 600; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; font-size: 18px; }
.kv dt { color: var(--dim); } .kv dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 9.5em 1fr 3.5em; gap: 8px; align-items: center; font-size: 14px; }
.bar .track { display: block; height: 14px; background: #1f1f23; border-radius: 2px; overflow: hidden; }
.bar .fill { display: block; height: 100%; background: var(--bar, var(--yellow)); }
.bar .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.bar.red .fill { background: var(--red); }

/* Network */
.network { background: var(--board); border: 1px solid #222; border-radius: 6px; padding: 8px; overflow: hidden; }
.network svg { display: block; width: 100%; height: auto; }
.network text { fill: var(--ink); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; }
.legend { color: var(--dim); font-size: 13px; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.train-late { animation: pulse 1s infinite; }
@media (prefers-reduced-motion: reduce) { .train-late { animation: none; } }

.empty { color: var(--dim); padding: 24px; text-align: center; }
.foot { margin: 24px 0 32px; color: var(--dim); font-size: 14px; border-top: 1px solid #222; padding-top: 12px; }
.foot #footline { color: var(--ink); font-size: 16px; }
.meta { margin: 6px 0; }
