/* ============================================================================
   styles.css — SB County Fire Weather prototype.
   Newsroom identity: rust red header/accents, warm cream surfaces, near-black
   ink, slate for secondary data. Serif display title, clean sans for data/UI,
   tabular numerals on all readings. NOT a dark dashboard.
   ========================================================================== */

:root {
  --rust:        #8C3B2E;
  --rust-dark:   #6E2C22;
  --rust-tint:   #B4583F;
  --cream:       #F7F2E7;
  --cream-2:     #FBF8F0;
  --cream-panel: #FCFAF3;
  --ink:         #211D18;
  --ink-soft:    #4A4239;
  --slate:       #5E6B78;
  --slate-2:     #8A97A3;
  --line:        #E4DCC9;
  --line-2:      #D6CCB4;

  /* fire-weather / status tones */
  --low:      #3C7A4B;
  --low-bg:   #E7F0E4;
  --mod:      #B67B12;
  --mod-bg:   #FBF0D8;
  --high:     #C24A16;
  --high-bg:  #FBE3D3;
  --extreme:  #A32020;
  --extreme-bg:#F7D9D6;

  --sans: "Source Sans 3", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --shadow: 0 10px 30px rgba(33,29,24,0.18);
  --num: "tnum" 1, "lnum" 1;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--cream);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;               /* map owns the viewport */
  -webkit-font-smoothing: antialiased;
}
.num { font-variant-numeric: tabular-nums lining-nums; font-feature-settings: var(--num); }

/* ---- Header --------------------------------------------------------- */
.sbw-header {
  background: var(--rust);
  color: var(--cream);
  border-bottom: 3px solid var(--rust-dark);
  flex: 0 0 auto;
}
.sbw-header-inner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; max-width: 1400px; margin: 0 auto;
}
.sbw-logo { color: var(--cream); flex: 0 0 auto; }
.sbw-header-titles { display: flex; flex-direction: column; }
.sbw-title {
  font-family: var(--serif); font-weight: 700;
  font-size: 22px; line-height: 1.1; margin: 0; letter-spacing: 0.1px;
}
.sbw-subtitle { font-size: 12.5px; margin: 2px 0 0; color: rgba(247,242,231,0.8); font-weight: 400; }

/* ---- Button strip --------------------------------------------------- */
.sbw-strip {
  flex: 0 0 auto;
  display: flex; gap: 8px;
  padding: 9px 18px;
  background: var(--cream-2);
  border-bottom: 1px solid var(--line);
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: thin;
}
.sbw-btn {
  position: relative;
  flex: 0 0 auto;
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  color: var(--ink); background: #fff;
  border: 1px solid var(--line-2); border-radius: 999px;
  padding: 8px 15px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.sbw-btn:hover { border-color: var(--rust-tint); box-shadow: 0 2px 6px rgba(140,59,46,0.12); }
.sbw-btn:active { transform: translateY(1px); }
.sbw-btn-badge {
  font-size: 11px; font-weight: 700; line-height: 1;
  padding: 3px 7px; border-radius: 999px;
  background: var(--slate-2); color: #fff; letter-spacing: .2px;
}
.sbw-btn-badge.dot-only { padding: 0; width: 9px; height: 9px; border-radius: 50%; }
/* tones set the badge + a subtle left cue */
.sbw-btn.tone-ok    .sbw-btn-badge { background: var(--low); }
.sbw-btn.tone-warn  { border-color: var(--mod); background: var(--mod-bg); }
.sbw-btn.tone-warn  .sbw-btn-badge { background: var(--mod); }
.sbw-btn.tone-alert { border-color: var(--extreme); background: var(--extreme-bg); }
.sbw-btn.tone-alert .sbw-btn-badge { background: var(--extreme); }

/* ---- Red Flag banner ------------------------------------------------ */
.sbw-alertbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  background: var(--extreme); color: #fff;
  padding: 9px 18px; font-size: 14px;
  border-bottom: 1px solid var(--extreme-bg);
}
.sbw-alertbar-icon { font-size: 13px; }
.sbw-alertbar-text { flex: 1 1 auto; }
.sbw-alertbar-more {
  background: rgba(255,255,255,0.16); color: #fff; border: 1px solid rgba(255,255,255,0.5);
  border-radius: 6px; padding: 5px 12px; font-family: var(--sans); font-weight: 600;
  font-size: 12.5px; cursor: pointer;
}
.sbw-alertbar-more:hover { background: rgba(255,255,255,0.28); }

/* ---- Map region ----------------------------------------------------- */
.sbw-map-region { flex: 1 1 auto; position: relative; min-height: 0; }
.sbw-map { position: absolute; inset: 0; background: var(--cream); }
.sbw-map-footnote {
  position: absolute; right: 8px; bottom: 22px; z-index: 500;
  margin: 0; font-size: 10.5px; color: var(--slate);
  background: rgba(251,248,240,0.9); padding: 3px 8px; border-radius: 4px;
  box-shadow: 0 1px 4px rgba(33,29,24,0.12);
  pointer-events: none; max-width: 340px; text-align: right;
}

/* ---- Map markers (chips) ------------------------------------------- */
.sbw-marker-wrap { background: none !important; border: none !important; }
.sbw-chip {
  display: inline-flex; align-items: center; gap: 4px;
  transform: translate(-50%, -50%);
  background: #fff; border: 1.5px solid var(--slate);
  border-radius: 999px; padding: 1px 7px 1px 5px;
  font-size: 11px; font-weight: 600; color: var(--ink);
  box-shadow: 0 1px 4px rgba(33,29,24,0.28); white-space: nowrap;
  font-family: var(--sans); transition: box-shadow .12s;
}
.sbw-marker-wrap:hover .sbw-chip { box-shadow: 0 2px 10px rgba(33,29,24,0.45); border-color: var(--rust); z-index: 900; }
/* directional label offsets to de-clutter the dense SB coastal corridor */
.sbw-chip.dir-n { transform: translate(-50%, calc(-50% - 16px)); }
.sbw-chip.dir-s { transform: translate(-50%, calc(-50% + 16px)); }
.sbw-chip.dir-e { transform: translate(calc(-50% + 62px), -50%); }
.sbw-chip.dir-w { transform: translate(calc(-50% - 62px), -50%); }
.sbw-chip-glyph { width: 9px; height: 9px; flex: 0 0 auto; }
.sbw-chip.type-asos { border-color: var(--slate); }
.sbw-chip.type-asos .sbw-chip-glyph { border-radius: 50%; background: var(--slate); }
.sbw-chip.type-raws { border-color: var(--rust); }
.sbw-chip.type-raws .sbw-chip-glyph {
  background: var(--rust); width: 0; height: 0; border-radius: 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-bottom: 9px solid var(--rust);
}
.sbw-chip-name { color: var(--ink-soft); font-weight: 600; }
.sbw-chip-val { color: var(--rust-dark); font-weight: 700; }
.sbw-chip.type-asos .sbw-chip-val { color: var(--slate); }

/* ---- Map controls: metric toggle + legend -------------------------- */
.sbw-metric-ctl {
  background: var(--cream-panel); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 6px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 4px;
}
.sbw-metric-caption { font-size: 11px; color: var(--slate); font-weight: 600; padding: 0 4px; text-transform: uppercase; letter-spacing: .5px; }
.sbw-metric-btn {
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-soft);
  border-radius: 7px; padding: 6px 11px; cursor: pointer;
}
.sbw-metric-btn:hover { border-color: var(--rust-tint); }
.sbw-metric-btn.active { background: var(--rust); color: #fff; border-color: var(--rust); }

.sbw-legend {
  background: rgba(252,250,243,0.94); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--ink-soft);
  box-shadow: 0 2px 8px rgba(33,29,24,0.12);
}
.sbw-legend-row { display: flex; align-items: center; gap: 7px; }
.sbw-legend-row + .sbw-legend-row { margin-top: 4px; }
.dot { width: 10px; height: 10px; display: inline-block; flex: 0 0 auto; }
.dot.asos { border-radius: 50%; background: var(--slate); }
.dot.raws { width: 0; height: 0; background: none;
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 10px solid var(--rust); }

/* ---- Leaflet popup override ---------------------------------------- */
.sbw-leaflet-pop .leaflet-popup-content-wrapper {
  background: var(--cream-panel); border-radius: 10px; box-shadow: var(--shadow);
}
.sbw-leaflet-pop .leaflet-popup-content { margin: 12px 14px; font-family: var(--sans); }
.sbw-pop-title { font-family: var(--serif); font-weight: 700; font-size: 15px; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.sbw-pop-type { font-family: var(--sans); font-size: 10px; font-weight: 700; color: var(--slate); border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 5px; letter-spacing: .5px; }
.sbw-pop-tbl { border-collapse: collapse; width: 100%; }
.sbw-pop-tbl th { text-align: left; font-weight: 600; color: var(--slate); font-size: 12px; padding: 2px 10px 2px 0; }
.sbw-pop-tbl td { text-align: right; font-weight: 700; font-size: 13px; padding: 2px 0; }
.sbw-pop-details {
  margin-top: 8px; width: 100%; background: var(--rust); color: #fff; border: none;
  border-radius: 7px; padding: 7px; font-family: var(--sans); font-weight: 600; font-size: 12.5px; cursor: pointer;
}
.sbw-pop-details:hover { background: var(--rust-dark); }

/* ---- Slide-over panel ---------------------------------------------- */
.sbw-backdrop {
  position: fixed; inset: 0; background: rgba(33,29,24,0.42);
  z-index: 1000; backdrop-filter: blur(1px);
}
.sbw-panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: 460px; max-width: 92vw;
  background: var(--cream-panel); z-index: 1001; box-shadow: -12px 0 34px rgba(33,29,24,0.28);
  transform: translateX(100%); transition: transform .28s cubic-bezier(.2,.7,.2,1);
  display: flex; flex-direction: column;
}
.sbw-panel.open { transform: translateX(0); }
.sbw-panel-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: var(--rust); color: var(--cream);
  border-bottom: 3px solid var(--rust-dark);
}
.sbw-panel-title { font-family: var(--serif); font-weight: 700; font-size: 19px; margin: 0; }
.sbw-panel-close {
  background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.4); color: #fff;
  width: 32px; height: 32px; border-radius: 8px; font-size: 22px; line-height: 1; cursor: pointer;
}
.sbw-panel-close:hover { background: rgba(255,255,255,0.28); }
.sbw-panel-body { flex: 1 1 auto; overflow-y: auto; padding: 18px 20px 40px; }

/* ---- Panel content primitives -------------------------------------- */
.sbw-note { color: var(--slate); font-style: italic; background: var(--cream); border: 1px dashed var(--line-2); border-radius: 8px; padding: 12px; }
.sbw-empty { color: var(--slate); background: var(--low-bg); border-radius: 8px; padding: 16px; text-align: center; }
.sbw-muted { color: var(--slate-2); font-size: 11.5px; margin-top: 12px; }
.sbw-context { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 14px; }
.sbw-subhead { font-family: var(--serif); font-size: 15px; margin: 20px 0 8px; }

.sbw-readout { border-radius: 10px; padding: 13px 15px; font-size: 14px; line-height: 1.45; margin-bottom: 16px; border-left: 5px solid var(--slate); background: var(--cream); }
.sbw-readout.cat-low { border-left-color: var(--low); background: var(--low-bg); }
.sbw-readout.cat-mod { border-left-color: var(--mod); background: var(--mod-bg); }
.sbw-readout.cat-high { border-left-color: var(--high); background: var(--high-bg); }
.sbw-readout.cat-extreme { border-left-color: var(--extreme); background: var(--extreme-bg); }

/* tables */
.sbw-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sbw-table th { text-align: left; font-weight: 700; color: var(--slate); font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; padding: 6px 8px; border-bottom: 2px solid var(--line-2); }
.sbw-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.sbw-table td.num, .sbw-table th.num { text-align: right; }
.sbw-table tbody tr.cat-low { background: var(--low-bg); }
.sbw-table tbody tr.cat-mod { background: var(--mod-bg); }
.sbw-table tbody tr.cat-high { background: var(--high-bg); }
.sbw-table tbody tr.cat-extreme { background: var(--extreme-bg); }
.sbw-table-hover tbody tr { cursor: pointer; }
.sbw-table-hover tbody tr:hover { background: var(--cream); box-shadow: inset 3px 0 0 var(--rust); }
.sbw-stn { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.sbw-row-flash { animation: rowflash 1.6s ease; }
@keyframes rowflash { 0%,100% { background: transparent; } 20% { background: var(--mod-bg); } }

.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.pill.cat-low { background: var(--low); color: #fff; }
.pill.cat-mod { background: var(--mod); color: #fff; }
.pill.cat-high { background: var(--high); color: #fff; }
.pill.cat-extreme { background: var(--extreme); color: #fff; }
.flag { color: var(--high); }

/* card grid (sundowner) */
.sbw-cardgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.sbw-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; }
.sbw-card-name { font-size: 12.5px; color: var(--slate); font-weight: 600; }
.sbw-card-main { font-size: 24px; font-weight: 700; color: var(--rust-dark); line-height: 1.1; margin-top: 3px; }
.sbw-unit { font-size: 12px; color: var(--slate); font-weight: 600; }
.sbw-card-sub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* metric grid (current) */
.sbw-metricgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sbw-metric { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; text-align: center; }
.sbw-metric-val { font-size: 26px; font-weight: 700; color: var(--rust-dark); }
.sbw-metric-lbl { font-size: 12px; color: var(--slate); margin-top: 4px; font-weight: 600; }

/* gust bar chart (sundowner) */
.sbw-bars { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding: 8px 4px 0; background: var(--cream); border-radius: 10px; }
.sbw-bar { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.sbw-bar-fill { width: 60%; min-height: 3px; border-radius: 4px 4px 0 0; background: var(--slate); }
.sbw-bar-fill.cat-low { background: var(--low); }
.sbw-bar-fill.cat-mod { background: var(--mod); }
.sbw-bar-fill.cat-high { background: var(--high); }
.sbw-bar-val { font-size: 11px; font-weight: 700; margin-top: 3px; }
.sbw-bar-lbl { font-size: 9.5px; color: var(--slate); margin-top: 1px; }

/* NWS alerts */
.sbw-alert { border: 1px solid var(--line-2); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.sbw-alert.sev-extreme, .sbw-alert.sev-severe { border-color: var(--extreme); }
.sbw-alert-head { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--cream); border: none; padding: 11px 13px; cursor: pointer; font-family: var(--sans); text-align: left; }
.sbw-alert.sev-extreme .sbw-alert-head, .sbw-alert.sev-severe .sbw-alert-head { background: var(--extreme-bg); }
.sbw-alert-event { font-weight: 700; font-size: 14px; }
.sbw-alert-sev { font-size: 11px; font-weight: 700; color: var(--extreme); text-transform: uppercase; }
.sbw-alert-body { padding: 0 13px 13px; font-size: 13px; }
.sbw-alert-when { font-weight: 600; color: var(--ink-soft); margin: 8px 0; }
.sbw-alert-area { color: var(--slate); font-size: 12px; margin-bottom: 8px; }
.sbw-alert-desc { line-height: 1.5; color: var(--ink-soft); }

/* NWS text forecast */
.sbw-fcst { border-bottom: 1px solid var(--line); padding: 12px 0; }
.sbw-fcst-name { font-weight: 700; font-size: 14px; display: flex; justify-content: space-between; }
.sbw-fcst-temp { color: var(--rust-dark); }
.sbw-fcst-text { font-size: 13px; line-height: 1.5; color: var(--ink-soft); margin-top: 4px; }

/* skeleton loader */
.sbw-skeleton .sk-line, .sbw-skeleton .sk-block { background: linear-gradient(90deg, var(--line) 25%, var(--cream) 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; }
.sk-line { height: 14px; margin-bottom: 10px; }
.sk-line.short { width: 60%; }
.sk-block { height: 160px; margin-top: 16px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- Mobile (375px) ------------------------------------------------- */
@media (max-width: 640px) {
  .sbw-title { font-size: 18px; }
  .sbw-subtitle { font-size: 11px; }
  .sbw-panel { width: 100vw; max-width: 100vw; }
  .sbw-map-footnote { max-width: 60%; font-size: 9px; bottom: 22px; }
  .sbw-cardgrid, .sbw-metricgrid { grid-template-columns: 1fr 1fr; }
  .sbw-strip { padding: 8px 12px; }
}

/* Fallback message if the panel registry script is blocked */
.sbw-strip-fallback { font: 500 13px/1.4 var(--sans); color: #8C3B2E; padding: 6px 2px; }

/* ---- Dual-engine map additions -------------------------------------- */
/* Anchor for Google Maps HTML chips (OverlayView). The .sbw-chip inside
   carries the same centering transforms used on Leaflet. */
.sbw-gchip-anchor { position: absolute; width: 0; height: 0; cursor: pointer; }
.sbw-gchip-anchor .sbw-chip { position: absolute; white-space: nowrap; }

/* Controls pushed into the Google Maps control stack need their own margins. */
.sbw-map-ctl { margin: 10px 10px 0 10px; }

/* Reset map button */
.sbw-reset-ctl { text-align: right; }
.sbw-reset-btn {
  font: 600 12.5px/1 var(--sans);
  color: var(--rust-dark);
  background: var(--cream);
  border: 1px solid rgba(140,59,46,0.45);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(33,29,24,0.25);
}
.sbw-reset-btn:hover { background: #fff; border-color: var(--rust); }

/* ---- Wind & Fuel Moisture additions ------------------------------------ */
/* Direction arrow inside map chips (wind metric) */
.sbw-chip-dir {
  display: inline-block;
  margin-right: 3px;
  font-size: 10px;
  line-height: 1;
  transform-origin: 50% 50%;
}
/* Direction arrow in the Wind panel table */
.sbw-dir-arrow {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
  transform-origin: 50% 50%;
  color: var(--rust, #b3512f);
}
/* Animated wind-flow embed (Windy.com) */
.sbw-windflow { margin: 10px 0 4px; }
.sbw-windy {
  width: 100%;
  height: 320px;
  border: 0;
  border-radius: 10px;
  display: block;
  background: #e8e4da;
}
/* Horizontal scroll wrapper for wide tables (fuel moisture) */
.sbw-xscroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 8px 0;
}
.sbw-xscroll .sbw-table { min-width: 560px; }
/* Highlight tones reused by wind/fuel tables */
.sbw-table tr.cat-mod  td { background: rgba(217, 119, 6, 0.10); }
.sbw-table tr.cat-high td { background: rgba(179, 45, 30, 0.12); }
