/* Standortkarte – Gestaltung.
   Leitlinie: Die Karte ist das Werkzeug, die Oberfläche tritt zurück. Dunkle, leicht durchscheinende Tafeln
   über einer hellen Karte; je Ebene genau eine Farbe, überall gleich (Schalter, Steckbrief, Auswahl in der Karte):
   Flurstück orange (wie die Markierung eines Grenzsteins), Gebäude blau (wie eine Blaupause), Nutzung grün. */

@font-face {
  font-family: "Geist"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("lib/schrift/geist-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Unbounded"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url("lib/schrift/unbounded-latin-wght-normal.woff2") format("woff2");
}

:root {
  --tinte: #0e1726;
  --tinte-glas: rgba(14, 23, 38, 0.88);
  --tinte-2: #18263c;
  --tinte-3: #22324b;
  --linie: rgba(226, 236, 250, 0.1);
  --text: #eaf0f8;
  --text-leise: #95a5bb;
  --flurstueck: #ff8a3d;
  --gebaeude: #7aa7ff;
  --nutzung: #4fd394;
  --warnung: #ffc857;
  --fehler: #ff7f7f;
  --papier: #f1f4f8;
  --papier-karte: #ffffff;
  --papier-text: #0e1726;
  --papier-leise: #56657a;
  --papier-linie: #dbe2eb;
  --radius: 16px;
  --radius-klein: 10px;
  --schatten: 0 10px 30px rgba(6, 12, 24, 0.28), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --schrift: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --schrift-marke: "Unbounded", "Geist", system-ui, sans-serif;
  font-family: var(--schrift);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
.unsichtbar { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--flurstueck); outline-offset: 2px; }
button, input, select { font: inherit; }

[data-farbe="flurstueck"] { --farbe: var(--flurstueck); }
[data-farbe="gebaeude"] { --farbe: var(--gebaeude); }
[data-farbe="nutzung"] { --farbe: var(--nutzung); }

/* --- Wortmarke ----------------------------------------------------------------------------------- */

.wortmarke {
  display: flex; align-items: center; gap: 10px; margin: 0;
  font-family: var(--schrift-marke); font-weight: 500; font-size: 15px; letter-spacing: 0.01em;
  color: var(--text); text-decoration: none;
}
.marke { /* Ein Flurstück mit markiertem Grenzpunkt */
  position: relative; width: 18px; height: 18px; flex: none;
  border: 2px solid currentColor; border-radius: 3px; transform: rotate(-8deg);
}
.marke::after {
  content: ""; position: absolute; right: -5px; top: -5px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--flurstueck); box-shadow: 0 0 10px var(--flurstueck);
}
#gemeinde-name { color: var(--text-leise); font-weight: 400; }

/* --- Kartenseite --------------------------------------------------------------------------------- */

.kartenseite { height: 100%; overflow: hidden; background: #e8ecf1; color: var(--text); }
html:has(.kartenseite) { height: 100%; }
#karte { position: absolute; inset: 0; }
.karte-ueberlagerung { position: absolute; z-index: 2; }

.kopf, .steckbrief, .hinweisband, .fusszeile, .schwebe, .treffer {
  background: var(--tinte-glas); color: var(--text);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--linie); box-shadow: var(--schatten);
}

.kopf {
  top: 14px; left: 14px; width: min(380px, calc(100% - 28px));
  border-radius: var(--radius); padding: 14px;
}

/* Suche: ein Feld; die Gemarkung erscheint nur bei einer Flurstücksnummer. */
.suche {
  position: relative; display: flex; align-items: stretch; margin-top: 12px;
  background: var(--tinte-2); border: 1px solid var(--linie); border-radius: 999px; padding: 3px;
}
.suche:focus-within { border-color: color-mix(in srgb, var(--flurstueck) 70%, transparent); }
.suche input {
  flex: 1 1 auto; min-width: 0; border: 0; background: none; color: var(--text); padding: 7px 4px 7px 12px; font-size: 14px;
}
.suche input::placeholder { color: var(--text-leise); }
.suche input:focus { outline: none; }
.suche input::-webkit-search-cancel-button { filter: invert(0.7); }
.suche select {
  display: none; flex: 0 0 auto; max-width: 42%; border: 0; border-left: 1px solid var(--linie); border-radius: 0;
  background: none; color: var(--text); padding: 0 8px; font-size: 13px; cursor: pointer;
}
.suche select option { color: var(--papier-text); }
.suche.flurstueck-modus select { display: block; }
.suche button[type="submit"] {
  flex: none; width: 34px; height: 34px; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--flurstueck); color: var(--tinte); display: grid; place-items: center;
}
.suche button[type="submit"] svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.suche button[type="submit"]:hover { filter: brightness(1.08); }
.treffer {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  border-radius: var(--radius-klein); max-height: 280px; overflow: auto; z-index: 3;
}
.treffer button {
  display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 7px;
  font-size: 13.5px; cursor: pointer; color: var(--text);
}
.treffer button:hover, .treffer button:focus-visible { background: var(--tinte-3); outline: none; }
.meldung { margin: 8px 4px 0; font-size: 13px; color: var(--warnung); }

/* Ebenen: drei Schalter, Farbe = Ebene */
.ebenen { margin-top: 12px; }
.schalter-reihe { display: flex; gap: 6px; flex-wrap: wrap; }
.schalter {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none;
  padding: 5px 11px 5px 9px; border-radius: 999px; font-size: 13px;
  background: var(--tinte-2); border: 1px solid var(--linie); color: var(--text);
  transition: background-color 0.15s, color 0.15s;
}
.schalter input { position: absolute; opacity: 0; pointer-events: none; }
.punkt {
  width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block;
  background: var(--farbe); box-shadow: 0 0 8px color-mix(in srgb, var(--farbe) 70%, transparent);
}
.schalter:has(input:checked) { background: color-mix(in srgb, var(--farbe) 16%, var(--tinte-2)); border-color: color-mix(in srgb, var(--farbe) 45%, transparent); }
.schalter:has(input:not(:checked)) { color: var(--text-leise); }
.schalter:has(input:not(:checked)) .punkt { background: none; box-shadow: inset 0 0 0 1.5px var(--farbe); }
.schalter:has(input:focus-visible) { outline: 2px solid var(--farbe); outline-offset: 2px; }
.ebenen-aus { margin: 8px 2px 0; font-size: 12.5px; color: var(--warnung); }
.fehlt { margin: 8px 2px 0; font-size: 12.5px; color: var(--warnung); }

.legende-knopf {
  margin-top: 10px; padding: 2px 0; border: 0; background: none; cursor: pointer;
  font-size: 12.5px; color: var(--text-leise);
}
.legende-knopf::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 7px; vertical-align: 2px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform 0.15s; }
.legende-knopf[aria-expanded="true"]::after { transform: rotate(225deg); vertical-align: -1px; }
.legende-knopf:hover { color: var(--text); }
.legende-tafel { margin-top: 8px; max-height: 46vh; overflow: auto; }
.legende-ebenen { list-style: none; margin: 0; padding: 0; }
.legende-ebenen li { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.legende-name { flex: 1; }
.legende-zahl { color: var(--text-leise); font-variant-numeric: tabular-nums; }
.legende-nutzung {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 8px; padding-top: 10px;
  border-top: 1px solid var(--linie); font-size: 12px; color: var(--text-leise);
}
.legende-nutzung i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legende-nutzung i.gestrichelt { background: none; border: 1.5px dashed #b59ad6; }

.klasse {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px;
  font-size: 11px; font-weight: 600; border-radius: 5px;
  border: 1px solid currentColor; color: var(--text-leise);
}

/* Hinweisbänder */
.hinweisband {
  top: 14px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 28px);
  border-radius: 999px; padding: 8px 16px; font-size: 13px;
}
.hinweisband.fehler { top: auto; bottom: 64px; border-radius: var(--radius-klein); color: #ffd5d5;
  background: color-mix(in srgb, #5a1620 80%, transparent); border-color: rgba(255, 127, 127, 0.35); }
@media (max-width: 1180px) { .hinweisband:not(.fehler) { top: auto; bottom: 64px; } }

/* Schweben: kurze Angaben unter dem Mauszeiger */
.schwebe {
  position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none;
  border-radius: var(--radius-klein); padding: 7px 10px; font-size: 12.5px; max-width: 280px;
  display: flex; flex-direction: column; gap: 3px;
}
.schwebe-zeile { display: flex; gap: 6px; align-items: baseline; color: var(--text-leise); }
.schwebe-zeile::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--farbe); flex: none; transform: translateY(-1px); }
.schwebe-zeile b { color: var(--text); font-weight: 600; }

/* Steckbrief */
.steckbrief {
  top: 14px; right: 14px; max-height: calc(100% - 28px); width: min(400px, calc(100% - 28px));
  border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden;
  animation: herein 0.22s ease-out;
}
@keyframes herein { from { opacity: 0; transform: translateX(12px); } }
@media (prefers-reduced-motion: reduce) { .steckbrief { animation: none; } }
.steckbrief-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 18px 18px 12px; }
.steckbrief-kopf h2 { margin: 0; font-family: var(--schrift-marke); font-weight: 500; font-size: 21px; line-height: 1.2; }
.unterzeile { margin: 4px 0 0; color: var(--text-leise); font-size: 13px; }
.schliessen {
  flex: none; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--linie); cursor: pointer;
  background: var(--tinte-2); color: var(--text-leise); display: grid; place-items: center;
}
.schliessen svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.schliessen:hover { color: var(--text); }
.steckbrief-inhalt { overflow: auto; padding: 0 14px 14px; overscroll-behavior: contain; }

.abschnitt {
  margin: 0 0 10px; padding: 12px 14px 12px 15px; border-radius: 12px; position: relative;
  background: color-mix(in srgb, var(--farbe) 7%, var(--tinte-2));
  border: 1px solid color-mix(in srgb, var(--farbe) 18%, transparent);
}
.abschnitt::before {
  content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--farbe); box-shadow: 0 0 10px var(--farbe);
}
.abschnitt-kopf { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.abschnitt-kopf h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--farbe); letter-spacing: 0.01em; }
.abschnitt-meta { margin-left: auto; display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-leise); white-space: nowrap; }
.marke-aus { font-size: 11px; color: var(--warnung); border: 1px solid color-mix(in srgb, var(--warnung) 50%, transparent); border-radius: 999px; padding: 0 7px; }

.kennzahl { margin: 2px 0 10px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.kennzahl-wert { font-family: var(--schrift-marke); font-size: 28px; font-weight: 500; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kennzahl-wert .keine-angabe { font-family: var(--schrift); font-size: 15px; }
.kennzahl-text { color: var(--text-leise); font-size: 12.5px; }

.werte { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; margin: 0; }
.werte dt { color: var(--text-leise); font-size: 13px; }
.werte dd { margin: 0; overflow-wrap: anywhere; }
.werte code { font-family: var(--schrift); font-size: 12.5px; color: var(--text-leise); }
.keine-angabe { color: var(--text-leise); font-style: italic; }
.objekt + .objekt { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--linie); }
.objekt-titel { margin: 0 0 7px; font-size: 16px; font-weight: 600; }
.etikett {
  display: inline-block; margin-left: 4px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 500;
  color: var(--farbe, var(--text-leise)); border: 1px solid color-mix(in srgb, var(--farbe, #fff) 40%, transparent); vertical-align: 1px;
  cursor: help;
}
.fehlt-zeile { margin: 8px 0 0; font-size: 12px; color: var(--text-leise); }
.leer { margin: 0; color: var(--text-leise); }

.kasten { border-radius: var(--radius-klein); padding: 9px 12px; margin: 0 0 10px; font-size: 13px; }
.kasten.warnung { color: var(--warnung); background: color-mix(in srgb, var(--warnung) 10%, transparent); border: 1px solid color-mix(in srgb, var(--warnung) 30%, transparent); }

.quelle-stand { margin: 4px 0 0; border-top: 1px solid var(--linie); }
.quelle-stand summary {
  list-style: none; cursor: pointer; padding: 11px 2px; font-size: 13px; color: var(--text-leise);
  display: flex; align-items: center; justify-content: space-between;
}
.quelle-stand summary::-webkit-details-marker { display: none; }
.quelle-stand summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.quelle-stand[open] summary::after { transform: rotate(225deg); }
.quelle-stand summary:hover { color: var(--text); }
.quelle-stand p { margin: 6px 0; font-size: 12.5px; color: var(--text-leise); }
.quelle-stand a, .namensnennung a { color: var(--text); }
table.stand { border-collapse: collapse; width: 100%; font-size: 12.5px; margin-bottom: 6px; }
table.stand th, table.stand td { text-align: left; padding: 5px 8px 5px 0; border-bottom: 1px solid var(--linie); vertical-align: top; }
table.stand th { font-weight: 500; color: var(--text-leise); }
table.stand .klasse { margin-right: 6px; }
.namensnennung { margin: 10px 2px 0; font-size: 11px; color: var(--text-leise); }

/* Fußzeile: Wege zu Quellen und Hinweisen */
.fusszeile {
  left: 14px; bottom: 14px; display: flex; gap: 2px; border-radius: 999px; padding: 4px;
}
.fusszeile a { color: var(--text-leise); text-decoration: none; font-size: 12.5px; padding: 5px 11px; border-radius: 999px; }
.fusszeile a:hover { color: var(--text); background: var(--tinte-3); }

/* Bedienelemente der Karte */
.maplibregl-ctrl-group { background: var(--tinte-glas) !important; border: 1px solid var(--linie); border-radius: 12px !important; box-shadow: var(--schatten) !important; overflow: hidden; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--linie) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) brightness(0.9); }
.maplibregl-ctrl-group button:not(:disabled):hover { background: var(--tinte-3) !important; }
.maplibregl-ctrl-scale { background: rgba(14, 23, 38, 0.7); color: var(--text); border-color: var(--text-leise); font-size: 11px; }
.maplibregl-ctrl-attrib { font-size: 11px; background: rgba(255, 255, 255, 0.75) !important; }
.maplibregl-ctrl-bottom-right { transition: right 0.2s; }
@media (min-width: 701px) {
  body.steckbrief-offen .maplibregl-ctrl-bottom-right { right: 424px; }
  body.steckbrief-offen .hinweisband { left: calc((100% - 428px) / 2); max-width: calc(100% - 470px); }
  .maplibregl-ctrl-bottom-right .maplibregl-ctrl { margin-right: 14px; }
}

@media (max-width: 700px) {
  .kopf { top: 8px; left: 8px; width: calc(100% - 16px); padding: 10px 10px 8px; }
  .wortmarke { font-size: 13px; }
  .schalter-reihe { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .schalter { flex: none; }
  .steckbrief {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 62vh;
    border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; animation-name: hoch;
  }
  @keyframes hoch { from { opacity: 0; transform: translateY(16px); } }
  .fusszeile { bottom: 34px; left: 8px; }
  body.steckbrief-offen .fusszeile { display: none; }
  .hinweisband.fehler, .hinweisband:not(.fehler) { bottom: 76px; }
  .legende-nutzung { grid-template-columns: 1fr; }
}

/* --- Textseite: Quellen & Stand, Hinweise ---------------------------------------------------------- */

.textseite { background: var(--papier); color: var(--papier-text); min-height: 100vh; }
.seitenkopf {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, calc((100% - 820px) / 2)); background: var(--tinte); color: var(--text);
}
.zur-karte {
  color: var(--tinte); background: var(--flurstueck); text-decoration: none; font-weight: 600; font-size: 13px;
  padding: 7px 14px; border-radius: 999px;
}
.zur-karte:hover { filter: brightness(1.08); }
.textspalte { max-width: 820px; margin: 0 auto; padding: 28px 16px 64px; }
.textspalte h1 { font-family: var(--schrift-marke); font-weight: 500; font-size: 26px; line-height: 1.2; margin: 36px 0 12px; scroll-margin-top: 80px; }
.textspalte section { scroll-margin-top: 64px; }
.textspalte p, .textspalte li { max-width: 70ch; }
.textspalte a { color: #1d4ed8; }
.sprungmarken { display: flex; gap: 8px; flex-wrap: wrap; }
.sprungmarken a { text-decoration: none; color: var(--papier-text); background: var(--papier-karte); border: 1px solid var(--papier-linie); padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.sprungmarken a:hover { border-color: var(--papier-leise); }
.textseite .leise { color: var(--papier-leise); font-size: 13px; }
.textseite .klasse { color: var(--papier-leise); }
.textseite .kasten.warnung { color: #7a4b00; background: #fff4dc; border-color: #f2d49a; }
.textseite .kasten.fehler { color: #8a1c1c; background: #fde8e8; }
.klassen { display: grid; grid-template-columns: max-content 1fr; gap: 6px 10px; margin: 12px 0 20px; font-size: 13px; color: var(--papier-leise); }
.klassen dd { margin: 0; }
.ebene-karte {
  position: relative; background: var(--papier-karte); border: 1px solid var(--papier-linie); border-radius: 14px;
  padding: 18px 20px; margin: 14px 0;
}
.ebene-karte[data-farbe]::before {
  content: ""; position: absolute; left: -1px; top: 18px; width: 3px; height: 26px; border-radius: 0 3px 3px 0; background: var(--farbe);
}
.ebene-karte h2 { display: flex; align-items: center; gap: 9px; margin: 0 0 8px; font-size: 18px; font-weight: 600; }
.ebene-karte h2 .punkt { box-shadow: none; }
.ebene-karte h3 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
.ebene-karte ul { padding-left: 18px; margin: 6px 0; }
.ebene-karte li { margin: 3px 0; }
.ergebnis { color: var(--papier-leise); font-size: 13px; }
.textseite .werte dt { color: var(--papier-leise); }
.textseite .werte code, .textseite code { font-size: 12.5px; color: var(--papier-leise); overflow-wrap: anywhere; }
.textseite .keine-angabe { color: var(--papier-leise); }
.tabelle { overflow-x: auto; }
.textseite table.stand th, .textseite table.stand td { border-bottom-color: var(--papier-linie); }
.textseite table.stand th { color: var(--papier-leise); }
.grundsaetze { padding-left: 18px; }
.grundsaetze li { margin: 6px 0; }
@media (max-width: 700px) {
  .textspalte h1 { font-size: 21px; }
  .ebene-karte { padding: 14px; }
  .seitenkopf .wortmarke { font-size: 12px; }
}
