@font-face {
  font-family: "Jersey 10";
  src: url("fonts/jersey-10-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ground: #121a2e;
  --panel: rgb(18 26 46 / 0.92);
  --edge: #4d5f8a;
  --ink: #f2f5fc;
  --ink-2: #aab5cf;
  --grid: #1e2944;
  --lake-a: #143468;
  --lake-b: #183c76;
  --lake-glint: #4a86d8;
  --shore: #6a9ff0;
  --station: #a3afcb;
  --pier: #3a4a70;
  --river: #2a5aa8;
  --river-green: #1fd8b0;
  --focus: #ffe14a;

  /* CTA line colours, lifted so they read on the dark map. */
  --line-red: #ff4057;
  --line-blue: #34b8ff;
  --line-brn: #c98a52;
  --line-g: #2ee66b;
  --line-o: #ff9230;
  --line-p: #b07cff;
  --line-pnk: #ff8ccf;
  --line-y: #ffe14a;

  --px: 2px; /* one map pixel; panels use the same grain */
  /* Jersey 10 sits on a 75-unit grid in a 1400-unit em, so at this size one
     font pixel is exactly one CSS pixel and every edge lands on the grid. */
  --type-1: calc(1400px / 75);
  --type-2: calc(2800px / 75);
  --frame: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6' viewBox='0 0 6 6' shape-rendering='crispEdges'%3E%3Cpath fill='%234d5f8a' fill-rule='evenodd' d='M1 0h4v1h1v4H5v1H1V5H0V1h1zM2 2v2h2V2z'/%3E%3C/svg%3E");
}

/* The map follows the sky over Chicago (see lib/sky.js). Day is the
   palette above; dusk turns purple with sunset on the water; at night the
   land darkens and the mile streets light up like streetlights. */
:root[data-sky="dusk"] {
  --ground: #1b1a35;
  --panel: rgb(27 26 53 / 0.92);
  --grid: #2c2a50;
  --lake-a: #1e2f66;
  --lake-b: #243770;
  --lake-glint: #f0946c;
  --shore: #9a94e6;
  --river: #3a4c9a;
  --pier: #3f3f70;
}
:root[data-sky="night"] {
  --ground: #0a0f1f;
  --panel: rgb(10 15 31 / 0.92);
  --grid: #5e4c2b;
  --lake-a: #0a1a3a;
  --lake-b: #0c1f44;
  --lake-glint: #2c5296;
  --shore: #3e6bb0;
  --station: #8a95b2;
  --river: #1d3f7a;
  --pier: #2a3552;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ground);
  color: var(--ink);
  font: 400 var(--type-1)/20px "Jersey 10", ui-monospace, monospace;
  -webkit-tap-highlight-color: transparent;
  /* One weight only: a faked bold would smear the pixel grid. */
  font-synthesis: none;
}

b, strong { font-weight: inherit; }

::selection { background: var(--line-y); color: var(--ground); }

#map {
  position: fixed;
  inset: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  cursor: grab;
  outline: none;
}
#map.dragging { cursor: grabbing; }
#map.pointing { cursor: pointer; }

.panel {
  position: fixed;
  background: var(--panel);
  background-clip: padding-box;
  border: calc(var(--px) * 2) solid transparent;
  border-image: var(--frame) 2 / calc(var(--px) * 2);
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: var(--px) solid var(--focus);
  outline-offset: var(--px);
}

svg { display: block; fill: currentColor; shape-rendering: crispEdges; }

/* Header */

.hud {
  top: 16px;
  left: 16px;
  width: min(330px, calc(100vw - 32px));
  padding: 12px 14px 14px;
}

.hud-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: var(--type-2);
  font-weight: 400;
  line-height: 40px;
}

.home {
  color: var(--ink-2);
  font-size: var(--type-1);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
}
.home:hover { color: var(--ink); }

.status {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 12px 0 0;
  font-variant-numeric: tabular-nums;
}

.mode {
  padding: 0 6px;
  background: var(--ink-2);
  color: var(--ground);
  font-weight: 400;
  text-transform: uppercase;
  font-size: var(--type-1);
  line-height: 20px;
}
.mode.live { background: var(--line-g); }
.mode.down { background: var(--line-o); }

#clock { color: var(--ink-2); }

.note {
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: var(--type-1);
}

/* Next trains */

.board {
  margin-top: 10px;
  padding-top: 8px;
  border-top: var(--px) solid var(--edge);
}

.board-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 28px;
}
.board-toggle svg { width: 14px; height: 14px; }
.board-toggle[aria-expanded="true"] svg { transform: scaleY(-1); }
.board-toggle:hover { color: var(--line-y); }

.board-pick {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px 10px;
  margin-top: 8px;
  color: var(--ink-2);
}
.board-pick label { display: contents; }

select {
  min-width: 0;
  padding: 2px 26px 2px 6px;
  border: var(--px) solid var(--edge);
  border-radius: 0;
  background: var(--ground) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 7 7' shape-rendering='crispEdges'%3E%3Cpath fill='%23aab5cf' d='M0 2h7v1H6v1H5v1H4v1H3V5H2V4H1V3H0z'/%3E%3C/svg%3E") no-repeat right 6px center;
  color: var(--ink);
  font: inherit;
  appearance: none;
  cursor: pointer;
}
select:hover { border-color: var(--ink-2); }

.board-favs {
  margin-top: 8px;
  color: var(--ink-2);
}
.fav-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.fav-list button {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 8px;
  border: var(--px) solid var(--edge);
  color: var(--ink);
}
.fav-list button:hover { border-color: var(--ink-2); }
.fav-list button[aria-current="true"] { border-color: var(--c); }
.fav-list i {
  width: calc(var(--px) * 3);
  height: calc(var(--px) * 3);
  background: var(--c);
}

.fav-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  margin-top: 6px;
  color: var(--ink-2);
}
.fav-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1; }
.fav-toggle:hover { color: var(--ink); }
.fav-toggle[aria-pressed="true"] { color: var(--line-y); }
.fav-toggle[aria-pressed="true"] svg { fill: currentColor; stroke: none; }

.arrivals {
  display: grid;
  gap: 2px;
  max-height: 40vh;
  margin: 10px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}
.arrivals button {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 26px;
  padding: 0 4px;
  text-align: left;
}
.arrivals button:hover { background: rgb(255 255 255 / 0.06); }
.arrivals i {
  width: calc(var(--px) * 3);
  height: calc(var(--px) * 3);
  background: var(--c);
}
.arrivals time { font-variant-numeric: tabular-nums; }
.arrivals .due { color: var(--line-y); }
.arrivals small { color: var(--ink-2); font-size: inherit; }
.arrivals .empty { color: var(--ink-2); padding: 0 4px; }

.board-note {
  margin: 8px 0 0;
  color: var(--ink-2);
}

/* Line legend: each entry hides or shows that line. */

.legend {
  left: 16px;
  bottom: 16px;
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 2px 18px;
  padding: 10px 12px;
}

.legend button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 0 4px;
  text-align: left;
}
.legend i {
  width: calc(var(--px) * 3);
  height: calc(var(--px) * 3);
  background: var(--c);
  flex: none;
}
.legend b {
  margin-left: auto;
  padding-left: 10px;
  color: var(--ink-2);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.legend button:hover { background: rgb(255 255 255 / 0.06); }
.legend button[aria-pressed="false"] { color: var(--ink-2); text-decoration: line-through; text-decoration-thickness: 2px; }
.legend button[aria-pressed="false"] i { background: transparent; box-shadow: inset 0 0 0 var(--px) var(--c); }

/* Zoom */

.zoom {
  right: 16px;
  bottom: 16px;
  display: grid;
  padding: 2px;
}
.zoom button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
}
.zoom button + button { border-top: var(--px) solid var(--edge); }
.zoom button:hover { background: rgb(255 255 255 / 0.06); }
.zoom svg { width: 21px; height: 21px; }

/* Selected train */

.card {
  right: 16px;
  top: 16px;
  width: 260px;
  padding: 12px 14px;
}
.card-close {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--ink-2);
}
.card-close:hover { color: var(--ink); }
.card-close svg { width: 14px; height: 14px; }

.card-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 32px 10px 0;
  font-size: var(--type-1);
  font-weight: 400;
}
.card-line i {
  width: calc(var(--px) * 4);
  height: calc(var(--px) * 4);
  background: var(--c);
  flex: none;
}
.card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
}
.card dt { color: var(--ink-2); }
.card dd { margin: 0; }
.card-flag {
  margin: 10px 0 0;
  color: var(--line-y);
}

/* Hover label */

.tip {
  position: fixed;
  z-index: 2;
  max-width: 240px;
  padding: 4px 8px;
  background: var(--ink);
  color: var(--ground);
  font-size: var(--type-1);
  pointer-events: none;
  white-space: nowrap;
}
.tip b { font-weight: 400; }

@media (max-width: 699px) {
  .hud {
    top: max(10px, env(safe-area-inset-top));
    left: 10px;
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 90px);
    overflow-y: auto;
    padding: 8px 10px 10px;
  }
  .arrivals { max-height: none; }
  .status { margin-top: 8px; }
  .note { display: none; }

  .legend {
    left: 10px;
    right: 66px;
    bottom: max(10px, env(safe-area-inset-bottom));
    display: flex;
    gap: 4px;
    padding: 4px 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .legend::-webkit-scrollbar { display: none; }
  .legend button { flex: none; min-height: 36px; }
  .legend b { padding-left: 0; }

  .zoom {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
  }
  .zoom button { width: 40px; height: 36px; }
  .zoom [data-zoom="fit"] { display: none; }

  .card {
    top: auto;
    right: 10px;
    left: 10px;
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 62px);
    width: auto;
  }
}
