/* Light is the base palette; the dark overrides below redefine only the
   tokens, so nothing downstream needs to know which theme is running. */
:root {
  --ink: #16181d;
  --muted: #5d6570;
  --line: #dfe3e8;
  --paper: #ffffff;
  --sunk: #f1f3f6;
  --void: #eef1f4;
  --accent: #1b6ac9;
  --tram: #e04a3f;
  --bus: #2f6fb5;
  --rail: #3f9a53;
  --ferry: #9a5bb5;
  --other: #8c95a1;
  --walk: #e8912a;
  --hole: #ffffff;      /* fill inside a hollow dot: the map's own ground */
  --ring: #16181d;      /* highlight around the hovered stop */
  --area-alpha: 0.30;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .10);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eceef2;
    --muted: #99a2ae;
    --line: #2b313a;
    --paper: #191d23;
    --sunk: #232830;
    --void: #12151a;
    --accent: #5b9df5;
    --tram: #ff6f5e;
    --bus: #5b9df5;
    --rail: #58c06f;
    --ferry: #c07fdb;
    --other: #7d8794;
    --walk: #f5a742;
    --hole: #191d23;
    --ring: #ffffff;
    --area-alpha: 0.34;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ink: #eceef2;
  --muted: #99a2ae;
  --line: #2b313a;
  --paper: #191d23;
  --sunk: #232830;
  --void: #12151a;
  --accent: #5b9df5;
  --tram: #ff6f5e;
  --bus: #5b9df5;
  --rail: #58c06f;
  --ferry: #c07fdb;
  --other: #7d8794;
  --walk: #f5a742;
  --hole: #191d23;
  --ring: #ffffff;
  --area-alpha: 0.34;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

.hide { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--void);
  -webkit-font-smoothing: antialiased;
}

#map { position: absolute; inset: 0; }

#bloom {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

/* --- panel ------------------------------------------------------------- */

#panel {
  position: absolute;
  z-index: 3;
  top: 16px;
  left: 16px;
  width: 306px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  padding: 18px 18px 14px;
  background: var(--paper);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.titlebar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

#panel h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -.01em;
}

.iconbtn {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.iconbtn:hover { color: var(--ink); border-color: var(--muted); }

.iconbtn.solid {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.transport {
  display: flex;
  align-items: center;
  gap: 10px;
}

.transport input[type=range] { flex: 1; }

#scrubOut {
  flex: none;
  min-width: 3.4em;
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.lede {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.control { margin-bottom: 14px; }
.control.row { display: flex; gap: 8px; }

.label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.label output {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: 0;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;   /* takes however many options it is given */
  gap: 4px;
  padding: 3px;
  background: var(--sunk);
  border-radius: 8px;
}

.label .unit { font-weight: 500; letter-spacing: .04em; opacity: .75; }

.segmented button {
  padding: 7px 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.segmented button.on {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .18);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.check input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

input[type=range] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

.btn {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn.ghost {
  background: transparent;
  color: var(--accent);
}

.btn:disabled { opacity: .45; cursor: default; }

#stats {
  margin: 0 0 14px;
  padding: 12px 0 2px;
  border-top: 1px solid var(--line);
}

#stats > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

#stats dt { font-size: 13px; color: var(--muted); }

#stats dd {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0 0 10px;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
  font-size: 12px;
  color: var(--muted);
}

#legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  border-radius: 50%;
  vertical-align: baseline;
}

#legend i[data-cat=tram]  { background: var(--tram); }
#legend i[data-cat=bus]   { background: var(--bus); }
#legend i[data-cat=rail]  { background: var(--rail); }
#legend i[data-cat=ferry] { background: var(--ferry); }
#legend i[data-cat=walk]  { background: var(--walk); }

#status {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  min-height: 1.5em;
}

#status.error { color: #e0574a; }

/* --- running clock ----------------------------------------------------- */

#clock {
  position: absolute;
  z-index: 3;
  right: 16px;
  top: 16px;
  padding: 10px 16px 8px;
  background: var(--paper);
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#clockValue { font-size: 30px; font-weight: 650; letter-spacing: -.02em; }
#clock small { margin-left: 4px; font-size: 13px; color: var(--muted); }

/* --- hover tooltip ----------------------------------------------------- */

#tip {
  position: absolute;
  z-index: 4;
  padding: 6px 9px 7px;
  background: var(--paper);
  border-radius: 7px;
  box-shadow: var(--shadow);
  pointer-events: none;
  white-space: nowrap;
  line-height: 1.35;
}

#tip strong { display: block; font-size: 13px; font-weight: 600; }

#tip span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --- credits ----------------------------------------------------------- */

/* Inside the panel, not floating beside it: the panel grows every time a
   control is added, and an absolutely positioned footnote in the same column
   collides with it sooner or later. */
#credits {
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--muted);
}

#credits p { margin: 0 0 5px; }
#credits a { color: inherit; }
#credits code { font-size: 10px; }

.origin-dot {
  width: 13px;
  height: 13px;
  border: 2.5px solid var(--paper);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
}

/* --- narrow screens ---------------------------------------------------- */

@media (max-width: 720px) {
  #panel {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 52%;
    padding: 14px;
  }
  #clock { right: 8px; top: 8px; padding: 6px 12px 5px; }
  #clockValue { font-size: 22px; }
  .lede { margin-bottom: 12px; }
}
