/* No framework, no build step. Mobile first; everything below works at 360px. */

:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #16191d;
  --muted: #5c6570;
  --line: #e2e5ea;
  --accent: #0b1220;

  --moving: #1a7f37;
  --moving-bg: #e8f5ec;
  --waiting: #0a5fbf;
  --waiting-bg: #e7f0fb;
  --scheduled: #6b7280;
  --scheduled-bg: #eef0f3;

  --radius: 12px;
  --pad: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --card: #161b22;
    --ink: #e6edf3;
    --muted: #9aa5b1;
    --line: #262d36;
    --accent: #e6edf3;

    --moving: #46d071;
    --moving-bg: #10281a;
    --waiting: #58a6ff;
    --waiting-bg: #0d2440;
    --scheduled: #8b949e;
    --scheduled-bg: #1b2028;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: max(var(--pad), env(safe-area-inset-top)) var(--pad)
           max(var(--pad), env(safe-area-inset-bottom));
}

h1 { font-size: 1.35rem; margin: 8px 0 20px; }
h2 { font-size: 1rem; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }

/* ---------- setup ---------- */

.step { margin-bottom: 28px; }

.step .num {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: .78rem;
  font-weight: 700;
}

.hint { color: var(--muted); font-size: .86rem; margin: -4px 0 10px; }

/* Once a step has its answer it folds down to the .chosen line: the search box,
   its list and the hint all go away until that line is pressed again. */
.step.done { margin-bottom: 14px; }
.step.done .hint,
.step.done input[type="search"],
.step.done .picker { display: none; }
.step.done .num { background: var(--moving); color: #fff; }

.chosen {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 11px 13px;
  font: inherit;
  color: inherit;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
/* display:flex would otherwise beat the browser's own [hidden] rule. */
.chosen[hidden] { display: none; }
.chosen:hover, .chosen:focus-visible { border-color: var(--waiting); }
.chosen:focus-visible { outline: 2px solid var(--waiting); outline-offset: 1px; }

.chosen-value { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.chosen-change { flex: none; font-size: .8rem; color: var(--waiting); }

input[type="search"] {
  width: 100%;
  padding: 11px 13px;
  font-size: 1rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  appearance: none;
}
input[type="search"]:focus { outline: 2px solid var(--waiting); outline-offset: 1px; }

.picker {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 44vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.picker:empty { display: none; }

.picker li { border-bottom: 1px solid var(--line); }
.picker li:last-child { border-bottom: 0; }

.picker button {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 14px;
  background: none;
  border: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.picker button:hover, .picker button:focus-visible { background: var(--scheduled-bg); }

.picker .badge {
  flex: none;
  min-width: 44px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  font-size: .82rem;
  text-align: center;
}
.picker .badge[data-kind="tram"] { background: var(--moving); color: #fff; }
.picker .desc { color: var(--muted); font-size: .88rem; }

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

#board header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 6px;
}

.trip { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }

.line {
  flex: none;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
}

.stops { font-size: .95rem; min-width: 0; }
.arrow { color: var(--muted); }

#change {
  flex: none;
  padding: 7px 12px;
  font: inherit;
  font-size: .85rem;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.feed { margin: 0 0 18px; font-size: .82rem; color: var(--muted); }
.feed.stale { color: #b54708; font-weight: 600; }
@media (prefers-color-scheme: dark) { .feed.stale { color: #f0a868; } }

.group { margin-bottom: 22px; }

.group h2 .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex: none;
}
.group[data-kind="moving"] h2 .dot { background: var(--moving); }
.group[data-kind="waiting"] h2 .dot { background: var(--waiting); }
.group[data-kind="scheduled"] h2 .dot { background: var(--scheduled); }

.group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.group ul:empty { display: none; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--scheduled);
  border-radius: var(--radius);
}
.group[data-kind="moving"] .row { border-left-color: var(--moving); background: var(--moving-bg); }
.group[data-kind="waiting"] .row { border-left-color: var(--waiting); background: var(--waiting-bg); }

.eta { flex: none; min-width: 66px; }
.eta .mins { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.eta .unit { font-size: .75rem; color: var(--muted); }
.eta .clock { display: block; font-size: .78rem; color: var(--muted); }

.detail { min-width: 0; flex: 1; font-size: .87rem; color: var(--muted); }
.detail strong { display: block; color: var(--ink); font-weight: 600; font-size: .95rem; }

.late { color: #b54708; }
.early { color: var(--moving); }
@media (prefers-color-scheme: dark) { .late { color: #f0a868; } }

.empty { margin: 0; padding: 12px 2px; color: var(--muted); font-size: .87rem; }

#board footer {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .78rem;
}

#fatal {
  max-width: 560px;
  margin: 24px auto;
  padding: 14px var(--pad);
  color: #b42318;
}

/* ---------- language ---------- */

/* Sits below both views, outside <main>, so it is the last thing on the page
   whichever view is showing. */
.lang {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 560px;
  margin: 8px auto 0;
  padding: 18px var(--pad) max(var(--pad), env(safe-area-inset-bottom));
  font-size: .8rem;
  color: var(--muted);
}

.lang .lang-label { margin-right: 2px; }

.lang button {
  padding: 5px 12px;
  font: inherit;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.lang button:hover { color: var(--ink); }
.lang button:focus-visible { outline: 2px solid var(--waiting); outline-offset: 1px; }
.lang button[aria-pressed="true"] {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
