/*
 * Farbwelt: warme umbrische Erdtöne, dazu Carabinieri-Blau und -Rot.
 * Die Belegqualität der Drehorte wird durchgehend über dieselben drei
 * Signalfarben transportiert (hoch / mittel / niedrig) plus eine eigene
 * Kennzeichnung für reine Handlungsorte.
 */

:root {
    --terracotta: #8B4513;
    --terracotta-hell: #A9662F;
    --sand: #D2B48C;
    --sand-hell: #EFE3D2;
    --blau: #1A365D;
    --rot: #C53030;
    --grund: #FDFBF7;
    --flaeche: #FFFFFF;
    --text: #2D3748;
    --text-leise: #6B7280;
    --linie: #E2E8F0;

    --beleg-hoch: #1A365D;
    --beleg-mittel: #B7791F;
    --beleg-niedrig: #A0AEC0;
    --handlungsort: #805AD5;

    --radius: 12px;
    --schatten: 0 2px 10px rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: 'Roboto', system-ui, sans-serif;
    background-color: var(--grund);
    color: var(--text);
    line-height: 1.6;
}

h1, h2, h3 {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--terracotta);
    line-height: 1.25;
}

a {
    color: var(--blau);
}

.hidden {
    display: none !important;
}

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

header {
    background: linear-gradient(135deg, #7B3E12 0%, #A9662F 55%, #C58B4E 100%);
    color: #FFF7ED;
    border-bottom: 5px solid var(--rot);
    padding: 2.5rem 1rem 2rem;
}

.kopf-inhalt {
    max-width: 1240px;
    margin: 0 auto;
}

.kopf-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.78rem;
    font-weight: 500;
    opacity: 0.85;
}

header h1 {
    color: #FFF7ED;
    font-size: clamp(2rem, 5vw, 3rem);
    margin: 0.2rem 0 0.5rem;
}

.kopf-untertitel {
    max-width: 62ch;
    font-size: 1.05rem;
    opacity: 0.95;
}

.kennzahlen {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.kennzahlen li {
    background: rgba(255, 247, 237, 0.14);
    border: 1px solid rgba(255, 247, 237, 0.35);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
}

.kennzahlen strong {
    font-size: 1.3rem;
    font-weight: 700;
}

.kennzahlen span {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* ------------------------------------------------------------------- Layout */

main {
    max-width: 1240px;
    margin: 0 auto;
    padding: 2rem 1rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

main > section {
    background: var(--flaeche);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    padding: 1.5rem;
    /* Eigener Stapelkontext: sonst zeichnet die positionierte Karte über die
       nachfolgenden Abschnitte (Detailansicht, Quellen). */
    position: relative;
    z-index: 1;
}

/* --------------------------------------------------------- Störungshinweis */

.fehlerbanner {
    background: #FFF5F5;
    border: 2px solid var(--rot);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    color: #742A2A;
    position: relative;
    z-index: 1;
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ Filter */

.steuerung-block + .steuerung-block {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--linie);
}

#steuerung h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.staffel-leiste {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.6rem;
    scrollbar-width: thin;
    scrollbar-color: var(--sand) var(--linie);
}

.staffel-leiste::-webkit-scrollbar {
    height: 8px;
}

.staffel-leiste::-webkit-scrollbar-track {
    background: var(--linie);
    border-radius: 4px;
}

.staffel-leiste::-webkit-scrollbar-thumb {
    background-color: var(--sand);
    border-radius: 4px;
}

.aera-marke {
    flex: 0 0 auto;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-leise);
    padding: 0 0.35rem 0 0.75rem;
    border-left: 1px solid var(--linie);
    white-space: nowrap;
}

.staffel-btn {
    flex: 0 0 auto;
    min-width: 2.6rem;
    background-color: var(--flaeche);
    border: 2px solid var(--sand);
    color: var(--terracotta);
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.staffel-btn:hover {
    background-color: var(--sand-hell);
}

.staffel-btn.aktiv {
    background-color: var(--terracotta);
    border-color: var(--terracotta);
    color: #fff;
}

.staffel-btn-alle,
.staffel-btn-ohne {
    border-color: var(--terracotta);
}

.staffel-btn.aera-spoleto {
    border-color: var(--blau);
    color: var(--blau);
}

.staffel-btn.aera-spoleto.aktiv {
    background-color: var(--blau);
    border-color: var(--blau);
    color: #fff;
}

.filterzeile {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    align-items: flex-end;
}

.filter-feld {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 12rem;
}

.filter-suche {
    flex: 1 1 20rem;
}

.filter-feld label {
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-leise);
}

.filter-feld input[type="search"],
.filter-feld select {
    font: inherit;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--linie);
    border-radius: 8px;
    background: var(--flaeche);
    color: var(--text);
}

.filter-feld input[type="search"]:focus,
.filter-feld select:focus {
    outline: 2px solid var(--terracotta-hell);
    outline-offset: 1px;
}

.filter-schalter {
    min-width: 16rem;
    gap: 0.35rem;
}

.filter-feld label.schalter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    cursor: pointer;
}

.knopf-schlicht {
    font: inherit;
    background: none;
    border: 1px solid var(--linie);
    border-radius: 8px;
    padding: 0.5rem 0.9rem;
    color: var(--text-leise);
    cursor: pointer;
}

.knopf-schlicht:hover {
    border-color: var(--terracotta);
    color: var(--terracotta);
}

/* ------------------------------------------------------- Staffelinformation */

#staffel-info h2 {
    font-size: 1.5rem;
}

.staffel-meta {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
    margin: 0.6rem 0 0.9rem;
}

.staffel-meta li {
    background: var(--sand-hell);
    color: #6B4423;
    border-radius: 999px;
    padding: 0.15rem 0.7rem;
    font-size: 0.85rem;
}

.staffel-abdeckung {
    border-left: 4px solid var(--rot);
    padding-left: 0.9rem;
    max-width: 90ch;
}

.staffel-hinweis {
    color: var(--text-leise);
    font-size: 0.9rem;
}

#staffel-info h3 {
    font-size: 1.05rem;
    margin: 1.2rem 0 0.5rem;
}

.tabellen-huelle {
    overflow-x: auto;
}

.drehzeit-tabelle {
    border-collapse: collapse;
    width: 100%;
    min-width: 40rem;
    font-size: 0.9rem;
}

.drehzeit-tabelle th,
.drehzeit-tabelle td {
    text-align: left;
    vertical-align: top;
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid var(--linie);
}

.drehzeit-tabelle th {
    background: var(--sand-hell);
    color: #6B4423;
    font-weight: 500;
    white-space: nowrap;
}

.zelle-zeitraum {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.zelle-quellen {
    white-space: nowrap;
}

/* --------------------------------------------------------- Karte und Liste */

#karten-bereich {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: stretch;
}

.karten-spalte {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

#map {
    height: 62vh;
    min-height: 420px;
    border-radius: var(--radius);
    border: 2px solid var(--sand);
    z-index: 0;
}

#map.karte-fehlt {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    color: var(--text-leise);
    background: var(--sand-hell);
}

.legende {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.1rem;
    font-size: 0.85rem;
    color: var(--text-leise);
}

.legende li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legendenpunkt {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}

.legendenpunkt-ohne {
    border: 2px dashed var(--text-leise);
    background: transparent;
}

.listen-spalte {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.listen-kopf {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--sand-hell);
}

.listen-kopf h2 {
    font-size: 1.3rem;
}

.treffer-zahl {
    font-size: 0.85rem;
    color: var(--text-leise);
    text-align: right;
}

.ortsliste {
    list-style: none;
    overflow-y: auto;
    max-height: calc(62vh + 2.2rem);
    min-height: 420px;
    scrollbar-width: thin;
}

.listen-gruppe {
    position: sticky;
    top: 0;
    background: var(--flaeche);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--terracotta);
    font-weight: 500;
    padding: 0.6rem 0 0.3rem;
    border-bottom: 1px solid var(--linie);
    z-index: 1;
}

.ortseintrag {
    border-bottom: 1px solid var(--linie);
}

.ortsknopf {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-left: 3px solid transparent;
    font: inherit;
    color: inherit;
    padding: 0.65rem 0.5rem 0.65rem 0.6rem;
    cursor: pointer;
}

.ortsknopf:hover {
    background: var(--sand-hell);
}

.ortseintrag.ausgewaehlt .ortsknopf {
    background: var(--sand-hell);
    border-left-color: var(--rot);
}

.ortsknopf-kopf {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ortsknopf-name {
    font-weight: 500;
}

.ortsknopf-meta {
    font-size: 0.82rem;
    color: var(--text-leise);
    padding-left: 1.3rem;
}

.ortsknopf-marken {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding-left: 1.3rem;
    margin-top: 0.2rem;
}

.punkt {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    flex: 0 0 auto;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--linie);
}

.marke {
    font-size: 0.7rem;
    border-radius: 999px;
    padding: 0.05rem 0.5rem;
    border: 1px solid;
    white-space: nowrap;
}

.marke-handlungsort {
    color: var(--handlungsort);
    border-color: var(--handlungsort);
}

.marke-widerspruch {
    color: #B7791F;
    border-color: #B7791F;
}

.marke-warnung {
    color: var(--rot);
    border-color: var(--rot);
}

.marke-ohne {
    color: var(--text-leise);
    border-color: var(--text-leise);
}

.leer-hinweis {
    padding: 1.5rem 0.5rem;
    color: var(--text-leise);
}

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

.markerpunkt {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.markerpunkt-hoch,
.punkt.markerpunkt-hoch,
.legendenpunkt.markerpunkt-hoch {
    background: var(--beleg-hoch);
}

.markerpunkt-mittel,
.punkt.markerpunkt-mittel,
.legendenpunkt.markerpunkt-mittel {
    background: var(--beleg-mittel);
}

.markerpunkt-niedrig,
.punkt.markerpunkt-niedrig,
.legendenpunkt.markerpunkt-niedrig {
    background: var(--beleg-niedrig);
}

.markerpunkt-handlungsort,
.punkt.markerpunkt-handlungsort,
.legendenpunkt.markerpunkt-handlungsort {
    background: var(--handlungsort);
    border-style: dashed;
    border-color: #fff;
}

.markerpunkt-aktiv {
    outline: 3px solid var(--rot);
    outline-offset: 2px;
    z-index: 1000 !important;
}

/* ------------------------------------------------------------ Detailansicht */

#details-container {
    border-top: 5px solid var(--rot);
    padding: 0;
}

#details-content {
    position: relative;
    padding: 1.75rem;
}

#close-details {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 50%;
    background: var(--sand-hell);
    color: var(--blau);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

#close-details:hover {
    background: var(--rot);
    color: #fff;
}

.details-typ {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-leise);
}

.details-kopf h2 {
    font-size: clamp(1.5rem, 3vw, 2.1rem);
    padding-right: 2.5rem;
}

.details-name-it {
    font-style: italic;
    color: var(--text-leise);
}

.badge-leiste {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.85rem 0 0;
}

.badge {
    font-size: 0.78rem;
    border-radius: 999px;
    padding: 0.15rem 0.7rem;
    border: 1px solid var(--linie);
    background: var(--grund);
    color: var(--text-leise);
}

.badge-stufe {
    color: #fff;
    border-color: transparent;
}

.badge-hoch {
    background: var(--beleg-hoch);
}

.badge-mittel {
    background: var(--beleg-mittel);
}

.badge-niedrig {
    background: #718096;
}

.badge-handlungsort {
    color: var(--handlungsort);
    border-color: var(--handlungsort);
}

.badge-widerspruch {
    color: #B7791F;
    border-color: #B7791F;
}

.details-spalten {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 1.5rem 2rem;
    margin-top: 1.5rem;
}

.details-haupt h3,
.details-neben h3 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--terracotta);
    margin: 1.2rem 0 0.35rem;
}

.details-haupt > h3:first-of-type,
.details-neben > h3:first-of-type {
    margin-top: 0;
}

#details-rolle {
    font-size: 1.05rem;
    border-left: 4px solid var(--rot);
    padding-left: 0.9rem;
}

.warnkasten {
    background: #FFF5F5;
    border: 1px solid #FEB2B2;
    border-radius: 8px;
    padding: 0.8rem 1rem;
    margin-bottom: 1.2rem;
    font-size: 0.92rem;
}

.warnkasten p + p {
    margin-top: 0.5rem;
}

.fakten {
    display: grid;
    grid-template-columns: minmax(8rem, auto) minmax(0, 1fr);
    gap: 0.3rem 0.9rem;
    font-size: 0.9rem;
}

.fakten dt {
    color: var(--text-leise);
}

.fakten dd {
    overflow-wrap: anywhere;
}

.quellenliste {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.88rem;
}

.quellenliste li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.2rem 0.6rem;
}

.quellen-marke {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--blau);
    color: #fff;
    border-radius: 4px;
    padding: 0.05rem 0.4rem;
    text-decoration: none;
    grid-row: span 2;
    align-self: start;
    margin-right: 0.2rem;
}

.quellen-marke:hover {
    background: var(--rot);
}

.quellen-kategorie {
    font-size: 0.78rem;
    color: var(--text-leise);
}

.quellen-fehlt {
    color: var(--text-leise);
}

.details-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.2rem;
}

.aktion-link {
    display: inline-block;
    background: var(--blau);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.aktion-link:hover {
    background: var(--terracotta);
}

/* ------------------------------------------------------ Hinweise & Quellen */

#hinweise h2,
#quellen-bereich h2 {
    font-size: 1.3rem;
    display: inline;
}

#hinweise ul {
    margin: 0.75rem 0 0 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 95ch;
}

#quellen-bereich summary {
    cursor: pointer;
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

#quellen-bereich summary span {
    font-size: 0.85rem;
    color: var(--text-leise);
}

.quellenregister {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}

.quellenregister li {
    border: 1px solid var(--linie);
    border-radius: 8px;
    padding: 0.75rem 0.9rem;
    font-size: 0.88rem;
}

.quellen-kopf {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    font-weight: 500;
}

.quellen-id {
    font-size: 0.75rem;
    background: var(--sand-hell);
    color: #6B4423;
    border-radius: 4px;
    padding: 0.05rem 0.4rem;
    flex: 0 0 auto;
}

.quellen-anmerkung {
    margin-top: 0.4rem;
    color: var(--text-leise);
}

/* ------------------------------------------------------------------ Fußzeile */

footer {
    background: var(--blau);
    color: #E2E8F0;
    text-align: center;
    padding: 2rem 1rem;
}

.fussnote {
    font-size: 0.82rem;
    opacity: 0.75;
    margin-top: 0.35rem;
}

/* ---------------------------------------------------- Leaflet-Anpassungen */

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    border-top: 4px solid var(--terracotta);
}

.leaflet-popup-content {
    margin: 0.75rem 1rem;
}

.popup h3 {
    font-size: 1.05rem;
    margin-bottom: 0.2rem;
}

.popup-meta {
    font-size: 0.82rem;
    color: var(--text-leise);
    margin: 0;
}

.popup-btn {
    margin-top: 0.6rem;
    background: var(--blau);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.35rem 0.7rem;
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.popup-btn:hover {
    background: var(--rot);
}

/* -------------------------------------------------------------- Responsiv */

@media (max-width: 900px) {
    #karten-bereich,
    .details-spalten {
        grid-template-columns: minmax(0, 1fr);
    }

    #map {
        height: 55vh;
        min-height: 340px;
    }

    .ortsliste {
        max-height: 26rem;
        min-height: 0;
    }
}

@media (max-width: 560px) {
    main {
        padding: 1.25rem 0.75rem 2rem;
    }

    main > section {
        padding: 1.1rem;
    }

    .fakten {
        grid-template-columns: minmax(0, 1fr);
        gap: 0 0.5rem;
    }

    .fakten dd {
        margin-bottom: 0.5rem;
    }
}
