/* ==========================================================================
   Quiz Page — built on top of the Coach May Pro design tokens
   (uses the same --primary / --gold / --bg-* / --text-* variables and
   .btn / .container / .section classes defined in style.css)
   ========================================================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Page header ---------- */
.quiz-hero {
    position: relative;
    padding-top: 8rem;
    padding-bottom: 3rem;
    overflow: hidden;
    text-align: center;
}

.quiz-hero-glow {
    position: absolute;
    top: 0;
    left: 50%;
    width: 560px;
    height: 560px;
    background-color: var(--primary-light);
    border-radius: 50%;
    filter: blur(110px);
    transform: translate(-50%, -40%);
    z-index: -1;
}

.quiz-hero .badge {
    margin-left: auto;
    margin-right: auto;
}

.quiz-hero h1 {
    font-size: 2.25rem;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.quiz-hero .subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
    max-width: 560px;
    margin: 0 auto 2rem;
}

.quiz-hero-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
}

.quiz-level-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    box-shadow: var(--shadow-sm);
}

.quiz-level-tag .dot-lvl {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.quiz-level-tag em {
    font-style: normal;
    color: var(--text-main);
    opacity: 0.65;
}

.lvl-DEBUTANT .dot-lvl { background-color: var(--primary); }
.lvl-INTERMEDIAIRE .dot-lvl { background-color: var(--gold); }
.lvl-AVANCE .dot-lvl { background-color: #E4572E; }

.level-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.level-pill.lvl-DEBUTANT { background-color: var(--primary-light); color: var(--primary); }
.level-pill.lvl-INTERMEDIAIRE { background-color: rgba(216, 164, 60, 0.15); color: var(--gold); }
.level-pill.lvl-AVANCE { background-color: rgba(228, 87, 46, 0.15); color: #E4572E; }
body.dark-theme .level-pill.lvl-INTERMEDIAIRE { color: var(--gold-light); }

/* ---------- Quiz app shell ---------- */
.quiz-app-section {
    padding-top: 0;
    padding-bottom: 6rem;
}

.quiz-shell {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
}

.quiz-screen { display: none; }
.quiz-screen.active { display: block; }

/* ---------- Start screen ---------- */
.quiz-start-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    text-align: center;
}

.quiz-options-config {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.25rem 1.5rem;
    margin: 2rem 0;
    text-align: left;
}

.quiz-options-config .config-title {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.4rem 0;
    font-size: 0.95rem;
    color: var(--text-main);
    cursor: pointer;
}

.check-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

/* ---------- Quiz in-progress screen ---------- */
.quiz-topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.quiz-topbar .progress-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.quiz-topbar-spacer { flex: 1; }

.btn-quiz-end {
    background: none;
    border: 1.5px solid rgba(228, 87, 46, 0.4);
    color: #E4572E;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.45rem 0.9rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.btn-quiz-end:hover { background-color: rgba(228, 87, 46, 0.1); }

.quiz-progress-track {
    display: flex;
    gap: 3px;
    margin-bottom: 1.75rem;
}

.quiz-progress-track .cell {
    flex: 1;
    height: 5px;
    border-radius: 3px;
    background-color: var(--border-color);
    transition: background-color 0.2s ease;
}
.quiz-progress-track .cell.done-correct { background-color: var(--primary); }
.quiz-progress-track .cell.done-wrong { background-color: #E4572E; }
.quiz-progress-track .cell.current { background-color: var(--gold); }

.quiz-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    box-shadow: var(--shadow-lg);
    padding: 2.25rem;
}

.quiz-question {
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.45;
    margin-bottom: 1.5rem;
}

.quiz-reftable-wrap { margin-bottom: 1.5rem; overflow-x: auto; position: relative; }

.quiz-reftable-hint {
    display: none;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 0.35rem;
}

table.quiz-ref-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background-color: var(--bg-color);
    border-radius: 0.75rem;
    overflow: hidden;
}
table.quiz-ref-table th,
table.quiz-ref-table td {
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    text-align: left;
    color: var(--text-main);
    white-space: nowrap;
}
table.quiz-ref-table th {
    background-color: var(--primary);
    color: var(--white);
    font-weight: 600;
}
table.quiz-ref-table tbody tr:nth-child(even) { background-color: rgba(0,0,0,0.02); }
body.dark-theme table.quiz-ref-table tbody tr:nth-child(even) { background-color: rgba(255,255,255,0.03); }

@media (max-width: 640px) {
    table.quiz-ref-table { font-size: 0.66rem; }
    table.quiz-ref-table th,
    table.quiz-ref-table td { padding: 0.35rem 0.3rem; }
    table.quiz-ref-table th { white-space: normal; line-height: 1.2; }

    /* Show a scroll hint only if the table still doesn't fully fit */
    .quiz-reftable-wrap.is-scrollable .quiz-reftable-hint { display: block; }
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border: none;
    padding: 0;
    margin: 0;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    text-align: left;
    font-family: inherit;
    color: inherit;
    background-color: var(--bg-color);
    border: 1.5px solid var(--border-color);
    border-radius: 0.85rem;
    padding: 0.9rem 1.1rem;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.quiz-option:hover:not(.locked) {
    border-color: var(--primary);
    background-color: var(--bg-card);
}
.quiz-option:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

.quiz-option-letter {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 0.5rem;
    border: 1.5px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quiz-option-text { font-size: 0.95rem; line-height: 1.4; }

.quiz-option.selected {
    border-color: var(--primary);
    background-color: var(--primary-light);
}
.quiz-option.selected .quiz-option-letter {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.quiz-option.locked { cursor: default; }

.quiz-option.correct-answer {
    border-color: #10B981;
    background-color: rgba(16, 185, 129, 0.12);
}
.quiz-option.correct-answer .quiz-option-letter {
    background-color: #10B981;
    border-color: #10B981;
    color: var(--white);
}

.quiz-option.wrong-answer {
    border-color: #EF4444;
    background-color: rgba(239, 68, 68, 0.12);
}
.quiz-option.wrong-answer .quiz-option-letter {
    background-color: #EF4444;
    border-color: #EF4444;
    color: var(--white);
}

.quiz-feedback {
    display: none;
    margin-top: 1.5rem;
    padding: 1rem 1.15rem;
    border-radius: 0.85rem;
    border: 1px solid;
    animation: fadeIn 0.4s ease;
}
.quiz-feedback.show { display: flex; gap: 0.75rem; align-items: flex-start; }

.quiz-feedback.is-correct {
    background-color: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.3);
}
.quiz-feedback.is-wrong {
    background-color: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.3);
}

.quiz-feedback-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--white);
    margin-top: 1px;
}
.quiz-feedback.is-correct .quiz-feedback-icon { background-color: #059669; }
.quiz-feedback.is-wrong .quiz-feedback-icon { background-color: #dc2626; }

.quiz-feedback-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}
.quiz-feedback.is-correct .quiz-feedback-title { color: #059669; }
.quiz-feedback.is-wrong .quiz-feedback-title { color: #dc2626; }

.quiz-feedback-explain {
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--text-muted);
}

.quiz-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.75rem;
}
.quiz-actions .btn { min-width: 160px; }
.quiz-actions .btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-quiz-check {
    background-color: var(--primary-dark);
    color: var(--white);
    box-shadow: var(--shadow-md);
}
.btn-quiz-check:hover:not(:disabled) { background-color: var(--primary); }

/* ---------- Results screen ---------- */
.quiz-results-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    box-shadow: var(--shadow-lg);
    padding: 2.75rem 2.25rem;
    text-align: center;
}

.quiz-results-card h2 { font-size: 1.75rem; margin-bottom: 1.75rem; }

.quiz-ring-wrap {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto 1.75rem;
}
.quiz-ring { width: 180px; height: 180px; transform: rotate(-90deg); }
.quiz-ring-track { fill: none; stroke: var(--bg-color); stroke-width: 13; }
.quiz-ring-fill {
    fill: none;
    stroke: var(--primary);
    stroke-width: 13;
    stroke-linecap: round;
    stroke-dasharray: 484.87;
    stroke-dashoffset: 484.87;
    transition: stroke-dashoffset 1s cubic-bezier(.4,0,.2,1), stroke 0.3s ease;
}
.quiz-ring-label {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.quiz-ring-pct { font-size: 2.25rem; font-weight: 700; color: var(--text-main); }
.quiz-ring-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 2px;
}

.quiz-stats-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
}
.quiz-stat-value { font-size: 1.65rem; font-weight: 700; color: var(--primary); }
.quiz-stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.quiz-stat-divider { width: 1px; height: 30px; background-color: var(--border-color); }

.quiz-results-msg {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.55;
    margin: 0 auto 1.5rem;
    max-width: 420px;
}

.quiz-share-box {
    background: var(--bg-color);
    border: 1px dashed var(--border-color);
    border-radius: 1rem;
    padding: 1.25rem 1rem;
    margin: 0 auto 1.75rem;
    max-width: 440px;
}

.quiz-share-title {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.75rem;
}

.quiz-share-buttons {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-whatsapp {
    background-color: #25D366;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.6rem 1.15rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.btn-whatsapp:hover {
    filter: brightness(1.08);
    transform: translateY(-2px);
}

.btn-copy-score {
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.6rem 1.15rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-copy-score:hover {
    background-color: var(--bg-card);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}


/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .quiz-hero h1 { font-size: 1.85rem; }
    .quiz-start-card, .quiz-results-card { padding: 1.75rem 1.35rem; }
    .quiz-card { padding: 1.5rem 1.25rem; }
    .quiz-question { font-size: 1.15rem; }
    .quiz-actions { flex-direction: column-reverse; }
    .quiz-actions .btn { width: 100%; }
    .quiz-topbar { gap: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .quiz-ring-fill, .quiz-feedback { transition: none !important; animation: none !important; }
}
