/* Mobile-first. Self-contained — the whole app lives inside an iframe, so nothing here
   can leak onto cabinradio.ca and the host theme cannot reach in. */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --line: #2a2f3a;
  --ok: #34a853;
  --stale: #fbbc04;
  --down: #ea4335;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
#app { display: flex; flex-direction: column; height: 100vh; }

#topbar {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
#topbar .title { font-weight: 600; }
#topbar .updated { color: var(--muted); font-size: 12px; text-align: right; }

#map { flex: 1 1 auto; min-height: 0; background: #0b0d10; }

.statusbar {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 10px; background: var(--panel); border-top: 1px solid var(--line);
}
.source-chip {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 3px 9px;
  border: 1px solid var(--line); border-radius: 999px; background: #0e1014;
}
.source-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--down); flex: none; }
.source-chip[data-status="ok"] .dot { background: var(--ok); }
.source-chip[data-status="stale"] .dot { background: var(--stale); }
.source-chip .chip-name { font-weight: 500; }
.source-chip .chip-detail { color: var(--muted); }

.attribution {
  padding: 6px 12px; font-size: 11px; color: var(--muted);
  background: var(--panel); border-top: 1px solid var(--line);
}
.attribution strong { color: var(--text); font-weight: 600; }

/* Dark-friendly Leaflet layer toggle */
.leaflet-control-layers {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
}
.leaflet-control-layers-expanded { padding: 8px 10px; }

/* Fire popups (Leaflet popups render light by default — keep them readable and compact) */
.fire-popup strong { font-size: 14px; }
.fire-popup table { margin-top: 6px; border-collapse: collapse; }
.fire-popup th {
  text-align: left; font-weight: 600; color: #444; padding: 1px 8px 1px 0;
  vertical-align: top; white-space: nowrap;
}
.fire-popup td { padding: 1px 0; }
.fire-popup .mt { color: #888; font-size: 11px; }
.fire-popup .src { margin-top: 6px; font-size: 11px; color: #888; }

/* Fire legend */
.legend {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; font-size: 12px; line-height: 1.5;
}
.legend-title { font-weight: 600; margin-bottom: 4px; }
.legend-row { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: none; }
.legend-note { margin-top: 5px; color: var(--muted); font-size: 11px; }
.legend-sep { margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--line); }
.legend-flame { flex: none; }

/* Active fires are flame icons — shape distinguishes the fires layer from air-quality circles and
   hotspot dots; colour still encodes control status. */
.fire-flame-marker { background: none; border: none; }
.fire-flame { display: block; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45)); }
.fire-flame.fire-out { opacity: 0.5; }

/* Satellite-heat detections are small squares (mirrors NASA FIRMS; distinct shape from flames/circles) */
.hotspot-marker { background: none; border: none; }
.hotspot-square {
  display: block; width: 8px; height: 8px;
  background: #ff5722; border: 1px solid #7a1f0a; opacity: 0.85;
}

/* Air-quality AQI badges */
.aqi-marker { background: none; border: none; }
.aqi-badge {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  border: 2px solid rgba(0, 0, 0, 0.4); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}
.aqi-badge.dark { color: #1a1a1a; }
.aqi-badge.light { color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); }
.aqi-badge.lowconf { border-style: dashed; opacity: 0.85; }
.fire-popup .warn { margin-top: 6px; color: #b8860b; font-size: 12px; }

/* Air-quality clusters (zoomed-out averages) — deliberately distinct from a single sensor badge:
   a double ring signals "group", the "~" + count signal "average of N", not one reading. */
.aqi-cluster-marker { background: none; border: none; }
.aqi-cluster {
  position: relative;
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  border: 2px solid #fff;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.4), 0 1px 5px rgba(0, 0, 0, 0.5);
}
.aqi-cluster.dark { color: #1a1a1a; }
.aqi-cluster.light { color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); }
.aqi-cluster.alert { box-shadow: 0 0 0 3px #ff2a2a, 0 1px 6px rgba(0, 0, 0, 0.6); } /* a sensor inside is Unhealthy+ */
.aqi-cluster .n {
  position: absolute; top: -5px; right: -5px;
  background: #171a21; color: #e8eaed; border: 1px solid #3a4150;
  font-size: 9px; font-weight: 600; line-height: 1; min-width: 14px; text-align: center;
  padding: 1px 3px; border-radius: 8px;
}

@media (max-width: 480px) {
  #topbar .title { font-size: 14px; }
  #topbar .updated { font-size: 11px; }
  .attribution { font-size: 10px; }
  .legend { font-size: 11px; padding: 6px 8px; }
}
