/* togVarsel — a departure board for one address. Single dark look, tuned for night use. */

:root {
  --navy: #10233a;
  --navy-deep: #0b1829;
  --rule: #24405f;
  --ink: #f3efe4;
  --muted: #9fb0c4;
  --amber: #ffb94a;
  --signal: #ff6b6b;

  --font-body: "Barlow", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-board: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;

  --measure: 44rem;
  --gutter: clamp(1rem, 4vw, 2rem);
}

* {
  box-sizing: border-box;
}

/* Author display rules (flex, grid) would otherwise beat the browser's default for [hidden]. */
[hidden] {
  display: none !important;
}

html {
  background: var(--navy-deep);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--navy);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

body > * {
  max-width: var(--measure);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

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

.masthead {
  padding-top: 1.75rem;
  padding-bottom: 1rem;
}

.masthead-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.masthead-address {
  margin: 0.1rem 0 0.5rem;
  font-family: var(--font-board);
  font-weight: 600;
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 1.05;
  letter-spacing: 0.005em;
}

.masthead-track {
  margin: 0;
  color: var(--muted);
  max-width: 36rem;
}

/* Banner -------------------------------------------------------------------- */

.banner {
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
}

.banner-inner {
  border-left: 4px solid var(--amber);
  padding: 0.5rem 0.9rem;
  background: var(--navy-deep);
  color: var(--ink);
}

.banner-inner.is-error {
  border-left-color: var(--signal);
}

/* Modes ----------------------------------------------------------------------- */

.modes {
  display: flex;
  gap: 1rem;
  padding-top: 0.25rem;
}

.mode {
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 0.4rem 0.1rem;
  cursor: pointer;
}

.mode.is-active {
  color: var(--ink);
  border-bottom-color: var(--amber);
}

.mode:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* History controls -------------------------------------------------------------- */

.history-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: flex-end;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.history-controls > label {
  display: inline-flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--muted);
}

.history-kind {
  display: inline-flex;
  gap: 1rem;
  padding-bottom: 0.35rem;
}

.history-kind label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink);
}

.history-kind input {
  accent-color: var(--amber);
}

.history-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}

.history-fields label {
  display: inline-flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--muted);
}

.history-controls select,
.history-controls input[type="time"] {
  font: inherit;
  color: var(--ink);
  background: var(--navy-deep);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  color-scheme: dark;
}

.history-controls select:focus-visible,
.history-controls input[type="time"]:focus-visible,
.preset:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.preset {
  font: inherit;
  font-weight: 600;
  color: var(--navy-deep);
  background: var(--amber);
  border: 0;
  border-radius: 4px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}

.history-note {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Controls ------------------------------------------------------------------ */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  padding-top: 0.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  position: relative;
  width: 2.4rem;
  height: 1.35rem;
  border-radius: 1rem;
  background: var(--rule);
  transition: background-color 120ms ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 120ms ease;
}

.switch input:checked + .switch-track {
  background: var(--amber);
}

.switch input:checked + .switch-track::after {
  transform: translateX(1.05rem);
  background: var(--navy-deep);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.switch-label {
  color: var(--ink);
}

/* Board --------------------------------------------------------------------- */

.board {
  list-style: none;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.train {
  display: grid;
  grid-template-columns: minmax(6.5rem, auto) 1fr auto;
  column-gap: 1rem;
  align-items: baseline;
  padding: 0.85rem 0 0.85rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  border-left: 4px solid transparent;
}

.train-countdown {
  font-family: var(--font-board);
  font-weight: 500;
  font-size: 2rem;
  line-height: 1;
  white-space: nowrap;
}

.train-countdown small {
  font-size: 0.55em;
  font-weight: 500;
  color: var(--muted);
}

.train-body {
  min-width: 0;
}

.train-kind {
  margin: 0;
  font-weight: 600;
}

.train-kind span {
  font-weight: 400;
  color: var(--muted);
}

.train-route {
  margin: 0.1rem 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.train-when {
  text-align: right;
  white-space: nowrap;
}

.train-clock {
  font-family: var(--font-board);
  font-weight: 500;
  font-size: 1.35rem;
}

.train-delay {
  display: block;
  color: var(--signal);
  font-size: 0.9rem;
}

.train-note {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Freight is the loud thing on the board. */
.train.is-freight {
  border-left-color: var(--amber);
}

.train.is-freight .train-countdown,
.train.is-freight .train-kind {
  color: var(--amber);
}

.train.is-freight .train-countdown {
  font-weight: 600;
  font-size: 2.4rem;
}

/* When freight is emphasised, passenger trains step back. */
.board.emphasize .train:not(.is-freight) {
  color: var(--muted);
}

.board.emphasize .train:not(.is-freight) .train-countdown {
  font-size: 1.6rem;
}

.board.emphasize .train:not(.is-freight) .train-kind {
  font-weight: 500;
  color: var(--muted);
}

.train.is-now .train-countdown {
  color: var(--ink);
}

.empty {
  padding-top: 2.5rem;
  padding-bottom: 2.5rem;
  color: var(--muted);
  max-width: 34rem;
}

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

.colophon {
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.colophon p {
  margin: 0.25rem 0;
}

@media (max-width: 30rem) {
  .train {
    grid-template-columns: minmax(5.5rem, auto) 1fr;
  }

  .train-when {
    grid-column: 1 / -1;
    text-align: left;
    padding-top: 0.15rem;
  }

  .train-delay,
  .train-note {
    display: inline;
    margin-left: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .switch-track,
  .switch-track::after {
    transition: none;
  }
}
