/* ===================================================================
   WeatherDVR — stylesheet
   One typeface, a light map, and a dark deck along the bottom.
   The deck is the one place the design is allowed to be loud.
   =================================================================== */

:root {
  --ink: #1b1f24;            /* body text on light surfaces           */
  --ink-2: #5c6670;          /* secondary text                        */
  --paper: #ffffff;          /* floating panels                       */
  --paper-2: #f2f4f6;        /* panel inner surfaces                  */
  --line: #d9dee3;           /* hairlines on light surfaces           */
  --deck: #171c22;           /* the transport deck                    */
  --deck-2: #222a33;         /* raised things on the deck             */
  --deck-line: #303a45;      /* hairlines on the deck                 */
  --deck-ink: #e9edf1;       /* text on the deck                      */
  --deck-ink-2: #8c98a5;     /* secondary text on the deck            */
  --cursor: #ffffff;         /* timeline playhead                     */
  --live: #ff3b30;           /* the only saturated accent: live dot   */
  --focus: #4c8dff;          /* keyboard focus ring                   */

  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 6px;
  --shadow: 0 2px 10px rgba(20, 30, 40, 0.14);
  --deck-h: 128px;           /* height of the bottom deck             */
  --panel-w: 300px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  font-family: var(--font);
  font-size: 14px; line-height: 1.4;
  color: var(--ink);
  background: var(--deck);
  overflow: hidden;
}

button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Map ---------- */
#map {
  position: absolute; inset: 0 0 var(--deck-h) 0;
  background: #e6ebf0;
}
.maplibregl-ctrl-attrib { font-family: var(--font); font-size: 11px; }

/* ---------- Top bar ---------- */
.topbar {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none;                        /* let the map take clicks between items */
  z-index: 5;
}
.topbar > * { pointer-events: auto; }

.brand {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 8px;
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  text-decoration: none; color: var(--ink); font-weight: 600; letter-spacing: 0.01em;
}
.brand-mark {                                   /* a small "record" ring, the DVR idea in 14px */
  width: 14px; height: 14px; border-radius: 50%;
  border: 3px solid var(--ink);
}
.brand-name { font-size: 15px; }

.actions { display: flex; gap: 6px; }

.btn {
  padding: 6px 12px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--ink);
}
.btn:hover:not(:disabled) { background: var(--paper-2); }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ---------- Layer panel ---------- */
.panel {
  position: absolute; top: 56px; left: 12px; bottom: calc(var(--deck-h) + 12px);
  width: var(--panel-w); max-height: 560px;
  display: flex; flex-direction: column;
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  z-index: 4; overflow: hidden;
}
.panel.is-hidden { display: none; }
.panel-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-hint { display: block; margin-top: 2px; font-size: 11.5px; color: var(--ink-2); }
.panel-foot { padding: 10px 14px; border-top: 1px solid var(--line); background: var(--paper-2); }

.layer-list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; }

.layer {
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.layer:last-child { border-bottom: 0; }
.layer-row { display: flex; align-items: center; gap: 10px; }
.layer-row input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.layer-name { font-weight: 500; flex: 1; }
.layer-kind {                                   /* small tag: live / archive / static */
  font-size: 11px; color: var(--ink-2);
  padding: 1px 6px; border: 1px solid var(--line); border-radius: 10px;
}
.layer-kind.live { color: var(--live); border-color: var(--live); }

.layer-body { margin-top: 8px; padding-left: 26px; }
.layer.is-off .layer-body { opacity: 0.45; }

.opacity { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); }
.opacity input[type="range"] { flex: 1; accent-color: var(--ink); }
.opacity output { width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

.smooth { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--ink); }
.smooth input { accent-color: var(--ink); margin: 0; }
.smooth span { color: var(--ink-2); }

.legend { margin-top: 8px; }
.legend-bar { height: 8px; border-radius: 4px; }
.legend-ticks {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--ink-2); margin-top: 3px; font-variant-numeric: tabular-nums;
}
.legend-units { font-size: 11px; color: var(--ink-2); margin-top: 2px; }

.layer-status { margin-top: 6px; font-size: 12px; color: var(--ink-2); }
.layer-status.warn { color: #9a5b00; }
.valid-time { font-variant-numeric: tabular-nums; }

.basemap { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.basemap select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); }

/* ---------- Readout (zoom + scale) ---------- */
.readout {
  position: absolute; right: 12px; top: 56px; z-index: 4;
  display: flex; gap: 10px;
  padding: 4px 10px; font-size: 12px; color: var(--ink-2);
  background: rgba(255,255,255,0.9); border-radius: var(--radius); box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
}

/* ---------- The deck ---------- */
.deck {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--deck-h);
  display: grid;
  grid-template-columns: auto auto 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "intervals transport clock"
    "track     track     track";
  column-gap: 20px;
  padding: 10px 16px 8px;
  background: var(--deck); color: var(--deck-ink);
  border-top: 1px solid var(--deck-line);
  z-index: 6;
}

.intervals { grid-area: intervals; display: flex; gap: 2px; align-self: center; }
.interval {
  padding: 5px 11px; border: 0; border-radius: 4px;
  background: transparent; color: var(--deck-ink-2); font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.interval:hover { color: var(--deck-ink); background: var(--deck-2); }
.interval[aria-selected="true"] { background: var(--deck-ink); color: var(--deck); }
.interval:disabled { opacity: 0.35; cursor: default; }

.transport { grid-area: transport; display: flex; align-items: center; gap: 4px; align-self: center; }
.tbtn {
  width: 32px; height: 30px; border: 0; border-radius: 4px;
  background: transparent; color: var(--deck-ink); font-size: 13px;
}
.tbtn:hover { background: var(--deck-2); }
.tbtn-play { width: 40px; font-size: 15px; background: var(--deck-2); }
.tbtn-play[aria-pressed="true"] { background: var(--deck-ink); color: var(--deck); }
.speed {
  margin-left: 6px; padding: 4px 6px;
  background: var(--deck-2); border: 1px solid var(--deck-line); border-radius: 4px; color: var(--deck-ink);
}
.loop { display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; font-size: 12.5px; color: var(--deck-ink-2); }
.loop input { accent-color: var(--deck-ink); }

.clock { grid-area: clock; justify-self: end; text-align: right; align-self: center; }
.clock-main {
  font-size: 26px; font-weight: 500; letter-spacing: 0.01em; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.clock-sub { display: flex; justify-content: flex-end; align-items: center; gap: 10px; font-size: 12px; color: var(--deck-ink-2); }
.link { background: none; border: 0; padding: 0; color: var(--deck-ink-2); text-decoration: underline; text-underline-offset: 2px; }
.link:hover { color: var(--deck-ink); }

.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--live);
  box-shadow: 0 0 0 0 rgba(255,59,48,0.6);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse { to { box-shadow: 0 0 0 8px rgba(255,59,48,0); } }

.track-wrap { grid-area: track; position: relative; margin-top: 6px; }
.track {
  display: block; width: 100%; height: 44px;
  border-radius: 4px; background: var(--deck-2);
  cursor: ew-resize; touch-action: none;
}
.track-range {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--deck-ink-2); margin-top: 3px; font-variant-numeric: tabular-nums;
}

/* ---------- About dialog ---------- */
.about { border: 0; border-radius: var(--radius); padding: 0; max-width: 460px; box-shadow: var(--shadow); }
.about::backdrop { background: rgba(23,28,34,0.5); }
.about form { padding: 20px 22px; }
.about h2 { margin: 0 0 8px; font-size: 18px; }
.about p { margin: 0 0 10px; max-width: 60ch; }
.about .fine { color: var(--ink-2); font-size: 12.5px; }
.about menu { margin: 14px 0 0; padding: 0; display: flex; justify-content: flex-end; }

/* ---------- Toast ---------- */
.toast {
  position: absolute; left: 50%; bottom: calc(var(--deck-h) + 16px);
  transform: translate(-50%, 8px);
  padding: 8px 14px; border-radius: var(--radius);
  background: var(--deck); color: var(--deck-ink); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
  z-index: 9;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Motion & small screens ---------- */
@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
  .toast { transition: none; }
}

@media (max-width: 760px) {
  :root { --deck-h: 170px; --panel-w: calc(100vw - 24px); }
  .deck {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "intervals clock"
      "transport transport"
      "track     track";
    column-gap: 8px;
  }
  .clock-main { font-size: 18px; }
  .panel { top: 56px; max-height: 45vh; }
  .readout { display: none; }
  .brand-name { display: none; }
}
