/* ============================================
   hauke.ninja — Nachhaltigkeit (Wald-Kataster)

   Alles ist unter .wald gescoped. Die Klassennamen der Seite
   (.section, .lead, .docs, .num, .org, .tip, .facts …) sind generisch
   und kollidieren sonst mit css/styles.css — dort existiert .lead
   bereits, dazu kommen die globalen Element-Regeln des Resets
   (section, p, h1–h4, a, ul/ol), die hier bewusst neutralisiert werden.
   css/styles.css wird nicht angefasst.
   ============================================ */

/* --- 1) Palette — abgeleitet aus den Tokens in css/styles.css ---
   --ink/--ink-2/--rule/--fg/--fg-dim/--stamp zeigen auf die echten
   Design-Tokens, damit die Seite den Theme-Toggle automatisch mitmacht.
   Kontraste gegen --ink: --fg 12.0:1 (hell) / 12.7:1 (dunkel),
   --fg-dim 5.1:1 / 6.3:1, --stamp 5.0:1 / 6.3:1, --p4 6.4:1 / 8.4:1. */
.wald {
  --ink:     var(--color-bg);
  --ink-2:   var(--color-surface);
  --rule:    var(--border-soft);
  --fg:      var(--color-ink);
  --fg-dim:  var(--color-ink-muted);
  /* --color-accent (#2a9aab) erreicht als Textfarbe auf --color-bg nur
     2.8:1. Gleicher Farbton, abgedunkelt auf 5.0:1. */
  --stamp:   #1b6f7b;
  --stamp-edge: var(--color-accent);

  /* Parzellen-Töne: hell → dunkel, Richtung Teal gezogen,
     damit sie neben --color-accent sitzen können. */
  --p1: #5fae93;
  --p2: #479277;
  --p3: #33785f;
  --p4: #215f49;
  --p5: #134734;

  --cell: 13px;
  --maxw: 1080px;
  --mono: var(--font-mono);
  --sans: var(--font-body);
}

/* Dark Mode der Site ist violett/pink — die Grüns werden hier heller,
   kühler und weniger gesättigt, damit sie neben #e070b0 nicht schreien. */
[data-theme="dark"] .wald {
  --stamp: var(--color-accent);
  --p1: #2f6d5a;
  --p2: #3d8a70;
  --p3: #4fa588;
  --p4: #68bd9f;
  --p5: #86d3b7;
}

/* --- 2) Basis (innerhalb des Scopes) --- */
.wald {
  background: var(--ink);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
}

/* Reset-Regeln aus styles.css zurückdrehen, die hier stören würden. */
.wald section { padding: 0; }
.wald p { max-width: none; margin: 0; }
.wald h1,
.wald h2,
.wald h3 { margin: 0; font-weight: 600; line-height: 1.12; }
.wald a { color: var(--stamp); }

.wald .page {
  max-width: var(--maxw);
  margin: 0 auto;
  /* +60px Höhe der fixierten .nav */
  padding: calc(clamp(2.5rem, 7vw, 6rem) + 60px) clamp(1.15rem, 5vw, 3rem) 5rem;
}

.wald :focus-visible {
  outline: 2px solid var(--stamp);
  outline-offset: 3px;
  border-radius: 2px;
}

.wald .eyebrow {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.wald .rule { border: 0; border-top: 1px solid var(--rule); margin: 0; }

/* --- Kopf --- */
.wald .masthead { max-width: 44ch; }

.wald .masthead h1 {
  font-family: var(--mono);
  font-size: clamp(1.95rem, 5.3vw, 3.15rem);
  letter-spacing: -.02em;
  margin: 1.15rem 0 0;
  text-wrap: balance;
}

/* Zwei Zeilen als eigene <span>, damit beide einzeln übersetzbar sind. */
.wald .masthead h1 span { display: block; }
.wald .masthead h1 span + span { color: var(--p4); }

.wald .lead {
  margin-top: 1.5rem;
  color: var(--fg-dim);
  font-size: 1.055rem;
  line-height: 1.65;
}

/* --- Zähler --- */
.wald .stand {
  margin-top: clamp(3rem, 7vw, 4.75rem);
  padding-top: 2.25rem;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem 3rem;
  align-items: end;
}

.wald .counter {
  display: flex;
  align-items: baseline;
  gap: .55rem;
  flex-wrap: wrap;
}

.wald .counter__value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(3.6rem, 13vw, 7.5rem);
  line-height: .85;
  letter-spacing: -.045em;
  color: var(--fg);
}

.wald .counter__unit {
  font-family: var(--mono);
  font-size: clamp(1.1rem, 3vw, 1.7rem);
  color: var(--p4);
}

.wald .counter__caption {
  margin-top: 1rem;
  color: var(--fg-dim);
  font-size: .94rem;
}

.wald .facts {
  margin: 0;
  display: grid;
  gap: 1.35rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wald .facts div { border-left: 1px solid var(--rule); padding-left: .95rem; }

.wald .facts dt {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.wald .facts dd {
  margin: .3rem 0 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.3rem;
}

/* --- Abschnittsköpfe --- */
.wald .section { margin-top: clamp(3.5rem, 8vw, 5.5rem); }

.wald .section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem 2rem;
  flex-wrap: wrap;
  padding-bottom: .85rem;
  border-bottom: 1px solid var(--rule);
}

.wald .section__head h2 {
  font-family: var(--mono);
  font-size: 1.02rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.wald .section__note {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--fg-dim);
}

/* --- Kataster --- */
.wald .plot {
  margin-top: 1.6rem;
  display: grid;
  gap: 2px;
  grid-template-columns: repeat(auto-fill, minmax(var(--cell), 1fr));
}

.wald .plot span {
  display: block;
  aspect-ratio: 1;
  border-radius: 1px;
  background: var(--c);
  opacity: .92;
  transition: opacity .18s, transform .18s;
}

.wald .plot.is-dimmed span { opacity: .2; }
.wald .plot.is-dimmed span.on { opacity: 1; transform: scale(1.14); }

.wald .plot__legend {
  margin-top: 1.1rem;
  display: flex;
  gap: 1.35rem;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--fg-dim);
}

.wald .plot__legend b {
  display: inline-block;
  width: .72rem;
  height: .72rem;
  border-radius: 1px;
  background: var(--p3);
  vertical-align: -1px;
  margin-right: .45rem;
}

.wald .tip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  transform: translate(-50%, -135%);
  background: var(--ink-2);
  border: 1px solid var(--stamp-edge);
  border-radius: 3px;
  padding: .5rem .7rem;
  font-family: var(--mono);
  font-size: .75rem;
  line-height: 1.45;
  color: var(--fg);
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

.wald .tip[hidden] { display: none; }
.wald .tip em { font-style: normal; color: var(--fg-dim); }

/* --- Prosa-Spalten --- */
.wald .cols {
  margin-top: 1.9rem;
  display: grid;
  gap: 2.4rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wald .cols h3 {
  font-family: var(--mono);
  font-size: .83rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--p4);
  margin-bottom: .7rem;
}

.wald .cols p { color: var(--fg-dim); font-size: .95rem; }

/* --- Belege --- */
.wald .docs {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.4rem;
  font-size: .94rem;
}

.wald .docs th {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--fg-dim);
  font-weight: 400;
  text-align: left;
  padding: 0 1rem .7rem 0;
  border-bottom: 1px solid var(--rule);
}

.wald .docs td {
  padding: .95rem 1rem .95rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.wald .docs tr { transition: background .15s; }
.wald .docs tbody tr.on { background: var(--ink-2); }

.wald .docs .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

.wald .docs th.num { text-align: right; }

/* In der Datum-Spalte steht der Leistungszeitraum ("Oktober 2025"), kein
   Ziffern-Datum — der tabellarische Ziffernsatz von .num bringt da nichts
   und Monatsnamen liest man in der Textschrift besser. Die Klasse bleibt
   trotzdem an der Zelle: sie liefert nowrap und in der Kartenansicht die
   Beschriftung aus data-label. */
.wald .docs .num.date {
  text-align: left;
  font-family: inherit;
  font-variant-numeric: normal;
}

/* Nur die äußerste Spalte schließt bündig mit dem Tabellenrand ab. Läge
   das padding-right: 0 auf allen .num-Zellen, klebte die Fläche an der
   Beleg-Spalte (Kopfzeile: »FLÄCHEBELEG«). */
.wald .docs th:last-child,
.wald .docs td:last-child { padding-right: 0; text-align: right; }

/* Empfänger & Projekt nimmt den freien Platz auf, die schmalen Spalten
   bleiben so breit wie ihr Inhalt. */
.wald .docs th:nth-child(2),
.wald .docs td:nth-child(2) { width: 100%; }

.wald .org { display: block; }
.wald .org small {
  display: block;
  color: var(--fg-dim);
  font-size: .8rem;
  margin-top: .15rem;
}

.wald .swatch {
  display: inline-block;
  width: .6rem;
  height: .6rem;
  border-radius: 1px;
  background: var(--c);
  margin-right: .6rem;
  vertical-align: 1px;
}

.wald .pdf {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  text-decoration: none;
  font-family: var(--mono);
  font-size: .76rem;
  letter-spacing: .06em;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .34rem .6rem;
  color: var(--stamp);
  white-space: nowrap;
  transition: border-color .15s, background .15s;
}

.wald .pdf:hover,
.wald .pdf:focus-visible {
  border-color: var(--stamp-edge);
  background: var(--ink-2);
}

.wald .fineprint {
  margin-top: 1.6rem;
  color: var(--fg-dim);
  font-size: .83rem;
  max-width: 62ch;
}

/* --- Motion --- */
@keyframes wald-settle {
  from { opacity: 0; transform: scale(.4); }
  to   { opacity: .92; transform: none; }
}

.wald .plot.run span {
  animation: wald-settle .5s backwards;
  animation-delay: calc(var(--i) * 1.1ms);
}

@media (prefers-reduced-motion: reduce) {
  .wald .plot.run span { animation: none; }
  .wald *, .wald *::before, .wald *::after { transition-duration: .01ms !important; }
}

/* --- Mobil --- */
@media (max-width: 760px) {
  .wald { --cell: 9px; }

  .wald .stand { grid-template-columns: 1fr; align-items: start; }
  .wald .cols { grid-template-columns: 1fr; gap: 1.9rem; }
  .wald .facts { grid-template-columns: 1fr 1fr; }

  /* Tabelle wird zur Kartenliste */
  .wald .docs,
  .wald .docs tbody,
  .wald .docs tr,
  .wald .docs td { display: block; width: 100%; }

  .wald .docs thead { display: none; }
  .wald .docs tr { border-bottom: 1px solid var(--rule); padding: 1.1rem 0; }
  .wald .docs td { border: 0; padding: .1rem 0; }

  .wald .docs td.num {
    text-align: left;
    font-size: .85rem;
    color: var(--fg-dim);
  }

  .wald .docs td.num::before {
    content: attr(data-label) " ";
    letter-spacing: .1em;
    text-transform: uppercase;
    font-size: .62rem;
  }

  /* In der Kartenansicht steht alles untereinander und linksbündig —
     die Rechtsbündigkeit der letzten Spalte gilt nur für die Tabelle. */
  .wald .docs td:last-child { padding-top: .8rem; text-align: left; }
}

/* --- Druck --- */
@media print {
  .wald .plot,
  .wald .plot__legend,
  .wald .tip { display: none; }

  .wald .page { padding-top: 0; }
}
