/* Firewatcher dashboard — floating-panel map UI */

:root {
  color-scheme: light;
  --glass: rgba(252, 252, 251, 0.86);
  --glass-strong: rgba(252, 252, 251, 0.95);
  --ink: #17150f;
  --ink-2: #52514e;
  --ink-muted: #8a8781;
  --grid: #e3e2da;
  --baseline: #c3c2b7;
  --border: rgba(23, 21, 15, 0.1);
  --accent: #eb6834;
  --accent-ink: #b44417;
  --accent-soft: rgba(235, 104, 52, 0.14);
  --track-off: #cfcdc4;
  --shadow: 0 8px 28px rgba(23, 21, 15, 0.16);
  --radius: 16px;
  --panel-w: 22.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --glass: rgba(24, 24, 22, 0.82);
    --glass-strong: rgba(24, 24, 22, 0.94);
    --ink: #f2efe9;
    --ink-2: #bdb9af;
    --ink-muted: #8a8781;
    --grid: #34332e;
    --baseline: #45443e;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #f0713c;
    --accent-ink: #f79066;
    --accent-soft: rgba(240, 113, 60, 0.2);
    --track-off: #4a4942;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font: 14.5px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Floating brand */

.brand {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 1000;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.brand-name { font-weight: 750; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.78rem; color: var(--ink-2); }
.brand nav { display: flex; gap: 0.8rem; margin-left: 0.5rem; font-size: 0.8rem; font-weight: 550; }

/* Panel */

.panel {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 1000;
  width: var(--panel-w);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scrollbar-width: thin;
  overscroll-behavior: contain;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.panel.hidden { transform: translateX(calc(100% + 20px)); opacity: 0; pointer-events: none; }

.panel-toggle {
  position: fixed;
  top: 14px;
  right: calc(var(--panel-w) + 26px);
  z-index: 1001;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--ink-2);
  font-size: 1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: right 0.28s ease;
}

.panel-toggle.panel-hidden-state { right: 14px; }
.panel-toggle:hover { color: var(--accent-ink); }

/* Cards */

.card {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.95rem 1rem;
  flex: 0 0 auto;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}

.card h2 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
  color: var(--ink-2);
}

.muted { font-size: 0.75rem; color: var(--ink-muted); }
.note { font-size: 0.76rem; color: var(--ink-muted); margin: 0.6rem 0 0; }
.note.tight { margin: -0.2rem 0 0.5rem; }

/* Today */

.today-stats { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 0.7rem; }
.today-stats[hidden] { display: none; }

.stat {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
}

.stat-value {
  font-size: 1.08rem;
  font-weight: 750;
  min-width: 5.2rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stat-label { font-size: 0.74rem; color: var(--ink-2); }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.2rem; }

.chip {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.28rem 0.75rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.chip:hover { color: var(--accent-ink); border-color: var(--accent); }
.chip-accent { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-soft); }

/* Layers */

.layer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.4rem 0;
}

.switch {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch .track {
  flex: 0 0 auto;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--track-off);
  position: relative;
  transition: background 0.18s ease;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s ease;
}

.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.layer-name { font-size: 0.88rem; font-weight: 550; }
.layer-name small { display: block; font-size: 0.7rem; font-weight: 500; color: var(--ink-muted); letter-spacing: 0.02em; }

.layer input[type="range"] { width: 5rem; accent-color: var(--accent); }

.layer-extra {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.4rem 2.55rem;
  font-size: 0.78rem;
  color: var(--ink-2);
}

.layer-extra input[type="date"] {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.15rem 0.45rem;
}

/* FWI legend */

.legend { margin: 0.1rem 0 0.5rem 2.55rem; }

.legend-bar {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #5faf4e 0%, #d9e14f 22%, #efb138 42%, #e2601f 62%, #b81e1e 80%, #571212 100%);
  border: 1px solid var(--border);
}

.legend-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 0.15rem;
}

.legend-note { display: block; font-size: 0.7rem; color: var(--ink-muted); margin-top: 0.2rem; }

/* Region card */

.region-select {
  width: 100%;
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.6rem;
}

.region-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.region-card .chart { margin-top: 0.3rem; }

/* Chart */

.chart svg { display: block; width: 100%; height: auto; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--baseline); stroke-width: 1; }
.chart .bar { fill: var(--accent); }
.chart .bar-hit { fill: transparent; cursor: pointer; }
.chart .bar.hover { opacity: 0.8; }
.chart text { font: 10.5px system-ui, -apple-system, "Segoe UI", sans-serif; fill: var(--ink-muted); }
.chart .tick-y { font-variant-numeric: tabular-nums; }
.chart .direct-label { fill: var(--ink-2); font-weight: 600; }

.chart-table { margin-top: 0.4rem; font-size: 0.78rem; }
.chart-table summary { cursor: pointer; color: var(--ink-2); }
.chart-table table { border-collapse: collapse; width: 100%; margin-top: 0.4rem; }
.chart-table th, .chart-table td {
  text-align: left;
  padding: 0.2rem 0.4rem;
  border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
}

/* About */

.about summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.about summary::after { content: "▸"; color: var(--ink-muted); transition: transform 0.15s; }
.about[open] summary::after { transform: rotate(90deg); }
.about summary::-webkit-details-marker { display: none; }
.about p { font-size: 0.82rem; color: var(--ink-2); margin: 0.5rem 0; }

.attribution {
  border-top: 1px solid var(--border);
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  font-size: 0.7rem;
  color: var(--ink-muted);
}
.attribution p { margin: 0.2rem 0; font-size: inherit; color: inherit; }

/* Tooltip */

.tooltip {
  position: fixed;
  z-index: 2000;
  pointer-events: none;
  background: var(--glass-strong);
  backdrop-filter: blur(10px);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem;
  max-width: 14rem;
}

.tooltip .t-title { font-weight: 650; }
.tooltip .t-value { color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* Leaflet chrome */

.leaflet-container { font: inherit; }

.leaflet-bottom.leaflet-left .leaflet-control-zoom {
  margin: 0 0 24px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.leaflet-control-zoom a {
  background: var(--glass-strong);
  color: var(--ink);
  border-color: var(--border) !important;
}

.leaflet-control-zoom a:hover { color: var(--accent-ink); background: var(--glass-strong); }

.leaflet-control-attribution {
  background: var(--glass) !important;
  color: var(--ink-muted);
  font-size: 0.65rem;
  border-radius: 8px 0 0 0;
}
.leaflet-control-attribution a { color: var(--ink-2); }

/* Mobile: bottom sheet */

@media (max-width: 760px) {
  .panel {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: 52vh;
  }

  .panel.hidden { transform: translateY(calc(100% + 16px)); }

  .panel-toggle { top: auto; bottom: calc(52vh + 18px); right: 10px; transition: bottom 0.28s ease; }
  .panel-toggle.panel-hidden-state { bottom: 10px; right: 10px; }

  .brand { max-width: calc(100vw - 80px); flex-wrap: wrap; row-gap: 0; padding: 0.45rem 0.85rem; }
  .brand-sub { display: none; }

  .leaflet-bottom.leaflet-left .leaflet-control-zoom { display: none; }
}

/* Language toggle */

.lang-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--accent-ink);
}

.lang-toggle:hover { text-decoration: underline; }

/* Symbol legends for the detection layers */

.sym-legend { margin-top: 0.15rem; }

.sym-list {
  list-style: none;
  margin: 0.3rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.8rem;
}

.sym-list li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--ink-2);
}

.sym {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.sym.sq { border-radius: 2px; }

/* Climate & fire scatter */

.climate-chips { margin-bottom: 0.5rem; }

.dot {
  fill: var(--accent);
  opacity: 0.75;
  stroke: none;
  cursor: pointer;
  transition: opacity 120ms;
}

.dot:hover, .dot:focus { opacity: 1; outline: none; }

.dot-peak { fill: var(--accent-ink); opacity: 0.95; }

/* Tile-loading pill */

.tiles-loading {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.78rem;
  color: var(--ink-2);
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.tiles-loading .spinner {
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: tl-spin 0.9s linear infinite;
}

@keyframes tl-spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .tiles-loading { bottom: auto; top: 64px; }
}
