@font-face {
  font-family: 'Inter';
  src: url('InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ── Design tokens — puhub.ee (weather_v3/frontend/style.css) ─────────────
   Same palette, type scale, blur and zero-radius geometry as puhub.

   ONE deliberate deviation: --panel-bg. puhub floats 0.22-alpha glass over a
   NIGHT basemap, where dark-on-dark reads fine. This map's definitive base is
   Ortofoto — a bright, high-variance aerial photo — and 0.22 alpha over it
   leaves body text unreadable against sunlit field and sand. Panels here are
   0.62/0.78, still glass and still blurred, but opaque enough to carry text
   over the brightest tile. The text-shadow trick puhub uses on .sidebar-body
   is kept as well, for the labels that do sit directly on the map.
   ────────────────────────────────────────────────────────────────────────── */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;

  --text-xs: 10px;
  --text-sm: 11px;
  --text-base: 13px;
  --text-md: 14px;
  --text-lg: 15px;
  --text-xl: 18px;

  --blue:  #3B82F6;
  --cyan:  #22D3EE;
  --amber: #FBBF24;
  --green: #34D399;
  --red:   #F87171;

  --text:       #F1F5F9;
  --text-dim:   #94A3B8;
  --text-quiet: rgba(148, 163, 184, 0.55);

  --panel-bg:            rgba(10, 18, 30, 0.62);
  --panel-bg-strong:     rgba(10, 18, 30, 0.78);
  --panel-border:        rgba(255, 255, 255, 0.07);
  --panel-border-strong: rgba(255, 255, 255, 0.12);

  --accent: var(--cyan);
  --blur: 18px;
  --bg: #050810;

  --sidebar-w: 344px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button, a, input, [role="button"], [role="switch"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%; height: 100%; overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Map ─────────────────────────────────────────────────────────────────── */
#map { position: absolute; inset: 0; z-index: 1; background: var(--bg); }

/* The heatmap pane. filter on the PANE (not per tile) is what makes this a
   heatmap rather than 256 separately-blurred squares: the browser composites
   every tile canvas in the subtree first, then blurs the group as one image,
   so adjacent tiles blend and there are no seams at tile edges.
   `.zooming` drops the filter during Leaflet's zoom animation — re-blurring a
   full-viewport pane every frame is the one thing that makes this stutter. */
.leaflet-pane.pane-data.heat {
  filter: blur(7px) saturate(1.25);
  will-change: filter;
}
.leaflet-pane.pane-data.heat.zooming { filter: none; }

/* ── Vignette ────────────────────────────────────────────────────────────── */
.map-vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background:
    radial-gradient(ellipse 78% 62% at 50% 50%, transparent 42%, rgba(5,8,16,0.42) 100%),
    linear-gradient(180deg, rgba(5,8,16,0.20) 0%, transparent 18%, transparent 78%, rgba(5,8,16,0.38) 100%);
}

/* ── Glass ───────────────────────────────────────────────────────────────── */
.glass {
  background: var(--panel-bg);
  backdrop-filter: blur(var(--blur)) saturate(130%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(130%);
  border: 1px solid var(--panel-border);
  border-radius: 0;
}
.glass-strong { background: var(--panel-bg-strong); border-color: var(--panel-border-strong); }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  position: absolute; top: 20px; right: 20px; z-index: 20;
  width: var(--sidebar-w); max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.3s cubic-bezier(.3,0,.2,1);
}
.sidebar.hidden { transform: translateX(calc(100% + 30px)); }

/* flex-shrink:0 is load-bearing. The sidebar is a flex column with a scrolling
   body; with 19 species the body's content height far exceeds the sidebar's
   max-height, and flex then shrinks its SIBLINGS to make room — which crushed
   the mode switch to a few clipped pixels of text. Only .sidebar-body may give. */
#active-banner, .ctrl-pair { flex-shrink: 0; }

#active-banner { padding: 12px 14px; }
.ab-row { display: flex; align-items: center; gap: 11px; }
.ab-swatch {
  width: 26px; height: 26px; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.22);
}
.ab-text { flex: 1; min-width: 0; }
#ab-collapse {
  flex-shrink: 0; width: 26px; height: 26px; color: var(--text-dim);
  display: flex; align-items: center; justify-content: center; transition: color .15s;
}
#ab-collapse:hover { color: var(--cyan); }
#ab-collapse svg { width: 16px; height: 16px; }
#ab-collapse:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.ab-name { font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em; }
.ab-meta {
  font-size: 9.5px; color: var(--text-dim); margin-top: 2px;
  text-transform: uppercase; letter-spacing: 0.11em;
}

/* Mode switch — puhub .ctrl-pair */
.ctrl-pair {
  display: flex; overflow: hidden;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
}
.ctrl-pair button { flex: 1; padding: 11px 12px; color: var(--text-dim); transition: all .15s; }
.ctrl-pair button + button { border-left: 1px solid var(--panel-border); }
.ctrl-pair button:hover { color: var(--text); }
.ctrl-pair button.active { color: var(--cyan); background: rgba(34,211,238,0.08); }
.ctrl-pair button:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }

.sidebar-body {
  overflow-y: auto; flex: 1; min-height: 0;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent;
  padding: 4px 0 8px;
}
.sidebar-body::-webkit-scrollbar { width: 4px; }
.sidebar-body::-webkit-scrollbar-track { background: transparent; }
.sidebar-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }

.sect { border-bottom: 1px solid var(--panel-border); padding-bottom: 6px; }
.sect:last-child { border-bottom: none; }
.sect-hd {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--text-quiet); padding: 11px 14px 6px;
}

/* ── Legend ──────────────────────────────────────────────────────────────── */
#legend { padding: 0 14px 8px; }

/* Continuous ramp (Soojuskaart) */
.legend-bar { height: 10px; width: 100%; border: 1px solid var(--panel-border-strong); }
.legend-scale {
  display: flex; justify-content: space-between; margin-top: 5px;
  font-size: 9.5px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.1em;
}

/* Class swatches (Detailne) */
.legend-cls { display: flex; align-items: center; gap: 10px; padding: 3.5px 0; font-size: 12.5px; }
.legend-cls .sw { width: 15px; height: 15px; flex: 0 0 auto; border: 1px solid rgba(0,0,0,0.3); }
.legend-note {
  margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--panel-border);
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-quiet);
}

/* ── Species picker ──────────────────────────────────────────────────────── */
#picker { padding: 0 4px; }
#picker .group-title {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-quiet); padding: 8px 10px 4px;
}
.sp-btn {
  display: block; width: 100%; text-align: left;
  padding: 7px 10px; transition: background .15s;
  border-left: 2px solid transparent;
}
.sp-btn:hover { background: rgba(255,255,255,0.04); }
.sp-btn.active { background: rgba(34,211,238,0.09); border-left-color: var(--cyan); }
.sp-btn .name { font-size: var(--text-base); color: var(--text); }
.sp-btn.active .name { color: var(--cyan); font-weight: 500; }
.sp-btn .latin { font-size: 10.5px; color: var(--text-dim); font-style: italic; }
.sp-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }
.sp-btn.out-season .name::after {
  content: " · pole hooaeg"; font-size: 9.5px; color: var(--amber); font-style: normal;
}

/* ── Layer rows + toggles ────────────────────────────────────────────────── */
.layer-list { display: flex; flex-direction: column; padding: 0 4px; }
.layer-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px;
  cursor: pointer; transition: background .15s; user-select: none;
}
.layer-row:hover { background: rgba(255,255,255,0.03); }
.layer-row:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }
.layer-row .nm { flex: 1; font-size: var(--text-base); color: var(--text); }
.layer-row .nm em { font-style: normal; color: var(--text-quiet); font-size: 11px; }
.layer-row.on .nm { color: var(--text); font-weight: 500; }
.layer-row .hint {
  display: block; font-size: 10px; color: var(--text-quiet); margin-top: 1px;
}

/* toggle */
.layer-row .sw {
  width: 28px; height: 16px; background: rgba(255,255,255,0.08);
  position: relative; flex-shrink: 0; transition: background .2s;
}
.layer-row .sw::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text-dim); transition: all .2s;
}
.layer-row.on .sw { background: rgba(34,211,238,0.35); }
.layer-row.on .sw::after { left: 14px; background: var(--cyan); box-shadow: 0 0 8px rgba(34,211,238,0.6); }

/* radio (base layers — single choice) */
.layer-row .rd {
  width: 14px; height: 14px; flex-shrink: 0;
  border: 1px solid var(--text-dim); position: relative;
}
.layer-row.on .rd { border-color: var(--cyan); }
.layer-row.on .rd::after {
  content: ''; position: absolute; inset: 3px; background: var(--cyan);
  box-shadow: 0 0 8px rgba(34,211,238,0.6);
}

/* ── Method ──────────────────────────────────────────────────────────────── */
#method summary { cursor: pointer; list-style: none; }
#method summary::-webkit-details-marker { display: none; }
#method summary::after { content: " ▸"; }
#method[open] summary::after { content: " ▾"; }
#method summary:hover { color: var(--text-dim); }
#method p { font-size: 11.5px; line-height: 1.6; color: var(--text-dim); padding: 0 14px 9px; }
#method code {
  background: rgba(255,255,255,0.07); padding: 1px 4px;
  font-size: 10.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
#method strong { color: var(--text); font-weight: 600; }
#method .allikad { color: var(--text-quiet); font-size: 10.5px; }
#method .disclaimer {
  color: #FCD9A0; background: rgba(251,191,36,0.09);
  border-left: 2px solid var(--amber); margin: 0 14px 10px; padding: 9px 11px;
}
#method .disclaimer strong { color: #FDE9C4; }

/* ── Top-left brand ──────────────────────────────────────────────────────── */
/* z-index below .sidebar (20): on mobile the sidebar drops over this corner, and
   the brand should pass under it rather than punch through the glass. */
.tl-cluster { position: absolute; top: 20px; left: 20px; z-index: 15; }
.brand { display: flex; align-items: center; gap: 12px; padding: 11px 16px 12px; }

/* The puhub spiral. Stroke is currentColor so the glow and the mark stay in
   step; the drop-shadow reproduces the halo the shipped logo.png has baked in. */
.brand .mark {
  width: 30px; height: 30px; flex-shrink: 0; color: var(--cyan);
  filter: drop-shadow(0 0 5px rgba(34, 211, 238, 0.55));
}
.brand-top {
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em;
  color: var(--text); line-height: 1.1;
}
.brand-top #brand-region {
  color: var(--text-dim); font-weight: 400;
  text-transform: uppercase; font-size: 9.5px; letter-spacing: 0.12em;
}

/* ── Wordmark: drawn S (puravik) + drawn j (mustikas) ────────────────────── */
/* The two SVG glyphs share one 62-unit viewBox with the baseline at y=48 and the
   cap line at y=10, so they set solid against Inter: cap height 38u is 0.727em
   (Inter's), which fixes the height at 62/38 * 0.727 = 1.186em, and the 14u of
   descender below the baseline is why they are nudged down 0.268em. Change the
   viewBox and these two numbers have to move with it. */
.wordmark {
  display: flex; align-items: baseline; margin-top: 2px;
  font-size: 19px; font-weight: 650; letter-spacing: -0.012em;
  color: var(--text); line-height: 1.15; white-space: nowrap;
}
/* overflow:visible lets the cap and the berry paint beyond their own boxes (the
   umbrella overhang, the floating berry) without widening the layout box, so the
   letters after them keep their normal spacing. */
.wordmark svg {
  height: 1.186em; width: auto; flex-shrink: 0; overflow: visible;
  position: relative; top: 0.268em;
}
.wordmark .wm { display: inline-block; }
.wordmark .sp { white-space: pre; }

/* Puravik: brown convex cap, pale pore surface, thick buff stem. The stem is the
   S's lower bowl — out to the right, then down and away to the left. */
.bolete .cap  { fill: #9A6437; }
.bolete .pore { fill: #EFE3CC; }
/* The stem is an outline path, so it must be FILLED. It was stroked back when it
   was a letterform S, and leaving that here renders the silhouette as a ring with
   a hole punched through the middle of the stem. */
.bolete .stem { fill: #E6D6B8; stroke: none; }

/* Mustikas: the tittle of the j as a berry — body, dusty bloom, calyx star. */
.berryj .jstem {
  fill: none; stroke: currentColor; stroke-width: 6.6;
  stroke-linecap: round; stroke-linejoin: round;
}
/* Blueberry, not "blue circle": deep blue-purple body, a darker lower-right so it
   reads as a sphere, the dusty pale bloom real berries carry, and a pale calyx
   crown. The crown is the single strongest cue at this size — but it has to sit
   high on the berry and stay small, or it turns into a sheriff's badge. */
.berryj .berry  { fill: url(#bb); }
.berryj .dimple { fill: #1E284A; opacity: 0.6; }
.berryj .calyx  { fill: #93A7D4; opacity: 0.9; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Sidebar toggle ──────────────────────────────────────────────────────── */
#sidebar-toggle {
  position: absolute; top: 20px; right: 20px; z-index: 21;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  color: var(--cyan); background: rgba(5,8,16,0.55);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sidebar.hidden ~ #sidebar-toggle { opacity: 1; pointer-events: auto; }
#sidebar-toggle svg { width: 18px; height: 18px; }
#sidebar-toggle:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ── Leaflet chrome ──────────────────────────────────────────────────────── */
.leaflet-control-attribution {
  background: rgba(0,0,0,0.35) !important;
  color: rgba(255,255,255,0.4) !important;
  font-size: 9px !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important;
  backdrop-filter: blur(6px);
  border: none !important; border-radius: 0 !important;
  padding: 2px 6px !important;
}
.leaflet-control-attribution a { color: rgba(255,255,255,0.55) !important; }

/* Zoom stays — this is a utility map and people zoom constantly. Restyled as
   glass, bottom-left: the brand moved to the top-left corner, so this corner is
   free and the controls no longer need to clear it. */
.leaflet-bottom.leaflet-left { bottom: 20px; left: 20px; }
.leaflet-control-zoom { border: none !important; box-shadow: none !important; margin: 0 !important; }
.leaflet-control-zoom a {
  width: 34px !important; height: 34px !important; line-height: 32px !important;
  background: rgba(5,8,16,0.55) !important;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--text) !important;
  border: 1px solid var(--panel-border) !important;
  border-radius: 0 !important;
  font-size: 17px !important; font-weight: 300 !important;
}
.leaflet-control-zoom a:hover { background: rgba(5,8,16,0.75) !important; color: var(--cyan) !important; }
.leaflet-control-zoom a + a { border-top: none !important; }

/* ── Popup ───────────────────────────────────────────────────────────────── */
.leaflet-popup-content-wrapper {
  background: rgba(10,18,30,0.88);
  backdrop-filter: blur(var(--blur)) saturate(130%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(130%);
  border: 1px solid var(--panel-border-strong);
  border-radius: 0; box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  color: var(--text);
}
.leaflet-popup-content { margin: 13px 15px; font-family: var(--font-sans); }
.leaflet-popup-tip { background: rgba(10,18,30,0.88); border: 1px solid var(--panel-border-strong); }
.leaflet-popup-close-button { color: var(--text-dim) !important; }
.leaflet-popup-close-button:hover { color: var(--text) !important; }

.stand-popup { font-size: 12.5px; line-height: 1.5; }
.stand-popup h3 {
  font-size: 9.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--text-quiet); margin-bottom: 7px;
}
.stand-popup .score-badge {
  display: inline-block; color: #05131a; border-radius: 0;
  padding: 3px 10px; font-weight: 650; font-size: 12px; margin-bottom: 9px;
}
.stand-popup table { border-collapse: collapse; }
.stand-popup td { padding: 1.5px 0; vertical-align: top; color: var(--text); }
.stand-popup td.k {
  color: var(--text-dim); padding-right: 12px; white-space: nowrap;
  font-size: 11px;
}
.stand-popup .miks {
  margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--panel-border);
  font-size: 11.5px; color: var(--text-dim); line-height: 1.55;
}
.stand-popup .miks strong { color: var(--text); }
.coords {
  margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--panel-border);
  font-size: 11px; color: var(--text-dim);
}
.coords code {
  background: rgba(255,255,255,0.07); padding: 1px 5px; user-select: all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.map-action {
  position: absolute; z-index: 18; left: 20px; bottom: 92px;
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid var(--panel-border); border-radius: 12px;
  color: var(--text); background: var(--panel-bg);
  box-shadow: var(--shadow); backdrop-filter: blur(14px);
}
.map-action svg { width: 22px; height: 22px; }
.map-action:hover { color: var(--cyan); border-color: rgba(34,211,238,.45); }
.map-action[aria-pressed="true"] { color: var(--cyan); background: rgba(8,31,38,.9); }
.map-action.locating svg { animation: locate-pulse 1.1s ease-in-out infinite; }
.map-action.location-error { color: var(--red); }
@keyframes locate-pulse { 50% { opacity: .35; transform: scale(.88); } }
.user-location-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 3px solid #fff; background: var(--cyan);
  box-shadow: 0 0 0 2px rgba(34,211,238,.4), 0 2px 8px rgba(0,0,0,.55);
}
#location-status {
  position: absolute; z-index: 18; left: 76px; bottom: 101px;
  max-width: min(310px, calc(100vw - 84px)); padding: 8px 11px;
  border: 1px solid var(--panel-border); border-radius: 9px;
  color: var(--text); background: var(--panel-bg-strong); box-shadow: var(--shadow);
  font-size: 12px; line-height: 1.35; opacity: 0; pointer-events: none;
  transform: translateY(4px); transition: opacity .18s, transform .18s;
}
#location-status.show { opacity: 1; transform: translateY(0); }

/* ── Load failure ────────────────────────────────────────────────────────── */
.boot-error {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; padding: 32px; z-index: 30;
  background: var(--bg); color: var(--text-dim); font-size: var(--text-base);
  line-height: 1.6; text-align: center;
}
.boot-error code {
  background: rgba(255,255,255,0.07); padding: 2px 6px; color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .sidebar {
    top: 0; right: 0; left: 0; width: 100%;
    max-height: 76vh; gap: 0;
    padding: 0;
  }
  .sidebar.hidden { transform: translateY(calc(-100% - 10px)); }
  #active-banner, .ctrl-pair, .sidebar-body { border-left: none; border-right: none; }
  /* The panel slides UP on mobile, not right — point the chevron where it goes. */
  #ab-collapse svg { transform: rotate(-90deg); }
  #sidebar-toggle { top: 12px; right: 12px; }
  .tl-cluster { top: 12px; left: 12px; }
  .leaflet-bottom.leaflet-left { bottom: 12px; left: 12px; }
  .map-action { left: 12px; bottom: 88px; width: 48px; height: 48px; }
  #location-status { left: 70px; bottom: 101px; }
  .brand { padding: 9px 13px 10px; gap: 10px; }
  .brand .mark { width: 26px; height: 26px; }
  .wordmark { font-size: 17px; }
}
