/* azweather.net -- EXPLORE surface. Dark, technical, data-driven. */

:root {
  --surface: #111827;
  --surface-2: #0B1220;
  --line: #1F2937;
  --text: #E5E7EB;
  --text-dim: #9CA3AF;
  --text-faint: #6B7280;
  --accent: #38BDF8;
  --warn: #F59E0B;
  --hot: #EF4444;
  --ok: #34D399;
  --panel-w: 320px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--surface-2);
  color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ---------------- map ---------------- */

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

#map-fallback {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  z-index: 50;
}

.fallback-inner {
  max-width: 420px;
  padding: 32px;
  text-align: center;
  color: var(--text-dim);
}

.fallback-inner h1 { color: var(--text); margin-bottom: 12px; }
.fallback-inner a { color: var(--accent); }

.maplibregl-ctrl-attrib {
  background: rgba(17, 24, 39, 0.75) !important;
  color: var(--text-faint);
  font-size: 10px;
}
.maplibregl-ctrl-attrib a { color: var(--text-dim); }

/* keep attribution clear of the panel */
.maplibregl-ctrl-bottom-right { right: var(--panel-w); transition: right 0.25s ease; }
body.panel-collapsed .maplibregl-ctrl-bottom-right { right: 48px; }

.maplibregl-popup-content {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  font-size: 12px;
}
.maplibregl-popup-tip { border-top-color: var(--line) !important; border-bottom-color: var(--line) !important; }
.maplibregl-popup-close-button { color: var(--text-dim); font-size: 16px; }

.popup-title { font-weight: 600; margin-bottom: 4px; }
.popup-grid { display: grid; grid-template-columns: auto auto; gap: 1px 12px; }
.popup-grid .k { color: var(--text-dim); }
.popup-raw {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  max-width: 260px;
  word-break: break-all;
}

/* GLM badge (map overlay) */
#glm-badge {
  position: fixed;
  top: 12px;
  left: 52px;
  z-index: 20;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}
#glm-badge.lit { color: var(--warn); border-color: var(--warn); }
#glm-badge.lit::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--warn);
  animation: pulse 1.2s ease-in-out infinite;
}

/* station markers */
.station-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(17, 24, 39, 0.9);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15), 0 2px 6px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 11px var(--mono);
  color: #0B1220;
  cursor: pointer;
  animation: breathe 5s ease-in-out infinite;
  transition: transform 0.15s ease;
}
/* hover scale lives on the inner div: MapLibre owns the transform of
   the outer marker element for positioning */
.station-wrap:hover .station-marker { transform: scale(1.18); }

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255,255,255,0.15), 0 2px 6px rgba(0,0,0,0.5); }
  50% { box-shadow: 0 0 0 3px rgba(255,255,255,0.08), 0 2px 6px rgba(0,0,0,0.5); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

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

#panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--panel-w);
  z-index: 30;
  /* opaque enough that map labels are never readable through it,
     even without backdrop-filter support */
  background: rgba(17, 24, 39, 0.965);
  backdrop-filter: blur(8px);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, border-color 0.2s ease;
}

#panel.collapsed { transform: translateX(calc(var(--panel-w) - 48px)); }

/* collapsed: the whole exposed strip is a click-to-expand target */
#panel.collapsed { cursor: pointer; }
#panel.collapsed:hover { border-left-color: var(--accent); }

@media (min-width: 768px) {
  /* keep the chevron visible on the exposed strip when collapsed --
     without this the expand control slides off-screen with the head */
  #panel.collapsed #panel-collapse {
    position: absolute;
    top: 12px;
    left: 11px;
    color: var(--accent);
    border-color: var(--accent);
  }
}

#panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

#panel-head .wordmark {
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 14px;
}
#panel-head .wordmark span { color: var(--accent); }
#panel-head .surface-tag {
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.2em;
  margin-right: auto;
}

#panel-collapse {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-dim);
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
#panel-collapse:hover { color: var(--text); border-color: var(--text-faint); }

/* collapsed strip: mini status remains visible on the exposed 48px */
#panel-strip {
  position: absolute;
  left: 0;
  top: 52px;
  width: 48px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 14px;
  font-family: var(--mono);
  font-size: 11px;
}
#panel.collapsed #panel-strip { display: flex; }
#panel-strip .strip-prob { color: var(--accent); font-weight: 700; }
#panel-strip .strip-wall {
  writing-mode: vertical-rl;
  letter-spacing: 0.15em;
  font-size: 9px;
  color: var(--text-dim);
}
#panel-strip .strip-dot { width: 8px; height: 8px; border-radius: 50%; }

#panel-body {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
#panel.collapsed #panel-body { visibility: hidden; }
#panel.collapsed #panel-head .wordmark,
#panel.collapsed #panel-head .surface-tag { visibility: hidden; }

#panel-body section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

#panel-body h2 {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  margin-bottom: 10px;
  text-transform: uppercase;
}

section.unavailable > *:not(h2):not(.sec-note) { opacity: 0.35; filter: saturate(0.3); }
.sec-note { display: none; font-size: 11px; color: var(--text-faint); margin-bottom: 8px; }
section.unavailable .sec-note { display: block; }

/* skeleton shimmer while first fetch is in flight */
.skeleton {
  color: transparent !important;
  border-radius: 4px;
  background: linear-gradient(90deg, #1F2937 25%, #273449 50%, #1F2937 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  min-height: 0.9em;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* status section */
.verdict-headline { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.verdict-detail { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }
.verdict-meta { font-size: 10px; color: var(--text-faint); font-family: var(--mono); margin-top: 8px; }

.status-row { display: flex; align-items: center; gap: 14px; }

.wall-block { flex: 1; }
.wall-badge {
  display: inline-block;
  font: 700 11px var(--mono);
  letter-spacing: 0.12em;
  border-radius: 4px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.wall-badge.st-idle { color: var(--text-dim); }
.wall-badge.st-watch { color: var(--accent); border-color: var(--accent); }
.wall-badge.st-forming { color: var(--warn); border-color: var(--warn); }
.wall-badge.st-approaching {
  color: var(--hot);
  border-color: var(--hot);
  animation: pulse 1.5s ease-in-out infinite;
}
.wall-badge.st-impact {
  color: #fff;
  background: var(--hot);
  border-color: var(--hot);
  animation: pulse 0.8s ease-in-out infinite;
}
.wall-detail { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.wall-detail .big { color: var(--text); font-weight: 600; }

/* gauges */
.gauge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}

.gauge-cell {
  background: rgba(31, 41, 55, 0.35);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 8px 6px;
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.gauge-cell:hover {
  border-color: #374151;
  background: rgba(31, 41, 55, 0.55);
}
.gauge-cell.wide { grid-column: span 2; }

.gauge-cell svg { display: block; margin: 0 auto; }
.gauge-track { stroke: var(--line); fill: none; stroke-linecap: round; }
.gauge-val { fill: none; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease, stroke 0.6s ease; }
.gauge-thresh { stroke: var(--text-faint); stroke-width: 1.5; }
.gauge-num { font: 700 13px var(--mono); fill: var(--text); }
.gauge-unit { font: 9px var(--mono); fill: var(--text-faint); }
.gauge-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 2px;
}
.gauge-spark { margin-top: 3px; }
.gauge-spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.2; opacity: 0.8; }
.gauge-spark.flat polyline { stroke: var(--text-faint); opacity: 0.5; }
.spark-note { font-size: 9px; color: var(--text-faint); }

/* cloud cover bars */
.cloud-rows { display: flex; flex-direction: column; gap: 5px; padding: 2px 4px; }
.cloud-row { display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--text-dim); }
.cloud-row .cl-name { width: 30px; text-align: left; font-family: var(--mono); }
.cloud-row .cl-bar { flex: 1; height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.cloud-row .cl-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.6s ease; }
.cloud-row .cl-pct { width: 34px; text-align: right; font-family: var(--mono); }

/* glm cell */
.glm-value { font: 700 20px var(--mono); padding: 6px 0 2px; }
.glm-value.lit { color: var(--warn); }
.glm-value .u { font-size: 10px; color: var(--text-faint); font-weight: 400; }

/* conditions */
.cond-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.cond-temp { font: 700 36px/1 var(--mono); }
.cond-temp .u { font-size: 16px; color: var(--text-dim); }
.cond-station { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }
.stale-chip {
  font: 600 9px var(--mono);
  color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.1em;
}
.cond-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  font-size: 12px;
}
.cond-grid .k { color: var(--text-faint); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.cond-grid .v { font-family: var(--mono); }

/* layer toggles */
.layer-cat { margin-bottom: 10px; }
.layer-cat:last-child { margin-bottom: 0; }
.layer-cat h3 {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  margin: 0 -6px;
  border-radius: 6px;
  font-size: 12.5px;
  transition: background 0.15s ease;
}
.layer-row:not(.stub):hover { background: rgba(31, 41, 55, 0.5); }
.layer-row .lname { flex: 1; }
.layer-row.stub { color: var(--text-faint); }
.layer-row .soon {
  font-size: 9px;
  color: var(--text-faint);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.08em;
}

.switch { position: relative; width: 32px; height: 18px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; cursor: pointer; margin: 0; }
.switch .track {
  position: absolute;
  inset: 0;
  background: var(--line);
  border-radius: 9px;
  transition: background 0.2s;
  pointer-events: none;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .track { background: rgba(56, 189, 248, 0.35); }
.switch input:checked + .track::after { transform: translateX(14px); background: var(--accent); }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + .track { opacity: 0.4; }

/* system health */
#sec-health h2 { cursor: pointer; margin-bottom: 0; }
#sec-health h2::after { content: " +"; color: var(--text-faint); }
#sec-health.open h2 { margin-bottom: 10px; }
#sec-health.open h2::after { content: " -"; }
#sec-health .health-body { display: none; }
#sec-health.open .health-body { display: block; }
.health-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 11.5px;
  font-family: var(--mono);
}
.health-row .hname { flex: 1; color: var(--text-dim); }
.health-row .hlag { color: var(--text-faint); font-size: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.g { background: var(--ok); }
.dot.y { background: var(--warn); }
.dot.r { background: var(--hot); }
.dot.n { background: var(--text-faint); }
.health-summary { display: inline-block; margin-left: 6px; vertical-align: middle; }

/* ---------------- radar bar ---------------- */

#radarbar {
  position: fixed;
  left: 12px;
  bottom: 26px;
  right: calc(var(--panel-w) + 24px);
  max-width: 560px;
  z-index: 25;
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#radar-play {
  width: 30px;
  height: 30px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
}
#radar-play:hover { border-color: var(--accent); }

.radar-mid { flex: 1; min-width: 0; }

#radar-scrub {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  outline: none;
  cursor: pointer;
}
#radar-scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}
#radar-scrub::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}

.radar-ticks {
  display: flex;
  justify-content: space-between;
  padding: 3px 5px 0;
}
.radar-ticks span { width: 1px; height: 4px; background: var(--text-faint); opacity: 0.6; }

#radar-time {
  font: 11px var(--mono);
  color: var(--text-dim);
  white-space: nowrap;
  flex: none;
}

/* ---------------- responsive ---------------- */

/* collapsed panel frees the width for a longer scrubber */
body.panel-collapsed #radarbar { right: 60px; }

@media (max-width: 1024px) {
  #panel { box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5); }
  /* panel overlays the map here -- keep the bar clear of it */
  #radarbar { right: calc(var(--panel-w) + 24px); max-width: none; }
}

@media (max-width: 767px) {
  #panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 55%;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 12px 12px 0 0;
    transition: transform 0.25s ease;
  }
  #panel.collapsed { transform: translateY(calc(100% - 48px)); }
  #panel.collapsed #panel-head .wordmark,
  #panel.collapsed #panel-head .surface-tag { visibility: visible; }
  #panel-strip {
    top: 10px;
    right: 48px;
    left: auto;
    width: auto;
    flex-direction: row;
    padding: 0;
    align-items: center;
  }
  #panel-strip .strip-wall { writing-mode: horizontal-tb; font-size: 10px; }
  #radarbar { bottom: 60px; left: 12px; right: 12px; }
  body.panel-collapsed #radarbar { right: 12px; }
  /* expanded sheet owns the bottom of the screen -- radar bar and
     attribution yield to it, and return when the sheet collapses */
  #panel:not(.collapsed) ~ #radarbar { display: none; }
  .maplibregl-ctrl-bottom-right { right: 0; bottom: 48px; }
  body:not(.panel-collapsed) .maplibregl-ctrl-bottom-right { display: none; }
  .cond-temp { font-size: 30px; }
}
