/* ================================================
   quiz.css – Nur Quiz-spezifische Styles
   Navbar, Footer, Fonts und Grid kommen aus
   Bootstrap + style.css (via menu.php / footer.php)
   ================================================ */

/* ================================================
   Kahoot-Farben als CSS-Variablen
   ================================================ */
:root {
    --answer-red:         #e21b3c;
    --answer-red-dark:    #b01530;
    --answer-blue:        #1368ce;
    --answer-blue-dark:   #0d50a0;
    --answer-yellow:      #d89e00;
    --answer-yellow-dark: #a87800;
    --answer-green:       #26890c;
    --answer-green-dark:  #1a6008;
    --correct-color:      #26890c;
    --wrong-color:        #e21b3c;
}

/* ================================================
   Hero-Badges (Themenzeile unter dem Titel)
   ================================================ */
.quiz-hero-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.quiz-hero-badge {
    background: rgba(255, 255, 255, 0.35);
    color: var(--primary-blue, #1e3c72);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 50px;
    padding: 0.35rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

/* ================================================
   SCREEN 1: Startscreen
   ================================================ */
.quiz-start-screen {
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border: 1px solid #c2e9fb;
    padding: 3rem 2rem;
    text-align: center;
}

.quiz-start-screen h2 {
    color: #1e3c72;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.quiz-start-screen .quiz-topic-label {
    color: #666;
    font-size: 1rem;
    margin-bottom: 2rem;
}

.quiz-meta {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}

.quiz-meta-item .meta-value {
    display: block;
    font-size: 2.2rem;
    font-weight: 700;
    color: #1e3c72;
    line-height: 1;
}

.quiz-meta-item .meta-label {
    display: block;
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.2rem;
}

.btn-quiz-start {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    border: none;
    padding: 0.9rem 3rem;
    font-size: 1.15rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(42, 82, 152, 0.3);
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-quiz-start:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(42, 82, 152, 0.4);
}

/* ================================================
   SCREEN 2: Frage-Header mit Fortschritt
   ================================================ */
.quiz-question-screen {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.quiz-header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border-radius: 10px;
    padding: 0.9rem 1.25rem;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.quiz-progress-text {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.progress-bar-container {
    flex: 1;
    min-width: 100px;
    height: 8px;
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: white;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.quiz-score-display {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
}

/* ================================================
   Countdown-Timer (kreisförmig)
   ================================================ */
.timer-container {
    display: flex;
    justify-content: center;
}

.timer-circle {
    position: relative;
    width: 90px;
    height: 90px;
}

.timer-svg {
    transform: rotate(-90deg);
    width: 90px;
    height: 90px;
}

.timer-track {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 6;
}

.timer-progress {
    fill: none;
    stroke: #1e3c72;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 226.2;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}

.timer-progress.warning { stroke: #d89e00; }
.timer-progress.danger  { stroke: #e21b3c; }

.timer-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e3c72;
    font-family: inherit;
    line-height: 1;
}

.timer-number.warning { color: #a87800; }
.timer-number.danger  { color: #e21b3c; }

/* ================================================
   Frage-Box
   ================================================ */
.quiz-question-box {
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border: 1px solid #c2e9fb;
    padding: 1.5rem 2rem;
    text-align: center;
}

.quiz-question-box h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
    line-height: 1.5;
    margin: 0;
}

/* ================================================
   Antwort-Buttons – Kahoot-Style
   Reihenfolge: Rot (▲), Blau (◆), Gelb (●), Grün (■)
   ================================================ */
.quiz-answers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.answer-btn {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1rem 1.25rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    line-height: 1.3;
    min-height: 70px;
    /* Erscheint animiert */
    opacity: 0;
    transform: scale(0.85);
    animation: answerAppear 0.3s ease forwards;
}

.answer-btn:nth-child(1) { animation-delay: 0.05s; }
.answer-btn:nth-child(2) { animation-delay: 0.15s; }
.answer-btn:nth-child(3) { animation-delay: 0.25s; }
.answer-btn:nth-child(4) { animation-delay: 0.35s; }

@keyframes answerAppear {
    to { opacity: 1; transform: scale(1); }
}

/* Farben + 3D-Schatten */
.answer-btn.red    { background-color: var(--answer-red);    box-shadow: 0 4px 0 var(--answer-red-dark); }
.answer-btn.blue   { background-color: var(--answer-blue);   box-shadow: 0 4px 0 var(--answer-blue-dark); }
.answer-btn.yellow { background-color: var(--answer-yellow); box-shadow: 0 4px 0 var(--answer-yellow-dark); }
.answer-btn.green  { background-color: var(--answer-green);  box-shadow: 0 4px 0 var(--answer-green-dark); }

.answer-btn:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.answer-btn:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: none;
}

.answer-btn:disabled {
    cursor: not-allowed;
    filter: brightness(0.55);
    box-shadow: none;
    transform: none;
}

/* MathJax-Output in farbigen Buttons: Textfarbe erben (= weiß) */
.answer-btn mjx-container { color: inherit; }
/* Display-Math in der Frage-Box: horizontal scrollbar bei Überlauf */
.quiz-question-box mjx-container[display="true"] {
    overflow-x: auto;
    max-width: 100%;
}

/* Icons (CSS-Formen ohne externe Ressourcen) */
.answer-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-triangle {
    width: 0;
    height: 0;
    border-left: 13px solid transparent;
    border-right: 13px solid transparent;
    border-bottom: 22px solid rgba(255,255,255,0.9);
}

.icon-diamond {
    width: 18px;
    height: 18px;
    background: rgba(255,255,255,0.9);
    transform: rotate(45deg);
    border-radius: 2px;
}

.icon-circle {
    width: 20px;
    height: 20px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
}

.icon-square {
    width: 18px;
    height: 18px;
    background: rgba(255,255,255,0.9);
    border-radius: 3px;
}

/* Richtige Antwort: immer grün, deutlich sichtbar.
   opacity:1 überschreibt die native Browser-Reduzierung für :disabled,
   die sonst "weiß auf weißem Hintergrund" erzeugt. */
.answer-btn.correct-answer,
.answer-btn.correct-answer:disabled {
    background-color: var(--correct-color) !important;
    box-shadow: 0 4px 0 var(--answer-green-dark),
                0 0 0 4px white,
                0 0 0 7px var(--correct-color) !important;
    filter: none !important;
    opacity: 1 !important;
    color: white !important;
    animation: correctPulse 0.45s ease !important;
}

/* Falsch gewählte Antwort stark abdunkeln */
.answer-btn.wrong-answer,
.answer-btn.wrong-answer:disabled {
    filter: brightness(0.3) !important;
    opacity: 1 !important;   /* Browser-Default :disabled opacity zurücksetzen */
    box-shadow: none !important;
}

/* Alle anderen Buttons nach Antwort leicht abdunkeln */
.answer-btn:disabled:not(.correct-answer):not(.wrong-answer) {
    filter: brightness(0.5) !important;
    opacity: 1 !important;
}

@keyframes correctPulse {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.06); }
    100% { transform: scale(1); }
}

/* ================================================
   Feedback-Banner
   ================================================ */
.quiz-feedback {
    border-radius: 10px;
    padding: 1rem 1.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 1.05rem;
    display: none;
    animation: feedbackSlide 0.3s ease;
}

@keyframes feedbackSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.quiz-feedback.correct {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.quiz-feedback.wrong {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.quiz-feedback .feedback-points {
    font-size: 0.88rem;
    margin-top: 0.2rem;
    opacity: 0.8;
}

.quiz-feedback .feedback-explanation {
    font-size: 0.88rem;
    font-weight: 400;
    margin-top: 0.5rem;
    line-height: 1.4;
}

/* Weiter-Button */
.btn-quiz-next {
    display: none;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    border: none;
    padding: 0.85rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(42, 82, 152, 0.3);
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-quiz-next.visible {
    display: block;
}

.btn-quiz-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(42, 82, 152, 0.4);
}

/* ================================================
   SCREEN 3: Ergebnis-Screen
   ================================================ */
.quiz-result-screen {
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border: 1px solid #c2e9fb;
    padding: 2.5rem 2rem;
    text-align: center;
}

.result-trophy {
    font-size: 5rem;
    display: block;
    margin-bottom: 1rem;
    animation: trophyBounce 0.6s ease;
}

@keyframes trophyBounce {
    0%   { transform: scale(0); }
    60%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.result-screen-title {
    color: #1e3c72;
    font-size: 1.7rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.result-screen-topic {
    color: #666;
    margin-bottom: 1.5rem;
}

.result-score-big {
    background: linear-gradient(135deg, #88c4ff 0%, #c2e9fb 100%);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.75rem;
}

.result-score-big .score-value {
    font-size: 3.2rem;
    font-weight: 700;
    color: #1e3c72;
    line-height: 1;
}

.result-score-big .score-label {
    font-size: 0.85rem;
    color: #555;
    margin-top: 0.3rem;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}

.result-stat .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
}

.result-stat .stat-label {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
}

.result-stat.correct .stat-value { color: var(--correct-color); }
.result-stat.wrong   .stat-value { color: var(--wrong-color); }
.result-stat.skipped .stat-value { color: #666; }

.result-rating {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.75rem;
    padding: 0.9rem 1rem;
    border-radius: 10px;
}

.result-rating.excellent { background: #d4edda; color: #155724; }
.result-rating.good      { background: #d1ecf1; color: #0c5460; }
.result-rating.ok        { background: #fff3cd; color: #856404; }
.result-rating.bad       { background: #f8d7da; color: #721c24; }

/* Fragenübersicht */
.result-details {
    text-align: left;
    margin-bottom: 2rem;
}

.result-details h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #1e3c72;
    margin-bottom: 0.75rem;
    text-align: center;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.result-table th {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 0.6rem 0.75rem;
    text-align: left;
}

.result-table th:last-child { text-align: right; }

.result-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #c2e9fb;
    vertical-align: top;
}

.result-table td:last-child { text-align: right; font-weight: 600; }

.result-table tr.row-correct { background: #f0fff4; }
.result-table tr.row-wrong   { background: #fff5f5; }
.result-table tr.row-timeout { background: #fffbf0; }

.result-icon-correct { color: var(--correct-color); }
.result-icon-wrong   { color: var(--wrong-color); }
.result-icon-timeout { color: #856404; }

/* Buttons im Ergebnis-Screen */
.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-result {
    padding: 0.85rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
}

.btn-result-primary {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    box-shadow: 0 5px 15px rgba(42, 82, 152, 0.3);
}

.btn-result-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(42, 82, 152, 0.4);
    color: white;
}

.btn-result-secondary {
    background: white;
    color: #1e3c72;
    border: 2px solid #1e3c72;
}

.btn-result-secondary:hover {
    background: #c2e9fb;
    transform: translateY(-2px);
    color: #1e3c72;
}

/* ================================================
   Lade-Spinner & Fehler
   ================================================ */
.quiz-loading {
    text-align: center;
    padding: 3rem 2rem;
    color: #666;
}

.quiz-spinner {
    width: 48px;
    height: 48px;
    border: 5px solid #c2e9fb;
    border-top-color: #1e3c72;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.quiz-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
}

/* ================================================
   Responsive
   ================================================ */
@media (max-width: 600px) {
    .quiz-answers {
        grid-template-columns: 1fr;
    }

    .quiz-start-screen {
        padding: 1.75rem 1rem;
    }

    .quiz-start-screen h2 {
        font-size: 1.4rem;
    }

    .quiz-question-box h2 {
        font-size: 1.05rem;
    }

    .answer-btn {
        font-size: 0.9rem;
        min-height: 58px;
    }

    .result-score-big .score-value {
        font-size: 2.5rem;
    }

    .result-actions {
        flex-direction: column;
        align-items: stretch;
    }

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

/* ================================================
   Accessibility
   ================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
