@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

/* DESIGN */

:root {
    /* SCHRIFTEN */
    --font-primary: 'Inter', sans-serif;
    --font-mono: 'Space Mono', monospace;

    /* GRUNDFARBEN */
    --color-cream: #FAF4E3;
    --color-sage: #9DAF99;
    --color-sage-light: #D8DFD6;
    --color-dark: #344238;
    --color-text-secondary: #586158;
    --color-accent: #C45C60;
    --color-accent-hover: #A9474B;

    /* HINTERGRÜNDE */
    --color-bg-start: var(--color-cream);
    --color-bg-card: var(--color-cream);
    --color-bg-sources: var(--color-sage-light);
    --color-bg-popup: var(--color-cream);

    /* TEXT */
    --color-text: var(--color-dark);
    --color-text-muted: var(--color-text-secondary);
    --color-meta: var(--color-accent);

    /* KARTE & NAVIGATION */
    --color-point: var(--color-sage);
    --color-point-active: var(--color-accent);

    /* RAHMEN */
    --color-border: var(--color-accent);

    /* SCHRIFTGRÖSSEN */
    --font-size-start: 56px;
    --font-size-start-subtitle: 22px;

    --font-size-title: 36px;
    --font-size-intro: 19px;
    --font-size-body: 17px;

    --font-size-small: 14px;
    --font-size-meta: 13px;
    --font-size-caption: 11px;

    /* SCHATTEN */
    --shadow-card: 10px 10px 30px rgba(0, 0, 0, 0.10);
    --shadow-card-active: 0 15px 40px rgba(0, 0, 0, 0.20);
}


/* ALLGEMEIN */

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;

    font-family: var(--font-primary);
    color: var(--color-text);
}


/* SPLIT-SCREEN / KARTE */

.app-container {
    display: block;
    height: 100vh;
}

#map {
    position: fixed;
    top: 0;
    left: 0;

    width: 100vw;
    height: 100vh;

    z-index: 1;
}

#story {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 2;

    width: 50%;
    height: 100vh;
    box-sizing: border-box;
    padding: clamp(24px, 5vh, 56px) clamp(16px, 3vw, 60px) 32px;

    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    touch-action: pan-y;

    scroll-snap-type: none;
    scroll-padding-top: 50px;

    /* Auch die Lücken und Ränder gehören zur Lesefläche, nicht zur Karte. */
    pointer-events: auto;
}


/* HOME-BUTTON */

.btn-back-home {
    position: fixed;
    top: 20px;
    left: 20px;

    z-index: 3;

    display: flex;
    align-items: center;
    gap: 8px;

    padding: 10px 16px;

    background-color: var(--color-cream);
    border: 1px solid var(--color-border);
    border-radius: 8px;

    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);

    font-family: var(--font-primary);
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);

    cursor: pointer;

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.btn-back-home:hover {
    transform: translateY(-2px);

    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}


/* STARTSCREEN */

.start-overlay {
    position: fixed;
    top: 0;
    left: 0;

    width: 100%;
    height: 100vh;

    background-color: var(--color-bg-start);

    z-index: 9999;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    transition: opacity 0.8s ease;
}

.start-content {
    text-align: center;

    max-width: 1000px;

    padding: 0 30px;
    margin-bottom: 3rem;
}


/* Hauptüberschrift Startscreen */

.start-content h1 {
    margin: 0 0 2rem;

    font-family: var(--font-primary);
    font-size: var(--font-size-start);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.02em;

    color: var(--color-text);
}


/* Unterüberschrift Startscreen */

.start-content p {
    margin: 0;

    font-family: var(--font-primary);
    font-size: var(--font-size-start-subtitle);
    font-weight: 400;
    line-height: 1.5;

    color: var(--color-text-muted);
}


/* Startbutton */

.start-btn {
    padding: 15px 30px;

    background-color: var(--color-accent);
    color: var(--color-cream);

    border: none;
    border-radius: 6px;

    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);

    font-family: var(--font-primary);
    font-size: 18px;
    font-weight: 600;

    cursor: pointer;

    transition:
        transform 0.2s ease,
        background-color 0.2s ease,
        box-shadow 0.2s ease;
}

.start-btn:hover {
    background-color: var(--color-accent-hover);

    transform: translateY(-3px);

    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.16);
}


/* Asynchrones Ausblenden via JavaScript */

.hidden {
    opacity: 0;
    pointer-events: none;
}


/* STORY-CARDS */

section {
    background-color: var(--color-bg-card);

    border-radius: 16px;

    box-shadow: var(--shadow-card);

    padding: 3rem 2rem;

    min-height: 80vh;

    margin-top: 10vh;
    margin-bottom: 10vh;

    transition: all 0.4s ease;
}

section.story-card {
    pointer-events: auto;

    width: 100%;
    min-width: 0;
    max-width: 564px;
    box-sizing: border-box;

    margin: 0 auto clamp(24px, 6vh, 64px);

    padding: 3rem 2rem 5rem;

    display: flex;
    flex-direction: column;

}

section.story-card:last-child { margin-bottom: 0; }


/* METADATEN */

.meta-label {
    margin-bottom: 1rem;

    font-family: var(--font-mono);
    font-size: var(--font-size-meta);
    font-weight: 700;

    line-height: 1.5;
    letter-spacing: 0.12em;

    color: var(--color-meta);

    text-transform: uppercase;
}


/* ORTSÜBERSCHRIFT */

.story-card h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;

    font-family: var(--font-primary);
    font-size: var(--font-size-title);
    font-weight: 700;

    line-height: 1.15;
    letter-spacing: -0.015em;

    color: var(--color-text);
}


/* HAUPTTEXT */

.story-card p {
    margin-bottom: 1.5rem;

    font-family: var(--font-primary);
    font-size: var(--font-size-body);
    font-weight: 400;

    line-height: 1.65;

    color: var(--color-text);
}


/* KURZBESCHREIBUNG / SUBTITLE */

.story-card p.station-subtitle {
    font-size: var(--font-size-intro);
    font-weight: 500;

    line-height: 1.5;

    color: var(--color-text);
}


/* TEXT-HERVORHEBUNG */

.highlight {
    background-image: linear-gradient(
        104deg,
        rgba(196, 92, 96, 0) 0.9%,
        rgba(196, 92, 96, 0.20) 2.4%,
        rgba(196, 92, 96, 0.24) 5.8%,
        rgba(196, 92, 96, 0.24) 93%,
        rgba(196, 92, 96, 0.16) 96%,
        rgba(196, 92, 96, 0) 98%
    );

    background-size: 0% 100%;
    background-repeat: no-repeat;
    background-position: left center;

    transition:
        background-size 0.8s cubic-bezier(0.32, 0, 0.07, 1);

    border-radius: 4px 8px 3px 6px;

    padding: 0.1em 0.3em;

    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

.active-station .highlight {
    background-size: 100% 100%;
}


/* KARTEN-POPUP */

.place-popup .maplibregl-popup-content {
    padding: 10px 14px;

    background-color: var(--color-bg-popup);

    border-radius: 10px;

    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);

    text-align: center;

    font-family: var(--font-primary);
    font-size: var(--font-size-small);
    font-weight: 600;
    line-height: 1.4;

    color: var(--color-text);
}

.place-popup.maplibregl-popup-anchor-top .maplibregl-popup-tip {
    border-bottom-color: var(--color-bg-popup);
}

.place-popup.maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
    border-top-color: var(--color-bg-popup);
}

.place-popup.maplibregl-popup-anchor-left .maplibregl-popup-tip {
    border-right-color: var(--color-bg-popup);
}

.place-popup.maplibregl-popup-anchor-right .maplibregl-popup-tip {
    border-left-color: var(--color-bg-popup);
}


/* MEDIEN */

.media-container {
    margin: 1.5rem 0 0;
}

.media-container img {
    width: 100%;
    height: auto;

    border-radius: 8px;

    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}


/* Bildunterschriften */

.media-container figcaption {
    margin-top: 0.6rem;

    font-family: var(--font-mono);
    font-size: var(--font-size-caption);
    font-weight: 400;

    line-height: 1.5;

    color: var(--color-text-muted);

    text-align: left;
}


/* QUELLEN / FUSSNOTEN */

.station-footnotes {
    margin-top: 1.5rem;
    padding-top: 1rem;

    border-top: 1px solid var(--color-border);

    font-size: var(--font-size-small);
}


/* Toggle */

.note-toggle {
    margin-top: auto;
    padding-top: 2rem;

    text-align: center;
}

.note-toggle summary {
    cursor: pointer;

    list-style: none;
    outline: none;

    font-family: var(--font-mono);
    font-size: var(--font-size-meta);
    font-weight: 700;

    letter-spacing: 0.08em;
    text-transform: uppercase;

    color: var(--color-accent);

    transition: color 0.2s ease;
}

.note-toggle summary:hover {
    color: var(--color-accent-hover);
}


/* Quellenbox */

.note-content {
    max-height: 200px;
    max-width: 100%;

    overflow-y: auto;
    overflow-wrap: break-word;

    margin-top: 1rem;
    margin-bottom: 20px;

    padding: 1.25rem;

    background-color: var(--color-bg-sources);

    border-radius: 8px;

    font-family: var(--font-primary);
    font-size: var(--font-size-small);
    font-weight: 400;

    line-height: 1.55;

    color: var(--color-text);

    text-align: left;

    hyphens: auto;
}


/* Quellenliste etwas kompakter */

.note-content ul {
    margin: 0;
    padding-left: 1.25rem;
}

.note-content li {
    margin-bottom: 0.75rem;
}

.note-content li:last-child {
    margin-bottom: 0;
}

.source-toggle .note-content {
    font-size: 0.85rem;
}

.source-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.source-list-item {
    display: grid;
    grid-template-columns: 2.5rem 1fr;
    column-gap: 0.5rem;
    margin-bottom: 1.25rem;
    line-height: 1.45;
}

.source-list-item:last-child {
    margin-bottom: 0;
}

.source-list-number {
    font-family: var(--font-mono);
    font-size: 0.85em;
    padding-top: 0.1em;
}

.source-list-citation {
    min-width: 0;
}

/* MAPLIBRE MARKER */

.marker {
    width: 16px;
    height: 16px;

    background-color: var(--color-point);

    border: 2px solid var(--color-cream);
    border-radius: 50%;

    box-sizing: border-box;

    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);

    cursor: pointer;
}

.marker:hover {
    border-color: var(--color-point-active);
    transform: scale(1.2);
}


/* Aktiver Kartenpunkt:
   gleiche Grundfarbe + rote Umrandung */

.active-marker {
    width: 18px;
    height: 18px;

    background-color: var(--color-point-active);

    border: 3px solid var(--color-point-active);

    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);

    transform: scale(1.15);

    z-index: 1000 !important;
}


/* DOT-NAVIGATION */

.dot-navigation {
    position: fixed;

    right: 20px;
    top: 50%;

    transform: translateY(-50%);

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    gap: 15px;

    z-index: 1000;
}


/* Verbindungslinie */

.dot-navigation::before {
    content: '';

    position: absolute;

    top: 0;
    bottom: 0;

    width: 2px;

    background-color: var(--color-sage);

    opacity: 0.65;

    z-index: -1;
}


/* Normaler Navigationspunkt */

.nav-dot {
    width: 14px;
    height: 14px;

    background-color: var(--color-point);

    border: 2px solid var(--color-cream);
    border-radius: 50%;

    box-sizing: border-box;

    cursor: pointer;

    transition:
        transform 0.25s ease,
        border-color 0.25s ease;
}

.nav-dot:hover {
    transform: scale(1.3);

    border-color: var(--color-point-active);
}


/* Aktiver Navigationspunkt */

.nav-dot.active-dot {
    background-color: var(--color-point-active);

    border: 3px solid var(--color-point-active);

    transform: scale(1.3);
}


/* MOBILE TYPOGRAFIE */

@media (max-width: 900px) {

    :root {
        --font-size-start: 42px;
        --font-size-start-subtitle: 18px;

        --font-size-title: 26px;
        --font-size-intro: 18px;
        --font-size-body: 16px;
    }

    .start-content {
        padding: 0 20px;
    }

    .story-card h2 {
        line-height: 1.2;
    }
}

.place-gallery {
    width: 100%;
    min-width: 0;
    margin: 1.5rem 0;
    overflow: hidden;
}

.place-gallery .swiper-slide {
    width: 100%;
    height: auto;
    margin: 0;
    box-sizing: border-box;
}

.place-gallery-img {
    display: block;

    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 420px;

    object-fit: contain;
    border-radius: 8px;
}

.place-gallery-caption {
    margin-top: 0.6rem;

    font-family: var(--font-mono);
    font-size: var(--font-size-caption);

    color: var(--color-text-muted);
    line-height: 1.5;
    text-align: center;
}

.place-gallery .swiper-button-prev,
.place-gallery .swiper-button-next {
    color: var(--color-accent);
}

.place-gallery .swiper-pagination {
    position: relative;
    inset: auto;

    margin-top: 0.75rem;

    font-family: var(--font-mono);
    font-size: var(--font-size-caption);

    color: var(--color-text-muted);
}
.free-map-link {
    margin-top: 24px;
    color: var(--color-text);
    font-size: 14px;
}

/* Mobil: Karte oben, Erzählung darunter unabhängig scrollbar. */
@media (max-width: 900px) {
    :root { --mobile-map-height: clamp(180px, 32dvh, 280px); }
    html, body { height: 100dvh; overflow: hidden; }
    .app-container { height: 100dvh; }
    #map { width: 100%; height: var(--mobile-map-height); }
    #story {
        position: fixed;
        top: var(--mobile-map-height);
        left: 0;
        width: 100%;
        height: calc(100dvh - var(--mobile-map-height));
        box-sizing: border-box;
        padding: 12px 12px max(24px, env(safe-area-inset-bottom));
        background: var(--color-sage-light);
        overflow-y: auto;
        overflow-x: hidden;
        pointer-events: auto;
        touch-action: pan-y;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
        scroll-padding-top: 12px;
        border-top: 1px solid var(--color-border);
    }
    section.story-card {
        width: 100%;
        min-width: 0;
        max-width: none;
        min-height: calc(100dvh - var(--mobile-map-height) - 24px);
        box-sizing: border-box;
        margin: 0 0 clamp(24px, 5dvh, 48px);
        padding: 22px 16px;
        overflow-wrap: anywhere;
        box-shadow: 0 4px 14px rgba(0, 0, 0, .07);
    }
    section.story-card:last-child { margin-bottom: 0; }
    .story-card p { text-align: left; }
    .dot-navigation { display: none; }
    #map .maplibregl-ctrl-group:has(.maplibregl-ctrl-zoom-in) { display: none; }
    .btn-back-home { top: max(10px, env(safe-area-inset-top)); left: 10px; padding: 10px 12px; font-size: 13px; }
    .maplibregl-popup { max-width: 190px !important; }
    .place-popup .maplibregl-popup-content { font-size: 11px; padding: 6px 8px; line-height: 1.35; }
    .start-overlay { height: 100dvh; box-sizing: border-box; padding: 28px 16px; overflow-y: auto; justify-content: flex-start; }
    .start-content { padding: 0; margin: auto 0 24px; }
    .start-content h1 { font-size: clamp(28px, 8vw, 40px); margin-bottom: 20px; }
    .story-selection { display: flex; flex-direction: column; width: 100%; gap: 12px; }
    .start-btn { width: 100%; box-sizing: border-box; margin: 0; padding: 16px; font-size: 16px; }
    .free-map-link { margin-bottom: auto; padding: 12px; }
    .note-content { max-height: none; }
}

@media (max-width: 900px) and (max-height: 500px) {
    :root { --mobile-map-height: clamp(120px, 35dvh, 180px); }
}

/* Kompakte Zeitspur: Jahr und kontinuierlicher Lesefortschritt. */
.story-time {
    --time-progress: 0%;
    position: fixed;
    z-index: 3;
    top: clamp(24px, 5vh, 56px);
    left: calc(var(--story-card-left, 50vw) - 6px);
    transform: translateX(-100%);
    width: min(200px, calc(50vw - 92px));
    box-sizing: border-box;
    padding: 10px 14px 12px;
    border-radius: 8px;
    background: var(--color-bg-card);
    color: var(--color-dark);
    box-shadow: 0 2px 12px rgba(52, 66, 56, .12);
    pointer-events: none;
}
.story-time[hidden] { display: none; }
.story-year {
    margin: 0 0 8px;
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.04em;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.story-year-compact { font-size: 13px; line-height: 1.4; }
.story-time-track {
    position: relative;
    height: 2px;
    background: var(--color-sage-light);
    border-radius: 2px;
}
.story-time-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--time-progress);
    border-radius: inherit;
    background: var(--color-accent);
}
.story-time-cursor {
    position: absolute;
    top: -2px;
    left: var(--time-progress);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-accent);
    transform: translateX(-50%);
}
@media (max-width: 900px) {
    .story-time {
        top: auto;
        left: 12px;
        right: auto;
        transform: none;
        bottom: calc(100dvh - var(--mobile-map-height) + 12px);
        width: min(200px, calc(100vw - 24px));
        padding: 8px 12px 10px;
    }
    .story-year { font-size: 20px; margin-bottom: 6px; }
    .story-year-compact { font-size: 12px; }
}
