/* The page ignores the viewer's light/dark preference on purpose: it is a
   night map at every hour, so the trains stay the brightest thing on it. */
:root {
  --bg-bot: #0a1018;
  --ink: #e9eff7;
  --ink-2: #a7b3c4;
  --ink-3: #78859a;
  --rule: rgba(39, 51, 63, 0.7);
  --panel: rgba(13, 20, 30, 0.82);
  --ice: #5aa9ff;
  --ic: #ff7a45;
  --reg: #35d69a;
  --night: #ffd93d;
  --tram: #ff8fd8;
}

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

body {
  background: var(--bg-bot);
  color: var(--ink);
  font-family:
    "IBM Plex Sans",
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    sans-serif;
  font-weight: 300;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* The glow layer keeps a small backing store; the CSS stretch is the blur,
   and the compositor does the additive blend instead of a canvas blit. */
/* Two fingers belong to the map, one finger still scrolls the page down
   to the legend and the controls. */
#map {
  touch-action: pan-y;
}

#glow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: screen;
  mix-blend-mode: plus-lighter;
}

#glow[hidden] {
  display: none;
}

#dock {
  display: contents;
}

/* ---- clock ---------------------------------------------------------- */
header {
  position: absolute;
  z-index: 3;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  text-shadow:
    0 0 10px var(--bg-bot),
    0 0 4px var(--bg-bot);

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 1em 0;
}

#clock {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 300;
  font-size: clamp(2rem, 4.6vw, 3rem);
  line-height: 1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

#clock .mins {
  opacity: 0.6;
}

#running {
  margin-top: 2px;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  font-family: "IBM Plex Mono", monospace;
}

/* The clock hints when the night fast-forward is running. */
#running[data-ffwd="true"]::after {
  content: " · fast-forwarding the night";
}

/* ---- panels --------------------------------------------------------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

#legend {
  position: fixed;
  z-index: 3;
  left: 20px;
  bottom: 20px;
  padding: 13px 15px 11px;
  min-width: 222px;
  max-width: 330px;
}

#legend h2 {
  font-size: 0.62rem;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  margin-bottom: 9px;
}

#legend footer {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  font-size: 0.66rem;
  line-height: 1.45;
}

#legend footer a,
#legend footer a:visited {
  font-weight: 500;
  color: white;
}

.lg {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 3px 0;
  font-size: 0.83rem;
}

.sw {
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px var(--panel);
}

.lg .nm {
  flex: 1 1 auto;
  color: var(--ink);
}

.lg .ct {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

#controls {
  position: fixed;
  z-index: 3;
  right: 20px;
  bottom: 20px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

button {
  font: inherit;
  font-size: 0.78rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 5px 11px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

button:hover {
  background: rgba(128, 128, 128, 0.13);
}

button[aria-pressed="true"] {
  border-color: currentColor;
}

#play {
  min-width: 64px;
}

.spd {
  display: flex;
  gap: 5px;
}

.spd button {
  padding: 5px 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
}

/* Bloom controls: a toggle, then two small sliders that only appear when
   the glow is on. */
#bloomctl label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.66rem;
  color: var(--ink-3);
}

#bloomctl input[type="range"] {
  width: 64px;
  accent-color: var(--ink-3);
}

/* The scrubber is a transparent range input laid over the day profile, so
   pointer, touch and keyboard seeking all stay native; its thumb is the
   playhead. */
#profile {
  position: relative;
  width: 268px;
  height: 40px;
}

#profcv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#scrub {
  position: absolute;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  outline: none;
  cursor: pointer;
}

#scrub::-webkit-slider-runnable-track {
  background: transparent;
  height: 100%;
}

#scrub::-moz-range-track {
  background: transparent;
  height: 100%;
}

#scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 3px;
  height: 40px;
  border-radius: 1px;
  background: var(--ink);
  cursor: pointer;
}

#scrub::-moz-range-thumb {
  width: 3px;
  height: 40px;
  border: 0;
  border-radius: 1px;
  background: var(--ink);
  cursor: pointer;
}

#scrub:focus-visible {
  outline: 1px solid var(--ink-3);
  outline-offset: 2px;
}

/* ---- provenance ----------------------------------------------------- */
#meta {
  position: absolute;
  z-index: 3;
  left: 14px;
  top: 52px;
  max-width: 250px;
  font-size: 0.68rem;
  line-height: 1.5;
  color: var(--ink-3);
  background: rgba(5, 8, 14, 0.62);
  padding: 9px 12px;
  border-radius: 8px;
}

#meta strong {
  color: var(--ink-2);
  font-weight: 500;
}

#tooltip {
  position: fixed;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -140%);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 0.76rem;
  white-space: nowrap;
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  transition: opacity 0.12s;
}

#tooltip[data-on="true"] {
  opacity: 1;
}

#tooltip .tn {
  font-weight: 500;
}

#tooltip .th {
  color: var(--ink-2);
  font-size: 0.72rem;
}

#hint {
  display: none;
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  background: var(--bg-bot);
  font-size: 0.8rem;
  color: var(--ink-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#loading[hidden] {
  display: none;
}

/* ---- narrow screens -------------------------------------------------- */
/* The map keeps a full screen to itself; everything else moves below the
   fold. The network pills stay on the map -- switching must never need a
   scroll. */
@media (max-width: 820px) {
  body {
    overflow: auto;
    overflow-x: hidden;
  }

  #stage {
    position: relative;
    inset: auto;
    width: 100%;
    height: 100svh;
    height: 100dvh;
  }

  #meta {
    display: none;
  }

  #dock {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 12px 20px;
  }

  #legend,
  #controls {
    position: static;
    z-index: auto;
    max-width: none;
    min-width: 0;
  }

  #controls {
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 12px 14px;
  }

  #profile {
    flex: 1 1 140px;
    width: auto;
    min-width: 0;
  }

  #hint {
    display: block;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 10px;
    z-index: 3;
    text-align: center;
    font-size: 0.64rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-3);
    pointer-events: none;
  }

  #hint span {
    display: block;
    font-size: 0.9rem;
    line-height: 1;
    margin-top: 2px;
  }
}
