/* Selbstversorger-Karte
   Nutzt die Farbtokens aus style.css; hier stehen nur die Bausteine,
   die es sonst nirgends im Blog gibt. */

/* Die Einführungstexte laufen über die volle Spaltenbreite. style.css
   begrenzt .archive-desc auf 40rem - für einen Lesetext neben einer
   bildschirmbreiten Karte wirkt das wie ein abgeschnittener Absatz. */
.map-intro { max-width: none; }

/* --- Werkzeugleiste über der Karte --- */
/* Kopfzeile beider Spalten. Gleiche Höhe, damit Karte und Liste daneben auf
   derselben Linie beginnen - die Auswahlleiste ist sonst höher als die
   Listenüberschrift und die Karte rutscht nach unten. */
.map-toolbar,
.map-side-title {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .75rem;
    min-height: 2.9rem;
    margin: 0 0 .6rem;
}

.map-toolbar-field { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.map-toolbar-label { font-size: .78rem; color: #666; }

.map-toolbar select {
    max-width: 100%;
    padding: .35rem .6rem;
    border: 1px solid rgba(0, 0, 0, .18);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-size: .9rem;
    color: inherit;
    cursor: pointer;
}
.map-toolbar select:hover,
.map-toolbar select:focus-visible { border-color: var(--green, #249d79); outline: none; }

/* --- Auswahl: Liste links, Karte rechts --- */
.map-split {
    display: grid;
    grid-template-columns: 1fr minmax(230px, 300px);
    gap: 1.25rem;
    /* stretch statt start: beide Spalten werden so hoch wie die höhere. Die
       Liste bringt ihre Höhe mit, die Karte füllt den Rest der Spalte - dadurch
       enden Karte und Liste auf derselben Linie. */
    align-items: stretch;
    margin: 1.5rem 0;
}

/* Werkzeugleiste oben, Karte dehnt sich, Quellenangabe schliesst ab */
.map-split-main { display: flex; flex-direction: column; }
/* Im Quelltext steht die Auswahlliste vor der Karte - sie ist der Inhalt, mit
   dem man arbeitet, und soll bei schmalen Fenstern und für Vorleseprogramme
   zuerst kommen. Auf breiten Fenstern tauschen wir die Spalten nur optisch. */
.map-split-side { order: 2; }
.map-split-main { order: 1; }

.map-side-title { font-size: 1rem; }

.map-choices {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.map-choices li + li { border-top: 1px solid rgba(0, 0, 0, .07); }

.map-choice {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .55rem .8rem;
    text-decoration: none;
    color: inherit;
    transition: background .12s;
}
.map-choice:hover,
.map-choice:focus-visible { background: #f2f6f4; outline: none; }

/* Leere Auswahl bleibt anklickbar, tritt aber zurück - dort steht dann
   der Hinweis, dass noch nichts eingetragen ist */
.map-choice.is-empty { opacity: .45; }

.map-choice-name { flex: 1 1 auto; font-weight: 600; font-size: .92rem; }
.map-choice-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; }
.map-choice-count {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    font-size: .82rem;
    color: #555;
    background: rgba(0, 0, 0, .05);
    border-radius: 999px;
    padding: .08rem .5rem;
}

/* Knopf für das Kartenbild: die Grenzen stehen sofort, die Kacheln von
   openstreetmap.org kommen erst auf Klick bzw. bei erteilter Einwilligung */
.map-tiles-btn {
    position: absolute;
    right: .6rem;
    top: .6rem;
    z-index: 500;
    border: 1px solid rgba(0, 0, 0, .18);
    border-radius: 999px;
    background: rgba(255, 255, 255, .94);
    color: #333;
    font-size: .8rem;
    padding: .3rem .75rem;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}
.map-tiles-btn:hover { background: #fff; border-color: var(--green, #249d79); }

/* --- Auswahlraster (wird noch auf der Ergebnisseite gebraucht) --- */
.map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .75rem;
    margin: 1.5rem 0;
}

.map-tile {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .85rem 1rem;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 10px;
    background: #fff;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}

.map-tile:hover,
.map-tile:focus-visible {
    border-color: var(--green, #249d79);
    box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
    transform: translateY(-1px);
}

/* Leere Kombination bleibt anklickbar, tritt aber zurück - dort steht dann
   der Hinweis, dass noch nichts eingetragen ist */
.map-tile.is-empty { opacity: .45; }

.map-tile-name { flex: 1 1 auto; font-weight: 600; }

.map-tile-count {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    font-size: .9rem;
    color: #555;
    background: rgba(0, 0, 0, .05);
    border-radius: 999px;
    padding: .1rem .55rem;
}

.map-tile-dot {
    flex: 0 0 auto;
    width: 11px; height: 11px;
    border-radius: 50%;
}

/* --- Brotkrumen --- */
.map-crumbs {
    font-size: .88rem;
    color: #666;
    margin-bottom: .75rem;
}
.map-crumbs a { color: inherit; }
.map-crumbs span { margin: 0 .35rem; opacity: .6; }

.map-cat-desc { color: #555; font-size: .95rem; }

/* --- Karten ---
   WICHTIG: position/z-index erzeugen hier einen eigenen Stapelkontext.
   Leaflet vergibt intern z-index bis 1000 (Bedienelemente) - ohne diesen
   Rahmen schieben sich Plus/Minus-Knopf und Marker beim Scrollen vor den
   Kopfbereich, der bei z-index 100 klebt. Im Kontext bleibt alles darunter. */
.map-states,
.map-consent {
    position: relative;
    z-index: 0;
    isolation: isolate;
    margin: 1.5rem 0;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 10px;
    overflow: hidden;
    background: #eef1f0;
}

.map-consent {
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-consent-box { text-align: center; padding: 2rem 1.25rem; max-width: 460px; }
.map-consent-box p { margin: 0 0 .6rem; }
.map-consent-box .small { font-size: .85rem; color: #555; }

.map-loading { padding: 2rem; color: #555; text-align: center; }

.map-canvas { height: 460px; width: 100%; }
/* Die Länderauswahl braucht keine Kacheln. Deutschland ist hochkant, deshalb
   bekommt sie einen schmaleren, mittig gesetzten Rahmen - in voller Spaltenbreite
   stünde die Landkarte verloren in einer grauen Fläche. */
.map-states {
    margin: 0;
    background: #f6f8f7;
    /* wächst mit der Spalte; der Mindestwert verhindert nur, dass die Karte bei
       einer sehr kurzen Liste zusammenfällt */
    flex: 1 1 auto;
    min-height: 400px;
}
.map-canvas-states { height: 100%; background: #f6f8f7; cursor: pointer; }

/* Marker: schlichter Punkt, Farbe kommt aus der Kategorie */
.map-pin {
    display: block;
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
}

/* --- Popup, Aufbau wie im Admin: Kategorie, Name, Anschrift, Bundesland --- */
.svb-popup { font-size: .9rem; }
.svb-popup-cat {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .15rem;
}
.svb-popup-name { font-size: 1rem; margin: 0 0 .3rem; line-height: 1.25; }
.svb-popup-addr,
.svb-popup-desc { margin: .3rem 0; }
.svb-popup-state { color: #777; }
.svb-popup-contact { margin: .5rem 0 0; display: flex; gap: .5rem; font-size: 1.1rem; }
.svb-popup-contact a { text-decoration: none; }

/* --- Detailseite: Karte links, scrollbare Liste rechts ---
   Beide bekommen dieselbe feste Höhe, deshalb steht sie als Variable an einer
   Stelle. 690 statt 460 Pixel = 50 Prozent höher. */
.map-split-detail { --map-h: 690px; }
.map-split-detail .map-consent { height: var(--map-h); min-height: var(--map-h); margin: 0; }
.map-split-detail .map-canvas { height: 100%; }

.map-list-wrap {
    height: var(--map-h);
    overflow-y: auto;
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: 10px;
    background: #fff;
}
/* Die Kopfzeile bleibt beim Scrollen stehen - sonst weiss man nach zwanzig
   Zeilen nicht mehr, was man da eigentlich vor sich hat */
.map-list-wrap .map-list-head {
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 0;
    padding: .6rem .9rem .5rem;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, .1);
}
.map-list-wrap .map-list-head h2 { font-size: .98rem; margin: 0 0 .1rem; }
.map-list-wrap .map-list {
    margin: 0;
    border: 0;
    border-radius: 0;
}

/* --- Ergebnisliste: Zeilen, keine Kacheln --- */
.map-list-head { margin-top: 2rem; }
.map-list-head h2 { margin-bottom: .25rem; }
.map-list-hint { font-size: .78rem; color: #777; margin: 0; }

.map-list {
    list-style: none;
    margin: .75rem 0 0;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.map-item {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    padding: .4rem .75rem;
    border-top: 1px solid rgba(0, 0, 0, .07);
    cursor: pointer;
    transition: background .12s;
}
.map-item:first-child { border-top: 0; }
.map-item:hover,
.map-item:focus-visible { background: #f2f6f4; outline: none; }
.map-item.is-active { background: #e6f2ec; box-shadow: inset 3px 0 0 var(--green, #249d79); }

.map-item-dot {
    flex: 0 0 auto;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-top: .38rem;
}

.map-item-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .02rem; }
.map-item-name { font-weight: 600; font-size: .87rem; line-height: 1.3; }
.map-item-addr,
.map-item-desc { font-size: .78rem; color: #666; line-height: 1.35; }

.map-item-contact {
    flex: 0 0 auto;
    display: flex;
    gap: .35rem;
    font-size: .92rem;
    line-height: 1.5;
}
.map-item-contact a { text-decoration: none; }

/* --- Querverweise --- */
.map-cross {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2.5rem;
}
.map-cross h2 { font-size: 1.05rem; margin-bottom: .6rem; }

.map-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.map-chips a {
    display: inline-flex;
    align-items: baseline;
    gap: .35rem;
    padding: .25rem .6rem;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 999px;
    font-size: .85rem;
    text-decoration: none;
    color: inherit;
}
.map-chips a:hover { border-color: var(--green, #249d79); }
.map-chips span { color: #777; font-variant-numeric: tabular-nums; }

/* --- Fussnote --- */
.map-note {
    margin-top: 2rem;
    font-size: .88rem;
    color: #666;
}
.map-credit { font-size: .8rem; color: #888; margin: .5rem 0 0; }
.map-credit-under { margin-top: .45rem; }

@media (max-width: 860px) {
    /* Unter dieser Breite stehen zwei Spalten zu eng - Liste über die Karte,
       also zurück zur Reihenfolge des Quelltextes */
    .map-split { grid-template-columns: 1fr; }
    .map-split-side { order: 1; }
    .map-split-main { order: 2; }
    /* Untereinander gibt es keine gemeinsame Höhe mehr - feste Werte */
    .map-states { min-height: 0; }
    .map-canvas-states { height: 520px; }
    .map-split-detail { --map-h: 480px; }
    /* Die Liste darf hier mitwachsen, statt in einem kurzen Fenster zu scrollen */
    .map-list-wrap { height: auto; max-height: 70vh; }
}

@media (max-width: 600px) {
    .map-canvas { height: 340px; }
    .map-canvas-states { height: 460px; }
    .map-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .map-item { flex-wrap: wrap; }
}
