/* StormReach Radar v2 — map-first layout.
   Loaded after radar.css, which still supplies the topbar, sprite and tokens. */

:root {
  --r2-rail: 372px;
  --r2-gap: 12px;
  --r2-radius: 14px;
  --r2-panel: rgba(6, 18, 23, .92);
  --r2-line: var(--line, rgba(255, 255, 255, .10));
  --r2-line-strong: var(--line-strong, rgba(255, 255, 255, .18));
  --r2-text-dim: rgba(226, 240, 244, .62);
  --tone-critical: #ff4d4d;
  --tone-high: #ff9f1a;
  --tone-watch: #ffd21a;
  --tone-quiet: #6ec8f0;
  --tone-unknown: #9fb2bb;
}

.radar2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--r2-rail);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "map rail";
  gap: var(--r2-gap);
  padding: var(--r2-gap);
  height: calc(100dvh - 64px);
  min-height: 620px;
  box-sizing: border-box;
}

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

.radar2 .map-stage {
  grid-area: map;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--r2-line);
  border-radius: var(--r2-radius);
  background: #0b1418;
  min-height: 320px;
}

.map-canvas { position: absolute; inset: 0; z-index: 0; }

.radar2 .map-stage.is-placing { cursor: crosshair; }
.radar2 .map-stage.is-placing .leaflet-container,
.radar2 .map-stage.is-placing .gm-style { cursor: crosshair !important; }

.map-hud {
  position: absolute;
  left: 12px;
  right: 12px;
  z-index: 30;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}
.map-hud-top { top: 12px; }
.map-hud-bottom { bottom: 12px; align-items: flex-end; }
.map-hud > * { pointer-events: auto; }

.hud-group {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 7px 11px;
  border: 1px solid var(--r2-line-strong);
  border-radius: 11px;
  background: rgba(4, 14, 18, .82);
  backdrop-filter: blur(18px) saturate(140%);
  color: #eaf5f8;
  font-size: 12px;
  line-height: 1.25;
}
.hud-group .hud-label {
  color: var(--cyan, #61c9f2);
  font-size: 9px;
  font-weight: 760;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.hud-actions { padding: 5px; gap: 4px; }

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #eaf5f8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.hud-btn:hover { border-color: var(--r2-line-strong); background: rgba(255, 255, 255, .06); }
.hud-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.hud-btn.primary { background: linear-gradient(150deg, #ff9f1a, #f97316); color: #1a0d00; }
.hud-btn.primary:hover { filter: brightness(1.06); }
.hud-btn.is-active { background: rgba(97, 201, 242, .18); border-color: rgba(97, 201, 242, .5); color: #bfe9fb; }
.hud-btn[aria-pressed="false"] { opacity: .55; }
/* [hidden] must beat the inline-flex above — this exact rule has bitten twice. */
.hud-btn[hidden] { display: none !important; }

.radius-control {
  display: grid;
  gap: 5px;
  min-width: 240px;
  padding: 9px 12px;
  border: 1px solid var(--r2-line-strong);
  border-radius: 11px;
  background: rgba(4, 14, 18, .82);
  backdrop-filter: blur(18px) saturate(140%);
  color: #eaf5f8;
  font-size: 11px;
}
.radius-control strong { color: var(--cyan, #61c9f2); font-size: 12px; }
.radius-control input[type="range"] { width: 100%; accent-color: #ff9f1a; }

.place-hint {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid rgba(255, 159, 26, .45);
  border-radius: 10px;
  background: rgba(60, 32, 4, .9);
  color: #ffd9a8;
  font-size: 11.5px;
}
.place-hint[hidden] { display: none !important; }

/* Area pins ride on gmap.js's anchor overlay. */
.area-pin {
  display: grid;
  gap: 1px;
  justify-items: center;
  padding: 5px 9px;
  border: 1.5px solid var(--tone-unknown);
  border-radius: 999px;
  background: rgba(3, 12, 16, .9);
  color: #f2fafc;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}
.area-pin[data-tone="critical"] { border-color: var(--tone-critical); }
.area-pin[data-tone="high"] { border-color: var(--tone-high); }
.area-pin[data-tone="watch"] { border-color: var(--tone-watch); }
.area-pin[data-tone="quiet"] { border-color: var(--tone-quiet); }
.area-pin[data-selected="true"] { transform: scale(1.06); box-shadow: 0 0 0 3px rgba(255, 255, 255, .16), 0 8px 22px rgba(0, 0, 0, .5); }
.area-pin-stat { font-size: 9.5px; font-weight: 800; color: var(--tone-unknown); }
.area-pin-stat[data-tone="critical"] { color: var(--tone-critical); }
.area-pin-stat[data-tone="high"] { color: var(--tone-high); }
.area-pin-stat[data-tone="watch"] { color: var(--tone-watch); }
.area-pin-stat[data-tone="quiet"] { color: var(--tone-quiet); }

/* --------------------------------------------------------------- rail --- */

.area-rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 14px;
  border: 1px solid var(--r2-line);
  border-radius: var(--r2-radius);
  background: var(--r2-panel);
  overflow: hidden;
}
.area-rail > header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.area-rail h1 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.area-rail h1 span {
  margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: rgba(97, 201, 242, .14); color: var(--cyan, #61c9f2);
  font-size: 11px; font-weight: 700;
}
.area-rail > header button {
  border: 1px solid var(--r2-line-strong); border-radius: 8px;
  padding: 5px 10px; background: transparent; color: var(--r2-text-dim);
  font-size: 11px; cursor: pointer;
}
.area-rail > header button:hover { color: #eaf5f8; background: rgba(255, 255, 255, .05); }

.area-warning {
  padding: 10px 12px;
  border: 1px solid rgba(255, 159, 26, .35);
  border-radius: 10px;
  background: rgba(48, 27, 4, .7);
  color: #ffd9a8;
  font-size: 11.5px;
  line-height: 1.45;
}
.area-warning strong { display: block; margin-bottom: 3px; color: #ffc46b; }
.area-warning hr { margin: 8px 0; border: 0; border-top: 1px solid rgba(255, 196, 107, .25); }
.area-warning[hidden] { display: none !important; }

.area-list {
  flex: 1 1 auto;
  min-height: 90px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  display: grid;
  gap: 6px;
  align-content: start;
}
.area-row-main {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--r2-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .022);
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.area-row-main:hover { background: rgba(255, 255, 255, .06); border-color: var(--r2-line-strong); }
.area-row.is-selected .area-row-main { border-color: rgba(97, 201, 242, .55); background: rgba(97, 201, 242, .09); }
.area-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.area-row-head strong { font-size: 13px; }
.area-row-meta { color: var(--r2-text-dim); font-size: 11px; }
.area-row-meta b { color: #eaf5f8; }
.out-of-range { color: var(--tone-high); font-style: normal; }

.area-empty { padding: 16px; border: 1px dashed var(--r2-line-strong); border-radius: 10px; text-align: center; }
.area-empty strong { display: block; margin-bottom: 5px; font-size: 13px; }
.area-empty span { color: var(--r2-text-dim); font-size: 11.5px; line-height: 1.5; }
.area-empty em { color: var(--tone-high); font-style: normal; }

.chip {
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 9.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--tone-unknown);
}
.chip[data-tone="critical"] { color: var(--tone-critical); }
.chip[data-tone="high"] { color: var(--tone-high); }
.chip[data-tone="watch"] { color: var(--tone-watch); }
.chip[data-tone="quiet"] { color: var(--tone-quiet); }
.chip[data-trigger="true"] { background: rgba(255, 77, 77, .16); }

/* ------------------------------------------------------------- detail --- */

.area-detail {
  flex: 0 0 auto;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--r2-line-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, .035);
  max-height: 58%;
  overflow-y: auto;
}
.area-detail[hidden] { display: none !important; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.detail-eyebrow { color: var(--cyan, #61c9f2); font-size: 8.5px; font-weight: 780; letter-spacing: .12em; text-transform: uppercase; }
.detail-head h2 { margin: 2px 0 0; font-size: 16px; }
.detail-sub { margin: 2px 0 0; color: var(--r2-text-dim); font-size: 10.5px; }
.icon-button { border: 0; background: transparent; color: var(--r2-text-dim); cursor: pointer; padding: 2px; }
.icon-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.detail-now { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.detail-metric { display: grid; gap: 1px; padding: 8px; border: 1px solid var(--r2-line); border-radius: 9px; }
.detail-metric span { color: var(--r2-text-dim); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.detail-metric strong { font-size: 15px; }
.detail-metric small { color: var(--r2-text-dim); font-size: 10px; }

.detail-verdict { padding: 9px 11px; border-radius: 9px; border: 1px solid currentColor; color: var(--tone-quiet); }
.detail-verdict[data-tone="critical"] { color: var(--tone-critical); }
.detail-verdict[data-tone="high"] { color: var(--tone-high); }
.detail-verdict[data-tone="watch"] { color: var(--tone-watch); }
.detail-verdict[data-trigger="true"] { background: rgba(255, 77, 77, .1); }
.detail-verdict strong { display: block; font-size: 12.5px; }
.detail-verdict span { color: var(--r2-text-dim); font-size: 11px; }

.detail-hours { display: flex; align-items: flex-end; gap: 3px; height: 62px; padding-top: 4px; }
.detail-hours .hour { flex: 1 1 0; display: grid; align-content: end; justify-items: center; gap: 3px; height: 100%; }
.detail-hours .hour i { display: block; width: 100%; min-height: 2px; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, var(--tone-quiet), rgba(110, 200, 240, .25)); }
.detail-hours .hour b { color: var(--r2-text-dim); font-size: 8px; font-weight: 600; }

.slider-row { display: grid; gap: 5px; font-size: 11px; color: var(--r2-text-dim); }
.slider-row strong { color: var(--cyan, #61c9f2); }
.slider-row input[type="range"] { width: 100%; accent-color: var(--cyan, #61c9f2); }
.detail-controls .hint { margin: 4px 0 0; color: var(--r2-text-dim); font-size: 10px; }
.detail-actions { display: flex; gap: 6px; }
.detail-actions .ghost {
  flex: 1 1 auto; padding: 7px 9px; border: 1px solid var(--r2-line-strong);
  border-radius: 8px; background: transparent; color: #eaf5f8; font-size: 11.5px; cursor: pointer;
}
.detail-actions .ghost:hover { background: rgba(255, 255, 255, .06); }
.detail-actions .danger { color: #ff8f8f; border-color: rgba(255, 77, 77, .35); }
.detail-empty { margin: 0; color: var(--r2-text-dim); font-size: 11.5px; }

/* ------------------------------------------------- weather panel --- */
/* Apple Weather in shape: current conditions, a scrollable hourly strip,
   then seven days whose bars share one temperature scale. It floats over the
   map rather than taking a row of its own, so the map stays the biggest
   thing on the screen — which is the point of this tab. */

.wx {
  position: absolute;
  z-index: 40;
  left: 12px;
  bottom: 12px;
  width: min(392px, calc(100% - 24px));
  max-height: min(560px, calc(100% - 96px));
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 20px;
  background: rgba(8, 20, 27, .72);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .48);
  overflow: hidden;
}

.wx-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 14px 14px 10px;
}
.wx-eyebrow {
  display: block;
  color: var(--r2-text-dim);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.wx-head h2 { margin: 2px 0 0; font-size: 13.5px; font-weight: 700; }

.wx-reset,
.wx-collapse {
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  color: #dbeaf0;
  font-size: 10.5px;
  font-weight: 650;
}
.wx-reset:hover, .wx-collapse:hover { background: rgba(255, 255, 255, .12); }
.wx-reset[hidden] { display: none !important; }
.wx-collapse { display: inline-flex; padding: 5px; }
.wx-collapse svg { width: 16px; height: 16px; transition: transform 220ms var(--ease, ease); }
.wx.is-collapsed .wx-collapse svg { transform: rotate(180deg); }

.wx-body { overflow-y: auto; overscroll-behavior: contain; padding: 0 14px 12px; }
.wx.is-collapsed .wx-body { display: none; }

/* current conditions */
.wx-now {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 4px 2px 14px;
}
.wx-now-icon { width: 38px; height: 38px; stroke: #cfe9f4; stroke-width: 1.4; }
.wx-now-temp { font-size: 42px; font-weight: 300; line-height: 1; letter-spacing: -.02em; }
.wx-now-meta { min-width: 0; }
.wx-now-meta span { display: block; font-size: 12.5px; }
.wx-now-meta small { display: block; margin-top: 2px; color: var(--r2-text-dim); font-size: 11px; }

/* hourly strip */
.wx-hours {
  display: flex;
  gap: 2px;
  padding: 10px 2px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}
.wx-hours::-webkit-scrollbar { height: 5px; }
.wx-hours::-webkit-scrollbar-thumb { border-radius: 3px; background: rgba(255, 255, 255, .16); }
.wx-hour {
  flex: 0 0 auto;
  display: grid;
  gap: 5px;
  justify-items: center;
  min-width: 48px;
  padding: 4px 4px 2px;
  border-radius: 12px;
  scroll-snap-align: start;
}
.wx-hour.is-now { background: rgba(255, 255, 255, .08); }
.wx-hour-time { color: var(--r2-text-dim); font-size: 10.5px; font-weight: 650; }
.wx-hour.is-now .wx-hour-time { color: #eaf6fa; }
.wx-hour-icon { width: 19px; height: 19px; stroke: #cfe9f4; stroke-width: 1.5; }
.wx-hour-rain { min-height: 12px; color: #7fc9ec; font-size: 10px; font-weight: 700; }
.wx-hour-rain[data-faint="true"] { opacity: 0; }
.wx-hour-temp { font-size: 13px; font-weight: 600; }
.wx-hour-temp:not([style]) { color: var(--r2-text-dim); opacity: .5; }

/* seven days */
.wx-days { margin: 0; padding: 4px 0 0; list-style: none; }
.wx-days .day {
  display: grid;
  grid-template-columns: 40px 22px 38px 30px minmax(60px, 1fr) 34px;
  gap: 8px;
  align-items: center;
  padding: 7px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.wx-days .day:last-child { border-bottom: 0; }
.day-name { font-size: 12px; font-weight: 650; color: #e6f2f6; }
.day-icon { width: 20px; height: 20px; fill: none; stroke: #cfe9f4; stroke-width: 1.5; }
.day-rain { text-align: left; }
.day-rain b { color: #7fc9ec; font-size: 11.5px; font-weight: 700; }
.day-rain small { display: block; color: var(--r2-text-dim); font-size: 9.5px; }
.day-rain[data-faint="true"] b { color: var(--r2-text-dim); }
.day-low { color: var(--r2-text-dim); font-size: 12px; text-align: right; }
.day-temp { font-size: 12.5px; font-weight: 600; text-align: right; }

.wx-bar {
  position: relative;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .12);
}
.wx-bar i { position: absolute; top: 0; height: 100%; border-radius: 3px; }
.wx-now-dot {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  border: 1.5px solid rgba(10, 20, 26, .9);
  border-radius: 50%;
  background: #fff;
  transform: translateY(-50%);
}

.wx-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  color: var(--r2-text-dim);
  font-size: 10px;
}
.wx-source { opacity: .7; }
.day-empty { padding: 14px; color: var(--r2-text-dim); font-size: 11.5px; text-align: center; list-style: none; }

/* status pill tones in the topbar */
.system-live[data-tone="sync"] i { background: var(--tone-watch); }
.system-live[data-tone="warn"] i { background: var(--tone-high); }

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

@media (max-width: 1180px) {
  .radar2 {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(430px, 64vh) auto;
    grid-template-areas: "map" "rail";
    height: auto;
  }
  .area-rail { max-height: none; }
  .area-detail { max-height: none; }
}

@media (max-width: 720px) {
  .radar2 { padding: 8px; gap: 8px; }
  .map-hud { left: 8px; right: 8px; flex-wrap: wrap; }
  .map-hud-top { top: 8px; }
  .map-hud-bottom { bottom: 8px; }
  .radius-control { min-width: 0; width: 100%; }
  .wx { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 52%; }
}

/* The radius control moves right so the weather panel owns the bottom-left. */
.map-hud-bottom { justify-content: flex-end; }
.map-hud-bottom .place-hint { margin-right: auto; }
