:root {
  --erft: #1F4E46;        /* Dunkles Flussgrün: Kopfzeile, Akzente */
  --erft-hell: #2E6B60;
  --backstein: #A6472F;   /* Rheinischer Backstein: Reiter, Links */
  --papier: #FBFAF7;
  --tinte: #26241F;
  --karte-rand: #D8D2C4;
  --linie: #E4DFD3;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Source Sans 3", system-ui, sans-serif;
  font-size: 17px;
  color: var(--tinte);
  background: var(--papier);
  display: flex;
  flex-direction: column;
}

/* ── Kopfzeile ─────────────────────────────── */
header {
  background: var(--erft);
  color: #F2EFE7;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  z-index: 1100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.home-knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 4px;
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  flex: none;
}

.home-knopf:hover { background: rgba(255,255,255,0.15); }

.home-knopf:focus-visible {
  outline: 3px solid #C9E0DB;
  outline-offset: 1px;
}

/* Suchfeld: nur auf großen Bildschirmen sichtbar (siehe Media Query unten),
   dort ganz rechts in der Kopfzeile */
.suche {
  margin-left: auto;
  display: none;
  align-items: center;
}

.suche input {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--erft-hell);
  border-radius: 4px;
  background: #F2EFE7;
  color: var(--tinte);
  width: min(260px, 60vw);
}

.kategorien-auswahl {
  position: relative;
}

#kategorien-knopf {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--erft-hell);
  border-radius: 4px;
  background: #F2EFE7;
  color: var(--tinte);
  cursor: pointer;
  white-space: nowrap;
}

.suche input:focus,
#kategorien-knopf:focus {
  outline: 3px solid #C9E0DB;
  outline-offset: 1px;
}

.kategorien-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 1200;
  background: var(--papier);
  border: 1px solid var(--karte-rand);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  padding: 0.5rem;
  min-width: 220px;
  max-width: min(320px, 85vw);
}

.kategorien-panel[hidden] { display: none; }

.kategorien-zeile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.4rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--tinte);
}

.kategorien-zeile:hover { background: var(--linie); }

.kategorien-zeile .kategorien-name { flex: 1; }

.kategorien-anzahl {
  font-size: 0.8rem;
  opacity: 0.7;
  flex: none;
}

.kategorien-zeile input[type="checkbox"] {
  accent-color: var(--erft);
  width: 16px;
  height: 16px;
  flex: none;
}

.kategorien-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.25);
  flex: none;
}

.kategorien-aktionen {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--linie);
}

.kategorien-aktion {
  flex: 1;
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--erft-hell);
  border-radius: 4px;
  background: #F2EFE7;
  color: var(--tinte);
  cursor: pointer;
}

.kategorien-aktion:hover { background: var(--linie); }

.kategorien-aktion:focus-visible {
  outline: 3px solid #C9E0DB;
  outline-offset: 1px;
}

/* ── Hauptbereich: Sidebar (nur Desktop) + Karte ──────── */
.hauptbereich {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  display: none;
  width: 240px;
  flex: none;
  background: var(--papier);
  border-right: 1px solid var(--karte-rand);
  padding: 1rem;
  overflow-y: auto;
}

.sidebar h2 {
  font-family: "Bitter", serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--erft);
  margin-bottom: 0.6rem;
}

.karte-bereich {
  position: relative;
  flex: 1;
  min-width: 0;
}

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

/* Standort-Button: eigenes Leaflet-Control, stapelt sich unter die Zoom-Buttons */
.leaflet-control-standort a {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tinte);
  background: #fff;
}

.leaflet-control-standort a:hover { background: var(--linie); }

.leaflet-control-standort a[aria-pressed="true"] {
  background: var(--erft-hell);
  color: #fff;
}

/* Eigene Marker: Pin im Kartennadel-Stil */
.ort-marker {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.45));
}

.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
  background-color: rgba(31, 78, 70, 0.25) !important;
}
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background-color: var(--erft) !important;
  color: #F2EFE7 !important;
  font-family: "Source Sans 3", sans-serif;
  font-weight: 600;
}

/* ── Popup als Karteikarte ─────────────────── */
.leaflet-popup-content-wrapper {
  background: var(--papier);
  border: 1px solid var(--karte-rand);
  border-radius: 3px;
  box-shadow: 2px 3px 0 rgba(38,36,31,0.12);
}

.leaflet-popup-content {
  margin: 0;
  width: 250px !important;
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.95rem;
  line-height: 1.45;
}

.karteikarte { padding: 0.75rem 0.9rem 0.9rem; }

.karteikarte .reiter-zeile {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.karteikarte .reiter {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.1rem 0.5rem;
  border-radius: 2px;
}

.karteikarte .reiter-ehemalig {
  color: #F2EFE7;
  background: #4A473F;
}

.karteikarte h2 {
  font-family: "Bitter", serif;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.3;
  margin-bottom: 0.5rem;
  color: var(--tinte);
}

.karteikarte img {
  display: block;
  max-width: 100%;
  max-height: 160px;
  width: auto;
  height: auto;
  margin: 0 auto 0.5rem;
  border: 1px solid var(--karte-rand);
  border-radius: 2px;
}

.karteikarte .bild-platzhalter {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 70px;
  margin: 0 auto 0.5rem;
  border: 1px dashed var(--karte-rand);
  border-radius: 2px;
  color: var(--tinte);
  opacity: 0.6;
  font-size: 0.8rem;
  font-style: italic;
}

.karteikarte a.wiki-link {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--erft);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.karteikarte a.wiki-link:hover,
.karteikarte a.wiki-link:focus {
  color: var(--backstein);
}

/* Fußzeile der Popup-Karte: Wiki-Link links, Foto-Upload-Knopf rechts.
   Unten statt oben rechts, damit er nicht mit Leaflets eigenem
   Schließen-Kreuz (oben rechts) kollidiert. */
.karteikarte-fuss {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  margin-top: 0.3rem;
}

.karteikarte-fuss-zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
}

.karteikarte a.meldung-link {
  font-size: 0.72rem;
  color: var(--tinte);
  opacity: 0.6;
  text-decoration: none;
  text-underline-offset: 2px;
}

.karteikarte a.meldung-link:hover,
.karteikarte a.meldung-link:focus {
  opacity: 0.9;
}

.karteikarte-upload-knopf {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--erft-hell);
  border-radius: 4px;
  background: #F2EFE7;
  color: var(--erft);
  cursor: pointer;
}

.karteikarte-upload-knopf:hover { background: var(--linie); }

.karteikarte-upload-knopf:focus-visible {
  outline: 3px solid #C9E0DB;
  outline-offset: 1px;
}

.leaflet-popup-tip { background: var(--papier); border: 1px solid var(--karte-rand); }

/* ── Foto-Upload-Dialog ─────────────────────── */
/* Eigene Höhe statt vh: mobile Browser ändern die sichtbare Höhe je nach
   Adressleiste/Werkzeugleiste – dvh berücksichtigt das, vh ist der
   Rückfall für ältere Browser. Buttons stehen in einem eigenen,
   nicht-scrollenden Fußbereich, damit sie unabhängig vom Scroll-Zustand
   immer erreichbar sind (siehe .hochladen-aktionen unten). */
dialog#hochladen-dialog {
  display: flex;
  flex-direction: column;
  /* Das globale "* { margin: 0 }"-Reset überschreibt sonst das UA-Default
     margin:auto, das <dialog> normalerweise zum Zentrieren braucht (Autoren-CSS
     schlägt immer Browser-Standardstile) – ohne das hier landet der Dialog
     oben links statt mittig im Viewport. */
  margin: auto;
  border: 1px solid var(--karte-rand);
  border-radius: 4px;
  background: var(--papier);
  color: var(--tinte);
  padding: 0;
  max-width: min(420px, 92vw);
  max-height: 92vh;
  max-height: 92dvh;
  width: 100%;
}

dialog#hochladen-dialog::backdrop { background: rgba(38,36,31,0.5); }

#hochladen-formular {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.hochladen-formular-inhalt {
  overflow-y: auto;
  /* Sicherheitsnetz: einige mobile Browser geben <input type="date"> eine
     eigene Mindestbreite, die width:100% ignoriert und sonst über den
     Dialogrand hinausragen würde. */
  overflow-x: hidden;
  min-height: 0;
  padding: 1rem 1.2rem 0.8rem;
}

#hochladen-titel {
  font-family: "Bitter", serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--erft);
  margin-bottom: 0.4rem;
}

/* Fokus landet beim Öffnen des Dialogs hier (siehe autofocus im Markup),
   statt beim CC-BY-SA-Link – der wäre sonst als erstes fokussierbares
   Element automatisch angesprungen worden. Kein sichtbarer Ring nötig, da
   die Überschrift keine eigene Aktion auslöst. */
#hochladen-titel:focus { outline: none; }

.hochladen-kontext {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--erft);
  background: var(--linie);
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  margin-bottom: 0.5rem;
}

.hochladen-warnung {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--backstein);
  margin-bottom: 0.35rem;
}

.hochladen-hinweis {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-bottom: 0.7rem;
}

.hochladen-hinweis a {
  color: var(--erft);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hochladen-hinweis a:hover,
.hochladen-hinweis a:focus {
  color: var(--backstein);
}

#hochladen-formular label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

#hochladen-formular input[type="file"],
#hochladen-formular input[type="text"],
#hochladen-formular input[type="date"],
#hochladen-formular textarea {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.32rem 0.6rem;
  border: 1px solid var(--erft-hell);
  border-radius: 4px;
  background: #F2EFE7;
  color: var(--tinte);
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-bottom: 0.6rem;
}

#hochladen-formular textarea { resize: vertical; }

#hochladen-formular input:focus-visible,
#hochladen-formular textarea:focus-visible {
  outline: 3px solid #C9E0DB;
  outline-offset: 1px;
}

#hochladen-vorschau {
  display: block;
  max-width: 100%;
  max-height: 110px;
  width: auto;
  height: auto;
  margin: 0 auto 0.6rem;
  border: 1px solid var(--karte-rand);
  border-radius: 2px;
}

.hochladen-spamfalle { position: absolute; left: -9999px; }

.hochladen-status {
  background: #F2EFE7;
  border: 1px solid var(--karte-rand);
  border-left: 3px solid var(--erft-hell);
  border-radius: 3px;
  padding: 0.5rem 0.7rem;
  font-size: 0.88rem;
  margin-bottom: 0.6rem;
}

.hochladen-status.hochladen-status--fehler { border-left-color: var(--backstein); }

.hochladen-aktionen {
  display: flex;
  flex: none;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.7rem 1.2rem;
  border-top: 1px solid var(--karte-rand);
}

.hochladen-aktionen .kategorien-aktion { flex: none; padding: 0.4rem 1rem; }

/* ── Statusmeldungen ───────────────────────── */
.status {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  background: var(--papier);
  border: 1px solid var(--karte-rand);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  padding: 1.2rem 1.5rem;
  max-width: min(420px, 90vw);
  text-align: center;
  font-size: 1rem;
}

.status strong { font-family: "Bitter", serif; }

.status.versteckt { display: none; }

footer {
  background: var(--erft);
  color: #F2EFE7;
  font-size: 0.78rem;
  padding: 0.35rem 1rem;
  text-align: center;
}

footer a { color: inherit; }

@media (max-width: 600px) {
  header { gap: 0.5rem; padding: 0.6rem 0.8rem; }
}

/* Ab hier "großer Bildschirm": feste Sidebar statt Kategorien-Panel,
   Suchfeld erscheint in der Kopfzeile */
@media (min-width: 900px) {
  .kategorien-auswahl { display: none; }
  .suche { display: flex; }
  .sidebar { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
