/* Shared styling for the SLV methane dashboard.
   Colors are defined once as tokens and redefined for dark mode under both the
   OS media query and an explicit data-theme stamp, so the viewer's toggle wins
   either way. Charts read these tokens rather than raw hex. */

:root {
  color-scheme: light;
  --surface-0: #f4f3f0;
  --surface-1: #fcfcfb;
  --surface-2: #eceae5;
  --border: #d9d6cf;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7b7a74;
  --accent: #2a78d6;
  --good: #1baf7a;
  --warn: #eda100;
  --critical: #e34948;

  /* Categorical slots, fixed order. Validated light: worst adjacent CVD dE 9.1,
     normal-vision dE 19.6. Never cycle past slot 8 -- fold into "Other". */
  --series-1: #2a78d6;  /* blue    */
  --series-2: #eb6834;  /* orange  */
  --series-3: #1baf7a;  /* aqua    */
  --series-4: #eda100;  /* yellow  */
  --series-5: #e87ba4;  /* magenta */
  --series-6: #008300;  /* green   */
  --series-7: #4a3aa7;  /* violet  */
  --series-8: #e34948;  /* red     */

  --grid: #e4e2dc;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #242423;
    --border: #3a3a37;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8d8c83;
    --accent: #3987e5;
    --good: #199e70;
    --warn: #c98500;
    --critical: #e66767;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --grid: #2e2e2b;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #242423;
  --border: #3a3a37;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8d8c83;
  --accent: #3987e5;
  --good: #199e70;
  --warn: #c98500;
  --critical: #e66767;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --grid: #2e2e2b;
}

* { box-sizing: border-box; }

/* The hidden attribute must beat the layout rules below, which set display. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px 64px; }

header.site {
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  margin-bottom: 28px;
}
header.site .wrap { display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap; padding-top: 18px; padding-bottom: 18px; }
header.site h1 { font-size: 1.15rem; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
header.site nav { display: flex; gap: 16px; margin-left: auto; flex-wrap: wrap; }
header.site nav a { color: var(--text-secondary); text-decoration: none; font-size: 0.9rem; }
header.site nav a:hover, header.site nav a[aria-current="page"] { color: var(--accent); }

h2 { font-size: 1.05rem; font-weight: 650; margin: 40px 0 6px; letter-spacing: -0.01em; }
h3 { font-size: 0.92rem; font-weight: 600; margin: 24px 0 4px; color: var(--text-secondary); }
p.lede { color: var(--text-secondary); margin: 0 0 18px; max-width: 70ch; }
p.note { color: var(--text-muted); font-size: 0.85rem; max-width: 74ch; margin: 8px 0 0; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-top: 14px;
}

/* Filter row: one row above the charts it controls. */
.controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin: 14px 0 6px;
}
.control { display: flex; flex-direction: column; gap: 4px; }
.control label { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
select, button, input[type="date"] {
  font: inherit;
  font-size: 0.9rem;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 10px;
  min-height: 36px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); color: var(--accent); }
button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.chart { width: 100%; min-height: 320px; }
.chart-tall { min-height: 460px; }

/* Stat tiles: a headline number is not a chart. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 14px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.tile .label { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.tile .value { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 0.82rem; color: var(--text-secondary); }

/* Table view: the relief rule for the low-contrast light-mode slots, and the
   accessible alternative to reading values off a chart. */
table.data { border-collapse: collapse; width: 100%; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
table.data td.num, table.data th.num { text-align: right; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: baseline; }
details.table-view { margin-top: 10px; }
details.table-view summary { cursor: pointer; color: var(--text-secondary); font-size: 0.86rem; }
details.table-view .scroll { max-height: 340px; overflow: auto; margin-top: 8px; }

.banner {
  border-radius: 10px;
  padding: 14px 16px;
  margin: 18px 0;
  border: 1px solid var(--critical);
  background: color-mix(in srgb, var(--critical) 9%, var(--surface-1));
}
.banner h2 { margin: 0 0 6px; font-size: 0.95rem; color: var(--critical); }
.banner ul { margin: 8px 0 0; padding-left: 20px; color: var(--text-secondary); font-size: 0.88rem; }
.banner li { margin-bottom: 5px; }

.status { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.status th, .status td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.status th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.dot.fresh { background: var(--good); }
.dot.aging { background: var(--warn); }
.dot.stale { background: var(--critical); }

footer.site {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 18px 0;
  color: var(--text-muted);
  font-size: 0.84rem;
}
footer.site a { color: var(--text-secondary); }

.loading { color: var(--text-muted); padding: 40px 0; text-align: center; font-size: 0.9rem; }
.error { color: var(--critical); padding: 20px 0; font-size: 0.9rem; }

@media (max-width: 640px) {
  .wrap { padding: 0 16px 48px; }
  header.site .wrap { gap: 10px; }
  header.site nav { margin-left: 0; gap: 12px; }
  .controls { gap: 10px; }
  .control { flex: 1 1 140px; }
}

/* A table row that opens a detail view. Cursor and hover are the only cue the
   row is interactive, so both are needed. */
tr.pick { cursor: pointer; }
tr.pick:hover td { background: var(--surface-2); }
