/* Exams – module styles (Cloodle). Colours come from the site.css tokens, so
   light/dark contrast stays ≥ 4.5:1. State is always also shown as text. */

/* Checkbox/radio borders ≥ 3:1 against the surface (WCAG 1.4.11) in the exam pages. */
.start-panel .form-check-input, .level-option .form-check-input, #examEditForm .form-check-input,
.question-form .form-check-input, .add-time-form .form-check-input { border-color: #6b7686; }
[data-bs-theme="dark"] :is(.start-panel, .level-option, #examEditForm, .question-form) .form-check-input { border-color: #8a96a6; }
:is(.start-panel, .level-option, #examEditForm, .question-form) .form-check-input:checked { border-color: var(--cl-primary); }

/* ── Course exam list ──────────────────────────────────────────────────────── */
.exam-list > li { padding-inline: 0; }
.panel > .exam-list > li:first-child { padding-top: .25rem; }
.exam-list .item-desc .badge { font-weight: 600; }
.exam-list .item-side { min-width: 8rem; }
.exam-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
@media (max-width: 575.98px) {
    .exam-list > li { flex-wrap: wrap; }
    .exam-list .item-side { flex-direction: row; flex-wrap: wrap; align-items: center; text-align: left; width: 100%; padding-left: 3.15rem; }
}

/* ── Settings ──────────────────────────────────────────────────────────────── */
.level-option { padding: .5rem .5rem .5rem 2rem; border-radius: .45rem; margin-bottom: .25rem; }
.level-option:has(input:checked) { background: var(--cl-primary-soft); }
.level-extra { border-top: 1px solid var(--cl-border); margin-top: .75rem; }
.danger-zone { border-color: var(--cl-danger); }

/* ── Question bank ─────────────────────────────────────────────────────────── */
.question-bank { list-style: none; padding: 0; margin: 0; }
.question-card { scroll-margin-top: 1rem; }
.question-card.is-editing { border-color: var(--cl-primary); box-shadow: 0 0 0 2px var(--cl-primary-soft); }
.question-card .prose > :last-child { margin-bottom: .5rem; }
.question-tools { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.option-preview { list-style: none; padding: 0; margin: 0 0 .5rem; }
.option-preview li { display: flex; gap: .45rem; align-items: baseline; padding: .15rem 0; }
.option-preview li.is-correct { font-weight: 600; }
.option-preview li.is-correct i { color: var(--cl-success); }
.option-letter { min-width: 2.4rem; justify-content: center; font-weight: 700; }
@media (min-width: 1200px) {
    .question-form { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
}
.question-form:focus { outline: none; }
.question-form:focus-visible { box-shadow: 0 0 0 3px var(--cl-focus); }

/* ── Start page ────────────────────────────────────────────────────────────── */
.exam-running { border: 2px solid var(--cl-primary); margin-bottom: 1rem; }
.gate-problems { border-left: .35rem solid var(--cl-accent); }
.start-panel { border: 2px solid var(--cl-primary); }
.recorded-list { padding-left: 1.2rem; }
.recorded-list li { margin-bottom: .35rem; }

/* ── Taking an exam ────────────────────────────────────────────────────────── */
.exam-take { max-width: 54rem; margin-inline: auto; }
.exam-disclosure { font-size: .95rem; }
.exam-bar {
    position: sticky;
    top: 0;
    z-index: 1010;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1.5rem;
    padding: .6rem 1rem;
    margin: 0 0 1rem;
    background: var(--cl-surface);
    border: 1px solid var(--cl-border);
    border-radius: var(--cl-radius);
    box-shadow: 0 .25rem .75rem rgba(16, 32, 64, .08);
}
.exam-bar-item { display: flex; flex-direction: column; line-height: 1.2; }
.exam-bar-label { font-size: .78rem; color: var(--cl-muted); font-weight: 600; }
.exam-timer { font-size: 1.45rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.exam-timer.is-low { color: var(--cl-warning-ink); }
.exam-timer.is-critical { color: var(--cl-danger); }
#answeredCount { font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.exam-save { flex-direction: row; align-items: center; gap: .4rem; font-size: .9rem; color: var(--cl-muted); margin-left: auto; }
.exam-save[data-state="saved"] i { color: var(--cl-success); }
.exam-save[data-state="error"] { color: var(--cl-danger); font-weight: 650; }
.exam-save[data-state="ended"] { color: var(--cl-ink); font-weight: 650; }
@media (max-width: 575.98px) {
    .exam-bar { gap: .35rem 1rem; padding: .5rem .75rem; }
    .exam-timer { font-size: 1.25rem; }
    .exam-save { margin-left: 0; width: 100%; font-size: .85rem; }
}

.exam-jump ol { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; padding: 0; margin: 0 0 1rem; }
.exam-jump a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.4rem;
    height: 2.4rem;
    padding: 0 .4rem;
    border: 1px solid #8a96a6;
    border-radius: .45rem;
    text-decoration: none;
    font-weight: 650;
    color: var(--cl-ink);
    background: var(--cl-surface);
}
.exam-jump a.is-answered { background: var(--cl-primary); border-color: var(--cl-primary); color: #fff; }
[data-bs-theme="dark"] .exam-jump a.is-answered { color: #0b1420; }
.exam-jump a.is-answered::after { content: "✓"; font-size: .7rem; margin-left: .15rem; }

.exam-question { scroll-margin-top: 6rem; min-width: 0; }
.exam-question + .exam-question { margin-top: 1rem; }
.exam-question-legend { padding: 0; margin-bottom: .25rem; font-size: inherit; }   /* Bootstrap: float + width 100% keeps it off the border */
.exam-question-legend h2 { font-weight: 700; }
.exam-question-text { margin-bottom: .75rem; }
.exam-question-text > :last-child { margin-bottom: 0; }
.exam-options { display: grid; gap: .35rem; }
.exam-options-inline { grid-template-columns: repeat(auto-fit, minmax(9rem, max-content)); gap: .35rem 1rem; }
.exam-option {
    margin: 0;
    padding: .55rem .75rem .55rem 2.35rem;
    border: 1px solid var(--cl-border);
    border-radius: .45rem;
}
.exam-option:has(input:checked) { border-color: var(--cl-primary); background: var(--cl-primary-soft); }
.exam-option .form-check-input { margin-top: .2rem; border-color: #6b7686; }   /* ≥ 3:1 (WCAG 1.4.11) */
[data-bs-theme="dark"] .exam-option .form-check-input { border-color: #8a96a6; }
.exam-option .form-check-input:checked { border-color: var(--cl-primary); }
.exam-option .form-check-label { display: block; cursor: pointer; }
.exam-essay { min-height: 12rem; }
.exam-q-state { margin-top: .5rem; color: var(--cl-muted); }
.exam-question.is-answered .exam-q-state { color: var(--cl-success); }
.exam-question.is-answered .exam-q-state::before { content: "✓ "; }
.exam-submit { margin-top: 1.5rem; border: 2px solid var(--cl-primary); }

/* ── Result + review ───────────────────────────────────────────────────────── */
.exam-score { display: inline-block; padding: .75rem 1.5rem; border: 2px solid var(--cl-success); border-radius: var(--cl-radius); }
.exam-score .value { font-size: 2rem; font-weight: 750; }
.exam-score .label { color: var(--cl-muted); font-weight: 600; }
.answer-review + .answer-review { margin-top: 1rem; }
.answer-points { font-variant-numeric: tabular-nums; }
.answer-options { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .3rem; }
.answer-options li { display: flex; flex-wrap: wrap; gap: .45rem; align-items: baseline; padding: .35rem .6rem; border: 1px solid var(--cl-border); border-radius: .4rem; }
.answer-options li.is-chosen { border-color: var(--cl-primary); }
.answer-options li.is-correct { border-color: var(--cl-success); border-width: 2px; }
.answer-options li.is-wrong { border-style: dashed; border-color: var(--cl-danger); }
.answer-text { white-space: pre-wrap; }
.essay-answer {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    padding: .75rem 1rem;
    background: var(--cl-surface-2);
    border: 1px solid var(--cl-border);
    border-radius: .45rem;
    max-height: 28rem;
    overflow-y: auto;
}
.teacher-feedback { padding: .5rem .75rem; border-left: .3rem solid var(--cl-primary); background: var(--cl-primary-soft); margin-top: .5rem; }
.grading-row { border-top: 1px dashed var(--cl-border); padding-top: .5rem; }
.grade-actions { margin-top: 1rem; }
.events-table tr.is-notable td { font-weight: 600; }
.not-started-list { columns: 16rem auto; margin: 0; padding-left: 1.2rem; }

/* ── Monitor ───────────────────────────────────────────────────────────────── */
.monitor-table th[scope="row"] { font-weight: 600; }
.monitor-table tr.is-stale > * { background: rgba(242, 169, 0, .12); }
.add-time-form { display: flex; gap: .3rem; align-items: center; flex-wrap: nowrap; }
.add-time-form .form-select { width: auto; }
