/* Shared look for all pages. Loaded after each page's own <style>, so it wins on equal specificity.
   Page files keep only their layout; colours, type and common components live here. */

:root {
  --font: "Barlow", system-ui, sans-serif;
  --font-cond: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;

  --bg: #121416;
  --panel: #1a1d20;
  --panel-solid: #1a1d20;
  --line: #2e3337;
  --line-strong: #454b50;
  --text: #ebe7df;
  --muted: #979893;

  /* The interface is monochrome; colour is reserved for data. */
  --accent: #ebe7df;
  --accent-dim: rgba(235, 231, 223, 0.09);
  --ok: #93c07f;
  --late: #e3a948;
  --warn: #e0685a;

  --radius: 4px;
  --radius-sm: 3px;
}

html, body { font-family: var(--font); font-variant-numeric: tabular-nums; background: var(--bg); color: var(--text); }
.leaflet-container { font-family: var(--font); }
.mono { font-family: var(--font); font-variant-numeric: tabular-nums; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---------- surfaces ---------- */
.card, .brand, .seg, .panel, .legend, .player, .layers, .readout {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* ---------- header ---------- */
.brand { padding: 9px 14px; gap: 14px; }
.brand h1 { font-family: var(--font-cond); font-size: 17px; font-weight: 600; letter-spacing: 0; }
.brand small { font-size: 12px; color: var(--muted); }
.brand .dot {
  width: 8px; height: 8px; border-radius: 1px; background: var(--ok);
  box-shadow: none; animation: none; flex: none;
}
.brand.stale .dot { background: var(--warn); box-shadow: none; }
.sitenav { display: flex; gap: 2px; padding-left: 12px; border-left: 1px solid var(--line); flex-wrap: wrap; }
.sitenav a {
  color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none;
  padding: 4px 7px; border: 0; border-radius: var(--radius-sm); margin: 0; white-space: nowrap;
}
.sitenav a:hover { color: var(--text); background: var(--accent-dim); }
.sitenav a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--text); border-radius: 0; }

/* ---------- segmented controls / filters ---------- */
.seg { padding: 3px; gap: 2px; }
.seg button, .filters button {
  font-family: var(--font); font-size: 14px; font-weight: 500;
  border-radius: var(--radius-sm); padding: 6px 12px; transition: none;
}
.seg button.active, .filters button.active, .layers button.active {
  background: var(--text); color: var(--bg); border-color: transparent;
}
.filters button { border: 1px solid var(--line); }

/* ---------- side panel ---------- */
.section h2, .legend h2 {
  font-family: var(--font-cond); font-size: 14px; font-weight: 600;
  text-transform: none; letter-spacing: 0; color: var(--text);
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.legend h2 span:last-child { color: var(--muted); font-weight: 500; }
.stat, .detail, .forecast, .day, .pollen-card { border-radius: var(--radius-sm); border-color: var(--line); }
.stat .v { font-weight: 600; }
.rank li { border-bottom: 1px solid var(--line); border-radius: 0; }
.rank li:hover { color: var(--text); background: var(--accent-dim); }
.rank li.sel { background: var(--accent-dim); box-shadow: inset 3px 0 0 var(--text); }
.pollen-card.sel { border-color: var(--text); }
.chip { border-radius: 2px; }

/* ---------- buttons ---------- */
.foot button, .iconbtn {
  background: transparent; color: var(--text); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); font-family: var(--font); font-weight: 500; font-size: 13px;
}
.foot button:hover, .iconbtn:hover { background: var(--accent-dim); filter: none; }
input[type=range], input[type=checkbox] { accent-color: var(--text); }

/* ---------- leaflet ---------- */
.leaflet-tooltip.st-tip {
  background: var(--panel); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); box-shadow: 0 2px 8px rgba(0, 0, 0, .45); font-family: var(--font);
}
.leaflet-control-attribution { background: rgba(18, 20, 22, .8) !important; color: var(--muted) !important; }
.leaflet-control-zoom { border: 1px solid var(--line) !important; border-radius: var(--radius) !important; box-shadow: none !important; }
.leaflet-control-zoom a {
  background: var(--panel) !important; color: var(--text) !important; border-color: var(--line) !important;
  border-radius: 0 !important; font-family: var(--font) !important;
}
.leaflet-control-zoom a:hover { background: #24282c !important; }

/* ---------- status / loading ---------- */
.toast { background: #2b1a18; border: 1px solid var(--warn); color: #f3d3cd; border-radius: var(--radius-sm); }
.loading .ring { width: auto; height: auto; border: 0; border-radius: 0; animation: none; }
.loading .ring::after { content: "Daten werden geladen …"; color: var(--muted); font-size: 14px; }

/* ---------- radar page specifics that depend on the shared colours ---------- */
.layers { padding: 4px; }
.layers button { border-radius: var(--radius-sm); font-family: var(--font); font-size: 14px; }
.layers button.active img { filter: none; opacity: 1; }
.btn { border-radius: var(--radius-sm); border-color: var(--line-strong); }
.btn:hover { color: var(--text); background: var(--accent-dim); }
.btn.play { border-radius: var(--radius-sm); background: var(--text); color: var(--bg); }
.btn.play:hover { color: var(--bg); filter: none; background: #fff; }
.ticks i { border-radius: 1px; }
.ticks i.cur { background: var(--text); }

/* =====================================================================
   Phone layout (shared by all pages)
   - slim header bar with the page nav
   - one row of mode buttons below it
   - side panel becomes a bottom sheet: peek (default), open or hidden (see mobile.js)
   - legend is a compact strip above the sheet; tap it for its options
   ===================================================================== */
.sheet-handle, .sheet-toggle, .optbtn { display: none; }

@media (max-width: 900px) {
  :root { --bar-h: 44px; --sheet-peek: min(30vh, 260px); --sheet-open: 78vh; --sheet-min: 30px; }
  /* Current sheet height: peek (default), open, or hidden (handle row only). */
  body { --sheet-h: var(--sheet-peek); }
  body.sheet-open { --sheet-h: var(--sheet-open); }
  body.sheet-hidden { --sheet-h: var(--sheet-min); }

  /* header bar */
  .brand {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1001; height: var(--bar-h);
    border-radius: 0; border-width: 0 0 1px; box-shadow: none; padding: 0 8px 0 12px; gap: 10px;
  }
  .brand h1, .brand small, .brand > div:not(.dot) { display: none; }
  .brand .sitenav { display: flex; flex: 1; justify-content: space-around; flex-wrap: nowrap; border: 0; padding: 0; gap: 0; }
  .sitenav a { font-size: 14px; padding: 10px 6px; }
  .sitenav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--text); }

  /* mode buttons: one row under the bar, scrolls sideways if it has to */
  .topbar {
    top: calc(var(--bar-h) + 8px); left: 8px; right: 8px; max-width: none;
    flex-wrap: nowrap; gap: 6px; overflow-x: auto; scrollbar-width: none;
  }
  .topbar::-webkit-scrollbar { display: none; }
  .topbar > .seg { flex: none; }
  .seg button { padding: 6px 9px; font-size: 13.5px; }
  .seg { padding: 2px; gap: 1px; }

  /* map controls: pinch to zoom instead of buttons */
  .leaflet-control-zoom { display: none; }
  body:has(aside.panel) .leaflet-bottom.leaflet-right { bottom: var(--sheet-h); transition: bottom .22s ease; }
  .leaflet-control-attribution { font-size: 9px; }

  /* bottom sheet */
  aside.panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: var(--sheet-h);
    border-radius: 10px 10px 0 0; border-width: 1px 0 0; box-shadow: 0 -2px 10px rgba(0, 0, 0, .35);
    transition: height .22s ease;
  }
  .sheet-handle {
    display: block; flex: none; position: relative; width: 100%; height: 28px; margin: 0; padding: 0;
    background: none; border: 0; cursor: grab; touch-action: none;
  }
  .sheet-handle::before {
    content: ""; position: absolute; left: 50%; top: 11px; width: 40px; height: 4px; margin-left: -20px;
    border-radius: 2px; background: var(--line-strong);
  }
  .sheet-toggle {
    display: block; position: absolute; top: 0; right: 4px; z-index: 2; height: 28px; padding: 0 10px; background: none; border: 0;
    color: var(--muted); font: 500 12.5px var(--font); cursor: pointer;
  }
  .sheet-toggle:hover { color: var(--text); }
  body.sheet-hidden aside.panel > :not(.sheet-handle):not(.sheet-toggle) { visibility: hidden; }
  aside.panel > .panel-scroll { padding: 4px 14px 14px; }
  body:not(.sheet-open) aside.panel .foot { display: none; }
  .section { margin-bottom: 16px; }
  .stat { padding: 8px; }
  .stat .v { font-size: 18px; }

  /* legend strip above the sheet */
  .legend:not(aside) {
    left: 8px; right: 8px; width: auto; bottom: calc(var(--sheet-h) + 22px); transition: bottom .22s ease;
    padding: 7px 10px 6px; cursor: pointer;
  }
  .legend:not(aside) .title { margin-bottom: 5px; }
  .legend .controls, .legend .foot-note { display: none; }
  .legend.legend-open .controls { display: flex; }
  .legend.legend-open .foot-note { display: block; }
  .legend:not(aside)::after {
    content: "mehr ▾"; position: absolute; top: 7px; right: 10px; font-size: 11.5px; color: var(--muted);
  }
  .legend:not(aside).legend-open::after { content: "weniger ▴"; }
  .legend .title span:last-child { margin-right: 56px; }
  body.sheet-open .legend:not(aside) { display: none; }
}
