/* --- Global Styles --- */
html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f1f5f9;
}

/* --- General Button Styles --- */
.control-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.control-button.active {
    background-color: #0369a1; /* sky-700 */
    color: white;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.control-button.inactive {
    background-color: #f1f5f9; /* slate-100 */
    color: #0369a1; /* sky-700 */
    border-color: #e2e8f0; /* slate-200 */
}

.control-button.reset-button {
    background-color: #fee2e2; /* red-100 */
    color: #b91c1c; /* red-800 */
    border-color: #fca5a5; /* red-300 */
}

.control-button:hover {
    transform: translateY(-2px);
}

.jump-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e3a8a;
    background-color: #dbeafe;
    border: 1px solid #93c5fd;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.jump-button:hover {
    background-color: #bfdbfe;
    color: #1e40af;
}

/* --- Network Graph Styles --- */
.node {
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    position: absolute;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.node:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    z-index: 15;
    filter: none !important; /* On hover, always show full color */
}

.node.active {
    box-shadow: 0 0 0 4px #38bdf8;
    border-color: #0284c7;
    transform: scale(1.05);
    z-index: 20;
    filter: none !important;
}

.node.related {
    outline: 2px dashed #22d3ee;
    filter: none !important;
}

.node.faded {
    filter: saturate(30%);
}

.node.faded .node-title,
.node.faded .node-keywords {
    color: #9ca3af !important;
}

.node-content {
    text-align: center;
}

.node-title {
    font-weight: 600;
}

.node-keywords {
    font-size: 0.8rem;
    line-height: 1.2;
    color: #475569;
}

/* Quiz Mode Styles */
.node.locked {
    background-color: #e2e8f0 !important;
    border-color: #94a3b8 !important;
    filter: none;
}

.node.locked .node-content {
    display: none;
}

.node-locked-icon {
    display: none;
    font-size: 2.5rem;
    font-weight: 700;
    color: #64748b;
}

.node.locked .node-locked-icon {
    display: block;
}

/* --- Layout and Panel Styles --- */
.tier-title {
    text-align: center;
    font-weight: 700;
    color: #475569;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 2rem;
    border-bottom: 2px solid #cbd5e1;
    padding-bottom: 0.5rem;
    position: relative;
    z-index: 2;
    background-color: #f1f5f9;
}

#detail-content {
    transition: opacity 0.15s ease-in-out;
}

#detail-content.content-hiding {
    opacity: 0;
}

/* Mobile-first: Panel slides up from the bottom */
@media (max-width: 1023px) {
    #detail-view {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 75%;
        z-index: 40;
        transform: translateY(105%);
        border-top-left-radius: 1.5rem;
        border-top-right-radius: 1.5rem;
        transition: transform 0.3s ease-in-out;
        will-change: transform;
    }
    #detail-view:not(.hidden-panel) {
        transform: translateY(0);
    }
}

/* Desktop: Permanent 2-column grid layout */
@media (min-width: 1024px) {
    #main-container {
        display: grid;
        grid-template-columns: 2fr 1fr;
        gap: 2rem;
        align-items: start;
    }
    #detail-view {
        position: sticky;
        top: 2rem;
        max-height: calc(100vh - 4rem);
        overflow-y: hidden;
    }
    #detail-content {
        height: 100%;
        overflow-y: auto;
    }
    #detail-view.hidden-panel {
        display: block;
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }
    #close-panel {
        display: none;
    }
}

/* --- Connector & Arrow Styles --- */
#connector-canvas, #timeline-arrow-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}
#connector-canvas {
    z-index: 1;
}
.connector-line {
    stroke: #64748b;
    stroke-width: 2;
    stroke-opacity: 0.5;
    transition: all 0.3s;
}
.connector-line.highlighted {
    stroke: #0ea5e9;
    stroke-width: 3.5;
    stroke-opacity: 1;
}

/* --- Quiz Panel Styles --- */
.quiz-answer-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    background-color: white;
    font-weight: 500;
    transition: all 0.2s ease;
}

.quiz-answer-btn:not([disabled]):hover {
    border-color: #38bdf8;
    background-color: #f0f9ff;
}

.quiz-answer-btn.correct {
    background-color: #dcfce7;
    border-color: #4ade80;
    color: #15803d;
}

.quiz-answer-btn.incorrect {
    background-color: #fee2e2;
    border-color: #f87171;
    color: #b91c1c;
}

.quiz-answer-btn:disabled {
    cursor: not-allowed;
}

/* --- Quiz Feedback & Timer Styles --- */
#quiz-status-display {
    transition: opacity 0.3s;
}

#quiz-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.95);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    padding: 2rem;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out;
}

#quiz-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

#overlay-title.feedback-correct {
    color: #16a34a;
}

#overlay-title.feedback-incorrect {
    color: #dc2626;
}

.timer-modal {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.timer-modal.visible {
    opacity: 1;
    pointer-events: auto;
}

/* --- Styles for Timeline --- */
#timeline-section {
    margin-top: 4rem;
}

#timeline-outer-container {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    user-select: none;
    width: 100%;
    position: relative;
    overflow: hidden;
    padding-bottom: 1rem;
}

#timeline-labels-container {
    width: 160px;
    flex-shrink: 0;
    /* NEU: Dieselben Grid-Eigenschaften wie der Haupt-Container */
    display: grid;
    gap: 0.25rem 0;
}

.timeline-row-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #334155;
    text-align: left;
    padding-left: 0.5rem;
    height: 36px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: color 0.2s ease;
}

.timeline-row-label:hover {
    color: #0369a1;
}

#timeline-grid-container {
    position: relative;
    display: grid;
    gap: 0.25rem 0;
    overflow-x: auto;
    flex-grow: 1;
    min-width: 0;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#timeline-grid-container::-webkit-scrollbar {
    display: none;
}

.timeline-header, .timeline-row-track {
    display: grid;
}

.timeline-header {
    border-bottom: 2px solid #cbd5e1;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

.timeline-year {
    text-align: center;
    font-weight: 600;
    color: #475569;
    font-size: 0.875rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.timeline-year:hover {
    color: #0369a1;
}


.timeline-row-track {
    height: 36px;
}

.timeline-spacer {
    height: 0.75rem;
}

.timeline-item {
    position: relative;
    height: 24px;
    align-self: center;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0 0.5rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    color: white;
    border: 1px solid rgba(0,0,0,0.05);
    width: calc(100% - 4px);
    margin: 0 auto;
    z-index: 2;
    cursor: pointer;
}

.timeline-item.is-process {
    color: #1e293b;
}

.timeline-item.is-highlighted {
    opacity: 1 !important;
    filter: saturate(1) !important;
}

.timeline-item.not-highlighted {
    opacity: 0.5;
    filter: saturate(0.5);
}

.timeline-item.category-highlighted {
    opacity: 1 !important;
    filter: saturate(1) !important;
    outline: 2px solid #334155;
    outline-offset: 2px;
}

.timeline-item.category-faded {
    opacity: 0.3 !important;
    filter: saturate(0) !important;
}

#now-marker {
    position: absolute;
    top: -28px;
    bottom: 0;
    background-color: rgba(239, 68, 68, 0.15);
    border: 2px solid #ef4444;
    border-bottom: none;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    z-index: 3;
    pointer-events: auto;
    cursor: ew-resize;
    opacity: 0;
    transform: translateY(20px);
}

#now-marker.fade-in {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out, left 0.2s ease-out;
}

#now-marker::before {
    content: 'JETZT';
    position: absolute;
    top: 3px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ef4444;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

#timeline-arrow-svg {
    z-index: 1;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    overflow: visible;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1.05);
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.5);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 0 0 7px rgba(239, 68, 68, 0.7);
    }
}

.is-pulsing {
    animation: pulse 1.5s infinite ease-in-out;
}

/* --- Special Node States (for network graph) --- */
.node.quiz-active {
    background-color: #fee2e2 !important;
    border-color: #f87171 !important;
    animation: pulse 1.5s infinite ease-in-out;
}

.node.quiz-active .node-locked-icon {
    display: block;
    color: #b91c1c;
}

.node.quiz-active:hover {
    transform: none;
}

/* --- REFACTORING: Klassenbasierte Zentrierung statt ID-Hacks --- */

/* 1. Neue Utility-Klasse für die Basis-Zentrierung */
.node.node-centered-x {
    left: 50%;
    transform: translateX(-50%);
}

/* 2. Kombinierter Hover-Effekt für zentrierte Knoten */
.node.node-centered-x:hover {
    transform: translateX(-50%) translateY(-4px) scale(1.03);
}

/* 3. Kombinierter Aktiv-Effekt für zentrierte Knoten */
.node.node-centered-x.active {
    transform: translateX(-50%) scale(1.05);
}

/* 4. Spezielle Animation, die die Zentrierung beibehält */
@keyframes pulse-with-translate {
    0%, 100% {
        transform: translateX(-50%) scale(1.05);
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.5);
    }
    50% {
        transform: translateX(-50%) scale(1.15);
        box-shadow: 0 0 0 7px rgba(239, 68, 68, 0.7);
    }
}

/* 5. Wende die spezielle Animation nur auf zentrierte Quiz-Knoten an */
.node.node-centered-x.quiz-active {
    animation-name: pulse-with-translate;
    /* Basis-Transform wird von der Animation gesetzt, daher hier nicht nötig */
}

/* 6. Stelle sicher, dass der Hover-Effekt die Animation nicht stört */
.node.node-centered-x.quiz-active:hover {
    transform: translateX(-50%); /* Verhindere Skalierung bei Hover */
}

.zeitraum-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 1rem;
    align-items: center;
}
.zeitraum-label {
    font-weight: 600;
    color: #475569; /* slate-600 */
}
.zeitraum-data {
    color: #1e3a8a; /* blue-800, für die blaue Schrift */
}

/* In styles.css hinzufügen, falls nicht vorhanden */
@keyframes horizontal-slide-invite-animation {
    0% { transform: translateX(0); }
    25% { transform: translateX(40px); }
    75% { transform: translateX(-40px); }
    100% { transform: translateX(0); }
}

.horizontal-slide-invite {
    animation: horizontal-slide-invite-animation 1.5s ease-in-out forwards;
}

