@keyframes animatedBackground {
    0% { background-position: 0% 60%; }
    50% { background-position: 100% 60%; }
    100% { background-position: 0% 60%; }
}

:root {
    --filter-fallback-text: 'Filter nicht verf\00fcgbar';
}

/* --- Language Switcher --- */

.lang-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
    cursor: pointer;
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 4px 12px;
    font-family: 'Asap Condensed', sans-serif;
    font-size: 14px;
    color: #ccc;
    transition: all 0.2s;
    user-select: none;
}

.lang-switcher:hover {
    border-color: white;
    color: white;
}

body {
    background: linear-gradient(150deg, rgba(21,32,26,1), rgb(38, 56, 46), rgba(116,106,98,1), rgb(58, 51, 45));
    background-size: 200% 200%;
    animation: animatedBackground 5s ease-in-out infinite;
    background-attachment: fixed;
    color: white;
    font-family: 'Asap Condensed', sans-serif;
    margin: 0;
    padding: 0;
}

header {
    text-align: center;
    padding: 40px 20px 10px;
}

header h1 {
    font-size: 48px;
    margin: 0;
}

header p {
    font-family: 'Courier New', monospace;
    margin-top: 8px;
}

header a {
    color: #aaa;
    text-decoration: none;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

header a:hover {
    color: white;
}

.meta {
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #999;
    margin: 0 20px 20px;
}

/* --- 3-Column Grid Layout --- */

.app-grid {
    display: grid;
    grid-template-columns: 250px 1fr 350px;
    gap: 20px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

.sidebar-inner {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.detail-inner {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.charts-column {
    min-width: 0;
}

/* --- Filter Bar (Dauerdemo Toggle) --- */

.filter-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.2);
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    display: none;
}

.toggle-switch input:disabled + .slider {
    opacity: 0.4;
    cursor: not-allowed;
}

.toggle-switch:has(input:disabled) {
    cursor: not-allowed;
}

.slider {
    width: 40px;
    height: 22px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 11px;
    position: relative;
    transition: background 0.3s;
    flex-shrink: 0;
}

.slider::after {
    content: '';
    width: 18px;
    height: 18px;
    background: #ccc;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.toggle-switch input:checked + .slider {
    background: #e63946;
}

.toggle-switch input:checked + .slider::after {
    transform: translateX(18px);
    background: white;
}

.toggle-label {
    font-size: 14px;
    color: #ccc;
}

.filter-info {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #e63946;
}

.filter-hint {
    font-size: 11px;
    color: #888;
    margin: 4px 0 0;
    line-height: 1.4;
}


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

.filter-section h3 {
    font-size: 16px;
    margin: 0 0 10px;
    color: #ccc;
}

.filter-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-form label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: #999;
    font-family: 'Courier New', monospace;
}

.filter-input,
.filter-date {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #ccc;
    padding: 6px 8px;
    font-family: 'Asap Condensed', sans-serif;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}

.filter-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.filter-input:focus,
.filter-date:focus {
    outline: none;
    border-color: #e63946;
}

.filter-date::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
}

.filter-btn {
    background: #e63946;
    border: 1px solid #e63946;
    color: white;
    padding: 8px 16px;
    font-family: 'Asap Condensed', sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.filter-btn:hover {
    background: #c1303b;
    border-color: #c1303b;
}

.filter-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.filter-btn-clear {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.4);
    color: #ccc;
}

.filter-btn-clear:hover {
    border-color: white;
    color: white;
    background: transparent;
}

.filter-status {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #e63946;
    margin: 4px 0 0;
    min-height: 16px;
}

/* --- Cluster Tags --- */

.cluster-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.cluster-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    font-size: 12px;
    color: #ccc;
    background: rgba(255, 255, 255, 0.05);
}

.cluster-tag-x {
    background: none;
    border: none;
    color: #888;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0 0 0 2px;
}

.cluster-tag-x:hover {
    color: #e63946;
}

.cluster-input-row {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.cluster-input-row .filter-input {
    flex: 1;
    min-width: 0;
}

.cluster-disclaimer {
    font-family: 'Courier New', monospace;
    font-size: 14px !important;
    color: #666;
    margin: 8px 0 0;
    line-height: 1.4;
}

/* --- Chart Cards --- */

.section-title {
    text-align: center;
    font-size: 28px;
    margin: 50px 0 5px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.section-subtitle {
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #999;
    margin: 0 0 25px;
}

.chart-card {
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 20px;
    margin-bottom: 30px;
    position: relative;
    transition: opacity 0.3s;
}

.chart-card h2 {
    margin-top: 0;
    font-size: 22px;
}

.chart-container {
    width: 100%;
    min-height: 400px;
}

.chart-map {
    min-height: 500px;
}

.chart-tall {
    min-height: 500px;
}

/* Fallback warning on chart cards (variant not loaded) */
.chart-card.filter-fallback::before {
    content: var(--filter-fallback-text);
    position: absolute;
    top: 8px;
    right: 8px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #e6a23c;
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 8px;
    z-index: 10;
}

/* Filter unavailable hint */
.chart-card.filter-unavailable {
    opacity: 0.5;
}

.filter-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.45);
    padding: 6px 0 0;
}

/* --- Map Controls --- */

.map-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 14px;
    color: #ccc;
    user-select: none;
}

.toggle input[type="checkbox"] {
    accent-color: #e63946;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.map-zoom-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #ccc;
    width: 30px;
    height: 30px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    font-family: 'Asap Condensed', sans-serif;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-zoom-btn:hover {
    border-color: white;
    color: white;
}

/* --- Year Buttons --- */

.year-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.year-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #ccc;
    padding: 4px 12px;
    font-family: 'Asap Condensed', sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.year-btn:hover {
    border-color: white;
    color: white;
}

.year-btn.active {
    background: #e63946;
    border-color: #e63946;
    color: white;
}

/* --- UMAP Controls --- */

.umap-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.umap-select {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #ccc;
    padding: 4px 8px;
    font-family: 'Asap Condensed', sans-serif;
    font-size: 14px;
    cursor: pointer;
}

.umap-select option {
    background: #1a1a2e;
    color: #ccc;
}

/* --- Chart Stats & Subtitles --- */

.chart-stat {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #aaa;
    margin: 0 0 8px;
}

.chart-subtitle {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #999;
    margin: -8px 0 8px;
}

.chart-method {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #666;
    margin: 4px 0 0;
    text-align: left;
    line-height: 1.3;
}

/* --- Detail Panel --- */

.detail-panel {
    min-width: 0;
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.detail-header h3 {
    margin: 0;
    font-size: 16px;
    color: #ccc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.detail-close {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ccc;
    width: 28px;
    height: 28px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 8px;
    transition: all 0.2s;
}

.detail-close:hover {
    border-color: white;
    color: white;
}

.detail-placeholder {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #666;
    text-align: center;
    padding: 30px 0;
}

.detail-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-item {
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 12px;
    transition: border-color 0.2s;
    cursor: pointer;
}

.detail-item:hover {
    border-color: rgba(255, 255, 255, 0.35);
}

.detail-item.open {
    border-color: #e63946;
}

.detail-expanded {
    display: none;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.detail-item.open .detail-expanded {
    display: block;
}

.detail-item.open .detail-topic {
    color: #fff;
}

.detail-exp-row {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #aaa;
    line-height: 1.6;
    word-break: break-word;
}

.detail-exp-label {
    color: #888;
    margin-right: 6px;
}

.detail-exp-label::after {
    content: ':';
}

.detail-topic {
    font-size: 13px;
    color: #ddd;
    line-height: 1.3;
    margin-bottom: 4px;
    word-break: break-word;
}

.detail-meta {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #888;
    line-height: 1.3;
}

.detail-loading,
.detail-message,
.detail-error {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
}

.detail-loading { color: #999; }
.detail-message { color: #666; }
.detail-error { color: #e63946; }

.detail-note {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #e63946;
    margin: 0 0 8px;
    text-align: center;
}

.detail-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.detail-page-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ccc;
    padding: 4px 10px;
    font-family: 'Asap Condensed', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.detail-page-btn:hover:not(:disabled) {
    border-color: white;
    color: white;
}

.detail-page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.detail-page-info {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #888;
}

/* --- Footer --- */

footer {
    text-align: center;
    padding: 30px 350px 30px 250px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #999;
}

footer a {
    color: #aaa;
    text-decoration: none;
}

footer a:hover {
    color: white;
}

/* --- Responsive: Mobile < 900px --- */

@media (max-width: 900px) {
    .app-grid {
        grid-template-columns: 1fr;
        padding: 0 15px;
    }

    .sidebar-inner,
    .detail-inner {
        position: static;
        max-height: none;
        overflow-y: visible;
    }

    .sidebar {
        order: 0;
    }

    .charts-column {
        order: 1;
    }

    .detail-panel {
        order: 2;
    }

    header h1 {
        font-size: 32px;
    }

    .chart-container {
        min-height: 300px;
    }

    .chart-map {
        min-height: 350px;
    }

    footer {
        padding: 30px 15px;
    }
}

@media (max-width: 600px) {
    header h1 {
        font-size: 28px;
    }

    .chart-container {
        min-height: 250px;
    }
}
