/* archief2 — Weerstation Heerenveen
   Custom CSS (Bulma verwijderd). Kleuren via variabelen, zodat een
   donkere modus later eenvoudig is. */

:root {
  color-scheme: light dark;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1f2933;
  --active-text: #fff;
  --muted: #66707a;
  --accent: #1d6fb8;
  --accent-soft: #e8f1f9;
  --line: #e2e6ea;
  --row-even: #fafbfc;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Donkere modus: volgt de apparaat-instelling (prefers-color-scheme). */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #111a2e;
    --text: #e2e8f0;
    --active-text: #0b1220;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --accent-soft: #0f1b33;
    --line: #1e293b;
    --row-even: #132039;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .3);
  }

  body { background: linear-gradient(160deg, #0b1220 0%, #0f1b33 50%, #0b1220 100%); }
}

* { box-sizing: border-box; }

/* Geen blauwe tap-highlight-vierkant op mobiel */
* { -webkit-tap-highlight-color: transparent; }

html {
  -webkit-text-size-adjust: 100%;
  /* Scrollbar-ruimte altijd reserveren: voorkomt horizontale layout-shift
     wanneer de scrollbar na het laden verschijnt (grafieken) en de
     navigatieknoppen dan net onder de muisaanwijzer vandaan schuiven. */
  overflow-y: scroll;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3, p { margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; line-height: 1.2; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

a:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

.section { padding: 1.25rem 0; }

/* Header + pagina-kop --------------------------------------------------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  padding-top: .7rem;
  padding-bottom: .7rem;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}

.brand-tag {
  font-size: .85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.page-head {
  background: linear-gradient(180deg, var(--accent-soft), var(--bg));
  border-bottom: 1px solid var(--line);
  padding: 1.5rem 0 1.25rem;
}

.page-head h1 { margin: 0 0 .25rem; }

.page-sub { color: var(--muted); margin: 0; }

/* Navigatie -------------------------------------------------------------- */

.subnav {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

/* Op desktop blijft de navigatie zichtbaar tijdens scrollen (snel browsen).
   Mobiel niet: daar neemt de balk te veel ruimte in. */
@media (min-width: 900px) {
  .subnav { position: sticky; top: 0; z-index: 20; }
}

.subnav-inner {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding-top: .6rem;
  padding-bottom: .6rem;
}

/* Hiërarchie-niveaus: scrollen op mobiel, wrap op desktop */
.crumbs {
  display: flex;
  gap: .35rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Extra ruimte onderaan zodat de mobiele scrollbar niet tegen de pillen aan zit */
  padding: .2rem 0 .6rem;
  scrollbar-width: thin;
}

@media (min-width: 768px) {
  .crumbs { flex-wrap: wrap; overflow-x: visible; }
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .3rem .85rem;
  font-size: .9rem;
  color: var(--text);
  white-space: nowrap;
  background: var(--surface);
  user-select: none;
  -webkit-user-select: none;
}
.pill:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pill.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--active-text);
  font-weight: 600;
}

.pager { display: flex; gap: .4rem; }

/* Zelfde uitstraling als de pillen (die tekst-links werken overal):
   rond, padding, geen vaste knopmaat, geen pijl-glyph. */
.pager-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .3rem .85rem;
  background: var(--surface);
  color: var(--text);
  font-size: .9rem;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}
.pager-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager-btn:active { background: var(--accent-soft); }
.pager-btn.is-disabled { opacity: .35; pointer-events: none; }

/* Records-tabel: tabel op desktop, kaarten op mobiel ---------------------- */

.section-title { margin: 0 0 .75rem; }

/* Titel + vorige/volgende-knoppen op één rij */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.section-head .section-title { margin: 0; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table th, .data-table td {
  padding: .65rem .9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.data-table th {
  background: var(--accent-soft);
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

.data-table tbody tr:nth-child(even) { background: var(--row-even); }
.data-table tbody tr:hover { background: var(--accent-soft); }

.data-table td.num { text-align: right; }
.data-table th.num { text-align: right; }
.data-table td > span, .history-table td > span { opacity: .55; font-size: .85em; }
.data-table .methode { color: var(--muted); font-weight: 400; font-size: .85em; }

@media (max-width: 767px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody { display: block; }
  .data-table tbody {
    display: grid;
    gap: .6rem;
  }
  .data-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0 .75rem;
    padding: .7rem .9rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .data-table td {
    border: 0;
    padding: 0;
  }
  .data-table td:first-child {
    grid-column: 1 / -1;
    font-weight: 600;
  }
  .data-table td:nth-child(2) { font-size: 1.05rem; text-align: left; }
  .data-table td:nth-child(3) { text-align: right; color: var(--muted); font-size: .88rem; }
}

/* Grafieken --------------------------------------------------------------- */

.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* Ruimte tussen de jaren-staafgrafiek en de tabel eronder */
#years-charts { margin-bottom: 1.5rem; }

@media (min-width: 900px) {
  .charts-grid { grid-template-columns: 1fr 1fr; }
  .chart-card.is-wide { grid-column: 1 / -1; }
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  min-width: 0; /* grid-item: laat krimpen i.p.v. uit te rekken */
}

.chart-title { margin: 0 0 .5rem; }
.chart {
  width: 100%;
  /* Vaste hoogte zodat de pagina niet groeit zodra uPlot de canvas plaatst */
  min-height: 260px;
}

.chart canvas { max-width: 100%; }

/* Historische tabel (dagpagina) ------------------------------------------- */

.section-sub { color: var(--muted); }

.history-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.history-table th, .history-table td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.history-table th {
  background: var(--accent-soft);
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

.history-table td.num { text-align: right; }
.history-table th.num { text-align: right; }
.history-table tbody tr:nth-child(even) { background: var(--row-even); }
.history-table .diff { color: var(--muted); }

/* Recordmarkering in de extremen-tabel (maandpagina).
   font-size/opacity overschrijven de td > span-regel van de jaartabel
   (die is bedoeld voor °C-eenheden, niet voor de recordwaarden). */
.history-table .is-high { color: #d64545; font-weight: 600; font-size: inherit; opacity: 1; }
.history-table .is-low { color: #4a7bd6; font-weight: 600; font-size: inherit; opacity: 1; }

/* min | max-cellen: flex op een wrapper BINNEN de cel (de td blijft een
   normale tabelcel — display:flex op de td zelf breekt de kolommen).
   Twee helften: alle pipes staan exact onder elkaar in het kolomcentrum. */
.history-table th.minmax { text-align: center; }
.history-table td.minmax > .mm-wrap { display: flex; align-items: baseline; font-size: inherit; opacity: 1; }
.history-table td.minmax > .mm-wrap > .mm-min, .history-table td.minmax > .mm-wrap > .mm-max { flex: 1; font-size: inherit; opacity: 1; }
.history-table td.minmax > .mm-wrap > .mm-min { text-align: right; }
.history-table td.minmax > .mm-wrap > .mm-max { text-align: left; }
/* Pipe rustiger dan de waarden */
.history-table td.minmax > .mm-wrap > .mm-pipe { flex: none; color: var(--muted); opacity: .5; margin: 0 .35rem; }

/* Totaalrij "Alle jaren" in de jaartabel */
.history-table tr.total-row td {
  border-top: 2px solid var(--line);
  font-weight: 600;
  background: var(--accent-soft);
}

.history-table .placeholder { text-align: center; color: var(--muted); font-style: italic; padding: 1rem; }

/* Getrapte kleurcodering in de jaartabel: afwijking van de gemiddelde
   temperatuur t.o.v. het gemiddelde over alle jaren. rgba = werkt in
   zowel lichte als donkere modus. Na zebra/hover, dus tint wint. */
.history-table tbody tr.warm-1 { background: rgba(214, 69, 69, .10); }
.history-table tbody tr.warm-2 { background: rgba(214, 69, 69, .20); }
.history-table tbody tr.warm-3 { background: rgba(214, 69, 69, .25); }
.history-table tbody tr.koud-1 { background: rgba(74, 123, 214, .10); }
.history-table tbody tr.koud-2 { background: rgba(74, 123, 214, .20); }
.history-table tbody tr.koud-3 { background: rgba(74, 123, 214, .25); }

/* Hover: de rij wordt helderder in zíjn eigen kleur (getinte rijen) of
   accent-soft (ongetinte rijen). Specificiteit wint over de basis-tints. */
.history-table tbody tr:hover { background: var(--accent-soft); }
.history-table tbody tr.warm-1:hover { background: rgba(214, 69, 69, .22); }
.history-table tbody tr.warm-2:hover { background: rgba(214, 69, 69, .35); }
.history-table tbody tr.warm-3:hover { background: rgba(214, 69, 69, .48); }
.history-table tbody tr.koud-1:hover { background: rgba(74, 123, 214, .22); }
.history-table tbody tr.koud-2:hover { background: rgba(74, 123, 214, .35); }
.history-table tbody tr.koud-3:hover { background: rgba(74, 123, 214, .48); }

/* Legenda onder de jaartabel: zachte italic
   (staat buiten de tabel, dus geen .history-table-voorvoegsel) */
.legend-note {
  display: block;
  margin-top: .5rem;
  font-size: .82em;
  font-style: italic;
  color: var(--muted);
  opacity: .8;
}

@media (max-width: 767px) {
  .history-table { font-size: .85rem; }
  .history-table th, .history-table td { padding: .4rem .5rem; }
}

/* Dagtabel maandpagina: horizontaal scrollbaar op smalle schermen */
.table-scroll { overflow-x: auto; }
.table-scroll th, .table-scroll td { white-space: nowrap; }

/* Eerste kolom (datum) blijft staan bij horizontaal scrollen.
   sticky vereist border-collapse: separate (met collapse werkt het niet
   betrouwbaar in Firefox) én een overflow die géén scroll-container maakt:
   de tabel gebruikt overflow:hidden voor de afgeronde hoeken, dus hier clip
   (visueel hetzelfde, maar sticky werkt wél). */
.table-scroll .history-table { border-collapse: separate; border-spacing: 0; overflow: clip; }
.table-scroll .history-table th:first-child,
.table-scroll .history-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  border-right: 1px solid var(--line);
}
/* Ondoorzichtige achtergrond: zebra en hover ook zichtbaar in de bevroren cel */
.table-scroll .history-table td:first-child { background: var(--surface); }
.table-scroll .history-table tbody tr:nth-child(even) td:first-child { background: var(--row-even); }
.table-scroll .history-table tbody tr:hover td:first-child { background: var(--accent-soft); }

/* Windroos (dagpagina) -------------------------------------------------------- */

:root {
  --rose-0: #c6dbef;
  --rose-1: #9ecae1;
  --rose-2: #6baed6;
  --rose-3: #4292c6;
  --rose-4: #08519c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --rose-0: #1d3a4f;
    --rose-1: #24506e;
    --rose-2: #2f6d95;
    --rose-3: #3d8cc0;
    --rose-4: #7db8e0;
  }
}

.rose-wrap {
  display: flex;
  gap: 2rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.windrose { width: min(420px, 100%); height: auto; }
.windrose .rose-ring { fill: none; stroke: var(--line); stroke-width: 1; }
.windrose .rose-ring-label { fill: var(--muted); font-size: 10px; }
.windrose .rose-dir { fill: var(--text); font-size: 12px; font-weight: 600; text-anchor: middle; }
.windrose .rose-calm { fill: var(--text); font-size: 22px; font-weight: 700; text-anchor: middle; }
.windrose .rose-calm-label { fill: var(--muted); font-size: 11px; text-anchor: middle; }

.rose-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  font-size: .9rem;
}
.rose-legend li { display: flex; align-items: center; gap: .55rem; }
.rose-chip { width: 18px; height: 12px; border-radius: 3px; display: inline-block; }
.rose-class-0 { fill: var(--rose-0); background: var(--rose-0); }
.rose-class-1 { fill: var(--rose-1); background: var(--rose-1); }
.rose-class-2 { fill: var(--rose-2); background: var(--rose-2); }
.rose-class-3 { fill: var(--rose-3); background: var(--rose-3); }
.rose-class-4 { fill: var(--rose-4); background: var(--rose-4); }

/* Windroos in een grafiek-kaart (maandpagina): compact, legenda eronder */
.chart-card .rose-wrap {
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  padding: .25rem 0;
  border: 0;
  box-shadow: none;
}
.chart-card .windrose { width: min(280px, 100%); }
.chart-card .rose-legend { font-size: .75rem; gap: .35rem .9rem; flex-direction: row; flex-wrap: wrap; justify-content: center; }

/* Footer ------------------------------------------------------------------ */

.site-footer {
  margin-top: 2.5rem;
  padding: 1.25rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .85rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-pdf {
  color: var(--muted);
  font-size: .8rem;
  white-space: nowrap;
}

.footer-pdf:hover { color: var(--accent); }

@media (max-width: 600px) {
  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: .5rem;
  }
}

/* Print / PDF --------------------------------------------------------------- */
/* Simpel: geen navigatie, echte tabel (A4-portrait is < 767px, anders mobiele
   kaarten), altijd licht thema (anders witte tekst op papier in dark mode),
   nette bladbreuken. Grafieken en dark mode printen zoals ze zijn. */

@media print {
  :root {
    color-scheme: light;
    --bg: #fff;
    --surface: #fff;
    --text: #111;
    --muted: #555;
    --accent: #1d6fb8;
    --accent-soft: #eef4fa;
    --line: #c9ced4;
    --row-even: #f6f8fa;
    --shadow: none;
    --rose-0: #c6dbef;
    --rose-1: #9ecae1;
    --rose-2: #6baed6;
    --rose-3: #4292c6;
    --rose-4: #08519c;
  }

  @page { margin: 14mm; }

  .site-header, .subnav, .site-footer, .pager { display: none; }
  .page-head { background: none; }

  /* Echte tabel i.p.v. mobiele kaarten */
  .data-table { display: table; }
  .data-table thead { display: table-header-group; }
  .data-table tbody { display: table-row-group; }
  .data-table tr {
    display: table-row;
    background: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
  }
  .data-table th, .data-table td {
    display: table-cell;
    padding: .5rem .7rem;
    border-bottom: 1px solid var(--line);
  }
  .data-table td:first-child { grid-column: auto; font-weight: inherit; }
  .data-table td:nth-child(2), .data-table td:nth-child(3) {
    font-size: inherit;
    text-align: right;
    color: inherit;
  }

  /* Rijen/kaarten niet doormidden, koppen niet onderaan laten */
  .chart-card, .rose-wrap, .section-head, .history-table tr, .data-table tr { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
}
