/* ============================================================
   QUIZ ENGINE STYLES — K53 Learners Test
   BEM classes matching quiz.js output
   ============================================================ */

/* ─── Base / Reset ──────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ─── Quiz Container ────────────────────────────────────── */
.quiz-question {
    max-width: 720px;
    margin: 0 auto;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    color: #1a1a1a;
    background: #f2f2f7;
    min-height: 100vh;
}

/* ============================================================
   1. LOADING STATE
   ============================================================ */
.quiz-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    min-height: 60vh;
}

.quiz-loading__spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e5ea;
    border-top-color: #CC0000;
    border-radius: 50%;
    animation: quiz-spin 0.7s linear infinite;
}

.quiz-loading__text {
    margin-top: 16px;
    font-size: 15px;
    color: #8e8e93;
    font-weight: 500;
}

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

/* ============================================================
   2. ERROR STATE
   ============================================================ */
.quiz-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    min-height: 60vh;
    text-align: center;
}

.quiz-error__heading {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 8px;
}

.quiz-error__desc {
    font-size: 15px;
    color: #555;
    margin: 0 0 24px;
    line-height: 1.5;
    max-width: 360px;
}

/* Retry button inside error (uses .btn .btn--primary from global) */
.quiz-error .btn {
    min-width: 160px;
}

/* ============================================================
   3. QUESTION HEADER — Red bar
   ============================================================ */
.quiz-question__header {
    background: #CC0000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    gap: 12px;
}

.quiz-question__badge {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.18);
    padding: 4px 10px;
    border-radius: 6px;
}

/* ─── Timer ─────────────────────────────────────────────── */
.quiz-question__timer {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: 'SF Mono', 'Menlo', 'Courier New', monospace;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.quiz-question__timer-icon {
    font-size: 15px;
    line-height: 1;
}

.quiz-question__timer-value {
    min-width: 48px;
    text-align: right;
}

/* Timer urgency — under 5 minutes */
.quiz-question__timer.is-urgent {
    color: #ff9500;
    animation: quiz-timer-blink 0.8s step-start infinite;
}

@keyframes quiz-timer-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

/* ============================================================
   4. PROGRESS BAR
   ============================================================ */
.quiz-question__progress {
    height: 4px;
    background: transparent;
    overflow: hidden;
}

.quiz-question__progress-track {
    height: 4px;
    background: #f0f0f0;
    width: 100%;
    overflow: hidden;
}

.quiz-question__progress-fill {
    height: 100%;
    background: #CC0000;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2px;
    border-radius: 0 2px 2px 0;
}

/* ============================================================
   5. QUESTION IMAGE
   ============================================================ */
.quiz-question__image-wrap {
    text-align: center;
    padding: 16px 16px 0;
}

.quiz-question__image {
    max-height: 200px;
    max-width: 100%;
    border-radius: 12px;
    object-fit: contain;
    display: inline-block;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* ============================================================
   6. QUESTION TEXT
   ============================================================ */
.quiz-question__text {
    font-size: 17px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.52;
    padding: 20px 20px 0;
    margin: 0;
}

/* Strip inherited inline formatting inside question text */
.quiz-question__text * {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    background: none;
    text-decoration: none;
}

/* ============================================================
   7. OPTION BUTTONS
   ============================================================ */
.quiz-question__options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 20px 0;
}

.quiz-question__option-item {
    /* wrapper if needed — no special styles */
}

.quiz-option-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: #ffffff;
    border: 1.5px solid #ebebeb;
    border-radius: 12px;
    padding: 14px 16px;
    font-family: inherit;
    font-size: 15px;
    color: #1a1a1a;
    line-height: 1.4;
    cursor: pointer;
    min-height: 48px;
    text-align: left;
    transition: border-color 0.15s ease,
                background-color 0.15s ease,
                box-shadow 0.15s ease,
                transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    appearance: none;
    -webkit-appearance: none;
}

.quiz-option-btn:hover:not(.quiz-option-btn--disabled) {
    border-color: #ccc;
    background: #fafafa;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.quiz-option-btn:active:not(.quiz-option-btn--disabled) {
    transform: scale(0.985);
}

/* Letter badge circle */
.quiz-option-btn__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #f2f2f7;
    font-size: 13px;
    font-weight: 700;
    color: #555;
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* Correct answer */
.quiz-option-btn--correct {
    background: #eafbe7;
    border-color: #34c759;
    color: #1a6e2e;
}

.quiz-option-btn--correct .quiz-option-btn__icon {
    background: #34c759;
    color: #fff;
}

/* Wrong answer */
.quiz-option-btn--wrong {
    background: #fff0f0;
    border-color: #CC0000;
    color: #CC0000;
}

.quiz-option-btn--wrong .quiz-option-btn__icon {
    background: #CC0000;
    color: #fff;
}

/* Disabled (after answering) */
.quiz-option-btn--disabled {
    cursor: default;
    opacity: 0.92;
    pointer-events: none;
}

/* ============================================================
   8. EXPLANATION
   ============================================================ */
.quiz-explanation {
    background: #f5f5f7;
    border-left: 3px solid #CC0000;
    padding: 14px 16px;
    margin: 16px 20px 0;
    border-radius: 0 10px 10px 0;
    animation: quiz-fade-in 0.25s ease-out;
}

.quiz-explanation__text {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
    margin: 0;
}

@keyframes quiz-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   9. NEXT BUTTON
   ============================================================ */
.quiz-question__next-wrap {
    padding: 20px 20px 24px;
}

.quiz-next-btn {
    display: block;
    width: 100%;
    padding: 15px 24px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    background: #CC0000;
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(204, 0, 0, 0.2);
}

.quiz-next-btn:hover {
    background: #b30000;
    box-shadow: 0 4px 12px rgba(204, 0, 0, 0.3);
}

.quiz-next-btn:active {
    transform: scale(0.98);
}

/* Global btn classes used alongside quiz-next-btn */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 13px 24px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn--primary {
    background: #CC0000;
    color: #fff;
    box-shadow: 0 2px 8px rgba(204, 0, 0, 0.18);
}

.btn--primary:hover {
    background: #b30000;
}

.btn--primary:active {
    transform: scale(0.98);
}

.btn--outline {
    background: #fff;
    color: #CC0000;
    border: 1.5px solid #CC0000;
}

.btn--outline:hover {
    background: #fff5f5;
}

.btn--outline:active {
    transform: scale(0.98);
}

/* ============================================================
   10. RESULTS SCREEN
   ============================================================ */
.quiz-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 20px 48px;
    max-width: 480px;
    margin: 0 auto;
    min-height: 80vh;
    justify-content: center;
}

.quiz-results__heading {
    font-size: 22px;
    font-weight: 800;
    color: #1a1a1a;
    margin: 0 0 28px;
}

/* Score circle */
.quiz-results__circle-wrap {
    margin-bottom: 8px;
}

.quiz-results__circle {
    width: 148px;
    height: 148px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 6px solid #ebebeb; /* overridden inline by JS for pass/fail */
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    position: relative;
}

.quiz-results__score-num {
    font-size: 38px;
    font-weight: 900;
    color: #1a1a1a;
    line-height: 1;
}

.quiz-results__score-pct {
    font-size: 14px;
    color: #8e8e93;
    margin-top: 4px;
    font-weight: 500;
}

/* Verdict badge (PASSED / FAILED) */
.quiz-results__verdict {
    display: inline-block;
    padding: 6px 22px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 16px;
    /* color set inline by JS */
}

.quiz-results__verdict--pass {
    background: #eafbe7;
    color: #34c759;
}

.quiz-results__verdict--fail {
    background: #fff0f0;
    color: #CC0000;
}

/* Stats grid */
.quiz-results__stats {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 32px;
    margin: 28px 0;
    width: 100%;
}

.quiz-results__stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.quiz-results__stat-value {
    font-size: 28px;
    font-weight: 800;
    color: #1a1a1a;
    line-height: 1;
}

.quiz-results__stat-label {
    font-size: 12px;
    color: #8e8e93;
    margin-top: 5px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

/* Color accents for stat values */
.quiz-results__stat-value--correct {
    color: #34c759;
}

.quiz-results__stat-value--wrong {
    color: #CC0000;
}

/* Action buttons */
.quiz-results__actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
    width: 100%;
}

.quiz-results__actions .btn {
    min-width: 150px;
    flex: 1;
}

/* ============================================================
   RESPONSIVE — Mobile-first adjustments
   ============================================================ */

/* Small phones */
@media (max-width: 480px) {
    .quiz-question__header {
        padding: 12px 14px;
    }

    .quiz-question__badge {
        font-size: 11px;
        padding: 3px 8px;
    }

    .quiz-question__text {
        font-size: 16px;
        padding: 16px 16px 0;
    }

    .quiz-question__options {
        padding: 14px 16px 0;
    }

    .quiz-option-btn {
        font-size: 14px;
        padding: 12px 14px;
        border-radius: 10px;
    }

    .quiz-option-btn__icon {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .quiz-explanation {
        margin: 14px 16px 0;
    }

    .quiz-question__next-wrap {
        padding: 16px 16px 20px;
    }

    .quiz-results__circle {
        width: 130px;
        height: 130px;
    }

    .quiz-results__score-num {
        font-size: 32px;
    }

    .quiz-results__stats {
        gap: 20px;
    }

    .quiz-results__stat-value {
        font-size: 24px;
    }

    .quiz-results__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .quiz-results__actions .btn {
        width: 100%;
    }
}

/* Desktop enhancements */
@media (min-width: 768px) {
    .quiz-question {
        margin-top: 20px;
        border-radius: 16px;
        overflow: hidden;
        min-height: auto;
        box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
    }

    .quiz-question__header {
        border-radius: 0;
    }

    .quiz-option-btn {
        border-radius: 10px;
    }

    .quiz-option-btn:hover:not(.quiz-option-btn--disabled) {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    }

    .quiz-results {
        margin-top: 40px;
    }

    .quiz-next-btn {
        border-radius: 10px;
        max-width: 320px;
        margin: 0 auto;
        display: block;
    }

    .quiz-question__next-wrap {
        text-align: center;
    }
}

/* ============================================================
   UTILITY — Helpers used by JS
   ============================================================ */

/* Colour classes that JS may use on stat values */
.correct-color { color: #34c759; }
.wrong-color   { color: #CC0000; }

/* Smooth appearance for dynamically injected elements */
.quiz-explanation,
.quiz-question__next-wrap {
    animation: quiz-fade-in 0.25s ease-out;
}
