/* REFINERY-FIRES — cockpit/datasheet style per style-guide.md */

:root {
  --bg: #FFF;
  --surface: #F5F5F5;
  --text: #1A1A1A;
  --muted: #6B6B6B;
  --dim: #505050;
  --border: #D4D4D4;
  --subtle: #E8E8E8;
  --accent: #0057FF;
  --red: #DC2626;
  --amber: #D97706;
  --green: #16A34A;
  --cyan: #06B6D4;
  /* year colors (data channel) — pre-strike era cool/grey, escalation era warm */
  --y20: #404552;
  --y21: #5C6470;
  --y22: #7E8896;
  --y23: #9CA3AF;
  --y24: #06B6D4;
  --y25: #D97706;
  --y26: #DC2626;
  --mono: 'Berkeley Mono','JetBrains Mono','IBM Plex Mono','Courier Prime',ui-monospace,SFMono-Regular,Menlo,monospace;
  --sans: 'Neue Haas Grotesk','Univers','Akzidenz-Grotesk',-apple-system,Helvetica,Arial,sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A0A0A;
    --surface: #141414;
    --text: #E5E5E5;
    --muted: #808080;
    --dim: #606060;
    --border: #2A2A2A;
    --subtle: #1A1A1A;
    --accent: #3B82F6;
    --y20: #4A5160;
    --y21: #6E7787;
    --y22: #8E96A4;
    --y23: #B0B5BD;
    --y24: #06B6D4;
    --y25: #D97706;
    --y26: #DC2626;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-rows: 24px auto 1fr 22px;
  min-height: 100vh;
}

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

/* STATUS BAR */
.statusbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 24px;
  padding: 0 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow-x: auto;
}
.sb-cell { display: inline-flex; align-items: center; gap: 6px; }
.sb-k { color: var(--muted); text-transform: uppercase; font-size: 9px; letter-spacing: 0.06em; }
.sb-right { margin-left: auto; }
.sb-dot { width: 6px; height: 6px; background: var(--green); display: inline-block; box-shadow: 0 0 6px var(--green); }

/* KPI STRIP */
.kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.kpi {
  background: var(--bg);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.kpi-l { font-size: 8px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.kpi-v { font-size: 20px; font-weight: 300; line-height: 1.1; letter-spacing: -0.01em; }
.kpi-s { font-size: 9px; color: var(--dim); }

/* TIMELINE (bottom of map) */
.timeline {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0 8px;
  font-size: 10px;
  flex-shrink: 0;
}
.tl-yrs { display: flex; }
.tl-play { min-width: 56px; }
.tl-bar {
  flex: 1;
  height: 10px;
  background: var(--subtle);
  border: 1px solid var(--border);
  position: relative;
  cursor: crosshair;
  min-width: 80px;
}
.tl-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent);
  width: 0%;
  opacity: 0.35;
}
.tl-ticks { position: absolute; inset: 0; pointer-events: none; }
.tl-tick {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
}
.tl-cursor {
  position: absolute;
  top: -2px; bottom: -2px;
  width: 1px;
  background: var(--text);
  left: 0%;
  pointer-events: none;
}
.tl-date {
  font-size: 10px;
  min-width: 86px;
  text-align: right;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.tl-leg {
  font-size: 8px;
  color: var(--dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.yr {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  height: 20px;
  padding: 0 10px;
  margin-right: -1px;
  cursor: pointer;
  transition: background 120ms ease-out, color 120ms ease-out;
}
.yr:hover { background: var(--subtle); }
.yr.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* GRID */
.grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  min-height: 0;
}
.panel {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.panel-map { grid-row: 1 / span 2; }
.panel-yrs { grid-column: 2; grid-row: 1; }
.panel-tab { grid-column: 2; grid-row: 2; }

@media (max-width: 980px) {
  .grid { grid-template-columns: 1fr; grid-template-rows: 50vh auto auto; }
  .panel-map { grid-row: 1; grid-column: 1; }
  .panel-yrs { grid-row: 2; grid-column: 1; }
  .panel-tab { grid-row: 3; grid-column: 1; }
}

.panel-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 22px;
  padding: 0 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}
.panel-t { color: var(--text); font-weight: 400; }
.panel-r { color: var(--dim); font-size: 9px; }

/* MAP */
#map {
  flex: 1;
  min-height: 320px;
  background: var(--surface);
}
.leaflet-container {
  background: var(--surface) !important;
  font-family: var(--mono) !important;
  font-size: 10px !important;
}
.leaflet-tile-pane { filter: grayscale(1) contrast(0.95); }
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: grayscale(1) invert(0.92) contrast(0.85) brightness(0.95); }
}
.leaflet-control-attribution {
  background: rgba(0,0,0,0) !important;
  color: var(--muted) !important;
  font-size: 8px !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  font-family: var(--mono) !important;
}
.leaflet-popup-content {
  margin: 6px 8px !important;
  font-size: 10px !important;
  line-height: 1.4 !important;
}
.leaflet-popup-close-button { color: var(--muted) !important; }

/* incident bubble */
.bubble {
  border-radius: 50%;
  border: 1px solid;
  opacity: 0.7;
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) {
  .bubble { mix-blend-mode: screen; opacity: 0.78; }
}

/* YEAR TABLE */
.ytab {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.ytab th, .ytab td {
  padding: 3px 8px;
  border-bottom: 1px solid var(--subtle);
  font-size: 11px;
  text-align: left;
}
.ytab th {
  font-size: 8px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
}
.ytab .num { text-align: right; font-variant-numeric: tabular-nums; }
.ytab tr.active td { background: var(--subtle); }
.ytab tr { cursor: pointer; }
.ytab tr:hover td { background: var(--subtle); }
.dist {
  display: block;
  height: 8px;
  background: var(--subtle);
  position: relative;
}
.dist > span { display: block; height: 100%; }

/* INCIDENT TABLE */
.tab-wrap {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.itab {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}
.itab th, .itab td {
  padding: 2px 6px;
  border-bottom: 1px solid var(--subtle);
  font-size: 10px;
  white-space: nowrap;
  vertical-align: middle;
}
.itab th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  font-size: 8px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  user-select: none;
}
.itab th.num { text-align: right; }
.itab td.num { text-align: right; font-variant-numeric: tabular-nums; }
.itab tbody tr:hover td { background: var(--subtle); }
.scalebar {
  display: inline-block;
  height: 6px;
  background: var(--subtle);
  width: 60px;
  vertical-align: middle;
  position: relative;
}
.scalebar > span { display: block; height: 100%; }
.conf { font-size: 8px; letter-spacing: 0.06em; padding: 0 3px; border: 1px solid; text-transform: uppercase; }
.conf-high { color: var(--green); border-color: var(--green); }
.conf-medium { color: var(--amber); border-color: var(--amber); }
.conf-low { color: var(--muted); border-color: var(--muted); }
.cause-fire { color: var(--red); }
.cause-explosion { color: var(--red); }
.cause-drone_strike { color: var(--amber); }
.cause-equipment_failure { color: var(--cyan); }
.cause-other { color: var(--muted); }

#filter {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 4px;
  width: 220px;
  height: 16px;
}
#filter:focus { outline: none; border-color: var(--accent); }

/* FOOTER */
.footer {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 22px;
  padding: 0 8px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.04em;
  overflow: hidden;
}
.footer > span:first-child {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}
.footer #ft-method {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ft-k { color: var(--dim); text-transform: uppercase; font-size: 8px; letter-spacing: 0.08em; margin-right: 4px; flex-shrink: 0; }
.ft-right { margin-left: auto; flex-shrink: 0; white-space: nowrap; }

/* color swatches by year (used by JS for bubbles + table) */
.y20 { color: var(--y20); }
.y21 { color: var(--y21); }
.y22 { color: var(--y22); }
.y23 { color: var(--y23); }
.y24 { color: var(--y24); }
.y25 { color: var(--y25); }
.y26 { color: var(--y26); }
