/* Quiz start, solo picker, curation and solo-results chart styles:
   quizzes/quiz.php, quizzes/solo/index.php and quizzes/solo/play.php.
   The question / answer / feedback kit is quizzes/includes/quiz-player.css;
   every results screen is quizzes/includes/results.css. Shared
   surfaces, buttons, pills, tiles and alerts come from
   includes/styles.css; this file only lays them out. */

/* ---------- Start panel (quiz.php) ---------- */
.quiz-start-desc {
    margin: 0 0 1rem;
    color: var(--text-secondary);
    font-size: var(--fs-lead);
    line-height: 1.6;
}

.quiz-start-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 1.5rem;
}

.quiz-start-stats {
    margin: 0 0 1.5rem;
}

.quiz-start .alert {
    margin: 0;
}

.quiz-start .quiz-signin {
    margin-top: 1.25rem;
}

/* ---------- Form groups ---------- */
.quiz-field {
    min-width: 0;
    margin: 0 0 1.5rem;
    padding: 0;
    border: 0;
}

/* Bootstrap sizes a legend like a heading; the group label is a
   .form-label. */
.quiz-field > legend.form-label {
    float: none;
    width: auto;
    font-size: var(--fs-body);
}

.quiz-field > label.form-label {
    display: block;
}

.quiz-field-note {
    margin-left: 0.25rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ---------- Mode tiles (.choice-tile.quiz-mode-btn) ----------
   One label per mode on every page: Spaced repetition, Random 10,
   Testing mode. The choice tile supplies the frame, the checked
   state, the focus ring and the trailing check; this lays out the
   icon chip, title and hint. */
.quiz-mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.quiz-mode-btn {
    align-items: flex-start;
    margin: 0;
    padding: 0.9rem 1rem;
}

.quiz-mode-btn-body {
    display: flex;
    flex: 1 1 auto;
    align-items: flex-start;
    gap: 0.85rem;
    min-width: 0;
}

.quiz-mode-btn-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.3rem;
    height: 2.3rem;
    border-radius: var(--r-sm);
    background: var(--primary-tint);
    color: var(--primary-text);
    font-size: 1.35rem;
    line-height: 1;
    transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.quiz-mode-btn:has(> input:checked) .quiz-mode-btn-icon {
    background: var(--primary-fill);
    color: #fff;
}

.quiz-mode-btn-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.quiz-mode-btn-title {
    color: var(--text-primary);
    font-size: var(--fs-body);
    font-weight: 700;
}

/* The tile is a <label>, and the global label rule is 600: the hint
   reads as body text under the 700 title. */
.quiz-mode-btn-hint {
    color: var(--text-secondary);
    font-size: var(--fs-meta);
    font-weight: 400;
    line-height: 1.4;
}

/* ---------- Radio pills (difficulty, test length) ----------
   .seg-pill labels driven by a real radio (input.btn-check before
   each label), so the group stays keyboard reachable and arrow keys
   move the choice. The shared .seg-pill marks the active pill from
   .is-active / aria-pressed; these rules give a checked radio the same
   look and focus ring. */
.quiz-seg > .btn-check:checked + .seg-pill {
    border-color: var(--pill-color);
    background: var(--surface-2);
    color: var(--text-primary);
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
    .quiz-seg > .btn-check:checked + .seg-pill {
        background: color-mix(in srgb, var(--pill-color) 22%, var(--card-bg));
    }
}

.quiz-seg > .btn-check:checked + .seg-pill::before {
    content: "\ea5e"; /* ti-check */
    content: "\ea5e" / "";
    flex-shrink: 0;
    font-family: 'tabler-icons';
    font-size: 1.1em;
    font-style: normal;
    font-weight: 400;
    line-height: 1;
}

.quiz-seg > .btn-check:focus-visible + .seg-pill {
    outline: var(--focus-outline);
    outline-offset: var(--focus-offset);
}

/* A form's radio group keeps every option in view: it wraps on phones
   instead of turning into the filter row's sideways scroller. */
@media (max-width: 600px) {
    .seg-pills.quiz-seg,
    .qdiff-rater .seg-pills {
        flex-wrap: wrap;
        overflow: visible;
        padding: 0;
    }
}

/* Difficulty hues: the --diff-* aliases when a page declares them,
   else the status text tokens. */
.seg-pill.is-diff-easy   { --pill-color: var(--diff-easy, var(--success-text)); }
.seg-pill.is-diff-medium { --pill-color: var(--diff-medium, var(--warning-text)); }
.seg-pill.is-diff-hard   { --pill-color: var(--diff-hard, var(--danger-text)); }

/* Why Start is still off (solo picker, signed-in quiz start): beside
   the button, hidden once it is enabled. */
.quiz-start-hint {
    flex: 1 1 14rem;
    align-self: center;
    margin: 0;
}

/* ---------- Question-count stepper ---------- */
.quiz-stepper {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.quiz-stepper-input.form-control {
    width: 4.75rem;
    min-height: var(--control-h);
    padding-inline: 0.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
}

.quiz-stepper-input::-webkit-outer-spin-button,
.quiz-stepper-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* The -5 / +5 steps carry text, not a glyph. */
.quiz-step-5 {
    font-size: var(--fs-sm);
    font-weight: 700;
}

/* ---------- Solo picker (solo/index.php) ----------
   One 720px column inside the narrow shell: back link, sign-in note,
   the picker and the progress card under it all share its edges. */
.quiz-picker-page > * {
    max-width: 720px;
    margin-inline: auto;
}

.quiz-picker-page > .page-back {
    display: flex;
    width: fit-content;
    margin-left: max(0px, calc((100% - 720px) / 2));
}

.quiz-check-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

/* The quiz list scrolls inside its own well; the padding leaves room
   for each tile's focus ring. */
.quiz-checkbox-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    padding: 0.55rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    background: var(--surface-2);
}

.quiz-checkbox-item {
    font-size: var(--fs-sm);
    font-weight: 600;
}

.quiz-picker-summary {
    margin: 0.5rem 0 0;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
}

.quiz-picker-signin {
    margin-bottom: 1rem;
}

/* ---------- Curation row (solo play feedback, manager+) ----------
   Admins set the stored difficulty with three .seg-pill toggles
   (aria-pressed); managers get the Edit question button. */
.qdiff-rater {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-top: 1.25rem;
}

.qdiff-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 700;
}

.qdiff-rater .seg-pills {
    min-width: 0;
}

.qdiff-saved {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--success-text);
    font-size: var(--fs-sm);
    font-weight: 700;
}

.qdiff-saved[hidden] {
    display: none;
}

.qedit-open {
    margin-left: auto;
}

/* In-place question editor (.fl-modal). */
.qedit-modal .fl-modal-body > .form-label {
    display: block;
}

.qedit-modal .fl-modal-body > .form-label ~ .form-label {
    margin-top: 1rem;
}

.qedit-sub {
    color: var(--text-muted);
    font-weight: 500;
}

.qedit-ans-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.qedit-ans-row > .form-check-input {
    flex: 0 0 auto;
    margin: 0;
}

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

.qedit-ans-add {
    margin-top: 0.25rem;
}

.qedit-err {
    margin: 1rem 0 0;
}

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

    .quiz-start-desc {
        font-size: var(--fs-body);
    }

    .quiz-mode-btn {
        padding: 0.75rem 0.85rem;
    }

    .quiz-mode-btn-icon {
        width: 2.1rem;
        height: 2.1rem;
        font-size: 1.2rem;
    }

    .quiz-checkbox-list {
        grid-template-columns: 1fr;
        max-height: 260px;
    }

    .quiz-start .form-actions > .btn,
    .quiz-picker .form-actions > .btn {
        flex: 1 1 auto;
    }
}

/* ---------- Solo results: difficulty chart (solo/play.php) ----------
   Testing mode's chart panel on the results screen (a .surface-panel in
   the results.css contract). The level names and question numbers are
   HTML, so they stay at --fs-xs on every screen; the dots are round
   spans placed by --x / --y (fractions of the plot field, inline data);
   only the line is SVG, stretched to the field with a constant stroke.
   A right answer is a solid --success-text dot and a wrong one a
   --danger-text ring, so shape tells them apart as well as colour. */
.diff-plot {
    --plot-h: 12rem;
    --plot-pad: 0.75rem;
    --dot: 0.85rem;
    display: grid;
    grid-template-columns: 4.2em minmax(0, 1fr);
    column-gap: 0.5rem;
    color: var(--text-secondary);
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1.2;
}

.diff-plot.is-dense {
    --dot: 0.6rem;
}

/* Hard / Medium / Easy, level with the grid lines. */
.diff-plot-axis {
    position: relative;
    height: var(--plot-h);
}

.diff-plot-axis > span {
    position: absolute;
    right: 0;
    top: calc(var(--plot-pad) + (100% - 2 * var(--plot-pad)) * var(--y));
    transform: translateY(-50%);
    white-space: nowrap;
}

.diff-plot-area {
    position: relative;
    height: var(--plot-h);
}

.diff-plot-field {
    position: absolute;
    inset: var(--plot-pad);
}

.diff-plot-grid {
    position: absolute;
    right: calc(var(--plot-pad) * -1);
    left: calc(var(--plot-pad) * -1);
    top: calc(var(--y) * 100%);
    border-top: 1px dashed var(--border-medium);
}

.diff-plot-line {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.diff-plot-line polyline {
    stroke: var(--primary-soft);
    stroke-width: 2.5;
    stroke-opacity: 0.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.diff-plot-dot {
    position: absolute;
    left: calc(var(--x) * 100%);
    top: calc(var(--y) * 100%);
    box-sizing: border-box;
    width: var(--dot);
    height: var(--dot);
    margin: calc(var(--dot) / -2) 0 0 calc(var(--dot) / -2);
    border-radius: 50%;
}

.diff-plot-dot.is-correct {
    border: 2px solid var(--card-bg);
    background: var(--success-text);
}

.diff-plot-dot.is-wrong {
    border: 2.5px solid var(--danger-text);
    background: var(--card-bg);
}

/* Question numbers under the dots they label. */
.diff-plot-ticks {
    position: relative;
    grid-column: 2;
    height: 1.6em;
    margin: 0 var(--plot-pad);
}

.diff-plot-ticks > span {
    position: absolute;
    top: 0.2em;
    left: calc(var(--x) * 100%);
    transform: translateX(-50%);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
    .diff-plot {
        --plot-h: 10rem;
    }
}

@media (max-width: 600px) {
    .diff-plot {
        --plot-h: 8.5rem;
        --plot-pad: 0.6rem;
    }
}

/* Forced colours drop backgrounds: keep the dots in system colours. */
@media (forced-colors: active) {
    .diff-plot-dot {
        forced-color-adjust: none;
    }

    .diff-plot-dot.is-correct {
        border-color: Canvas;
        background: CanvasText;
    }

    .diff-plot-dot.is-wrong {
        border-color: CanvasText;
        background: Canvas;
    }

    .diff-plot-line polyline {
        stroke: CanvasText;
    }
}
