:root {
  /* --ink: #1d2420; */
    --ink: oklch(0.9434 0.0041 219.99);
  /* --muted: #5e6a63; */
    --muted:oklch(0.8123 0.0041 219.99);
  --line: #e2e0d8;
  --soft: #f3f2ed;
  --accent: #2f6b4f;
  --nino: #d0453a;
  --neutral: #4c9a5b;
  --nina: #2f6db5;
  --match: #ff8a00;
  --card: rgba(255, 255, 255, .96);
  --dark: oklch(0.3052 0.0651 219.99);
  --shadow: 0 4px 18px rgba(0, 0, 0, .15);
}
html, body { margin: 0; height: 100%; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: #f4f2ec; overflow: hidden; }
#map { position: absolute; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- panels ---------- */
.card {
  position: absolute; top: 16px; z-index: 2;
  max-height: calc(100% - 32px);
  display: flex; flex-direction: column;
  background: var(--dark); border-radius: 12px; box-shadow: var(--shadow);
}
#panel { left: 16px; width: 330px; }
#sim { right: 16px; width: 320px; }
.card header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px 0; }
.card h1 { font-size: 18px; margin: 0; }
.collapse { border: 0; background: none; width: 28px; height: 28px; border-radius: 7px; font-size: 18px; color: var(--muted); }
.collapse:hover { background: rgba(0, 0, 0, .06); }
.card .body { padding: 4px 14px 14px; overflow-y: auto; }
.card.collapsed .body { display: none; }
.card.collapsed header { padding-bottom: 12px; }
section { border-top: 1px solid var(--line); padding: 10px 0; }
section.time { border-top: 0; }
h2 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); margin: 0 0 8px; }
.small { font-size: 12.5px; color: var(--ink); margin: 4px 0 0; }
select, input[type=text], input:not([type]) {
  font: inherit; font-size: 12.5px; padding: 3px 5px; border: 1px solid oklch(0.8123 0.0041 219.99); border-radius: 6px; background: oklch(0.8123 0.0041 219.99); max-width: 100%;
}

/* ---------- timeline ---------- */
.time-row { display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; margin-bottom: 2px; }
.time-row .badge { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#month-label { min-width: 4.6em; }
.month-src { height: 18px; line-height: 18px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.month-src .fc-tag { vertical-align: 1px; margin-right: 4px; }
#play { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 13px; flex: none; }
#play.on { background: #1d2420; }
#month-label { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; white-space: nowrap; }
.badge { margin-left: auto; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: #e3f0e5; color: var(--neutral); white-space: nowrap; }
.badge.nino { background: #fbe4e1; color: var(--nino); }
.badge.nina { background: #e1ebf8; color: var(--nina); }
#oni-chart { width: 100%; height: 64px; display: block; cursor: pointer; }
#oni-chart .thr { stroke: #b9b6aa; stroke-dasharray: 2 2; stroke-width: .6; vector-effect: non-scaling-stroke; }
#oni-chart .zero { stroke: #7d8a82; stroke-width: .6; vector-effect: non-scaling-stroke; }
#oni-chart .sel { stroke: #111; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
#enso-strip { height: 8px; border-radius: 3px; margin-top: 2px; }
#month { width: 100%; accent-color: #1d2420; margin: 2px 0 0; }
.ticks { position: relative; display: flex; justify-content: space-between; height: 16px; line-height: 16px;
  font-size: 11.5px; color: var(--ink); white-space: nowrap; }
/* hover readout sits on top of the end labels instead of pushing them onto a new line */
.ticks .hover-label { position: absolute; left: 0; right: 0; text-align: center; overflow: hidden; text-overflow: ellipsis; }
.ticks .hover-label:not(:empty) { background: var(--dark); }
.legend-row { display: flex; align-items: center; gap: 12px; font-size: 12px; margin-top: 6px; }
.legend-row .info { margin-left: auto; }
.legend-row span, .cats span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 10px; height: 10px; border-radius: 2px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); display: inline-block; }
.sw.nino { background: var(--nino); }
.sw.neutral { background: var(--neutral); }
.sw.nina { background: var(--nina); }

/* ---------- datasets ---------- */
.layer { padding: 3px 0; }
.check { display: flex; align-items: center; gap: 8px; padding: 2px 0; cursor: pointer; }
input[type=checkbox] {background: oklch(0.8123 0.0041 219.99); accent-color: var(--accent); margin: 0; }
.opts { margin: 2px 0 4px 21px; display: flex; flex-direction: column; gap: 5px; }
.ramp { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.ramp i { flex: 1; height: 10px; border-radius: 3px; }
.ramp .cats { flex-wrap: wrap; }
.cats { display: flex; flex-wrap: wrap; gap: 3px 10px; font-size: 11.5px; color: var(--muted); }
.src { font-size: 11.5px; color: var(--muted); margin: 0; border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- similarity ---------- */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
.field input { font-size: 13px; padding: 6px 8px; }
.you { background: oklch(0.4165 0.0651 219.99); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.you-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.you dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0 4px; font-size: 12.5px; }
.you dt { color: var(--muted); }
.you dd { margin: 0; }
.chip { font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 99px; background: #e3f0e5; color: var(--neutral); }
.chip.nino { background: #fbe4e1; color: var(--nino); }
.chip.nina { background: #e1ebf8; color: var(--nina); }
.matches { list-style: none; margin: 0; padding: 0; }
.matches li { padding: 7px 6px; margin: 2px 0;  cursor: pointer; font-size: 12.5px; border-radius: 6px; }
.matches li:hover { background: oklch(0.4165 0.0651 219.99); }
.m-top { display: flex; align-items: center; gap: 6px; }
.rank { width: 18px; height: 18px; border-radius: 50%; background: var(--match); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; flex: none; }
.score { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 4px; background: var(--line); border-radius: 2px; margin: 4px 0 3px; }
.bar i { display: block; height: 100%; background: var(--match); border-radius: 2px; }
.m-vals { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* irrigation: Canada-wide crop breakdown bar */
.irr-bar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; margin: 4px 0 5px; background: var(--line); }
.irr-bar i { display: block; height: 100%; }

/* ---------- tooltip ---------- */
#tip {
  position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none;
  background: var(--dark); color: var(--ink);
  border: 1px solid oklch(0.4165 0.0651 219.99); border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
  padding: 8px 11px; font-size: 12.5px; line-height: 1.45; max-width: 280px;
  font-variant-numeric: tabular-nums;
}
/* header: "Ecodistrict N" + region name */
#tip > b:first-child { display: block; font-size: 13.5px; letter-spacing: -.01em; }
#tip > b:first-child + .muted { margin-bottom: 5px; padding-bottom: 5px; border-bottom: 1px solid oklch(0.4165 0.0651 219.99); }
#tip b { color: #fff; font-weight: 650; }
#tip .muted { color: var(--muted); }
#tip .tip-match {
  margin-top: 5px; padding: 3px 7px; border-radius: 6px;
  background: rgba(255, 138, 0, .16); color: #ffb35c; box-shadow: inset 3px 0 0 var(--match);
}
#tip .tip-match b { color: #ffcf96; }
/* "Click to find places like this" hint */
#tip > .muted:last-child { margin-top: 6px; font-size: 11px; font-style: italic; opacity: .8; }
.maplibregl-ctrl-attrib { font-size: 11px; }

@media (max-width: 760px) {
  #panel { left: 10px; right: 10px; top: 10px; width: auto; max-height: 48%; }
  #sim { top: auto; bottom: 30px; left: 10px; right: 10px; width: auto; max-height: 40%; }
}

/* forecast */
#oni-chart .fc-zone { fill: rgba(40, 50, 60, 0.07); }
#oni-chart .fc-line { stroke: #555; stroke-width: 0.6; stroke-dasharray: 2 2; vector-effect: non-scaling-stroke; }
.fc-tag { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 1px 5px; border-radius: 3px; background: #333; color: #fff; vertical-align: 2px; }
.badge.fc { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 4px, transparent 4px 8px); }

/* precise time controls */
.hover-label { color: var(--ink, #1d2420); font-weight: 600; }
.step-row { display: flex; align-items: center; gap: 4px; margin: 8px 0 4px; }
.step-row select { flex: 1 1 auto; min-width: 0; padding: 3px 4px; font: inherit; font-size: 12.5px; }
.step { flex: none; min-width: 26px; height: 26px; padding: 0 6px; border: 1px solid oklch(0.8123 0.0041 219.99); border-radius: 5px;
  background: oklch(0.8123 0.0041 219.99); font: inherit; font-size: 14px; line-height: 1; cursor: pointer; color: #1d2420; }
.step:hover { background: oklch(0.8123 0.0041 219.99);}
.step.wide { font-size: 12px; font-weight: 600; }
.tape { width: 100%; height: auto; display: block; margin-top: 6px; cursor: grab; touch-action: none; user-select: none; }
.tape.dragging { cursor: grabbing; }
.tape .yr { stroke: var(--ink); stroke-width: .7; }
.tape .zero { stroke: var(--ink); stroke-width: .6; }
.tape .cur { fill: rgba(0,0,0,.06); stroke: #111; stroke-width: 1.4; }
.tape .lbl { font-size: 9px; fill: var(--ink); text-anchor: middle; }
.tape .lbl.now { fill: #111; font-weight: 700; }
.tape .fc { fill: rgba(40, 50, 60, 0.07); }

/* ---------- simplified layout ---------- */
.card h1 { display: flex; align-items: center; gap: 6px; }
h2 { display: flex; align-items: center; gap: 6px; }
.layer-head { display: flex; align-items: center; gap: 6px; }
.layer-head .check { flex: 1; font-weight: 600; }
.expand, .expand-pad { width: 24px; height: 22px; flex: none; }
.expand { border: 0; background: none; border-radius: 5px; color: var(--muted); font-size: 13px; padding: 0; }
.expand:hover { background: rgba(0, 0, 0, .06); }
.expand span { display: inline-block; transition: transform .15s; }
.expand[aria-expanded="true"] span { transform: rotate(180deg); }
.legend { margin: 2px 0 2px 21px; }
/* Temperature / Precipitation: picker on the layer's own row */
.layer-head .head-pick { flex: 0 0 50%; min-width: 0; }
.anom-toggle { font-size: 12.5px; margin: 4px 0 2px; }
/* "Advanced": every other layer, collapsed by default */
.adv-toggle { display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 8px; padding: 8px 0 4px;
  border: 0; border-top: 1px solid var(--line); background: none; text-align: left;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.adv-toggle .chev { margin-left: auto; color: var(--muted); font-size: 13px; transition: transform .15s; }
.adv-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.adv-count { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); }
#tip .fc-range { font-size: 11.5px; }

/* info icons: content lives in .info-src and is shown in one floating popover */
.info { display: inline-grid; place-items: center; width: 15px; height: 15px; flex: none; border-radius: 50%;
  border: 1px solid #b9b6aa; color: var(--muted); font: italic 600 10px/1 Georgia, serif; cursor: help;
  text-transform: none; letter-spacing: 0; user-select: none; }
.info:hover, .info:focus-visible, .info.open { background: var(--ink); border-color: var(--ink); color: #fff; outline: none; }
.info.warn { border-color: #c98a1b; color: #a26a00; background: #fff4dc; }
.info .info-src { display: none !important; }
.legend-row .info { display: inline-grid; }
#info-pop { position: fixed; z-index: 10; max-width: 270px; padding: 9px 11px; border-radius: 8px;
  background: #1f2622; color: #eef1ee; font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow); }
#info-pop a { color: #9fd6b6; }
#info-pop b { color: #fff; }

/* irrigation: Canada-wide crop breakdown bar (shown in its info popover) */
.irr-bar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; margin: 4px 0 5px; background: #3a423d; }
.irr-bar i { display: block; height: 100%; }
#info-pop .cats { color: #d4dad6; }
#info-pop .muted, #info-pop .small { color: #c6ccc8; }

/* "Generate report" on a match: only shown once the match is clicked */
.matches li.active { background: oklch(0.4165 0.0651 219.99); box-shadow: inset 3px 0 0 var(--match); }
.matches li .report-link { display: none; }
.matches li.active .report-link {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  text-decoration: none;
}
.matches li.active .report-link:hover { filter: brightness(1.1); }

/* ---------- intro dialog (first visit; ? in the panel header reopens it) ---------- */
.help { margin-left: auto; margin-right: 2px; width: 22px; height: 22px; padding: 0; border: 1px solid var(--muted); border-radius: 50%;
  background: none; color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1; }
.help:hover, .help:focus-visible { background: var(--ink); border-color: var(--ink); color: var(--dark); outline: none; }
#intro { width: min(440px, calc(100% - 32px)); max-width: none; max-height: calc(100% - 32px); overflow-y: auto;
  padding: 0; border: 0; border-radius: 12px; background: var(--dark); color: var(--ink); box-shadow: 0 12px 40px rgba(0, 0, 0, .45); }
#intro::backdrop { background: rgba(8, 18, 22, .55); }
.intro-body { padding: 20px 22px 18px; }
#intro h2 { display: block; font-size: 20px; text-transform: none; letter-spacing: -.01em; margin: 0 0 8px; color: #fff; }
.intro-lead { margin: 0 0 16px; font-size: 14px; line-height: 1.5; }
.intro-steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 12px; }
.intro-steps li { counter-increment: step; display: grid; grid-template-columns: 22px 1fr; gap: 10px; font-size: 13.5px; line-height: 1.45; }
.intro-steps li::before { content: counter(step); width: 22px; height: 22px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.intro-steps b { color: #fff; }
.intro-foot { margin: 16px 0 0; font-size: 12.5px; color: var(--muted); }
.intro-i { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid #b9b6aa;
  font: italic 600 10px/1 Georgia, serif; vertical-align: 1px; }
.intro-go { display: block; margin: 18px 0 0 auto; padding: 8px 18px; border: 0; border-radius: 7px;
  background: var(--accent); color: #fff; font-weight: 600; }
.intro-go:hover { filter: brightness(1.12); }

/* ---------- yield forecast (yield-forecast.js) ---------- */
.yf-chart { width: 100%; height: auto; display: block; margin-top: 6px; }
.yf-chart text { font-size: 9px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.ramp .fc-tag { flex: none; }
