:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    /* Primaerblau: dunkel genug fuer >= 4.5:1 mit weisser Schrift (WCAG AA, Text & Links) */
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-accent: #3b82f6; /* helleres Blau nur fuer rein dekorative Akzente/Glows */
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.5);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Map Section */
.map-section {
    flex: 1;
    position: relative;
    height: 100%;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* Glassmorphism Filter Overlay */
.floating-filter {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 1000;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    width: 380px;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
}

.floating-filter h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-main);
}

.input-group {
    position: relative;
    margin-bottom: 16px;
}

.input-group i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.2rem;
}

.input-group input {
    width: 100%;
    padding: 12px 12px 12px 42px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background: white;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.filter-controls {
    display: flex;
    gap: 12px;
}

.select-wrapper {
    position: relative;
    flex: 1;
}

.select-wrapper select {
    width: 100%;
    padding: 12px 40px 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    appearance: none;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.select-wrapper select:focus {
    outline: none;
    border-color: var(--primary);
}

.select-wrapper i {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
}

.btn-reset {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.btn-reset:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

/* List Section */
.list-section {
    width: 480px;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.05);
    z-index: 2;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.list-section.expanded {
    width: 75vw;
}

.list-header {
    padding: 24px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.list-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Listenmodus: Karte ausblenden (Universal Design – innerhalb derselben Seite) */
.app-container.map-hidden .map-section {
    display: none;
}

.app-container.map-hidden .list-section,
.app-container.map-hidden .list-section.expanded {
    width: 100%;
}

/* Filter-Panel angedockt in der Liste (Listenmodus) – Suche/Filter bleiben verfügbar */
.floating-filter.filter-docked {
    position: static;
    width: auto;
    background: #fff;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    box-shadow: none;
    padding: 16px 24px;
    transition: none;
}

.floating-filter.filter-docked > h2,
.floating-filter.filter-docked > p {
    display: none;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.event-grid {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr));
    gap: 16px;
    align-content: start;
}

/* Custom Scrollbar for List */
.event-grid::-webkit-scrollbar {
    width: 8px;
}

.event-grid::-webkit-scrollbar-track {
    background: transparent;
}

.event-grid::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}

/* Event Card */
.event-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.event-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--card-color, var(--primary));
    transition: width 0.3s ease;
}

.event-card:hover,
.event-card.active {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: #cbd5e1;
}

.event-card.active::before {
    width: 6px;
}

.event-card .event-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.4;
    color: var(--text-main);
    padding-right: 32px;
    /* make room for bookmark */
}

.bookmark-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: all 0.2s;
    z-index: 2;
}

.bookmark-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.bookmark-btn.bookmarked {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.event-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.meta-item i {
    font-size: 1.1rem;
    color: var(--card-color, var(--primary));
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    /* visibility erst nach dem Ausblenden auf hidden setzen, beim Einblenden sofort sichtbar
       (sonst ist der Dialog beim Öffnen kurz nicht fokussierbar) */
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    padding: 24px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 900px;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    transform: translateY(30px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #f1f5f9;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-color);
    transition: background 0.2s, transform 0.2s;
    z-index: 10;
}

.modal-close:hover {
    background: #e2e8f0;
    transform: rotate(90deg);
}

.modal-header {
    padding: 32px 32px 24px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.modal-badge {
    display: inline-block;
    padding: 6px 14px;
    background: var(--primary);
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-main);
    margin-bottom: 16px;
    line-height: 1.4;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.modal-body {
    padding: 32px;
    overflow-y: auto;
}

.modal-body h3 {
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 16px;
    font-weight: 600;
}

.modal-body p {
    color: #475569;
    line-height: 1.7;
    margin-bottom: 12px;
}

.modal-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    background: #f8fafc;
    padding: 16px;
    border-radius: 12px;
}

.info-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.info-box i {
    font-size: 1.5rem;
    color: var(--primary);
    background: white;
    padding: 8px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.info-box div {
    display: flex;
    flex-direction: column;
}

.info-box span {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.info-box strong {
    font-size: 0.95rem;
    color: var(--text-main);
}

.ph-btn {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.ph-btn:hover {
    text-decoration: underline;
}

.section-title {
    font-size: 1.1rem;
    color: var(--text-main);
    margin: 24px 0 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    display: block;
    width: 4px;
    height: 16px;
    background: var(--primary);
    border-radius: 4px;
}

.modal-text-block {
    color: #475569;
    line-height: 1.6;
    font-size: 0.95rem;
}

.modal-text-block p {
    margin-bottom: 12px;
}

/* Custom Marker */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Maus-/programmatischer Fokus ohne Outline, Tastatur-Fokus aber deutlich sichtbar (WCAG 2.4.7) */
.custom-marker:focus {
    outline: none;
}

.custom-marker:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
    border-radius: 4px;
}

.marker-pin {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    background: var(--marker-color, #1d4ed8);
    /* dunkle Kontur, damit auch helle Markerfarben gegen die Karte erkennbar sind (WCAG 1.4.11) */
    border: 1.5px solid rgba(15, 23, 42, 0.55);
    position: relative;
    transform: rotate(-45deg);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.marker-pin::after {
    content: '';
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.marker-pin:hover,
.marker-pin.active {
    transform: rotate(-45deg) scale(1.15);
    box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

/* Map Popup Styling */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    font-family: 'Inter', sans-serif;
    margin: 16px;
}

.leaflet-popup-content h3 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    color: var(--text-main);
}

.leaflet-popup-content p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* DSGVO Map Consent Gate */
.map-consent {
    position: absolute;
    inset: 0;
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(248, 250, 252, 0.94);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.map-consent.visible {
    display: flex;
}

.map-consent-box {
    background: #fff;
    max-width: 420px;
    width: 100%;
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    text-align: center;
}

.map-consent-box > i {
    font-size: 2.5rem;
    color: var(--primary);
    display: block;
    margin-bottom: 10px;
}

.map-consent-box h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-main);
}

.map-consent-box p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.map-consent-box a {
    color: var(--primary);
}

.map-consent-remember {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 18px;
    cursor: pointer;
}

.map-consent-remember input {
    cursor: pointer;
}

.map-consent-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s ease;
}

.map-consent-btn:hover {
    background: var(--primary-hover);
}

/* Legal footer (Datenschutz/Impressum links) */
.legal-footer {
    flex-shrink: 0;
    padding: 12px 24px;
    background: #fff;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.8rem;
}

.link-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: underline;
    cursor: pointer;
}

.link-btn:hover {
    color: var(--primary);
}

.legal-footer a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
}

.legal-footer a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.legal-footer span {
    color: #cbd5e1;
}

/* Legal pages (Datenschutz / Impressum) */
body.legal {
    height: auto;
    min-height: 100vh;
    overflow: auto;
    background: var(--bg-color);
}

.legal-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 48px 24px 80px;
}

.legal-container .back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.legal-container .back-link:hover {
    text-decoration: underline;
}

.legal-container h1 {
    font-size: 1.85rem;
    margin-bottom: 6px;
    color: var(--text-main);
}

.legal-container h2 {
    font-size: 1.22rem;
    margin: 34px 0 12px;
    color: var(--text-main);
}

.legal-container h3 {
    font-size: 1.02rem;
    margin: 20px 0 8px;
    color: var(--text-main);
}

.legal-container p,
.legal-container li {
    color: #334155;
    line-height: 1.7;
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.legal-container ul {
    margin: 0 0 12px 20px;
}

.legal-container a {
    color: var(--primary);
}

.legal-updated {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 24px;
}

.legal-note {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 0.88rem;
    margin: 16px 0;
}

.legal-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px 22px;
    margin-bottom: 16px;
}

/* Responsive Design */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }

    .map-section {
        height: 50vh;
        flex: none;
    }

    .floating-filter {
        width: calc(100% - 32px);
        left: 16px;
        top: 16px;
        padding: 16px;
    }

    .list-section,
    .list-section.expanded {
        width: 100%;
        height: 50vh;
    }

    .app-container.map-hidden .list-section {
        height: 100%;
    }
}

/* ===================================================================
   Barrierefreiheit (WCAG 2.1 AA)
   =================================================================== */

/* Nur für Screenreader sichtbar */
.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip-Link: wird bei Tastatur-Fokus sichtbar */
.skip-link {
    position: absolute;
    left: 8px;
    top: -60px;
    z-index: 2000;
    background: var(--primary);
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 8px;
}

/* Deutlich sichtbarer Tastatur-Fokus für alle interaktiven Elemente */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Selects haben eigene :focus-Regeln ohne Outline – Tastatur-Fokus erzwingen */
.select-wrapper select:focus-visible,
.select-wrapper-modern select:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Titel-Button der Karte: sieht aus wie Überschrift, ganze Karte klickbar */
.event-card .event-card-title {
    position: static;
}

.card-open-btn {
    display: inline;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.card-open-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}

.card-open-btn:focus {
    outline: none;
}

.card-open-btn:focus-visible::after {
    outline: 3px solid var(--primary);
    outline-offset: -3px;
    border-radius: 16px;
}

/* Lesezeichen-Button über dem Klick-Overlay halten */
.bookmark-btn {
    z-index: 3;
}

/* Leeranzeige der Liste */
.list-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #475569;
    padding: 20px;
}

/* Reduzierte Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===================================================================
   Druckansicht der gemerkten Veranstaltungen
   =================================================================== */
#printArea {
    display: none;
}

@media print {
    body > *:not(#printArea) {
        display: none !important;
    }

    #printArea {
        display: block !important;
    }

    .print-doc {
        font-family: 'Inter', Arial, sans-serif;
        color: #000;
        padding: 0;
    }

    .print-doc h1 {
        font-size: 20pt;
        margin: 0 0 4pt;
    }

    .print-meta {
        color: #444;
        margin: 0 0 16pt;
        font-size: 10pt;
    }

    .print-event {
        border: 1px solid #999;
        border-left: 4px solid #3b82f6;
        padding: 10pt 12pt;
        margin-bottom: 12pt;
        border-radius: 4pt;
        page-break-inside: avoid;
    }

    .print-event h2 {
        font-size: 13pt;
        margin: 0 0 6pt;
    }

    .print-event p {
        font-size: 10.5pt;
        line-height: 1.4;
        margin: 2pt 0;
    }

    .print-inhalt {
        margin-top: 6pt;
    }

    @page {
        margin: 1.5cm;
    }
}