/* =========================================================================
   Toiletten-App - Aussehen
   Auf Handy-Bedienung ausgelegt: grosse Tap-Flaechen, Bedienelemente unten
   in Daumenreichweite, dunkler Modus wird automatisch uebernommen.
   ========================================================================= */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16202b;
  --muted: #64748b;
  --line: #e2e8f0;

  --toilet: #0f766e;   /* Petrol - Toiletten */
  --changing: #b45309; /* Bernstein - Wickelstationen */
  --primary: #0f766e;
  --primary-text: #ffffff;
  --danger: #b91c1c;
  --star: #f59e0b;

  --radius: 16px;
  --shadow: 0 8px 30px rgba(15, 32, 43, .16);
  /* Sicherheitsabstand fuer Geraete mit Notch / Gestenleiste */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #1a212b;
    --text: #e8eef4;
    --muted: #94a3b8;
    --line: #2b3542;
    --toilet: #2dd4bf;
    --changing: #fbbf24;
    --primary: #14b8a6;
    --primary-text: #06231f;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

/* Das HTML-Attribut "hidden" muss IMMER gewinnen. Ohne diese Zeile bleiben
   Elemente sichtbar, denen wir weiter unten ein eigenes "display" geben
   (z.B. display:flex bei den Flächen von unten). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

#map { position: absolute; inset: 0; z-index: 1; background: var(--bg); }

/* Im dunklen Modus die Karte leicht abdunkeln, damit sie nicht blendet */
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: brightness(.72) contrast(1.05) saturate(.85); }
}

/* ---------------------------- Kopfzeile ---------------------------------- */

#topbar {
  position: absolute;
  top: calc(8px + var(--safe-t));
  left: 8px; right: 8px;
  z-index: 500;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  pointer-events: none;
}

/* Auf breiten Bildschirmen blendet Leaflet oben links seine +/- Knöpfe ein.
   Dort Platz lassen, sonst liegt unsere Leiste darüber. */
@media (min-width: 720px) {
  #topbar { left: 56px; }
}

#topbar h1 {
  margin: 0;
  background: var(--surface);
  border-radius: 999px;
  box-shadow: var(--shadow);
  pointer-events: auto;
}
#topbar h1 button {
  border: none; background: none; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 700; letter-spacing: .2px;
  color: var(--text);
  padding: 8px 12px;
  display: flex; align-items: center; gap: 5px;
}
.info-mark { color: var(--muted); font-size: 13px; font-weight: 400; }

/* Runder Knopf für die Liste der letzten Änderungen */
#btn-recent {
  flex: none;
  width: 36px; height: 36px;
  border: none; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow);
  font-size: 17px; line-height: 1; cursor: pointer;
  pointer-events: auto;
}

#filters {
  display: flex; gap: 6px; flex-wrap: wrap;
  min-width: 0; max-width: 100%;   /* nie über den Bildschirmrand hinaus */
  pointer-events: auto;
}

.chip {
  flex: none;               /* nicht stauchen - lieber umbrechen */
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--surface); color: var(--muted);
  padding: 8px 12px; border-radius: 999px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow);
  opacity: .55;
}
.chip.active { opacity: 1; color: var(--text); border-color: var(--primary); }

/* ---------------------------- Hinweisbalken ------------------------------ */

#status {
  flex: 1 0 100%;           /* immer eine eigene Zeile unter den Filtern */
  text-align: center;
}
#status span {
  display: inline-block;
  background: var(--surface); color: var(--muted);
  padding: 7px 14px; border-radius: 999px;
  font-size: 13px; box-shadow: var(--shadow);
  max-width: 92%;
  pointer-events: auto;
}

/* ---------------------------- Runde Knöpfe ------------------------------- */

#fabs {
  position: absolute;
  right: 14px;
  bottom: calc(20px + var(--safe-b));
  z-index: 500;
  display: flex; flex-direction: column; gap: 12px;
}

.fab {
  width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-size: 22px; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
}
.fab:active { transform: scale(.94); }
.fab-primary {
  background: var(--primary); color: var(--primary-text);
  border-color: transparent; font-size: 28px; font-weight: 300;
  width: 60px; height: 60px;
}

/* ---------------------------- Fadenkreuz --------------------------------- */

#crosshair {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 450; color: var(--primary);
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
}

#add-bar {
  position: absolute;
  left: 12px; right: 12px;
  bottom: calc(16px + var(--safe-b));
  z-index: 600;
  background: var(--surface); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
#add-bar p { margin: 0 0 10px; font-size: 14px; color: var(--muted); text-align: center; }

/* ---------------------------- Flächen von unten -------------------------- */

#backdrop {
  position: fixed; inset: 0; z-index: 700;
  background: rgba(6, 12, 18, .45);
  backdrop-filter: blur(2px);
}

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 800;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow);
  max-height: 85vh;
  display: flex; flex-direction: column;
  animation: slide-up .22s ease-out;
}
@keyframes slide-up { from { transform: translateY(100%); } }

@media (min-width: 720px) {
  .sheet {
    left: auto; right: 20px; bottom: 20px;
    width: 420px; border-radius: var(--radius);
    max-height: calc(100vh - 40px);
  }
}

.sheet-grip {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--line);
  margin: 10px auto 0;
  flex: none;
}

.sheet-close {
  position: absolute; top: 10px; right: 10px;
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: transparent; color: var(--muted);
  font-size: 18px; cursor: pointer;
}

.sheet-body {
  padding: 8px 20px calc(24px + var(--safe-b));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet h2 { margin: 6px 40px 4px 0; font-size: 20px; line-height: 1.25; }
.sheet h3 { margin: 22px 0 8px; font-size: 15px; color: var(--muted); }

.muted { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.hint  { color: var(--muted); font-size: 12px; margin: 14px 0 8px; }
.req   { color: var(--danger); }

/* ---------------------------- Begrüßung ---------------------------------- */

.intro-text { margin: 0 0 14px; font-size: 15px; line-height: 1.55; }

.intro-list {
  list-style: none; margin: 0 0 14px; padding: 0;
  display: grid; gap: 10px;
}
.intro-list li {
  display: grid; grid-template-columns: 26px 1fr; gap: 8px;
  font-size: 15px; line-height: 1.45;
}
.intro-list span { font-size: 17px; line-height: 1.3; }

/* ---------------------------- Merkmale ----------------------------------- */

.attrs { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 8px; }
.attrs li {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; padding: 8px 12px;
  background: var(--bg); border-radius: 10px;
}
.attrs .val { margin-left: auto; font-weight: 600; }
.attrs .yes { color: var(--toilet); }
.attrs .no  { color: var(--danger); }

.rating-big { font-size: 20px; margin: 4px 0 4px; }
.rating-big .num { font-weight: 700; }
.rating-big .cnt { font-size: 13px; color: var(--muted); font-weight: 400; }
.stars-view { color: var(--star); letter-spacing: 2px; }

/* ------------------------- Letzte Änderungen ----------------------------- */

.counts {
  display: flex; gap: 10px;
  margin: 12px 0;
}
.counts div {
  flex: 1;
  background: var(--bg); border-radius: 12px;
  padding: 10px 12px; text-align: center;
}
.counts strong { display: block; font-size: 22px; line-height: 1.2; }
.counts span { font-size: 13px; color: var(--muted); }

.recent-list { list-style: none; margin: 12px 0 0; padding: 0; }
.recent-list li { border-top: 1px solid var(--line); }
.recent-list li:first-child { border-top: none; }
.recent-list li.muted { padding: 12px 0; }

.recent-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  border: none; background: none; cursor: pointer;
  font: inherit; color: var(--text); text-align: left;
  padding: 12px 4px;
  border-radius: 8px;
}
.recent-item:hover { background: var(--bg); }
.recent-item .stars-view { flex: none; font-size: 14px; }
.recent-new { flex: none; font-size: 13px; font-weight: 600; color: var(--primary); }
.recent-name { overflow-wrap: anywhere; }

/* ---------------------------- Bewertungsliste ---------------------------- */

.review {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.review:first-child { border-top: none; }
.review-head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.review-del {
  margin-left: auto;
  border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: 15px; line-height: 1;
  padding: 6px 8px; border-radius: 8px;
}
.review-del:hover { background: var(--bg); color: var(--danger); }
.review-del[disabled] { opacity: .4; cursor: default; }
.review-text { margin: 6px 0 0; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.review-tags { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg); color: var(--muted);
}

/* ---------------------------- Formulare ---------------------------------- */

.field-label {
  display: block; margin: 18px 0 8px;
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px;
}

.stars { display: flex; gap: 4px; }
.stars button {
  background: none; border: none; cursor: pointer;
  font-size: 34px; line-height: 1; padding: 0 2px;
  color: var(--line);
}
.stars button.on { color: var(--star); }

.tri { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.tri-label { font-size: 15px; flex: 1; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button {
  border: none; background: var(--surface); color: var(--muted);
  padding: 9px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
  min-width: 46px;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--primary); color: var(--primary-text); }
.seg-wide { width: 100%; }
.seg-wide button { flex: 1; padding: 12px 6px; }

input[type=text], textarea {
  width: 100%; padding: 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 16px; /* 16px verhindert Zoom beim Tippen auf iOS */
  resize: vertical;
}
input[type=text]:focus, textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }

/* ---------------------------- Knöpfe ------------------------------------- */

.row { display: flex; gap: 10px; margin-top: 14px; }
.row .btn { flex: 1; }

.btn {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 16px; font: inherit; font-weight: 600;
  cursor: pointer; background: var(--surface); color: var(--text);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.btn-ghost { background: var(--bg); }
.btn-block { width: 100%; margin-top: 18px; padding: 15px; font-size: 16px; }

/* Bewusst zurückhaltend: soll man finden, aber nicht versehentlich treffen. */
.btn-remove {
  width: 100%;
  margin-top: 24px;
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.btn-remove:hover { color: var(--danger); border-color: var(--danger); }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---------------------------- Marker ------------------------------------- */

/* Große Marker - nur bei nahem Zoom, sonst verdecken sie die Karte */
/* Hülle um den Pin. Sie ist absichtlich viel größer als der Pin selbst -
   der Platz wird für den Sterne-Ring gebraucht. Damit die große Fläche nicht
   die Nachbar-Marker "abschirmt", nimmt nur der Pin selbst Klicks entgegen. */
.poi-icon { pointer-events: none; }
.poi-icon .pin { pointer-events: auto; }

.pin-wrap {
  position: relative;
  width: 64px; height: 64px;
}
.pin-wrap .pin { position: absolute; left: 15px; top: 15px; }

/* Ein kleiner Stern des Bewertungs-Rings. Der Winkel kommt je Stern als
   CSS-Variable --a von außen (270deg = 9 Uhr, dann in 45er-Schritten weiter).
   Ablauf der Transformation von rechts nach links gelesen:
     1. rotate(-a)  dreht das Sternzeichen wieder gerade,
     2. translateY  schiebt es 24 px nach oben (= nach außen),
     3. rotate(a)   dreht die ganze Bewegung auf die gewünschte Uhrzeit.
   Kontrast: acht kleine Schatten rings um das Zeichen ergeben eine Kontur
   (CSS kennt keine echte Umrandung für Text). Zwei Stellschrauben je Zeile:
   die dritte Zahl ist die Weichzeichnung, die letzte die Deckkraft.
     hart      = 0px / #000        (scharfe Kante)
     MITTEL    = 1px / rgba(...,.75)   <- aktuell eingestellt
     weich     = ein einzelner Schein 0 0 2px statt der acht Schatten */
.rstar {
  position: absolute;
  left: 50%; top: 50%;
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  font-size: 12px; line-height: 12px; font-style: normal; text-align: center;
  color: var(--star);
  text-shadow:
    -1px -1px 1px rgba(0, 0, 0, .75),  0 -1px 1px rgba(0, 0, 0, .75),  1px -1px 1px rgba(0, 0, 0, .75),
    -1px  0   1px rgba(0, 0, 0, .75),                                  1px  0   1px rgba(0, 0, 0, .75),
    -1px  1px 1px rgba(0, 0, 0, .75),  0  1px 1px rgba(0, 0, 0, .75),  1px  1px 1px rgba(0, 0, 0, .75),
    0 1px 3px rgba(0, 0, 0, .45);
  transform: rotate(var(--a)) translateY(-24px) rotate(calc(-1 * var(--a)));
}

.pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
}
.pin span { transform: rotate(45deg); font-size: 16px; line-height: 1; }
.pin-toilet   { background: var(--toilet); }
.pin-changing { background: var(--changing); }
.pin-both     { background: linear-gradient(135deg, var(--toilet) 50%, var(--changing) 50%); }
/* Selbst eingetragener Ort: gelber Rand statt weißem - genau wie bei den
   kleinen Punkten (.dot.is-local). Früher saß hier ein gelber Eckpunkt; der
   lag dem Sterne-Ring im Weg, weil ihn die Drehung des Pins ausgerechnet
   auf die 12-Uhr-Position schob. */
.pin.is-local { border-color: var(--star); }

/* Kleine Punkte - mittlere Zoomstufen. Zeigen nur, DASS hier etwas ist. */
.dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.dot-toilet   { background: var(--toilet); }
.dot-changing { background: var(--changing); }
.dot-both     { background: linear-gradient(135deg, var(--toilet) 50%, var(--changing) 50%); }
.dot.is-local { border-color: var(--star); }

.me-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: #2563eb; border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .25);
}

/* ---------------------------- Meldung ------------------------------------ */

#toast {
  position: fixed;
  left: 50%; bottom: calc(90px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 900;
  background: #16202b; color: #fff;
  padding: 12px 18px; border-radius: 12px;
  font-size: 14px; max-width: 88vw; text-align: center;
  box-shadow: var(--shadow);
}
#toast.err { background: var(--danger); }

/* Leaflet-Steuerelemente an unser Layout anpassen */
.leaflet-control-attribution {
  font-size: 11px;
  background: rgba(255,255,255,.85) !important;
}
@media (prefers-color-scheme: dark) {
  .leaflet-control-attribution { background: rgba(26,33,43,.85) !important; }
  .leaflet-control-attribution a { color: var(--primary) !important; }
}
.leaflet-control-zoom { display: none; } /* am Handy stört das nur */
@media (min-width: 720px) { .leaflet-control-zoom { display: block; } }
