/* Hochwasser-Check NRW - Design "Gutachten" (editorial-amtlich, hell)
   Fonts selbst gehostet (DSGVO): Fraunces (Display-Serif) + Source Sans 3 (Text). */

@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/fonts/fraunces-latin-600.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/fraunces-latin-700.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/source-sans-3-latin-400.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/fonts/source-sans-3-latin-600.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/source-sans-3-latin-700.woff2") format("woff2");
}

:root {
  --bg: #F7F4EE; --panel: #FFFFFF; --paper-soft: #FCFAF4;
  --ink: #16323B; --muted: #66757B; --line: #D9D2C2; --line-soft: #E7E1D4;
  --accent: #A35A1F;
  --hoch: #B3361C; --erhoeht: #B4690E; --mittel: #99720A;
  --maessig: #99720A; --gering: #3E7A47; --kein: #3E7A47; --unbekannt: #7C857F;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 12px; --radius-s: 8px;
  --shadow: 0 1px 2px rgba(22, 50, 59, .04), 0 4px 16px rgba(22, 50, 59, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
.container { max-width: 860px; margin: 0 auto; padding: 28px 20px 72px; }

h1, h2, h3 { font-family: var(--serif); color: var(--ink); }
h1 { font-size: 2rem; line-height: 1.15; font-weight: 700; margin: 0 0 .3em; letter-spacing: -.01em; }
h2 { font-size: 1.45rem; line-height: 1.25; font-weight: 600; margin: 1.7em 0 .6em; }
h3 { font-size: 1.1rem; line-height: 1.3; font-weight: 600; margin: 0; }
small { color: var(--muted); font-weight: 400; }
a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: #7C4416; }
::selection { background: #EBDCC9; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
input:focus-visible { outline: none; }

.hero { text-align: center; margin: 28px 0 32px; }
.hero .sub { color: var(--muted); max-width: 600px; margin: 0 auto; font-size: 1.02rem; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px; margin: 16px 0;
  box-shadow: var(--shadow);
}

/* form */
.form .field { display: block; margin: 16px 0; }
.field.big .q { display: block; font-weight: 600; margin-bottom: 8px; }
input[type=text], input[type=email] {
  width: 100%; padding: 13px 15px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font: inherit; font-size: 1rem;
}
input[type=text]::placeholder, input[type=email]::placeholder { color: #9AA5A3; }
input[type=text]:focus, input[type=email]:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(22, 50, 59, .12);
}
fieldset { border: 1px solid var(--line); border-radius: var(--radius-s); margin: 20px 0; padding: 14px 16px; }
legend {
  padding: 0 8px; color: var(--muted); font-size: .8rem;
  text-transform: uppercase; letter-spacing: .09em; font-weight: 600;
}
legend small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.field.check {
  display: flex; gap: 12px; align-items: flex-start; padding: 9px 10px;
  border-radius: var(--radius-s); cursor: pointer;
}
.field.check:hover { background: var(--paper-soft); }
.field.check input {
  margin-top: 4px; width: 18px; height: 18px; flex: none;
  accent-color: var(--ink); cursor: pointer;
}
.btn {
  display: inline-block; background: var(--ink); color: #FDFCF9; border: 0;
  padding: 13px 24px; border-radius: var(--radius-s); font: inherit;
  font-size: 1rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #0F242B; color: #FDFCF9; }
.btn.small { padding: 8px 15px; font-size: .9rem; white-space: nowrap; }
.btn.ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--ink); padding: 12px 23px;
}
.btn.ghost:hover { background: rgba(22, 50, 59, .06); }
.btn.ghost.small { padding: 7px 14px; }
.disclaimer { color: var(--muted); font-size: .85rem; margin-top: 16px; }
.back {
  display: inline-block; margin-bottom: 12px; color: var(--muted);
  font-size: .9rem; text-decoration: none;
}
.back:hover { color: var(--ink); }

/* result header (Briefkopf) */
.result-head { border-width: 2px; }
.result-head h1 { margin: 0; font-size: 1.7rem; }
.result-head .addr { color: var(--muted); margin: .25em 0; font-size: .95rem; }
.result-head .kicker { margin: 0 0 6px; }
.result-head .summary { margin: .5em 0 0; }
.head-grid { display: flex; gap: 24px; align-items: center; }

/* Verdikt: Top-3 + Aktionsleiste im Briefkopf */
.top3 {
  border-top: 1px solid var(--line-soft); margin-top: 20px; padding-top: 16px;
  display: flex; gap: 8px 16px; align-items: baseline; flex-wrap: wrap;
}
.top3-label {
  font-size: .76rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); flex: none;
}
.top3 ol {
  list-style: none; margin: 0; padding: 0; counter-reset: t;
  display: flex; gap: 6px 22px; flex-wrap: wrap;
}
.top3 li { counter-increment: t; }
.top3 li::before {
  content: counter(t) ". "; font-family: var(--serif); font-weight: 700;
  color: var(--accent);
}
.top3 a { color: var(--ink); font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.actions form { margin: 0; }

/* Sticky-Sprungnavigation */
.toc {
  position: sticky; top: 0; z-index: 50;
  display: flex; gap: 2px; flex-wrap: wrap;
  background: rgba(247, 244, 238, .96);
  border-bottom: 1px solid var(--line);
  padding: 9px 2px; margin: 20px 0 8px;
}
.toc a {
  color: var(--muted); text-decoration: none; font-size: .85rem;
  font-weight: 600; padding: 5px 11px; border-radius: 999px; white-space: nowrap;
}
.toc a:hover { color: var(--ink); background: var(--paper-soft); }
[id] { scroll-margin-top: 76px; }

/* nummerierte Gutachten-Sektionen */
main { counter-reset: sec; }
.sec { margin: 36px 0; counter-increment: sec; }
.sec > h2 { display: flex; align-items: baseline; gap: 12px; margin: 0 0 14px; }
.sec > h2::before {
  content: counter(sec, decimal-leading-zero);
  font-family: var(--sans); font-size: .85rem; font-weight: 700;
  letter-spacing: .08em; color: var(--accent); flex: none;
}
.sec > .card { margin: 0 0 14px; }
.card h2:first-child { margin-top: .1em; }
.luftbild-img { width: 100%; border-radius: var(--radius-s); display: block; }

/* Foto-Dropzone */
.dropzone {
  position: relative; border: 2px dashed var(--line); border-radius: var(--radius-s);
  background: var(--paper-soft); text-align: center; padding: 28px 16px; margin: 14px 0 10px;
}
.dropzone.drag { border-color: var(--accent); background: #FBF3E4; }
.dropzone input[type=file] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.dz-text { margin: 0; color: var(--ink); }
.dz-count { margin: 6px 0 0; color: var(--muted); font-size: .9rem; min-height: 1.2em; }
.thumbs { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 6px; }
.thumb { position: relative; width: 86px; height: 86px; }
.thumb img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: var(--radius-s); border: 1px solid var(--line); display: block;
}
.thumb-x {
  position: absolute; top: -8px; right: -8px; width: 24px; height: 24px;
  border-radius: 50%; background: var(--ink); color: #FDFCF9; border: 0;
  font-size: 14px; line-height: 1; cursor: pointer; padding: 0;
}
.thumb-x:hover { background: var(--hoch); }
/* Thumbnail-Fallback, wenn der Browser das Format nicht rendert (HEIC ausser Safari) */
.thumb-noprev {
  display: flex; align-items: center; justify-content: center; padding: 6px;
  background: var(--paper-soft); border: 1px solid var(--line); border-radius: var(--radius-s);
}
.thumb-name { font-size: .7rem; color: var(--muted); text-align: center; line-height: 1.2; word-break: break-all; overflow: hidden; }
.upload-alt { margin-top: 18px; }

/* Foto-Guide (A4): aufklappbare Aufnahme-Anleitung vor dem Upload */
.foto-guide {
  margin: 4px 0 14px; border: 1px solid var(--line);
  border-radius: var(--radius-s); background: var(--paper-soft);
}
.foto-guide > summary {
  padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--ink); list-style: none;
}
.foto-guide > summary::-webkit-details-marker { display: none; }
.foto-guide > summary::before {
  content: "▸"; display: inline-block; margin-right: 8px; color: var(--accent);
}
.foto-guide[open] > summary::before { content: "▾"; }
.foto-guide > summary span { color: var(--muted); font-weight: 400; font-size: .9rem; }
.guide-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px; padding: 4px 14px 6px;
}
.guide-item { display: flex; gap: 10px; align-items: flex-start; }
.guide-item svg { width: 30px; height: 30px; flex: 0 0 auto; color: var(--accent); margin-top: 2px; }
.guide-item strong { display: block; color: var(--ink); font-size: .95rem; }
.guide-item div span { color: var(--muted); font-size: .85rem; line-height: 1.3; }
.guide-tip { padding: 0 14px 12px; margin: 0; }
.alerts input[type=email] { max-width: 340px; }
/* Honeypot: fuer Menschen unsichtbar (off-screen, nicht display:none -> Bots
   fuellen es eher); aus Tab-Reihenfolge und A11y-Baum genommen. */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.leaflet-tile { filter: saturate(.72); }

/* Pegel-Verlaufs-Sparkline (A7) */
.sparkline-wrap { margin: 6px 0 2px; }
.sparkline-wrap figcaption { color: var(--muted); margin-top: 2px; }
.sparkline { width: 100%; max-width: 320px; height: 40px; display: block; }
.sparkline polyline { stroke: var(--muted); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sparkline.up polyline { stroke: var(--erhoeht); }
.sparkline.down polyline { stroke: var(--gering); }

/* dezente Reveal-Animation beim Laden der Ergebnisseite */
@media (prefers-reduced-motion: no-preference) {
  .result-head, .toc, main > section { animation: rise .45s ease backwards; }
  .result-head { animation-delay: .04s; }
  .toc { animation-delay: .1s; }
  main > section:nth-of-type(1) { animation-delay: .16s; }
  main > section:nth-of-type(2) { animation-delay: .22s; }
  main > section:nth-of-type(3) { animation-delay: .28s; }
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.score-circle {
  flex: none; width: 104px; height: 104px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; font-family: var(--serif); font-size: 2.5rem;
  font-weight: 700; line-height: 1; background: var(--paper-soft);
  border: 3px solid var(--line); color: var(--ink);
}
.score-circle small { font-size: .72rem; font-family: var(--sans); margin-top: 4px; letter-spacing: .04em; }
.band-hoch, .band-hoch .score-circle { border-color: var(--hoch); }
.band-erhoeht, .band-erhoeht .score-circle { border-color: var(--erhoeht); }
.band-maessig, .band-maessig .score-circle { border-color: var(--maessig); }
.band-gering, .band-gering .score-circle { border-color: var(--gering); }

#map {
  height: 340px; border-radius: var(--radius); margin: 16px 0;
  border: 1px solid var(--line); position: relative; z-index: 0;
  box-shadow: var(--shadow);
}

/* Gefahren-Layer-Steuerung (B1) */
.hazard-ctrl {
  margin: 0 0 16px; padding: 12px 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-s); box-shadow: var(--shadow);
}
.hz-title { margin: 0 0 8px; font-weight: 600; color: var(--ink); }
.hz-toggles { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.hz-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.hz-opacity { display: inline-flex; align-items: center; gap: 8px; margin: 12px 0 0; color: var(--muted); font-size: .9rem; }
.hz-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; }
.hz-legend-item { margin: 0; }
.hz-legend-item figcaption { font-size: .8rem; color: var(--muted); margin-bottom: 2px; }
.hz-legend-item img { max-width: 220px; height: auto; display: block; background: #fff; border-radius: 4px; }
.hz-hint { margin: 10px 0 0; }

/* hazards */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid .card { margin: 0; }
.hazard ul { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: .92rem; }
.hazard-head { display: flex; gap: 10px; align-items: center; }
.badge {
  font-size: .74rem; font-weight: 700; padding: 4px 11px; border-radius: 999px;
  letter-spacing: .05em; text-transform: uppercase; flex: none;
}
.lvl-hoch { background: var(--hoch); color: #FFF6F2; }
.lvl-mittel { background: #F2E3BC; color: #6E5106; }
.lvl-gering { background: #DCEBDA; color: #2C5A34; }
.lvl-kein { background: #DCEBDA; color: #2C5A34; }
.lvl-unbekannt { background: #E7E4DB; color: #565F59; }

.ctx { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }

/* measures */
.measures { list-style: none; counter-reset: m; padding: 0; margin: 0; }
.measure { position: relative; padding-left: 78px; }
.measure::before {
  counter-increment: m; content: counter(m, decimal-leading-zero);
  position: absolute; left: 24px; top: 20px;
  font-family: var(--serif); font-size: 1.6rem; font-weight: 700;
  color: var(--accent); line-height: 1;
}
.measure-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.tag {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); border: 1px solid var(--line); padding: 3px 9px;
  border-radius: 6px; flex: none; font-weight: 600;
}
.measure .why { color: var(--ink); font-weight: 600; margin: 8px 0 4px; }
.measure .desc { color: var(--muted); font-size: .93rem; margin: 0 0 10px; }
.measure .cost { font-size: .93rem; margin: 0 0 10px; }
.product {
  display: flex; gap: 14px; align-items: center; justify-content: space-between;
  background: var(--paper-soft); border: 1px solid var(--line-soft);
  border-radius: var(--radius-s); padding: 12px 14px; margin-top: 10px;
}
.product .price { color: var(--erhoeht); font-size: .9rem; font-weight: 600; }

.insurance.reco { border-color: var(--erhoeht); border-width: 1.5px; }
.insurance .headline { font-weight: 700; }
.climate p { color: var(--muted); }
.climate .climate-quant { color: var(--ink); }
.situation .warn { color: var(--erhoeht); }
.situation ul { margin: 6px 0 0; padding-left: 18px; }

.sources { margin-top: 36px; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line); padding-top: 18px; }
.sources a { color: var(--muted); }
.error { border-color: var(--hoch); }

/* hero kicker + example chip (Startseite) */
.kicker {
  font-size: .78rem; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 10px;
}
.example-row { color: var(--muted); font-size: .9rem; margin: 10px 0 0; }
.chip {
  display: inline-block; background: var(--paper-soft); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px;
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.chip:hover { border-color: var(--ink); }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 18px; }
.form > .btn[type=submit] { width: 100%; padding: 15px 24px; margin-top: 6px; }

/* Lade-Overlay (app.js) */
.load-overlay {
  position: fixed; inset: 0; z-index: 1000; display: none;
  align-items: center; justify-content: center;
  background: rgba(247, 244, 238, .95);
}
.load-overlay.show { display: flex; }
.load-box { text-align: center; max-width: 380px; padding: 0 24px; }
.load-spinner {
  width: 46px; height: 46px; margin: 0 auto 18px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--ink);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.load-msg { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; margin: 0 0 8px; }
.load-hint { color: var(--muted); font-size: .88rem; margin: 0; }
@media (prefers-reduced-motion: reduce) {
  .load-spinner { animation: none; }
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  .container { padding: 20px 14px 56px; }
  h1 { font-size: 1.65rem; }
  h2 { font-size: 1.3rem; }
  .grid { grid-template-columns: 1fr; }
  .checks { grid-template-columns: 1fr; }
  .head-grid { flex-direction: column; text-align: center; }
  .top3 { flex-direction: column; gap: 8px; }
  .top3 ol { flex-direction: column; gap: 6px; }
  .actions { justify-content: center; }
  .toc { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .toc a { padding: 8px 12px; }
  .measure { padding-left: 24px; padding-top: 52px; }
  .measure::before { left: 24px; top: 18px; }
  .product { flex-direction: column; align-items: flex-start; }
  .measure-head { flex-wrap: wrap; }
  .thumb-x { width: 28px; height: 28px; }
}

/* Wachstum & Monetarisierung (GROWTH.md): Kennzeichnung, CTAs, Premium */
.ad-tag {
  display: inline-block; margin-left: 4px; padding: 0 5px;
  font-family: var(--sans); font-size: .62rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); background: var(--paper-soft);
  border: 1px solid var(--line-soft); border-radius: 4px; vertical-align: middle;
}
.ad-note, .legal-note { color: var(--muted); margin: .2em 0 1em; }
.insurance-cta { margin: 14px 0 6px; }
.premium-cta { border-color: var(--accent); }
.premium-cta h2 { margin-top: 0; }
.kommune-list { columns: 2; column-gap: 28px; margin: 0; padding-left: 1.1em; }
.kommune-list li { margin: 4px 0; break-inside: avoid; }
@media (max-width: 560px) { .kommune-list { columns: 1; } }
.card.answer { border-left: 4px solid var(--accent); background: var(--paper-soft); }
.card.answer .lead { margin: 0; font-size: 1.08rem; }
.widget-body { margin: 0; background: transparent; }
.widget { max-width: 520px; margin: 0 auto; padding: 8px; }
.widget .form { margin: 0; }
.widget-title { margin: 0 0 10px; }
.widget-by { margin: 10px 0 0; text-align: center; }
.embed-code { background: var(--ink); color: #F3EFE6; padding: 12px 14px;
  border-radius: var(--radius-s); overflow-x: auto; font-size: .82rem; white-space: pre-wrap;
  word-break: break-all; }
.embed-code code { color: inherit; }
