:root {
  --bg: #0b0d10;
  --panel: #14171c;
  --panel-border: #262b33;
  --text: #e8ecf1;
  --text-dim: #8b93a1;
  --accent: #ff6b35;
  --green: #3ddc84;
  --amber: #ffb020;
  --red: #ff4d4f;
  /* The floor was 12px, which every viewport under ~1270px wide hit (the 1.1vw
     term dominates). That rendered 0.65rem labels at 7.8px. 14px is the lowest
     floor that keeps the smallest label legible. */
  font-size: clamp(14px, min(1.1vw, 1.8vh), 22px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  /* 'Segoe UI' and Roboto are both absent on Apple platforms, so Mac and iOS
     fell through to Helvetica — poor at the small sizes this UI leans on.
     system-ui/-apple-system gets them SF instead. */
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

a { color: var(--accent); }

/* Every figure on this page is repainted on each poll. Proportional digits
   change width as they change value, so the numbers visibly twitch. */
.stat-tile .value, .fire-summary .metric .n, .feed-status-row,
.fire-list li .meta, .hotspot-row, .aircraft-list li .meta {
  font-variant-numeric: tabular-nums;
}

/* Nothing defined a focus indicator, so keyboard users were relying on the UA
   default ring, which is near-invisible over these dark panels. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.dashboard {
  display: grid;
  grid-template-columns: 1.1fr 1.6fr 1.1fr;
  grid-template-rows: auto 1fr auto;
  gap: 0.6rem;
  height: 100vh;
  height: 100dvh; /* mobile browsers shrink the viewport when the URL bar shows */
  padding: 0.6rem;
}

.header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.8rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 0.5rem;
}

.header h1 {
  font-size: 1.3rem;
  margin: 0;
  letter-spacing: 0.02em;
}
.header h1 .accent { color: var(--accent); }
/* Orange is the fire colour. Account/Log out are chrome and were competing with
   the data for it; the upsell links keep the accent because they are the CTA. */
#auth-nav a { color: var(--text-dim); }
#auth-nav a:hover { color: var(--text); }

/* These start empty and are filled by the first poll. Deferring the scripts made
   the shell paint before that data lands, so without a reserved height the
   header grew ~90px on a phone and shoved the map — the largest thing on
   screen — down with it. That was 0.878 of cumulative layout shift. Reserving
   the filled height costs nothing and holds the page still. */
#feed-status-row, #auth-nav { min-height: 1.2rem; }
#fire-summary { min-height: 3.6rem; }

.feed-status-row { display: flex; gap: 1rem; font-size: 0.75rem; color: var(--text-dim); }
.feed-status { display: flex; align-items: center; gap: 0.35rem; }
.feed-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--green); }
.feed-status.stale .feed-dot { background: var(--amber); }
.feed-status.error .feed-dot { background: var(--red); }
.feed-status.stale, .feed-status.error { color: var(--amber); }
/* The page polls constantly but had no motion anywhere, so a live dashboard and
   a frozen one looked identical. A healthy feed breathes; a stale or errored one
   holds still, so stillness is itself the warning. */
@keyframes fw-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.feed-status:not(.stale):not(.error) .feed-dot {
  animation: fw-pulse 2.4s ease-in-out infinite;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 0.5rem;
  padding: 0.7rem 0.9rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 0 0 0.5rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.col-fires { grid-column: 1; grid-row: 2; }
.col-map { grid-column: 2; grid-row: 2; padding: 0; }
.col-map #map { width: 100%; height: 100%; border-radius: 0.5rem; }
.col-right { grid-column: 3; grid-row: 2; display: flex; flex-direction: column; gap: 0.6rem; min-height: 0; }
/* Weather is a fixed set of tiles, so it takes its natural height instead of an
   equal third — splitting the column three ways squeezed the tiles and left the
   aircraft list with nowhere to put its entries. */
.col-right #weather-panel { flex: 0 0 auto; }
.col-right #alerts-panel { flex: 1 1 30%; min-height: 6rem; }
.col-right #aircraft-panel { flex: 1 1 70%; min-height: 8rem; }
#aircraft-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.footer {
  grid-column: 1 / -1;
  font-size: 0.65rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.8rem;
  gap: 1rem;
}
/* Was amber, which is the alert colour — a permanent legal notice and a live
   weather alert should not speak in the same voice. Full-contrast text keeps
   its prominence without borrowing the alert semantics. */
.footer .disclaimer { color: var(--text); font-weight: 600; flex: 1; }
.footer .attribution a { color: var(--text-dim); text-decoration: underline; }
.footer .attribution { display: flex; gap: 0.8rem; flex-wrap: wrap; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.stat-tile {
  background: #1b1f26;
  border-radius: 0.35rem;
  padding: 0.5rem 0.6rem;
}
.stat-tile.wide { grid-column: 1 / -1; }
.stat-tile.alert { border-left: 2px solid var(--amber); }
.stat-tile .label { font-size: 0.65rem; color: var(--text-dim); text-transform: uppercase; }
.stat-tile .value { font-size: 1.4rem; font-weight: 600; }
.stat-tile .value.sm { font-size: 0.8rem; font-weight: 500; line-height: 1.35; }
.stat-tile .value .unit { font-size: 0.8rem; color: var(--text-dim); font-weight: 400; }
.stat-tile .wind-dir { font-size: 0.8rem; color: var(--text-dim); font-weight: 600; }
/* inline-block so the rotation applies; the glyph points downwind */
.wind-arrow { display: inline-block; font-size: 0.9rem; color: var(--accent); }

.fire-summary { display: flex; gap: 0.8rem; margin-bottom: 0.6rem; }
.fire-summary .metric { flex: 1; text-align: center; background: #1b1f26; border-radius: 0.35rem; padding: 0.4rem; }
.fire-summary .metric .n { font-size: 1.3rem; font-weight: 700; color: var(--accent); }
/* A zero was rendering in the same emergency orange as 24 uncontained fires.
   Nothing to report should recede, not shout. */
.fire-summary .metric .n.zero { color: var(--text-dim); }
.fire-summary .metric .l { font-size: 0.6rem; color: var(--text-dim); text-transform: uppercase; }
/* The headline counts every active acre; this keeps the narrower "still
   spreading" figure visible without a fourth tile. */
.fire-summary .metric .sub {
  font-size: 0.55rem; color: var(--text-dim); margin-top: 0.15rem;
  font-variant-numeric: tabular-nums;
}

/* These scroll rather than truncate — the old behaviour measured the container
   and dropped every entry that did not fit, so aircraft and alerts vanished
   with no indication anything was missing. */
.fire-list, .alert-list, .aircraft-list {
  list-style: none; margin: 0; padding: 0 0.4rem 0 0;
  overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0;
  scrollbar-width: thin; scrollbar-color: var(--panel-border) transparent;
}
.fire-list::-webkit-scrollbar, .alert-list::-webkit-scrollbar, .aircraft-list::-webkit-scrollbar { width: 0.4rem; }
.fire-list::-webkit-scrollbar-thumb, .alert-list::-webkit-scrollbar-thumb, .aircraft-list::-webkit-scrollbar-thumb {
  background: var(--panel-border); border-radius: 0.2rem;
}
.fire-list li, .alert-list li, .aircraft-list li {
  padding: 0.4rem 0; border-bottom: 1px solid var(--panel-border); font-size: 0.78rem;
}
/* Fire rows fly the map to the fire, so they need to read as interactive.
   Bleeding into the panel padding keeps the hover band full-width. */
.fire-list li { padding-inline: 0.5rem; margin-inline: -0.5rem; cursor: pointer; }
.fire-list li:hover { background: #1b1f26; }

/* Containment as a number is unscannable across 47 rows. As a bar of what is
   still uncontained, the longest mark is always the most dangerous fire, and a
   fully contained one falls silent. */
.fire-list li .containment {
  height: 2px; margin-top: 0.3rem; border-radius: 1px;
  background: var(--panel-border); overflow: hidden;
}
.fire-list li .containment span { display: block; height: 100%; background: var(--accent); }
.fire-list li .containment span.unknown { background: #3a414d; }
/* Line complete. Green because the line holding is good news — but the row is
   still in the list, because the fire is still burning. */
.fire-list li .containment span.lined { background: var(--green); }

.fire-note {
  font-size: 0.6rem; color: var(--text-dim); font-style: italic;
  line-height: 1.4; margin-bottom: 0.6rem;
}
.fire-list li:last-child, .alert-list li:last-child, .aircraft-list li:last-child { border-bottom: none; }
.fire-list li .name, .aircraft-list li .name { font-weight: 600; }
.fire-list li .meta, .aircraft-list li .meta { color: var(--text-dim); font-size: 0.7rem; line-height: 1.35; }
.fire-list li.new-24h .name::after { content: ' \25CF NEW'; color: var(--red); font-size: 0.65rem; }
/* De-emphasis used to be opacity: 0.55, which dropped the meta line to 2.64:1
   and the tag to 2.39:1 — both well under WCAG AA. No opacity below 1.0 clears
   4.5:1 here, because the base colours already sit near the floor.
   Weight alone now carries the distinction: greying the name as well made a
   contained-but-still-burning fire read as a resolved, ignorable row. */
.fire-list li.contained .name { font-weight: 400; }
.tag-contained {
  margin-left: 0.4rem; padding: 0.05rem 0.3rem; border-radius: 0.2rem;
  background: var(--panel-border); color: #a3acbb;
  font-size: 0.55rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  vertical-align: middle;
}
.aircraft-list .ac-type { color: var(--text-dim); font-weight: 400; }

.alert-list li { color: var(--amber); }
.alert-list li .event { font-weight: 700; }
/* NWS ships a severity on every alert and it was being thrown away, so a Red
   Flag Warning rendered identically to an air quality advisory. Amber stays the
   default; only Severe and Extreme escalate. */
.alert-list li.sev-severe, .alert-list li.sev-extreme {
  color: var(--red); border-left: 2px solid var(--red);
  padding-left: 0.5rem; margin-left: -0.5rem;
}
.alert-list li.sev-minor { color: var(--text-dim); }
.alert-list .none, .fire-list .none, .aircraft-list .none { color: var(--text-dim); font-size: 0.78rem; }

.picker { margin-bottom: 0.6rem; }
.picker select {
  width: 100%; background: #1b1f26; color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 0.35rem; padding: 0.4rem; font-size: 0.8rem;
}

.locked-panel {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; text-align: center; gap: 0.5rem; color: var(--text-dim);
}
.locked-panel a { font-weight: 600; }

.legend { display: flex; gap: 0.8rem; font-size: 0.65rem; color: var(--text-dim); margin-top: 0.4rem; }
.legend .dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; margin-right: 0.25rem; }
.legend .fire .dot { background: var(--green); }
.legend .possible .dot { background: var(--amber); }
.legend .background .dot { background: #555; }

.maplibregl-popup-content {
  background: var(--panel); color: var(--text); font-size: 0.75rem; border: 1px solid var(--panel-border);
}
.maplibregl-ctrl-attrib { font-size: 0.6rem; }

.upsell-banner {
  font-size: 0.65rem; color: var(--text-dim); text-align: center; padding: 0.3rem; border-top: 1px dashed var(--panel-border); margin-top: 0.4rem;
}
.upsell-banner a { font-weight: 600; }

/* --- Narrow screens ------------------------------------------------------
   The three-column grid assumes a wide, fixed-height display. Below ~900px it
   stops fitting, so the dashboard becomes a single scrolling column: map first
   at a fixed height, then the panels at their natural size. */
@media (max-width: 900px) {
  /* The viewport-scaled root size exists so the fixed-height desktop grid fits
     in 100dvh. Below 900px the page scrolls instead, so there is nothing to fit
     and the scaling only shrank body text to 7-9px. A flat 16px restores it. */
  :root { font-size: 16px; }

  html, body { overflow: auto; height: auto; }

  .dashboard {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
    padding: 0.5rem;
  }

  .header {
    flex-wrap: wrap;
    gap: 0.4rem 0.8rem;
    justify-content: flex-start;
  }
  .header h1 { flex: 1 1 100%; font-size: 1.15rem; }
  .feed-status-row { flex-wrap: wrap; gap: 0.5rem 0.8rem; }
  /* The status row wraps to two lines at phone widths, so it needs more
     reserved height here than the single desktop line. */
  #feed-status-row { min-height: 2.6rem; }
  #auth-nav { min-height: 2rem; }

  /* Every panel here is filled client-side and stacks vertically, so each one
     growing from nothing drags all its siblings down the page. The :empty
     reservations apply only until the first render and cost nothing after, so
     a short list never leaves a gap. Sized from the measured filled heights. */
  #weather-tiles:empty { min-height: 15rem; }
  #hotspot-summary:empty { min-height: 7.5rem; }
  #fire-list:empty { min-height: 60vh; }
  #alert-list:empty, #aircraft-body:empty { min-height: 6rem; }

  /* Order: map, fires, then the right-hand panels. Every child needs an
     explicit order — flex defaults to 0, which would float the footer above
     anything given a positive order. */
  .header { order: 0; }
  .col-map { order: 1; height: 55dvh; min-height: 16rem; }
  .col-fires { order: 2; }
  .col-right { order: 3; }
  .footer { order: 4; }

  /* Panels size to content and the page scrolls, rather than each panel
     scrolling inside a squeezed box. */
  .panel { overflow: visible; }
  .col-right #alerts-panel, .col-right #aircraft-panel, .col-right #weather-panel { flex: 0 0 auto; }
  /* No nested scrollers on touch — a scrollable list inside a scrollable page
     swallows the swipe and strands you mid-page. The lists render full height
     and the page is the only thing that scrolls. */
  .fire-list, .alert-list, .aircraft-list { overflow-y: visible; overscroll-behavior: auto; }

  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-tile .value { font-size: 1.2rem; }
  .fire-summary { gap: 0.5rem; }

  .footer { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .footer .attribution { gap: 0.5rem 0.8rem; }

  /* These links rendered 9-10px tall — under the 24px WCAG 2.5.8 target size.
     Padding lifts the hit area without moving the text. */
  .footer .attribution a, #auth-nav a {
    display: inline-block; padding: 0.45rem 0; min-height: 1.5rem;
  }

  /* Anything under 0.7rem still lands below 11px at a 16px root. The dense
     desktop sizing does not survive the trip to a phone. */
  .tag-contained, .fire-summary .metric .l, .fire-summary .metric .sub,
  .stat-tile .label, .footer, .legend, .upsell-banner, .fire-note {
    font-size: 0.75rem;
  }
}

@media (max-width: 520px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .col-map { height: 45dvh; }
}

/* --- Auth / marketing pages (login, signup, pricing, account, legal) --- */
body.page {
  overflow: auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
}
.site-nav {
  width: 100%; max-width: 960px; display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 2rem; font-size: 0.9rem;
}
.site-nav .brand { font-weight: 700; letter-spacing: 0.02em; }
.site-nav .brand .accent { color: var(--accent); }
.site-nav a { color: var(--text-dim); text-decoration: none; margin-left: 1rem; }
.site-nav a:hover { color: var(--text); }

.card {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 0.5rem;
  padding: 1.5rem; width: 100%; max-width: 380px;
}
.card h1 { font-size: 1.3rem; margin-top: 0; }
.card label { display: block; font-size: 0.8rem; color: var(--text-dim); margin: 0.8rem 0 0.3rem; }
.card input {
  width: 100%; padding: 0.6rem; border-radius: 0.35rem; border: 1px solid var(--panel-border);
  background: #1b1f26; color: var(--text); font-size: 0.9rem;
}
.card button, .btn {
  display: inline-block; margin-top: 1.2rem; width: 100%; padding: 0.65rem; border: none; border-radius: 0.35rem;
  background: var(--accent); color: #12100e; font-weight: 700; font-size: 0.9rem; cursor: pointer; text-align: center;
  text-decoration: none;
}
.card button:hover, .btn:hover { filter: brightness(1.08); }
.btn.secondary { background: transparent; border: 1px solid var(--panel-border); color: var(--text); }
.form-msg { font-size: 0.8rem; color: var(--red); margin-top: 0.6rem; min-height: 1em; }
.form-msg.ok { color: var(--green); }
.muted-link { text-align: center; font-size: 0.8rem; margin-top: 1rem; color: var(--text-dim); }

.plans { display: flex; gap: 1.2rem; flex-wrap: wrap; justify-content: center; max-width: 1000px; }
.plan-card {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 0.5rem; padding: 1.5rem;
  width: 260px; display: flex; flex-direction: column;
}
.plan-card.featured { border-color: var(--accent); }
.plan-card .price { font-size: 2rem; font-weight: 700; margin: 0.4rem 0; }
.plan-card .price .period { font-size: 0.9rem; color: var(--text-dim); font-weight: 400; }
.plan-card ul { list-style: none; padding: 0; margin: 1rem 0; flex: 1; font-size: 0.85rem; }
.plan-card li { padding: 0.3rem 0; border-bottom: 1px solid var(--panel-border); }
.plan-card li.excluded { color: var(--text-dim); text-decoration: line-through; }

.page-content { max-width: 720px; font-size: 0.9rem; line-height: 1.6; color: var(--text); }
.page-content h1 { font-size: 1.5rem; }
.page-content h2 { font-size: 1.1rem; margin-top: 1.8rem; }
.page-content .callout { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 0.5rem; padding: 1rem; margin: 1rem 0; }

/* --- Satellite hotspots (NASA FIRMS) --- */
#hotspot-summary { margin-bottom: 0.6rem; }
.hotspot-none { font-size: 0.68rem; color: var(--text-dim); }
.hotspot-alert {
  border: 1px solid #ff2d55; border-left-width: 3px; border-radius: 0.35rem;
  padding: 0.45rem 0.6rem; background: rgba(255, 45, 85, 0.08);
}
.hotspot-title { font-size: 0.72rem; font-weight: 700; color: #ff6b81; text-transform: uppercase; letter-spacing: 0.04em; }
.hotspot-row { font-size: 0.68rem; color: var(--text); margin-top: 0.2rem; }
.hotspot-note { font-size: 0.6rem; color: var(--text-dim); margin-top: 0.3rem; font-style: italic; }

/* Same 0.75rem mobile floor as the block above. It has to live down here: this
   hotspot section is declared after the media query, so an override up there
   loses the cascade to the two rules directly above this one. */
@media (max-width: 900px) {
  .hotspot-note, .hotspot-none { font-size: 0.75rem; }
}
