/*
 * mcq.css — the multiple-choice question card, shared by every app in the estate.
 *
 * WHY THIS FILE EXISTS
 * The same question was being drawn three different ways: the Curriculum lesson player
 * (its own `.qz-*` rules in Curriculum/Css/lesson.css), the FlashCards study deck and the
 * Question Library (Tailwind classes built in QuestionGenerator/JS/QuestionRenderer.js),
 * and the live-lesson poll (Tailwind classes in LiveLessonServer/src/student/PollCard.tsx).
 * They disagreed on columns, on the option edge, and — the part that mattered to a student —
 * on how obviously a right answer was told apart from a wrong one.
 *
 * WHY PLAIN CSS AND NOT TAILWIND
 * The three hosts cannot all load the same Tailwind. Curriculum already ships hand-written
 * CSS precisely because tailwind.out.css is compiled from the ALMA repo and would not see
 * classes this app introduced; LiveLessonServer builds its own bundle entirely. Plain CSS
 * with its own tokens is the only mechanism all three can genuinely use. Decided by Andy,
 * 21 September 2026.
 *
 * WHO LOADS IT
 * Everything served from the ALMA web root gets it from Scripts/Courses/CourseHead.php.
 * The live lesson gets it from views/supporting/AppHead.ejs in LiveLessonServer: Apache
 * proxies /live to that Node app but still serves /CSS itself from this web root, which is
 * how that app already loads tailwind.out.css. So there is one copy of this file, not two —
 * do not add a second to any other repo.
 *
 * WHAT IT OWNS, AND WHAT IT DOES NOT
 * It owns the options and the mark: the option list, the letter chip, the chosen / right /
 * wrong / faded states, the verdict banner and the run-progress segments. It owns nothing
 * outside them. The lesson's badges and "Finish topic", the deck's spaced-repetition levels
 * and "Report a problem", the poll's teal bar and gold edge all stay with their own app —
 * which is why the three still look like three different places.
 */

:root {
    --mcq-ink:        #0F1F2E;
    --mcq-muted:      #64748B;
    --mcq-line:       #E3E8EF;
    --mcq-card:       #FFFFFF;
    --mcq-teal:       #155E75;
    --mcq-teal-soft:  #E3F1F5;
    --mcq-green:      #15803D;
    --mcq-green-soft: #DCF5E4;
    --mcq-red:        #E11D48;
    --mcq-red-soft:   #FFE4EA;
    --mcq-gold:       #D4AA3A;
    --mcq-radius:     14px;
}

/* ── The option list ──────────────────────────────────────────────────────
 * Short options pair up, long ones do not. The host decides which by adding
 * .mcq-opts--two, using the same test everywhere: four or more options, and
 * every one of them short. See mcqWantsTwoColumns() in QuestionRenderer.js
 * and wantsTwoColumns() in LiveLessonServer/src/shared/pollLayout.ts.
 *
 * Two columns is only ever an improvement while each option fits on one line.
 * A wide box split into two columns of wrapped text reads worse than one.
 */
.mcq-opts {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
}
.mcq-opts--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Narrower than this and a paired column is too tight for any real answer. */
@media (max-width: 620px) {
    .mcq-opts--two { grid-template-columns: 1fr; }
}

/* ── The option ───────────────────────────────────────────────────────────
 * Works as a <button> (Curriculum, polls) or as a <label> wrapping a hidden
 * radio or checkbox (the question bank, which needs a real form control).
 *
 * White on a neutral field, never a tint: an option may carry a JSXGraph plot,
 * and a plot arrives on white. Chosen and correct are said with the border,
 * the chip and the disc rather than by colouring the card behind them.
 */
.mcq-opt {
    position: relative;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 13px;
    width: 100%;
    min-height: 62px;
    margin: 0;
    padding: 13px 15px;
    text-align: left;
    font: inherit;
    font-size: 17px;
    color: var(--mcq-ink);
    background: var(--mcq-card);
    border: 2px solid var(--mcq-line);
    border-radius: var(--mcq-radius);
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 31, 46, .06);
    transition: box-shadow .13s ease, border-color .15s, background .15s, opacity .22s;
}
.mcq-opt * { box-sizing: border-box; }

/* Hover DEEPENS, it does not move. An earlier draft lifted the option 2px and
   Andy rejected it (21 September 2026): the travel was decoration, the shadow
   and the teal border were already doing the work. Nothing here may translate. */
.mcq-opt:hover:not(:disabled):not(.is-answered) {
    border-color: var(--mcq-teal);
    box-shadow: 0 5px 16px rgba(21, 94, 117, .18);
}
.mcq-opt:active:not(:disabled):not(.is-answered) {
    border-color: var(--mcq-teal);
    background: var(--mcq-teal-soft);
    box-shadow: 0 1px 2px rgba(15, 31, 46, .06);
}
.mcq-opt:focus-visible,
.mcq-opt:focus-within:has(input:focus-visible) {
    outline: 3px solid var(--mcq-gold);
    outline-offset: 2px;
}
.mcq-opt:disabled, .mcq-opt.is-answered { cursor: default; }

/* The form control, where there is one. Kept in the accessibility tree and
   focusable; the option itself is the visible control. */
.mcq-opt input[type="radio"],
.mcq-opt input[type="checkbox"] {
    position: absolute;
    width: 1px; height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

/* ── The letter chip ──────────────────────────────────────────────────────
 * Six fixed colours, as the question bank has always had them. Andy chose to
 * keep these on 21 September 2026, over three alternatives that avoided green
 * and red. The consequence is deliberate and worth stating: because a chip can
 * be green (B) or red (E) before anything has been marked, the CHIP CANNOT BE
 * TRUSTED TO SAY RIGHT OR WRONG. That job belongs entirely to the four signals
 * in the block below — fill, border, disc and fade — so none of them may be
 * dropped as redundant later on.
 */
.mcq-key {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: 10px;
    background: #F1F5F9;
    color: var(--mcq-muted);
    font-size: 13px;
    font-weight: 800;
    transition: background .15s, color .15s;
}
.mcq-opt[data-mcq-key="A"] .mcq-key { background: #3B82F6; color: #fff; }
.mcq-opt[data-mcq-key="B"] .mcq-key { background: #10B981; color: #fff; }
.mcq-opt[data-mcq-key="C"] .mcq-key { background: #F59E0B; color: #fff; }
.mcq-opt[data-mcq-key="D"] .mcq-key { background: #8B5CF6; color: #fff; }
.mcq-opt[data-mcq-key="E"] .mcq-key { background: #EF4444; color: #fff; }
.mcq-opt[data-mcq-key="F"] .mcq-key { background: #EC4899; color: #fff; }

.mcq-text {
    flex: 1;
    min-width: 0;
    /* A single rendered equation cannot wrap — MathJax and KaTeX both emit one
       inline-block — so an option too wide for its row scrolls rather than break the
       card. That part is deliberate and stays.
       What is hidden is the scrollbar itself. On a phone it drew a grey bar directly
       under the maths that read as an underline, and it showed up on exactly the
       marked options, because the tick or cross takes the ~39px that tips them into
       overflow. Reported 21 September 2026. Swipe and shift+wheel still scroll. */
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.mcq-text::-webkit-scrollbar { width: 0; height: 0; display: none; }
.mcq-mark {
    flex: none;
    width: 26px; height: 26px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 15px;
    font-weight: 900;
    line-height: 1;
}

/* ── Marked ───────────────────────────────────────────────────────────────
 * Right and wrong are each said four ways at once — fill, border, chip and
 * disc — and everything the student did not touch drops to 40%, so the eye
 * lands on the two options that matter. This is Curriculum's treatment, kept
 * because it is the one that reads at a glance; the question bank's two pale
 * tints did not, which is what started this work.
 *
 * These rules sit after the chip colours above and match their specificity,
 * so the mark always beats the letter.
 */
.mcq-opt.is-picked { border-color: var(--mcq-teal); }
.mcq-opt.is-picked .mcq-key { background: var(--mcq-teal); color: #fff; }

.mcq-opt.is-right { border-color: var(--mcq-green); background: var(--mcq-green-soft); }
.mcq-opt.is-right .mcq-key { background: var(--mcq-green); color: #fff; }
.mcq-opt.is-right .mcq-mark { display: inline-flex; background: var(--mcq-green); }
.mcq-opt.is-right .mcq-mark::before { content: "\2713"; }

.mcq-opt.is-wrong { border-color: var(--mcq-red); background: var(--mcq-red-soft); }
.mcq-opt.is-wrong .mcq-key { background: var(--mcq-red); color: #fff; }
.mcq-opt.is-wrong .mcq-mark { display: inline-flex; background: var(--mcq-red); }
.mcq-opt.is-wrong .mcq-mark::before { content: "\2715"; font-size: 13px; }

.mcq-opt.is-dim { opacity: .4; }

/* ── The escape hatch ─────────────────────────────────────────────────────
 * "Don't know" is not a distractor and should not compete as one. It takes
 * its own full-width row under the real answers, dashed and quiet, and never
 * wears a letter colour.
 */
.mcq-opt.is-pass {
    grid-column: 1 / -1;
    min-height: 52px;
    font-size: 15px;
    color: var(--mcq-muted);
    border-style: dashed;
}
.mcq-opt.is-pass .mcq-key,
.mcq-opt[data-mcq-key].is-pass .mcq-key {
    background: transparent;
    color: var(--mcq-muted);
    border: 1.5px dashed #CBD5E1;
}

/* ── Compact ──────────────────────────────────────────────────────────────
 * For a card in a rail rather than on a page. The live-lesson poll sits in the
 * chat column, about as wide as a phone, and the page-sized option eats most of
 * it. Same card, smaller gauge — and a rail is never two columns.
 */
.mcq-opts--sm .mcq-opt {
    min-height: 50px;
    gap: 10px;
    padding: 10px 12px;
    font-size: 15px;
    border-radius: 12px;
}
.mcq-opts--sm .mcq-key { width: 27px; height: 27px; border-radius: 8px; font-size: 12px; }
.mcq-opts--sm .mcq-mark { width: 22px; height: 22px; font-size: 13px; }

/* ── The verdict ──────────────────────────────────────────────────────────
 * Nobody should have to decode a tint. The banner names the right answer in
 * words. It keeps its space while hidden, so marking an answer does not make
 * the card jump under the cursor.
 */
.mcq-verdict {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 20px;
    padding: 13px 15px 13px 17px;
    border-radius: var(--mcq-radius);
    opacity: 0;
    transition: opacity .22s ease;
}
.mcq-verdict[hidden] { display: flex; visibility: hidden; }
.mcq-verdict.is-in { opacity: 1; }
.mcq-verdict.is-good { background: var(--mcq-green-soft); color: #14532D; }
.mcq-verdict.is-bad  { background: var(--mcq-red-soft);   color: #881337; }
.mcq-vicon {
    flex: none;
    width: 34px; height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 900;
    font-size: 17px;
    line-height: 1;
}
.mcq-verdict.is-good .mcq-vicon { background: var(--mcq-green); }
.mcq-verdict.is-good .mcq-vicon::before { content: "\2713"; }
.mcq-verdict.is-bad  .mcq-vicon { background: var(--mcq-red); }
.mcq-verdict.is-bad  .mcq-vicon::before { content: "\2715"; font-size: 14px; }
.mcq-vtext {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-size: 14.5px;
}
.mcq-vtext strong { font-size: 16.5px; font-weight: 800; }
/* Teal, in both banners, and deliberately NOT the banner's own colour.
   It was red inside the red banner and green inside the green one, which camouflaged
   the one thing in the box you are meant to press: Andy went looking for the Next
   button and could not pick it out of the pink (21 September 2026). The banner says
   how you did; the button says what happens next, and they are different jobs. */
.mcq-next {
    flex: none;
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    padding: 10px 17px;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    color: #fff;
    background: var(--mcq-teal);
    /* Soft depth, and it does not move — the same rule the options follow. */
    box-shadow: 0 1px 2px rgba(15, 31, 46, .1);
    transition: box-shadow .15s, filter .15s;
}
.mcq-next:hover { box-shadow: 0 5px 16px rgba(21, 94, 117, .28); }
.mcq-next:active { filter: brightness(.95); box-shadow: 0 1px 2px rgba(15, 31, 46, .1); }
.mcq-next:focus-visible { outline: 3px solid var(--mcq-gold); outline-offset: 2px; }

/* ── Run progress ─────────────────────────────────────────────────────────
 * For anything with a known number of questions: a segment per question,
 * green or red as it is answered. A poll has no run, so it has none of this.
 */
.mcq-run { display: flex; align-items: center; gap: 12px; }
.mcq-segs { flex: 1; display: flex; gap: 6px; }
.mcq-seg {
    flex: 1;
    height: 8px;
    border-radius: 99px;
    background: #E8EDF3;
    transition: background .25s, box-shadow .25s;
}
.mcq-seg.is-current { background: var(--mcq-teal-soft); box-shadow: inset 0 0 0 2px var(--mcq-teal); }
.mcq-seg.is-right { background: var(--mcq-green); }
.mcq-seg.is-wrong { background: var(--mcq-red); }
.mcq-count {
    font-size: 13px;
    font-weight: 700;
    color: var(--mcq-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
    .mcq-opt, .mcq-key, .mcq-seg, .mcq-verdict { transition: none; }
}
