/* Quiz player kit: the one question / answer / feedback look shared by
   every quiz player (quizzes/quiz.php, quizzes/solo/play.php and
   quizzes/multiplayer/index.php). Load it after styles.css.

   Markup (the question panel is the shared .surface-panel):
     <section class="surface-panel quiz-question" aria-labelledby="qText">
       <div class="quiz-question-head">
         <span class="eyebrow">Question 3 of 10</span>
         <div class="quiz-question-tools">[.timer-display] [End quiz]</div>
       </div>
       <div class="fl-progress fl-progress--compact" role="progressbar" ...>
         <div class="fl-progress-bar" style="width:20%"></div></div>
       <h2 class="question-text" id="qText">...</h2>
       <div class="answer-options">                  (or fieldset / .answer-grid)
         <button class="answer-btn surface-inset">   (or label / div)
           <span class="answer-letter">A</span>
           <span class="answer-text">...</span></button>
       </div>
       <div class="alert alert-success feedback-banner">...</div>
       <div class="form-actions quiz-actions">[.btn.btn-primary Next]</div>
     </section>

   Answer rows are .surface-inset rows. States (never colour alone):
     .selected (or a checked radio inside)  primary tint, 2px primary
                                            frame, letter on the fill,
                                            trailing ti-check
     .correct / .incorrect                  the success / danger tint,
                                            2px -text frame, letter chip
                                            on the -fill with ti-check /
                                            ti-x (the page prints the icon)
     .dimmed                                the other rows after feedback
     .disabled / .host-view                 multiplayer: time is up / the
                                            host's read-only copy
   The second frame pixel is an inset shadow, so a state change never
   moves the row's content. */

/* ---------- Stand-in H1 ----------
   The compact hero (and its H1) is not rendered at 960px and below.
   This copy stands in there and is not rendered above 960px, so the
   page has one H1 at every width. quiz.php's start screen shows it;
   play views add .visually-hidden. */
.quiz-h1-narrow {
    display: none;
}

@media (max-width: 960px) {
    .quiz-h1-narrow {
        display: block;
        margin: 0 0 1rem;
        color: var(--text-primary);
        font-size: 1.5rem;
        font-weight: 700;
        line-height: 1.25;
    }
}

/* ---------- Question panel ---------- */
.quiz-question {
    margin-bottom: var(--space-6);
}

.quiz-question-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.65rem;
}

.quiz-question-head .eyebrow {
    font-size: var(--fs-xs);
}

.quiz-question-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.quiz-question > .fl-progress {
    margin-bottom: 1.25rem;
}

.question-text {
    margin: 0 0 1.25rem;
    color: var(--text-primary);
    font-size: var(--fs-section-title);
    font-weight: 700;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

/* Count-down clock (quiz.php). The page script swaps in .warning
   under a minute and .danger under 30 seconds. */
.timer-display {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 2rem;
    padding: 0.25rem 0.8rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.timer-display.warning {
    border-color: var(--warning-border);
    background: var(--warning-tint);
    color: var(--warning-text);
}

.timer-display.danger {
    border-color: var(--danger-border);
    background: var(--danger-tint);
    color: var(--danger-text);
}

/* ---------- Answer list ---------- */
.answer-options,
.answer-grid {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

/* quiz.php wraps each answer in its own one-button form. */
.answer-form {
    display: contents;
}

/* ---------- Answer row (.answer-btn on .surface-inset) ---------- */
.answer-btn,
button.answer-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    min-height: 3.25rem;
    margin: 0;
    padding: 0.7rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--fs-body);
    font-weight: 500;
    line-height: 1.45;
    text-align: left;
}

button.answer-btn,
label.answer-btn {
    cursor: pointer;
    transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease,
                box-shadow var(--dur-fast) ease;
}

/* Feedback rows are plain divs: no pointer, no hover. */
div.answer-btn {
    cursor: default;
}

/* Hover tint for the clickable rows (a label row is not covered by the
   shared a/button rule). */
label.answer-btn:hover {
    border-color: var(--primary-soft);
    background: var(--primary-tint);
}

.answer-letter {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--border-medium);
    border-radius: var(--r-sm);
    background: var(--card-bg);
    color: var(--primary-text);
    font-size: var(--fs-sm);
    font-weight: 800;
    line-height: 1;
}

.answer-letter .ti {
    font-size: 1.15rem;
    line-height: 1;
}

.answer-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Selected (select-then-submit in solo play, the live pick in
   multiplayer). Solo play's rows keep the real radio, visually hidden. */
.answer-btn.selected {
    border-color: var(--primary-soft);
    background: var(--primary-tint);
    box-shadow: inset 0 0 0 1px var(--primary-soft);
}

.answer-btn:has(> input:checked) {
    border-color: var(--primary-soft);
    background: var(--primary-tint);
    box-shadow: inset 0 0 0 1px var(--primary-soft);
}

.answer-btn.selected .answer-letter {
    border-color: var(--primary-fill);
    background: var(--primary-fill);
    color: #fff;
}

.answer-btn:has(> input:checked) .answer-letter {
    border-color: var(--primary-fill);
    background: var(--primary-fill);
    color: #fff;
}

.answer-btn.selected::after {
    content: "\ea5e"; /* ti-check */
    content: "\ea5e" / "";
    flex: 0 0 auto;
    color: var(--primary-text);
    font-family: 'tabler-icons';
    font-size: 1.15rem;
    font-style: normal;
    line-height: 1;
}

/* Multiplayer's answer buttons also carry aria-pressed for screen
   readers. The .selected look above draws the pick, so the shared
   .surface-inset[aria-pressed] extras (absolutely placed check, wider
   right padding) stay off and the row keeps its own trailing check. */
.answer-btn[aria-pressed="true"] {
    padding-right: 1rem;
}

.answer-btn[aria-pressed="true"]::after {
    position: static;
    transform: none;
}

/* Keyboard focus on the hidden radio draws the ring on its row. The
   :focus-within line is the fallback for engines without :has(). */
label.answer-btn:focus-within {
    outline: var(--focus-outline);
    outline-offset: 2px;
}

label.answer-btn:has(> input:focus:not(:focus-visible)) {
    outline: none;
}

/* Feedback: one green for correct and one red for wrong, from the
   status tokens, in both themes. */
.answer-btn.correct {
    border-color: var(--success-text);
    background: var(--success-tint);
    box-shadow: inset 0 0 0 1px var(--success-text);
}

.answer-btn.correct .answer-letter {
    border-color: var(--success-fill);
    background: var(--success-fill);
    color: #fff;
}

.answer-btn.incorrect {
    border-color: var(--danger-text);
    background: var(--danger-tint);
    box-shadow: inset 0 0 0 1px var(--danger-text);
}

.answer-btn.incorrect .answer-letter {
    border-color: var(--danger-fill);
    background: var(--danger-fill);
    color: #fff;
}

.answer-btn.dimmed,
.answer-btn.dimmed .answer-letter {
    color: var(--text-muted);
}

/* Multiplayer: time is up (.disabled), or the host's read-only list
   (.host-view). The player's own pick keeps its selected look. */
.answer-btn.disabled,
.answer-btn.host-view {
    cursor: default;
}

.answer-btn.disabled:not(.selected) {
    color: var(--text-muted);
}

button.answer-btn.disabled:not(.selected):hover,
.answer-btn.host-view:hover {
    border-color: var(--border-soft);
    background: var(--surface-2);
}

/* ---------- Fill in the blank ---------- */
.fitb-label {
    display: block;
    margin-bottom: 0.5rem;
}

.fitb-row {
    display: flex;
    align-items: stretch;
    gap: 0.65rem;
}

.fitb-row > .form-control {
    flex: 1 1 auto;
    min-width: 0;
}

.fitb-row > .btn {
    flex: 0 0 auto;
}

/* ---------- Feedback banner (.alert-success / .alert-danger) ---------- */
.feedback-banner {
    margin: 1.25rem 0 0;
}

.feedback-banner .alert-title {
    display: block;
    margin-bottom: 0.2rem;
    font-size: var(--fs-body);
}

.feedback-banner p {
    margin: 0;
}

/* ---------- Actions (Submit / Next) ---------- */
.quiz-actions {
    margin-top: var(--space-5);
}

/* ---------- Phones ---------- */
@media (max-width: 600px) {
    .quiz-question {
        --panel-pad: 1.1rem;
    }

    .question-text {
        font-size: 1.15rem;
    }

    .answer-btn,
    button.answer-btn,
    .answer-btn[aria-pressed="true"] {
        gap: 0.7rem;
        padding: 0.6rem 0.8rem;
    }

    .answer-letter {
        width: 2rem;
        height: 2rem;
    }

    .quiz-actions > .btn {
        flex: 1 1 auto;
    }
}

@media (max-width: 480px) {
    .fitb-row {
        flex-direction: column;
    }
}
