/* Maverick Wx — radar page only (loaded by radar.html, after styles.css).
   The map fills the viewport under the masthead; the layer panel is a fixed-width instrument
   rail beside it on desktop and a slide-over sheet on phones. Tokens come from styles.css so
   the page follows the site's light/dark theme without a second palette. */

.radar-main {
  padding: 0;
  /* Full height minus the masthead: the map is the page, not a block inside it. */
  height: calc(100vh - var(--masthead-h));
  min-height: 460px;
}

.radar-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: 100%;
}

/* --- Panel --- */

.radar-panel {
  border-right: 1px solid var(--line);
  background: var(--card);
  overflow-y: auto;
  padding: 18px 18px 40px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.radar-panel-head h1 { margin: 0 0 4px; }
.radar-lede { color: var(--muted); font-size: 13px; margin: 0 0 8px; }

.radar-section {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.radar-section-note { color: var(--muted); font-size: 12px; margin: 0 0 10px; }

.radar-basemaps { margin-bottom: 10px; }
.radar-basemaps .tab { padding: 6px 11px; }

.radar-row {
  border: 1px solid var(--line);
  background: var(--card-2);
  padding: 10px 11px;
  margin-bottom: 8px;
}
.radar-row.is-on { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.radar-row-inline { padding: 8px 11px; }

.radar-row-head { display: flex; align-items: flex-start; gap: 9px; }
.radar-check { width: 15px; height: 15px; accent-color: var(--accent); flex: none; margin-top: 2px; }
.radar-row-label { display: flex; flex-direction: column; gap: 1px; cursor: pointer; min-width: 0; flex: 1; }
.radar-row-name { font-weight: 650; font-size: 14px; line-height: 1.2; }
.radar-row-provider {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.radar-forecast-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 4px;
  border: 1px solid var(--accent);
  color: var(--accent);
  letter-spacing: 0.1em;
}
.radar-row-summary { font-size: 12.5px; color: var(--ink); margin: 7px 0 4px; opacity: 0.85; }
.radar-row-meta { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin: 0; }

/* Health badge. "Unavailable" has to be legible at a glance: a blank map must never be the
   only signal that a feed died (invariant 4 in spirit — an outage is not "no weather"). */
.radar-status {
  margin-left: auto;
  flex: none;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 6px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.radar-status-idle { visibility: hidden; }
.radar-status-loading { color: var(--muted); }
.radar-status-live { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.radar-status-unavailable {
  color: #fff;
  background: var(--warn);
  border-color: var(--warn);
}

.radar-row-controls { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.radar-field { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.radar-field > span {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  width: 54px;
  flex: none;
}
.radar-select {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 12px;
  padding: 5px 7px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0;
}
.radar-opacity-wrap { display: flex; align-items: center; gap: 8px; }
.radar-opacity-wrap > span {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  width: 54px;
  flex: none;
}
.radar-opacity { flex: 1; accent-color: var(--accent); }

.radar-disclaimer {
  margin: 20px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
}

/* --- Map stage --- */

.radar-stage { position: relative; min-width: 0; height: 100%; }
.radar-map { position: absolute; inset: 0; background: #08131f; }

/* Both overlays are toggled with the `hidden` attribute, which a display rule would
   otherwise override. */
.radar-legend[hidden],
.radar-timeline[hidden] { display: none; }

.radar-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  max-width: 260px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border: 1px solid var(--line);
  padding: 9px 11px;
  box-shadow: var(--shadow);
}
.radar-legend h2 {
  margin: 0 0 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.radar-legend-scale { display: flex; gap: 0; }
.radar-legend-stop { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; }
.radar-legend-stop i { display: block; width: 100%; height: 10px; }
.radar-legend-stop span {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
}
.radar-legend-note { margin: 7px 0 0; font-size: 10.5px; color: var(--muted); line-height: 1.35; }

/* Animation transport. Only shown while an animated feed is on. */
.radar-timeline {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  /* Clear of the attribution/scale strip along the bottom edge (which is two rows tall when
     the attribution is expanded), and narrow enough not to collide with the legend parked
     bottom-left. */
  bottom: 58px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(480px, calc(100% - 330px));
  background: color-mix(in srgb, var(--card) 94%, transparent);
  border: 1px solid var(--line);
  padding: 7px 12px;
  box-shadow: var(--shadow);
}
.radar-play {
  font: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 0;
  padding: 5px 9px;
}
.radar-play:hover { border-color: var(--accent); }
.radar-frame { flex: 1; accent-color: var(--accent); min-width: 0; }
.radar-frame-readout { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.radar-frame-time { font-size: 12px; white-space: nowrap; color: var(--ink); }
/* A forecast frame is not an observation, and the two must never look alike: nowcast frames
   and every model frame are marked in the accent, in italics, against the upright mono of a
   measured time. The layer's name sits under it because "+3:00" is meaningless until you
   know whose lead time it is. */
.radar-frame-time.is-forecast { color: var(--accent); font-style: italic; }
.radar-frame-source {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.radar-frame-source.is-forecast { color: var(--accent); }

/* --- Markers + popups --- */

.radar-storm-marker {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
.radar-storm-dot {
  width: 13px;
  height: 13px;
  flex: none;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  background: var(--muted);
}
/* Wind-tier colours come from the shared chip ramp in styles.css. */
.radar-storm-dot.tier-unknown { background: #64748b; }
.radar-storm-dot.tier-td { background: #4b9fe0; }
.radar-storm-dot.tier-ts { background: #17b3a3; }
.radar-storm-dot.tier-c1 { background: #ffd43b; }
.radar-storm-dot.tier-c2 { background: #ff9f1c; }
.radar-storm-dot.tier-c3 { background: #f4632e; }
.radar-storm-dot.tier-c4 { background: #e01e5a; }
.radar-storm-dot.tier-c5 { background: #b5179e; }
.radar-storm-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.9), 0 0 6px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
}
.radar-invest-marker {
  display: block;
  width: 10px;
  height: 10px;
  border: 2px dashed rgba(255, 255, 255, 0.8);
  background: transparent;
}
.radar-invest-marker.risk-high { background: rgba(224, 72, 58, 0.5); }
.radar-invest-marker.risk-medium { background: rgba(242, 165, 59, 0.5); }
.radar-invest-marker.risk-low { background: rgba(230, 207, 69, 0.5); }
.radar-invest-marker.risk-unknown { background: rgba(147, 164, 181, 0.5); }

.radar-popup { font-family: var(--font-body); font-size: 13px; color: #1a2733; }
.radar-popup strong { font-family: var(--font-display); font-size: 16px; }
.radar-popup p { margin: 4px 0 0; }
.radar-popup-meta { font-family: var(--font-mono); font-size: 11px; color: #5c6b7a; }

/* MapLibre's own chrome, toned to the site rather than left in library default blue. */
.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-popup-content { border-radius: 0; padding: 11px 13px; }

/* --- Mobile: the panel becomes a sheet --- */

.radar-panel-toggle {
  display: none;
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 12;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 11px 16px;
  color: #fff;
  background: var(--navy);
  border: 1px solid var(--accent);
  border-radius: 0;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
}

@media (max-width: 900px) {
  .radar-shell { grid-template-columns: minmax(0, 1fr); }
  .radar-panel {
    position: fixed;
    z-index: 11;
    inset: var(--masthead-h) 0 0 0;
    transform: translateY(100%);
    transition: transform 0.18s ease;
    border-right: 0;
  }
  .radar-panel.is-open { transform: translateY(0); }
  .radar-panel-toggle { display: block; }
  .radar-timeline { width: calc(100% - 24px); }
  .radar-legend { max-width: 200px; bottom: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  .radar-panel { transition: none; }
}

footer { margin-top: 0; }
