/* Designsystem, übernommen aus dem IQ-Test-Projekt ("Kluge Kacheln") */
@font-face { font-family: 'Nunito'; font-weight: 400; font-display: swap; src: url('/fonts/Nunito_400Regular.ttf') format('truetype'); }
@font-face { font-family: 'Nunito'; font-weight: 600; font-display: swap; src: url('/fonts/Nunito_600SemiBold.ttf') format('truetype'); }
@font-face { font-family: 'Nunito'; font-weight: 700; font-display: swap; src: url('/fonts/Nunito_700Bold.ttf') format('truetype'); }
@font-face { font-family: 'Nunito'; font-weight: 800; font-display: swap; src: url('/fonts/Nunito_800ExtraBold.ttf') format('truetype'); }

:root {
  --hintergrund: #F6F3EE;
  --hintergrund-alt: #EFF4F1;
  --flaeche: #FFFFFF;
  --flaeche-leise: #FAF8F4;
  --rand: #E6E0D6;
  --text: #2F3B3A;
  --text-leise: #6E7B79;

  --primaer: #5E9C8F;
  --primaer-dunkel: #3F7468;
  --primaer-sanft: #DDEBE6;
  --lavendel: #9A8FD1;
  --lavendel-sanft: #ECE9F8;
  --pfirsich: #EFB49B;
  --pfirsich-sanft: #FBEAE2;
  --sonne: #E8C46A;
  --sonne-sanft: #FBF1D6;

  /* Bedeutungen */
  --gut: #5E9C8F;
  --gut-sanft: #DDEBE6;
  --gut-text: #3F7468;
  --schlecht: #D27A5C;
  --schlecht-sanft: #FBEAE2;
  --schlecht-text: #A65A40;

  --r-sm: 12px; --r-md: 18px; --r-lg: 24px; --r-xl: 32px; --r-pill: 999px;
  --schatten: 0 4px 14px rgba(63, 90, 84, 0.10);
  --schatten-sanft: 0 2px 6px rgba(63, 90, 84, 0.08);
  --schatten-blatt: 0 -6px 28px rgba(63, 90, 84, 0.14);

  --weich: cubic-bezier(.2, .8, .2, 1);
  --sicher-oben: env(safe-area-inset-top, 0px);
  --sicher-unten: env(safe-area-inset-bottom, 0px);
  --max: 520px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  font-size: 17px; line-height: 25px;
  color: var(--text);
  background: var(--hintergrund);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

#karte { position: fixed; inset: 0; }

/* ---------- Kopfzeile ---------- */
.kopf {
  position: fixed; z-index: 10;
  top: calc(var(--sicher-oben) + 12px); left: 12px; right: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  max-width: calc(var(--max) + 120px); margin: 0 auto;
  pointer-events: none;
}
.kopf > * { pointer-events: auto; }
.kopf-titel {
  display: flex; align-items: center; gap: 10px;
  background: var(--flaeche); border-radius: var(--r-pill);
  padding: 7px 18px 7px 7px; box-shadow: var(--schatten);
}
.logo {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primaer-sanft); color: var(--primaer-dunkel);
}
.kopf-zeile { font-size: 12px; line-height: 14px; font-weight: 700; color: var(--text-leise); letter-spacing: .04em; text-transform: uppercase; }
.kopf h1 { font-size: 19px; line-height: 22px; font-weight: 800; }
.kopf-knoepfe { display: flex; gap: 8px; }
.rundknopf {
  position: relative;
  width: 54px; height: 54px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--flaeche); color: var(--text); box-shadow: var(--schatten);
  transition: transform .15s var(--weich), opacity .15s;
}
.rundknopf:active, .knopf:active, .chip:active, .vorschau-karte:active { transform: scale(.97); opacity: .92; }
.punkt { position: absolute; top: 12px; right: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--lavendel); border: 2px solid var(--flaeche); }

/* ---------- Legende ---------- */
.legende {
  position: fixed; z-index: 5;
  left: 12px; bottom: calc(var(--sicher-unten) + 14px);
  display: flex; align-items: center; gap: 14px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px);
  border-radius: var(--r-pill); padding: 8px 14px;
  font-size: 14px; line-height: 18px; font-weight: 700; color: var(--text-leise);
  box-shadow: var(--schatten-sanft);
  transition: opacity .25s var(--weich), transform .25s var(--weich);
}
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.leg { display: inline-block; width: 12px; height: 12px; }
.leg-gut { background: var(--gut); border-radius: 50%; }
.leg-schlecht { background: var(--schlecht); border-radius: 3.5px; }
.beispiel-hinweis { background: var(--sonne-sanft); color: #8A6A1E; padding: 2px 9px; border-radius: var(--r-pill); font-size: 12px; }
body.hat-vorschau .legende { opacity: 0; transform: translateY(8px); pointer-events: none; }

/* ---------- Pins ---------- */
.pin {
  position: relative; display: block;
  width: 40px; height: 48px;
  animation: auftauchen .35s var(--weich) both;
}
.pin-kopf {
  position: absolute; left: 2px; top: 0;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  color: #fff;
  border: 2.5px solid #fff;
  box-shadow: 0 3px 8px rgba(63, 90, 84, .22);
  transition: transform .2s var(--weich);
  transform-origin: 50% 130%;
}
.pin-spitze {
  position: absolute; left: 50%; top: 33px; width: 12px; height: 12px;
  transform: translateX(-50%) rotate(45deg);
  border-right: 2.5px solid #fff; border-bottom: 2.5px solid #fff;
  border-bottom-right-radius: 3px;
}
.pin-gut .pin-kopf { background: var(--gut); border-radius: 50%; }
.pin-gut .pin-spitze { background: var(--gut); }
.pin-schlecht .pin-kopf { background: var(--schlecht); border-radius: 12px; }
.pin-schlecht .pin-spitze { background: var(--schlecht); }
.pin-behoben .pin-kopf, .pin-behoben .pin-spitze { background: #E2A58F; }
.pin-abzeichen {
  position: absolute; right: -2px; top: -4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--gut); color: #fff; border: 2px solid #fff;
  display: grid; place-items: center;
}
.pin.aktiv .pin-kopf { transform: scale(1.18); }
.pin.aktiv { z-index: 2; }

/* ---------- Cluster ---------- */
.cluster {
  --g: 50%;
  width: var(--d, 46px); height: var(--d, 46px); border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--gut) 0 var(--g), var(--schlecht) var(--g) 100%);
  box-shadow: 0 3px 10px rgba(63, 90, 84, .2);
  animation: auftauchen .35s var(--weich) both;
}
.cluster span {
  width: calc(100% - 10px); height: calc(100% - 10px); border-radius: 50%;
  background: var(--flaeche);
  display: grid; place-items: center;
  font-weight: 800; font-size: 16px; color: var(--text);
}

@keyframes auftauchen { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
@keyframes hochgleiten { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes blatt-rein { from { transform: translateY(100%); } to { transform: none; } }
@keyframes einblenden { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Vorschau-Karte ---------- */
.vorschau {
  position: fixed; z-index: 20;
  left: 12px; right: 12px; bottom: calc(var(--sicher-unten) + 12px);
  max-width: var(--max); margin: 0 auto;
}
.vorschau-karte {
  display: flex; gap: 14px; align-items: center; width: 100%; text-align: left;
  background: var(--flaeche); border-radius: var(--r-lg);
  padding: 10px; padding-right: 14px;
  box-shadow: var(--schatten);
  animation: hochgleiten .32s var(--weich) both;
  transition: transform .15s var(--weich);
}
.vorschau-bild { flex: none; width: 92px; height: 92px; border-radius: var(--r-md); object-fit: cover; background: var(--flaeche-leise); }
.vorschau-text { flex: 1; min-width: 0; display: grid; gap: 4px; }
.vorschau-titel { font-weight: 800; font-size: 18px; line-height: 23px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vorschau-meta { font-size: 14px; line-height: 18px; color: var(--text-leise); }
.vorschau-pfeil { flex: none; color: var(--text-leise); }

/* ---------- Kleine Bausteine ---------- */
.etikett {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; line-height: 16px; font-weight: 700;
  padding: 4px 10px 4px 8px; border-radius: var(--r-pill);
  white-space: nowrap; justify-self: start;
}
.etikett-gut { background: var(--gut-sanft); color: var(--gut-text); }
.etikett-schlecht { background: var(--schlecht-sanft); color: var(--schlecht-text); }
.etikett-neutral { background: var(--hintergrund); color: var(--text-leise); }
.etiketten { display: flex; flex-wrap: wrap; gap: 6px; }

.knopf {
  min-height: 60px; width: 100%;
  border-radius: var(--r-pill); padding: 0 28px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 700; font-size: 18px; line-height: 22px;
  transition: transform .15s var(--weich), opacity .15s;
}
.knopf-primaer { background: var(--primaer); color: #fff; box-shadow: var(--schatten-sanft); }
.knopf-sekundaer { background: var(--primaer-sanft); color: var(--primaer-dunkel); }
.knopf-leise { color: var(--primaer-dunkel); min-height: 48px; }

/* ---------- Blätter (Detail, Filter, Info) ---------- */
.schleier {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(47, 59, 58, .28);
  animation: einblenden .25s var(--weich) both;
}
.blatt {
  position: fixed; z-index: 40;
  left: 0; right: 0; bottom: 0;
  max-width: var(--max); margin: 0 auto;
  max-height: calc(100dvh - var(--sicher-oben) - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--hintergrund);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--schatten-blatt);
  padding: 10px 20px calc(var(--sicher-unten) + 24px);
  animation: blatt-rein .34s var(--weich) both;
}
.blatt-griff { width: 44px; height: 5px; border-radius: 3px; background: var(--rand); margin: 0 auto 12px; }
.blatt-kopf { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.blatt-kopf h2 { font-size: 21px; line-height: 28px; font-weight: 700; }
.schliessen {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--flaeche); box-shadow: var(--schatten-sanft); color: var(--text);
}

/* Detail */
.detail-bild-rahmen { position: relative; margin: 0 -8px; }
.detail-bild { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-lg); background: var(--flaeche-leise); }
.detail-bild-rahmen .schliessen { position: absolute; top: 12px; right: 12px; }
.detail-inhalt { display: grid; gap: 14px; padding: 18px 4px 0; }
.detail-inhalt h2 { font-size: 28px; line-height: 34px; font-weight: 800; }
.detail-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; line-height: 20px; color: var(--text-leise); }
.detail-meta span { display: inline-flex; align-items: center; gap: 5px; }
.karte-box {
  background: var(--flaeche); border-radius: var(--r-lg); padding: 18px;
  box-shadow: var(--schatten-sanft); display: grid; gap: 12px;
}
.karte-box p { color: var(--text-leise); font-size: 16px; line-height: 23px; }
.karte-box h3 { font-size: 18px; line-height: 24px; font-weight: 700; }
.box-behoben { background: var(--gut-sanft); box-shadow: none; display: flex; gap: 12px; align-items: center; }
.box-behoben .kreis { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--gut); color: #fff; display: grid; place-items: center; }
.box-behoben p { color: var(--gut-text); font-weight: 600; }

textarea {
  width: 100%; min-height: 96px; resize: vertical;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--flaeche-leise); border: 1.5px solid var(--rand); border-radius: var(--r-md);
  padding: 12px 14px;
}
textarea:focus { outline: none; border-color: var(--primaer); background: #fff; }
.hinweis-fehler { color: var(--schlecht-text) !important; background: var(--schlecht-sanft); border-radius: var(--r-sm); padding: 10px 14px; font-size: 15px; }
.knopf:disabled { opacity: .6; }
.falle { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Filter */
.filter-gruppe { display: grid; gap: 10px; margin-bottom: 20px; }
.filter-gruppe h3 { font-size: 14px; line-height: 18px; font-weight: 700; color: var(--text-leise); text-transform: uppercase; letter-spacing: .04em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 0 16px 0 12px;
  border-radius: var(--r-pill);
  background: var(--flaeche); border: 1.5px solid var(--rand);
  font-weight: 700; font-size: 15px; color: var(--text-leise);
  transition: background .2s, color .2s, border-color .2s, transform .15s var(--weich);
}
.chip[aria-pressed="true"] { background: var(--lavendel-sanft); border-color: var(--lavendel); color: var(--text); }
.chip-gut[aria-pressed="true"] { background: var(--gut-sanft); border-color: var(--gut); color: var(--gut-text); }
.chip-schlecht[aria-pressed="true"] { background: var(--schlecht-sanft); border-color: var(--schlecht); color: var(--schlecht-text); }
.chip .leg { flex: none; }
.filter-fuss { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 6px; }
.filter-fuss .knopf { min-height: 54px; }
.treffer { text-align: center; font-size: 14px; color: var(--text-leise); margin-top: 10px; }

/* Info */
.info-text { display: grid; gap: 12px; color: var(--text); }
.info-text p { color: var(--text-leise); }
.links { display: grid; gap: 2px; margin-top: 8px; background: var(--flaeche); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--schatten-sanft); }
.links a { display: flex; justify-content: space-between; align-items: center; padding: 15px 18px; color: var(--text); text-decoration: none; font-weight: 700; }
.links a + a { border-top: 1px solid var(--rand); }

/* ---------- MapLibre an das Design anpassen ---------- */
.maplibregl-ctrl-attrib { font-family: 'Nunito', sans-serif; font-size: 11px; background: rgba(255, 255, 255, .8) !important; border-radius: var(--r-pill) !important; }
.maplibregl-ctrl-attrib a { color: var(--text-leise); }
.maplibregl-ctrl-bottom-right { bottom: calc(var(--sicher-unten) + 70px); }
.maplibregl-ctrl-attrib-button { border-radius: 50%; }
body.hat-vorschau .maplibregl-ctrl-bottom-right { opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
