/* =========================================
   FARBPALETTE UND GLOBALE VARIABLEN
   ========================================= */
:root {
    --bg-color: #050505;
    --text-color: #00ff41; /* Klassisches Terminal-Grün */
    --glow-subtle: 0 0 5px rgba(0, 255, 65, 0.5);
    --glow-strong: 0 0 10px rgba(0, 255, 65, 0.8), 0 0 20px rgba(0, 255, 65, 0.4);

    /* Quiz-spezifische Variablen */
    --error-color: #ff0041;
    --glow-error: 0 0 10px rgba(255, 0, 65, 0.8);
    --border-color: rgba(0, 255, 65, 0.3);
}

/* =========================================
   SAFARI & MOBILE FIXES (WICHTIG!)
   ========================================= */
button, input, select, a, .nav-btn, .option-btn, .btn-hint, #next-btn, .restart-btn {
    -webkit-appearance: none !important;
    appearance: none !important;
    border-radius: 0;
    -webkit-tap-highlight-color: transparent; /* Verhindert das graue Aufblinken beim Tippen in Safari */
}

/* =========================================
   GRUNDLEGENDES SETUP
   ========================================= */
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Space Mono', monospace;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

h1 {
    font-size: 3rem;
    margin: 0;
    text-shadow: var(--glow-strong);
    letter-spacing: 2px;
}

main {
    display: flex;
    flex-wrap: wrap; /* Lässt Spalten auf kleinen Screens umbrechen */
    justify-content: center;
    gap: 40px;
    padding: 40px 20px;
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.column {
    flex: 1;
    min-width: 280px;
}

h2 {
    font-size: 1.5rem;
    border-bottom: 1px dashed var(--text-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    text-shadow: var(--glow-subtle);
}

ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

li {
    margin-bottom: 5px;
}

a {
    color: var(--text-color);
    text-decoration: none;
    display: block;
    padding: 12px 10px;
    border-left: 3px solid transparent;
    transition: all 0.2s ease-in-out;
    text-shadow: var(--glow-subtle);
}

footer {
    text-align: center;
    padding: 20px;
    border-top: 1px dashed var(--border-color);
    margin-top: auto;
}

/* =========================================
   QUIZ-SPEZIFISCHES DESIGN
   ========================================= */

#quiz-container {
    max-width: 850px;
    width: 100%;
    background-color: var(--bg-color);
    padding: 40px;
    border: 1px solid var(--border-color);
    box-shadow: var(--glow-subtle);
    box-sizing: border-box;
    margin: 0 auto;
}

.subtitle {
    text-align: center;
    color: rgba(0, 255, 65, 0.7);
    margin-bottom: 30px;
    font-size: 0.95rem;
    font-style: italic;
}

/* --- Fragen-Navigation --- */
.question-nav {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 15px;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--text-color) var(--bg-color);
}

.question-nav::-webkit-scrollbar {
    height: 6px;
}
.question-nav::-webkit-scrollbar-thumb {
    background-color: var(--text-color);
}

.nav-btn {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    font-weight: bold;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    user-select: none;
    font-family: 'Space Mono', monospace;
}

/* WICHTIG: !important zwingt auch Smartphones dazu, die Farben beizubehalten */
.nav-btn.active {
    border-color: var(--text-color) !important;
    background: rgba(0, 255, 65, 0.2) !important;
    color: var(--text-color);
    box-shadow: var(--glow-subtle);
}

.nav-btn.correct {
    border-color: var(--text-color) !important;
    color: var(--bg-color) !important;
    background: var(--text-color) !important;
    text-shadow: none;
}

.nav-btn.correct.active {
    box-shadow: var(--glow-strong);
}

.nav-btn.wrong {
    border-color: var(--error-color) !important;
    color: var(--error-color) !important;
    text-shadow: 0 0 5px var(--error-color);
}

.nav-btn.wrong.active {
    background: rgba(255, 0, 65, 0.1) !important;
}

/* --- Fortschrittsbalken --- */
.progress-bar {
    height: 8px;
    background: rgba(0, 255, 65, 0.1);
    border: 1px solid var(--border-color);
    margin-bottom: 10px;
    overflow: hidden;
}

#progress {
    height: 100%;
    background: var(--text-color);
    width: 0%;
    transition: width 0.4s ease;
    box-shadow: var(--glow-subtle);
}

.stats {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    margin-bottom: 25px;
    color: var(--text-color);
    font-size: 1.1rem;
    text-shadow: var(--glow-subtle);
}

/* --- Frage & Antworten --- */
.question-box h2 {
    font-size: 1.25rem;
    margin-bottom: 25px;
    font-weight: normal;
    line-height: 1.6;
    border-bottom: 1px dashed var(--text-color);
    padding-bottom: 15px;
}

.options {
    display: grid;
    gap: 15px;
    margin-bottom: 30px;
}

.option-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 16px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease-in-out;
    font-size: 1.05rem;
    touch-action: manipulation;
    font-family: 'Space Mono', monospace;
}

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

.option-btn.correct {
    border-color: var(--text-color) !important;
    background: rgba(0, 255, 65, 0.2) !important;
    box-shadow: var(--glow-strong);
    font-weight: bold;
}

.option-btn.wrong {
    border-color: var(--error-color) !important;
    background: rgba(255, 0, 65, 0.1) !important;
    color: var(--error-color) !important;
    text-shadow: 0 0 5px var(--error-color);
    box-shadow: var(--glow-error);
}

/* --- Hilfen & Erklärungen --- */
.hints-section {
    margin-bottom: 20px;
    padding-top: 20px;
    border-top: 1px dashed var(--border-color);
}

.btn-hint {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.95rem;
    margin-bottom: 10px;
    transition: all 0.2s;
    touch-action: manipulation;
    font-family: 'Space Mono', monospace;
}

.hint-text {
    background: rgba(0, 255, 65, 0.05);
    border-left: 4px solid var(--text-color);
    padding: 12px 15px;
    margin-bottom: 15px;
    font-size: 0.95rem;
}

.rationale-box {
    background: rgba(0, 255, 65, 0.05);
    border: 1px dashed var(--border-color);
    padding: 20px;
    margin-top: 20px;
    font-size: 1rem;
}

.rationale-box h3 {
    margin-top: 0;
    color: var(--text-color);
    font-size: 1.1rem;
    margin-bottom: 15px;
    text-shadow: var(--glow-subtle);
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 10px;
}

.rationale-step {
    margin-bottom: 12px;
}

b, i {
    text-shadow: var(--glow-subtle);
}

/* --- Weiter-Button & Resultate --- */
#next-btn {
    display: block;
    width: 100%;
    background: rgba(0, 255, 65, 0.05);
    color: var(--text-color);
    border: 1px solid var(--text-color);
    padding: 18px;
    margin-top: 30px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    font-family: 'Space Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#next-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: var(--border-color);
    box-shadow: none;
}

.result-screen {
    text-align: center;
}

.result-score {
    font-size: 4rem;
    color: var(--text-color);
    margin: 20px 0;
    font-weight: bold;
    text-shadow: var(--glow-strong);
}

.restart-btn {
    opacity: 1 !important;
    cursor: pointer !important;
}

/* =========================================
   HOVER-EFFEKTE (NUR FÜR DESKTOP / MAUS)
   ========================================= */
/* Dieser Block verhindert, dass die Farben auf dem Handy nach dem Antippen stecken bleiben */
@media (hover: hover) and (pointer: fine) {
    a:hover, a:focus {
        background-color: rgba(0, 255, 65, 0.1);
        border-left: 3px solid var(--text-color);
        text-shadow: var(--glow-strong);
        padding-left: 15px;
        outline: none;
    }

    .nav-btn:hover {
        background-color: rgba(0, 255, 65, 0.1);
        border-color: var(--text-color);
        text-shadow: var(--glow-strong);
    }

    .option-btn:hover:not(:disabled) {
        border-color: var(--text-color);
        background: rgba(0, 255, 65, 0.1);
        text-shadow: var(--glow-strong);
        padding-left: 25px;
    }

    .btn-hint:hover {
        background: rgba(0, 255, 65, 0.1);
        border-color: var(--text-color);
        text-shadow: var(--glow-subtle);
    }

    #next-btn:hover:not(:disabled) {
        background: rgba(0, 255, 65, 0.2);
        box-shadow: var(--glow-strong);
        text-shadow: var(--glow-strong);
    }
}

/* =========================================
   HELPER-KLASSEN FÜR JAVASCRIPT
   ========================================= */
/* WICHTIG: Die Tipps können nur versteckt werden, wenn diese Klasse hier ganz frei steht! */
.is-hidden {
    display: none !important;
}

/* =========================================
   MOBILE RESPONSIVENESS (SMARTPHONES)
   ========================================= */
@media (max-width: 600px) {
    #quiz-container {
        padding: 20px;
    }

    .option-btn {
        padding: 14px;
        font-size: 1rem;
    }

    .nav-btn {
        width: 44px;
        height: 44px;
    }

    #next-btn {
        padding: 16px;
        font-size: 1rem;
    }

    .rationale-box {
        padding: 15px;
        font-size: 0.95rem;
    }
}

/* --- Styling für Formular-Eingabefelder --- */
.terminal-form input[type="text"],
.terminal-form input[type="number"],
.terminal-form input[type="password"],
select.terminal-form,
.terminal-form textarea {
    width: 100%;             /* Nimmt die komplette Breite des Containers ein */
    padding: 15px;           /* Macht das Eingabefeld "dicker" (Innenabstand) */
    font-size: 1.1em;        /* Macht die Schrift deutlich größer */
    font-family: inherit;    /* Übernimmt deine Terminal-Schriftart */
    box-sizing: border-box;  /* Verhindert, dass das Padding das Layout sprengt */
    margin: 10px;

    /* (Optional) Falls du den Hacker-Look verstärken willst: */
    background-color: #111;  /* Sehr dunkler Hintergrund */
    color: #FFCC00;          /* Neongrüne Schrift beim Tippen */
    border: 1px solid #333;  /* Dezenter Rahmen */
    border-radius: 5px;      /* Leicht abgerundete Ecken */
}

/* --- Spezifische Korrekturen nur für das Select-Feld --- */
select.terminal-form {
    /* 1. Ein kleiner Pfeil nach unten im Terminal-Look (eckig) */
    appearance: none; /* Stellt sicher, dass der Standardpfeil WIRKLICH weg ist */
    width: 100%;             /* Nimmt die komplette Breite des Containers ein */
    padding: 15px;           /* Macht das Eingabefeld "dicker" (Innenabstand) */
    font-size: 1.1em;        /* Macht die Schrift deutlich größer */
    font-family: inherit;    /* Übernimmt deine Terminal-Schriftart */
    box-sizing: border-box;  /* Verhindert, dass das Padding das Layout sprengt */
    margin: 10px
}

/* Ändert die Rahmenfarbe, wenn der Schüler in das Feld klickt: */
.terminal-form input[type="text"]:focus,
.terminal-form input[type="password"]:focus,
select.terminal-form:focus,
.terminal-form textarea:focus {
    outline: none;
    border: 1px solid #00ff00;
}

/* Styling für den GHS-Container (identisch zu den anderen Eingabefeldern) */
.ghs-grid {
    width: 100%;             /* Nimmt die komplette Breite des Containers ein */
    display: flex;
    flex-wrap: wrap;
    gap: 15px;               /* Abstand zwischen den Bildern */
    padding: 15px;           /* Gleiche "Dicke" wie Textfelder */
    background-color: #111;  /* Gleicher, etwas hellerer Hintergrund */
    border: 1px solid #333;  /* Gleicher Rahmen */
    border-radius: 5px;      /* Abgerundete Ecken! */
    box-sizing: border-box;
    margin: 10px;
}

/* Styling für den GHS-Container (identisch zu den anderen Eingabefeldern) */
.sketch-grid {
    width: 100%;             /* Nimmt die komplette Breite des Containers ein */
    padding: 15px;           /* Gleiche "Dicke" wie Textfelder */
    background-color: #111;  /* Gleicher, etwas hellerer Hintergrund */
    border: 1px solid #333;  /* Gleicher Rahmen */
    border-radius: 5px;      /* Abgerundete Ecken! */
    box-sizing: border-box;
    margin: 10px;
}

/* Standardzustand der Bilder (nicht ausgewählt: grau und halbtransparent) */
.ghs-image {
    filter: grayscale(1) brightness(0.5);
    opacity: 0.5;
}

/* Wenn die versteckte Checkbox durch Klick AKTIVIERT wird (checked) */
.ghs-hidden-checkbox:checked + .ghs-card .ghs-image {
    filter: grayscale(0) brightness(1) !important; /* Volle Farbe */
    opacity: 1 !important;                         /* Volle Sichtbarkeit */
    transform: scale(1.05);                         /* Minimales Hervorheben */
}

/* --- TERMINAL CHECKBOX --- */
.terminal-checkbox {
    display: none; /* Versteckt die hässliche Browser-Checkbox */
}

.fake-checkbox .check-mark {
    opacity: 0; /* Versteckt das X standardmäßig */
    color: #ffcc00;
    font-weight: bold;
}

/* Die Magie: Wenn das unsichtbare Feld gecheckt ist, blende das X ein */
.terminal-checkbox:checked + .fake-checkbox .check-mark {
    opacity: 1;
}


/* =========================================
   LATEX HILFE SEITENLEISTE
   ========================================= */

/* Der schwebende Button unten rechts */
.floating-help-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    box-shadow: var(--glow-subtle);
    background-color: var(--bg-color);
}

/* Das Layout der Seitenleiste */
.latex-sidebar {
    position: fixed;
    top: 0;
    right: 0; /* Leiste klebt standardmäßig rechts... */
    transform: translateX(100%); /* ...wird aber zu 100% ihrer Breite aus dem Bild geschoben */
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background-color: #080808;
    border-left: 2px solid var(--text-color);
    box-shadow: -10px 0 30px rgba(0, 255, 65, 0.15);
    z-index: 9999; /* Extrem hoch, damit sie immer im Vordergrund ist */
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
}

/* Die Klasse, die per JavaScript hinzugefügt wird, um sie anzuzeigen */
.latex-sidebar.open {
    transform: translateX(0); /* Fährt die Leiste auf Position 0 zurück ins Bild */
}

/* Kopfbereich der Leiste */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #333;
    background-color: #050505;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.2em;
}

.close-btn {
    padding: 5px 10px;
    color: var(--error-color); /* Nutzt dein Rot aus dem CSS */
    border-color: var(--error-color);
}

.close-btn:hover {
    background-color: rgba(255, 0, 65, 0.1);
    box-shadow: var(--glow-error);
}

/* Scrollbarer Inhaltsbereich */
.sidebar-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Design der einzelnen Hilfe-Blöcke */
.help-section {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #222;
}

.help-section h3 {
    color: #FFCC00; /* Gelb für Zwischenüberschriften */
    font-size: 1em;
    margin-bottom: 10px;
}

.help-section code {
    display: inline-block;
    background-color: #111;
    border: 1px solid #333;
    color: var(--text-color);
    padding: 2px 6px;
    border-radius: 3px;
    margin: 3px 0;
    font-family: inherit;
}

.help-section pre code {
    display: block;
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
}

.help-section span {
    color: #ccc;
    font-size: 0.9em;
    margin-left: 10px;
}