/* PathogenWatch — palette and chrome, in the Maplore language (maplore.in):
   warm paper, dashed hairline frames, a faint contour field, Space Grotesk
   text, Space Mono numbers, DM Serif Display italic for titles. The DATA
   colours below are unchanged -- they are the validated data-viz set.

   Colours are the validated data-viz reference instance: categorical slots 1-3
   for the three biological terms, the blue sequential ramp for magnitude, and
   the fixed status palette for the clocks. Dark mode is a selected set of steps
   for the dark surface, not an inverted light mode. */

:root {
  color-scheme: light;
  --plane:        #f7f7f7;
  --surface:      #f7f7f7;
  --ink:          #0b0b0b;
  --ink-2:        #52514e;
  --muted:        #898781;
  --grid:         #e1e0d9;
  --axis:         #c3c2b7;
  --border:       #e4e4e7;

  /* categorical: thermal / habitat / dryness */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;

  /* sequential blue, 100 -> 700 */
  --q1: #cde2fb; --q2: #9ec5f4; --q3: #6da7ec;
  --q4: #3987e5; --q5: #256abf; --q6: #184f95; --q7: #0d366b;

  /* status — fixed, never themed */
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --critical: #d03b3b;

  --selbg:   rgba(42, 120, 214, 0.10);
  --hoverbg: rgba(42, 120, 214, 0.06);

  --radius: 0px;
  --mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "DM Serif Display", Georgia, serif;
  --topo-opacity: .05;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #1a1c1f; --surface: #1a1c1f; --topo-opacity: .10;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835;
    --border: #3f3f46;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --q1: #0d366b; --q2: #184f95; --q3: #256abf;
    --q4: #2a78d6; --q5: #3987e5; --q6: #6da7ec; --q7: #9ec5f4;
    --selbg:   rgba(57, 135, 229, 0.18);
    --hoverbg: rgba(57, 135, 229, 0.10);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #1a1c1f; --surface: #1a1c1f; --topo-opacity: .10;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835;
  --border: #3f3f46;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  --q1: #0d366b; --q2: #184f95; --q3: #256abf;
  --q4: #2a78d6; --q5: #3987e5; --q6: #6da7ec; --q7: #9ec5f4;
  --selbg:   rgba(57, 135, 229, 0.18);
  --hoverbg: rgba(57, 135, 229, 0.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--plane);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

/* No contour field on the instruments: behind maps and charts a pattern is
   noise competing with data. It belongs to the maplore.in front door only. */

.brand img { height: 22px; width: auto; vertical-align: -5px; margin-right: 6px; }
.brand .mk, .brand .inst { color: var(--ink); }
.brand .mk { font-weight: 800; text-transform: uppercase; letter-spacing: .04em; font-size: 13px; }
.brand .inst { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 20px; letter-spacing: 0; }

.wrap { max-width: 1480px; margin: 0 auto; padding: 0 16px 80px; }

/* -- masthead ---------------------------------------------------------- */
header.top {
  border-bottom: 1px dashed var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 40;
}
.top-in {
  max-width: 1480px; margin: 0 auto; padding: 14px 16px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.brand { font-size: 17px; font-weight: 640; letter-spacing: -0.01em; }
.brand span { color: var(--muted); font-weight: 400; }
.tagline { color: var(--ink-2); font-size: 13px; }
.spacer { flex: 1 1 auto; }
.theme-btn {
  border: 1px solid var(--border); background: transparent; color: var(--ink-2);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer;
  font-family: inherit;
}

/* -- the caveat. deliberately not dismissable -------------------------- */
.caveat {
  margin: 16px 0 0; padding: 11px 14px;
  border: 1px dashed var(--border); border-left: 3px solid var(--ink);
  border-radius: var(--radius); background: var(--surface);
  font-size: 13px; color: var(--ink-2); border-style: dashed;
}
.caveat b { color: var(--ink); font-weight: 620; }

/* -- clocks ------------------------------------------------------------ */
.clocks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.clock {
  background: transparent; border: 1px dashed var(--border);
  border-radius: var(--radius); padding: 13px 15px;
}
.clock h3 {
  margin: 0 0 3px; font-size: 11px; font-weight: 620; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 7px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.clock .big { font-family: var(--mono); font-size: 24px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.15; }
.clock .unit { font-size: 13px; color: var(--ink-2); font-weight: 400; }
.clock .sub { font-size: 12px; color: var(--muted); margin-top: 5px; }
.clock .note { font-size: 12px; color: var(--ink-2); margin-top: 7px; line-height: 1.4; }

/* -- layout ------------------------------------------------------------ */
.cols { display: grid; grid-template-columns: 460px 1fr; gap: 16px; margin-top: 16px; align-items: start; }
.panel {
  background: color-mix(in srgb, var(--surface) 82%, transparent); border: 1px dashed var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.panel > h2 {
  margin: 0; padding: 13px 15px 0; font-size: 14px; font-weight: 620; letter-spacing: -0.005em;
}
.panel > .hint { padding: 3px 15px 12px; font-size: 12px; color: var(--muted); margin: 0; }

/* -- ranked list ------------------------------------------------------- */
.rank-list { list-style: none; margin: 0; padding: 0 6px 8px; max-height: 540px; overflow-y: auto; }
.rank-row {
  display: grid; grid-template-columns: 24px minmax(0, 1fr) 92px; gap: 10px;
  align-items: center; padding: 7px 9px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
}
.rank-row > span { min-width: 0; }
.rank-row .where {
  font-size: 11px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; display: block; margin-top: 1px;
}
.rank-row:hover { background: var(--hoverbg); }
.rank-row[aria-selected="true"] { border-color: var(--s1); background: var(--selbg); }
.rank-row .n { font-family: var(--mono); font-size: 13px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.rank-row .name {
  font-size: 13px; font-weight: 560; display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rank-row .meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-top: 3px; flex-wrap: nowrap; }
.rank-row .pct { font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; display: block; }
.rank-row .pctlab { font-size: 10px; color: var(--muted); text-align: right; display: block; line-height: 1.25; }
.bar { height: 5px; border-radius: 3px; background: var(--grid); overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--q4); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px; padding: 1px 7px; font-size: 10.5px; font-weight: 560;
  border: 1px solid var(--border); color: var(--ink-2);
}
.chip.heat    { color: var(--s1); border-color: currentColor; }
.chip.habitat { color: var(--s2); border-color: currentColor; }
.chip.dryness { color: var(--s3); border-color: currentColor; }
.chip.fc      { color: var(--muted); border-style: dashed; }

/* -- map --------------------------------------------------------------- */
#map { height: 560px; width: 100%; border-radius: var(--radius); position: relative; overflow: hidden; }
.maplibregl-popup-content {
  background: var(--surface); color: var(--ink); border-radius: 8px;
  border: 1px solid var(--border); font-family: var(--sans); font-size: 12.5px;
  padding: 9px 11px; box-shadow: 0 6px 24px rgba(0,0,0,.14);
}
.maplibregl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.legend {
  display: flex; align-items: center; gap: 8px; padding: 10px 15px 13px;
  font-size: 11.5px; color: var(--muted); flex-wrap: wrap;
}
.legend .sw { width: 22px; height: 10px; border-radius: 2px; display: inline-block; }

/* -- charts ------------------------------------------------------------ */
.chartbox { padding: 0 15px 14px; }
svg.chart { display: block; width: 100%; overflow: visible; }
svg.chart text { font-family: var(--sans); font-size: 11px; fill: var(--muted); }
svg.chart .axis { stroke: var(--axis); stroke-width: 1; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
.serieskey { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-2); padding: 0 15px 10px; }
.serieskey i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

.tt {
  position: fixed; pointer-events: none; z-index: 90; opacity: 0;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.45;
  box-shadow: 0 8px 28px rgba(0,0,0,.16); transition: opacity .09s; max-width: 280px;
}
.tt b { font-weight: 620; }
.tt .row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }

/* -- tables ------------------------------------------------------------ */
table.t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.t th {
  text-align: left; font-weight: 560; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em; padding: 7px 10px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface);
}
table.t td { padding: 7px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.t td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
table.t tr:last-child td { border-bottom: 0; }

.tabs { display: flex; gap: 4px; padding: 0 9px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs button {
  border: 0; background: transparent; color: var(--muted); font-family: inherit;
  font-size: 13px; padding: 10px 11px; cursor: pointer; border-bottom: 2px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--s1); font-weight: 560; }
.tabpane { padding: 4px 0 0; max-height: 460px; overflow: auto; }

.gate { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 560; }
.gate.accepted { color: var(--good); }
.gate.rejected { color: var(--muted); }
.gate.abstained { color: var(--serious); }

.sub-note { font-size: 12px; color: var(--muted); padding: 10px 15px 14px; line-height: 1.5; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 12.5px; padding: 4px 15px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.h-sub { color: var(--muted); font-weight: 400; }

/* -- live status in the masthead -------------------------------------- */
.live { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.live .dot { width: 7px; height: 7px; flex-basis: 7px; }
.live.stale { color: var(--serious); }

/* -- weeks ahead ------------------------------------------------------- */
.weeks {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr);
  gap: 8px; padding: 0 15px 15px; overflow-x: auto;
}
.wk {
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px 10px;
  display: flex; flex-direction: column; gap: 5px; min-width: 0; background: var(--plane);
}
.wk.forecast { border-style: dashed; }
.wk.outlook  { border-style: dotted; border-width: 2px; }
.wk.target   { box-shadow: inset 0 0 0 1px var(--s1); border-color: var(--s1); }
.wk .d { font-size: 12px; font-weight: 600; display: flex; justify-content: space-between; gap: 6px; }
.wk .kind { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 560; }
.wk .kv2 { font-size: 11.5px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 6px; font-variant-numeric: tabular-nums; }
.wk .kv2 b { font-family: var(--mono); font-weight: 560; color: var(--ink); }
.wk .top { font-size: 11px; color: var(--muted); line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.lock { height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; display: flex; }
.lock > i { display: block; height: 100%; }

/* -- ranked list additions -------------------------------------------- */
.rank-row .spark { display: block; margin-top: 4px; }
.rank-row .mates { color: var(--muted); }
.chip.rec { color: var(--ink); border-color: var(--ink); }

/* -- season ------------------------------------------------------------ */
.season-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
h3.mini { margin: 0; padding: 4px 15px 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }

/* -- segmented control ------------------------------------------------- */
.seg { display: inline-flex; margin: 0 15px 10px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px;
  padding: 5px 12px; cursor: pointer;
}
.seg button[aria-selected="true"] { background: var(--selbg); color: var(--ink); font-weight: 560; }

.ok  { color: var(--good); font-weight: 600; }
.bad { color: var(--serious); font-weight: 600; }

@media (max-width: 1140px) {
  .cols { grid-template-columns: 1fr; }
  .clocks { grid-template-columns: 1fr; }
  .season-grid { grid-template-columns: 1fr; }
  #map { height: 420px; }
}
@media (max-width: 560px) {
  .tagline { display: none; }
  .rank-row { grid-template-columns: 22px minmax(0, 1fr) 76px; gap: 8px; }
  .weeks { grid-auto-columns: 140px; }
}

a.brand { text-decoration: none; }

/* -- instrument header (Maplore language) ----------------------------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 28px; align-items: end; padding: 34px 0 22px; border-bottom: 1px dashed var(--border); }
.hero .eyebrow { font-size: 13px; color: var(--muted); margin: 0; }
.hero h1 { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: clamp(44px, 6vw, 76px); line-height: 1; margin: 8px 0 14px; letter-spacing: -0.01em; }
.hero .lede { font-size: 18px; line-height: 1.5; color: var(--ink-2); margin: 0 0 20px; max-width: 46ch; }
.lens { display: inline-flex; border: 1px dashed var(--border); }
.lens button { font: inherit; font-size: 15px; font-weight: 600; padding: 10px 18px; background: transparent; color: var(--muted); border: 0; cursor: pointer; transition: background-color .2s, color .2s; }
.lens button span { font-weight: 400; font-size: 12px; margin-left: 6px; font-family: var(--mono); }
.lens button[aria-selected="true"] { background: var(--ink); color: var(--surface); }
.lens button:hover:not([aria-selected="true"]) { color: var(--ink); background: var(--hoverbg); }
.hero-r { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; margin: 0; }
.hero-r div { border-left: 1px dashed var(--border); padding-left: 14px; }
.hero-r dt { font-family: var(--mono); font-size: 34px; line-height: 1.05; color: var(--ink); }
.hero-r dd { margin: 4px 0 0; font-size: 13px; color: var(--muted); line-height: 1.35; }
.goa-pilot[hidden] { display: none; }
.gp-grid { display: grid; grid-template-columns: 1fr; gap: 18px; padding: 0 15px 6px; }
.gp-top { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0 18px; }
@media (max-width: 1140px) { .gp-top { grid-template-columns: 1fr; } }
.gp-top li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.gp-top li .n { font-family: var(--mono); color: var(--muted); }
.gp-top li .v { font-family: var(--mono); }
.gp-top li .w { color: var(--muted); font-size: 12px; display: block; }
.gp-weeks { padding: 0; grid-auto-columns: minmax(120px, 1fr); }
.gp-open { font-weight: 600; color: var(--ink); text-decoration: none; border-bottom: 1px solid currentColor; }
@media (max-width: 1140px) { .hero, .gp-grid { grid-template-columns: 1fr; } }

#weeks-panel[hidden] { display: none; }
