/* Lesvos fire dashboard, presentation layer.
   v2.0.1

   Oxocarbon, the IBM Carbon dark palette. Contrast rule enforced throughout:
   no low-contrast grey text on a grey ground. Secondary text is #c6c6c6 on
   #161616, about 11:1, and the dimmest text used anywhere is #a8a8a8 at about
   7:1. Nothing is set in #6f6f6f or darker on a dark panel. */

/* Self-hosted webfonts, latin subset. Served from the project so the dashboard
   works offline and behind a reverse proxy; paths stay relative to this
   stylesheet so any path prefix on the mount point is respected. */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('vendor/fonts/inter-latin-500-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('vendor/fonts/inter-latin-600-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('vendor/fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('vendor/fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
}

:root {
  /* Oxocarbon greys, background to foreground */
  --bg: #161616;
  --bg-inset: #1c1c1c;
  --panel: #262626;
  --panel-raised: #393939;
  --rule: #525252;

  /* Text: both tiers stay well clear of the background */
  --text: #f4f4f4;
  --text-2: #c6c6c6;
  --text-3: #a8a8a8;

  /* Oxocarbon accents */
  --blue: #33b1ff;
  --cyan: #3ddbd9;
  --magenta: #ff7eb6;
  --purple: #be95ff;
  --red: #ee5396;
  --green: #42be65;
  --yellow: #fddc69;
  --orange: #ff832b;

  --font: 'Inter', "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --panel-width: 400px;
  --masthead-height: 40px;
  --urgent-height: 54px;
  --footer-height: 30px;
  --radius: 2px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

/* Hold the type size when the phone is rotated. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

h1, h2, h3 { font-weight: 600; margin: 0; }
.hidden { display: none !important; }

/* --- masthead ----------------------------------------------------------- */

#masthead {
  height: var(--masthead-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
}
#masthead h1 { font-size: 13px; }
.subtitle { margin: 0; font-size: 10px; color: var(--text-2); }
.masthead-right {
  display: flex; align-items: center; gap: 9px;
  font-size: 11px; color: var(--text-2); font-family: var(--mono);
}
.clock { color: var(--text); }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3); flex: 0 0 8px;
}
.live-dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.live-dot.off { background: var(--red); }

/* --- banner ------------------------------------------------------------- */

.banner {
  padding: 9px 14px;
  background: var(--red);
  color: #161616;
  font-weight: 600;
  font-size: 13px;
}
.banner.warn { background: var(--yellow); color: #161616; }

/* Connection warning. Same block as the alert banner so the two read as one
   stack; it is stated plainly because the times below it go stale silently. */
#offline-banner {
  border-top: 1px solid var(--rule);
  line-height: 1.35;
}

/* --- urgent strip ------------------------------------------------------- */

.urgent {
  height: var(--urgent-height);
  display: flex;
  align-items: stretch;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--rule);
}
.urgent-cell {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 4px 10px;
  border-right: 1px solid var(--rule);
  min-width: 0;
}
.urgent-cell:last-child { border-right: none; }
.urgent-label {
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}
.urgent-value {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.urgent-value.good { color: var(--green); }
.urgent-value.warn { color: var(--yellow); }
.urgent-value.bad { color: var(--red); }
.urgent-value.small { font-size: 14px; }

/* Two-line timestamp: time large, date and age underneath. Nothing is clipped,
   which matters because a truncated time reads as a different time. */
.urgent-value.stacked {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  overflow: visible;
  white-space: normal;
}
.stack-main { font-size: 15px; font-weight: 600; color: inherit; white-space: nowrap; }
/* The full timestamp must never wrap or clip: a half-shown time reads as a
   different time. It is sized to fit "2026-07-29 16:06" in the narrowest cell. */
.stack-sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-2);
  font-family: var(--mono);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

/* --- layout ------------------------------------------------------------- */

main {
  display: flex;
  height: calc(100vh - var(--masthead-height) - var(--urgent-height) - var(--footer-height));
}
body:has(.banner:not(.hidden)) main {
  height: calc(100vh - var(--masthead-height) - var(--urgent-height) - var(--footer-height) - 38px);
}
body:has(#banner:not(.hidden)):has(#offline-banner:not(.hidden)) main {
  height: calc(100vh - var(--masthead-height) - var(--urgent-height) - var(--footer-height) - 76px);
}
#map-pane { position: relative; flex: 1 1 auto; min-width: 0; }
#map { position: absolute; inset: 0; background: #0b0b0b; }

#side-panel {
  width: var(--panel-width);
  flex: 0 0 var(--panel-width);
  background: var(--panel);
  border-left: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* --- floating panels ---------------------------------------------------- */

.panel-float {
  position: absolute;
  z-index: 500;
  background: rgba(38, 38, 38, 0.96);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 12px;
  color: var(--text);
}
#map-controls { top: 10px; left: 10px; width: 268px; }
/* Top right: the layer list now owns the bottom left corner. */
#legend { top: 10px; right: 10px; width: 274px; max-height: 62vh; overflow-y: auto; }
#legend > summary, #map-controls > summary {
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
  list-style: none;
  padding: 2px 0;
}
#legend > summary::-webkit-details-marker,
#map-controls > summary::-webkit-details-marker { display: none; }
#legend > summary::after, #map-controls > summary::after { content: " +"; }
#legend[open] > summary::after, #map-controls[open] > summary::after { content: " -"; }
#legend[open] > summary, #map-controls[open] > summary {
  margin-bottom: 7px; border-bottom: 1px solid var(--rule);
}

.control-row { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.control-row:last-child { margin-bottom: 0; }
.control-row > span { color: var(--text-2); font-size: 11px; }
/* States which day of imagery is on screen, directly under its picker. */
.control-note {
  font-size: 10px; color: var(--text-3); margin: -5px 0 8px; line-height: 1.35;
}
.checkbox-row { flex-direction: row; align-items: center; gap: 7px; }
.checkbox-row > span { color: var(--text); font-size: 12px; }
.slider-row output { color: var(--blue); font-family: var(--mono); }

input[type="date"], select, input[type="range"] {
  min-width: 0; max-width: 100%; width: 100%;
  background: var(--panel-raised);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 4px 6px;
  font-family: inherit;
  font-size: 12px;
}
input[type="range"] { padding: 0; accent-color: var(--blue); }
input[type="checkbox"] { accent-color: var(--blue); width: auto; }
input[type="date"]::-webkit-inner-spin-button,
input[type="date"]::-webkit-clear-button { display: none; -webkit-appearance: none; }
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(0.8); cursor: pointer;
}

/* --- legend ------------------------------------------------------------- */

.legend-title {
  font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 6px;
}
.legend-list { list-style: none; margin: 0; padding: 0; }
.legend-list li {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; color: var(--text); padding: 2px 0;
}
.swatch { flex: 0 0 auto; display: inline-block; }
.swatch-line { width: 20px; height: 0; border-top: 3px solid var(--c); }
.swatch-dash { border-top-style: dashed; }
.swatch-dot { border-top-style: dotted; }
.swatch-poly {
  width: 15px; height: 11px;
  border: 2px solid var(--c);
  background: color-mix(in srgb, var(--c) 18%, transparent);
}
.swatch-dotmark {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--purple); border: 1px solid var(--text);
}
.legend-ramp-wrap { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.legend-ramp-label { font-size: 10px; color: var(--text-2); }
.legend-ramp { display: flex; height: 9px; flex: 1 1 auto; border-radius: 1px; overflow: hidden; }
.legend-ramp > div { flex: 1 1 auto; }

/* --- tabs --------------------------------------------------------------- */

.tabs { display: flex; border-bottom: 1px solid var(--rule); flex: 0 0 auto; }
.tab {
  flex: 1 1 auto; padding: 9px 3px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-2); font-family: inherit; font-size: 12px; cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--panel-raised); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.pill {
  display: inline-block; min-width: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--red); color: #161616;
  font-size: 10px; font-weight: 700;
}

.tab-body { display: none; overflow-y: auto; padding: 11px; flex: 1 1 auto; }
.tab-body.active { display: block; }
.loading { color: var(--text-2); font-size: 12px; }

/* --- cards -------------------------------------------------------------- */

.card {
  background: var(--bg-inset);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 9px 10px;
  margin-bottom: 9px;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--blue); background: var(--panel-raised); }
.card h3 {
  font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 6px;
}
.card-lead { font-family: var(--mono); font-size: 22px; font-weight: 600; color: var(--text); }
.card-lead.good { color: var(--green); }
.card-lead.warn { color: var(--yellow); }
.card-lead.bad { color: var(--red); }
/* A lead that is a short sentence rather than a number, e.g. "feed unavailable". */
.card-lead.small { font-size: 14px; color: var(--text-2); }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 12px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-family: var(--mono); text-align: right; color: var(--text); }

.tag {
  display: inline-block; font-size: 10px; padding: 1px 6px;
  border-radius: 9px; border: 1px solid currentColor; margin-right: 4px;
}
.tag.est { color: var(--yellow); }
.tag.low { color: var(--red); }
.tag.ok { color: var(--green); }
.tag.info { color: var(--blue); }

/* Caveats live behind a disclosure so the urgent view stays short. */
details.detail { margin-top: 7px; }
details.detail > summary {
  cursor: pointer; font-size: 11px; color: var(--blue); list-style: none;
}
details.detail > summary::-webkit-details-marker { display: none; }
details.detail > summary::before { content: "+ "; }
details.detail[open] > summary::before { content: "- "; }
details.detail p {
  font-size: 11px; color: var(--text-2); margin: 5px 0 0;
  padding-left: 8px; border-left: 2px solid var(--rule);
}

.hint { font-size: 10px; color: var(--text-3); margin-top: 6px; }

/* --- alerts ------------------------------------------------------------- */

.alert-item {
  border-left: 3px solid var(--rule);
  padding: 7px 0 7px 9px;
  margin-bottom: 8px;
}
.alert-item.active { border-left-color: var(--red); }
.alert-title { font-size: 13px; color: var(--text); }
.alert-title a { color: inherit; text-decoration: none; }
.alert-title a:hover { color: var(--blue); text-decoration: underline; }
.alert-original { font-size: 11px; color: var(--text-2); margin-top: 3px; }
.alert-meta { font-size: 10px; color: var(--text-2); font-family: var(--mono); margin-top: 3px; }
.zone-chip {
  display: inline-block; font-size: 10px; padding: 1px 6px; margin: 2px 3px 0 0;
  border-radius: 2px; background: var(--magenta); color: #161616; font-weight: 600;
  cursor: pointer;
}

/* --- emergency numbers -------------------------------------------------- */

/* Rows are tap targets first and text second: 44 px minimum, number in mono at
   the left edge so it is findable without reading. */
.sos-list { list-style: none; margin: 0 0 10px; padding: 0; }
.sos-list li { margin-bottom: 6px; }
.sos-row {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 7px 10px;
  background: var(--bg-inset);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.sos-row:hover, .sos-row:focus, .sos-row:active {
  border-color: var(--blue);
  background: var(--panel-raised);
}
.sos-num {
  flex: 0 0 auto;
  min-width: 58px;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.sos-desc { font-size: 12px; color: var(--text-2); }
.sos-row.sos-primary { border-color: var(--red); min-height: 56px; }
.sos-row.sos-primary .sos-num { color: var(--red); font-size: 27px; }
.sos-row.sos-primary .sos-desc { color: var(--text); font-size: 13px; }
.sos-note { font-size: 11px; color: var(--text-2); margin: 6px 0 0; }

/* --- news --------------------------------------------------------------- */

.news-item { padding: 7px 0; border-bottom: 1px solid var(--rule); }
.news-item:last-child { border-bottom: none; }
.news-item a { color: var(--text); text-decoration: none; font-size: 13px; }
.news-item a:hover { color: var(--blue); text-decoration: underline; }
.news-original { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.news-meta { font-size: 10px; color: var(--text-2); margin-top: 2px; font-family: var(--mono); }

/* --- sources ------------------------------------------------------------ */

.source-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 5px 0; border-bottom: 1px solid var(--rule); font-size: 12px;
}
.source-row:last-child { border-bottom: none; }
.source-name { flex: 1 1 auto; color: var(--text); }
.source-age { font-family: var(--mono); font-size: 11px; color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.dot.ok { background: var(--green); }
.dot.stale { background: var(--yellow); }
.dot.error { background: var(--red); }
.dot.off { background: var(--text-3); }

/* --- footer ------------------------------------------------------------- */

#footer {
  height: var(--footer-height);
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: var(--panel); border-top: 1px solid var(--rule);
  font-size: 11px; color: var(--text-2);
  overflow: hidden; white-space: nowrap;
}
.footer-sources { color: var(--text-3); }

/* --- leaflet ------------------------------------------------------------ */

.leaflet-container { background: #0b0b0b; font-family: var(--font); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--panel); color: var(--text); border-radius: var(--radius);
}
.leaflet-popup-content { margin: 9px 11px; font-size: 12px; }
.leaflet-popup-content h4 { margin: 0 0 5px; font-size: 12px; color: var(--blue); }
.leaflet-popup-content .prov {
  font-size: 10px; color: var(--text-2); margin-top: 6px;
  padding-top: 5px; border-top: 1px solid var(--rule);
}
.leaflet-control-layers, .leaflet-bar a {
  background: var(--panel); color: var(--text); border-color: var(--rule);
}
.leaflet-bar a:hover { background: var(--panel-raised); color: var(--text); }
.leaflet-control-layers-expanded { color: var(--text); font-size: 12px; }
.leaflet-control-attribution {
  background: rgba(22, 22, 22, 0.86) !important;
  color: var(--text-2) !important; font-size: 10px;
}
.leaflet-control-attribution a { color: var(--text-2) !important; }

/* Map labels: readable over bright imagery without a grey-on-grey pairing. */
.map-label {
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 3px #000;
  white-space: nowrap;
}
.map-label-watch { font-size: 12px; color: var(--yellow); }
.map-label-zone { color: var(--magenta); font-size: 11px; }
.map-label-road { font-size: 11px; }
.map-label-area { color: var(--red); }
.map-label-measure {
  /* No panel behind this label: the boxed version read as a stray black square
     on the map. A heavy text shadow keeps it legible over bright imagery. */
  color: var(--yellow);
  font-family: var(--mono);
  font-weight: 500;
}

/* --- phones ------------------------------------------------------------- */

/* The desktop layout is a fixed side panel next to the map, with heights
   derived from calc() over --urgent-height. On a phone the urgent strip wraps
   to two rows, so those calc() rules go wrong; below this breakpoint the page
   becomes a flex column instead and lets the browser do the arithmetic. */

@media (max-width: 820px) {
  body {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }
  #masthead, .banner, .urgent, #footer { flex: 0 0 auto; }

  /* Height from the flex column, not from the variables. */
  main,
  body:has(.banner:not(.hidden)) main,
  body:has(#banner:not(.hidden)):has(#offline-banner:not(.hidden)) main {
    flex: 1 1 auto;
    flex-direction: column;
    height: auto;
    min-height: 0;
  }

  #map-pane { flex: 0 0 auto; height: 46vh; min-height: 0; }

  #side-panel {
    width: 100%;
    flex: 1 1 auto;
    border-left: none;
    border-top: 1px solid var(--rule);
    min-height: 0;
  }
  /* Tab bar pinned, body scrolls under it. */
  .tab-body { -webkit-overflow-scrolling: touch; }

  /* Urgent strip: wrap to two rows of three rather than squash six cells. */
  .urgent {
    height: auto;
    min-height: var(--urgent-height);
    flex-wrap: wrap;
  }
  .urgent-cell {
    flex: 1 1 33.333%;
    min-width: 33.333%;
    padding: 5px 9px;
    border-right: 1px solid var(--rule);
  }
  .urgent-cell:nth-child(3n) { border-right: none; }
  .urgent-cell:nth-child(-n+3) { border-bottom: 1px solid var(--rule); }
  .urgent-value { font-size: 17px; }
  .urgent-value.small { font-size: 12px; }

  /* Reference material off; the map is only 46vh here and must stay visible. */
  #legend { display: none; }

  /* Controls re-flowed into two columns: half the height of the stacked
     desktop version, so they cover a strip rather than most of the map. */
  #map-controls {
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px 10px;
    padding: 7px 9px;
    font-size: 11px;
  }
  #map-controls .control-row { margin-bottom: 0; min-width: 0; }
  #map-controls .checkbox-row { align-self: end; }

  /* Tap targets. */
  .tab { min-height: 44px; padding: 9px 2px; font-size: 13px; }
  .sos-row { min-height: 48px; }
  .sos-row.sos-primary { min-height: 60px; }

  #masthead { padding: 0 10px; }
  #footer { padding: 0 10px; }
  .footer-sources { overflow: hidden; text-overflow: ellipsis; }
}
