/* Examine/** (the examiner's list, new room, console and results) and ExamRoom (/x/{code}, the
   driver's screen). The question stage and media themselves are components/exam.css. */

/* ---------- shared: fields, links, spacing ----------
   These pages reuse the admin panels and fields; admin-forms.css only styles typed text inputs,
   so every text box here (email, untyped, search) gets the same look. Plain links are blue
   without the underline the .page default adds; buttons keep their own colours. */
:is(.exv-page, .exv-room) :is(input:not([type]), input[type="text"], input[type="email"], input[type="search"], input[type="url"], input[type="number"], select, textarea) {
    width: 100%; min-width: 0; background: var(--bg); border: 1px solid var(--border); border-radius: .55rem;
    padding: .55rem .75rem; color: var(--ink); font: inherit; font-size: .92rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
:is(.exv-page, .exv-room) :is(input, select, textarea):focus-visible {
    outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 22%, transparent);
}
.exv-page a:not(.cta):not(.admin-rowlink):not(.crumb) { color: var(--blue-ink); text-decoration: none; }
.exv-page a:not(.cta):not(.admin-rowlink):not(.crumb):hover { text-decoration: underline; text-underline-offset: 3px; }
.exv-page .admin-rowlink { color: var(--ink); font-weight: 600; text-decoration: none; }
.exv-page .admin-rowlink:hover { color: var(--blue-ink); }
.exv-page .cta-solid { color: #fff; }
.exv-page .cta-ghost { color: var(--ink); }
.exv-page > .admin-panel, .exv-page > section.admin-panel { margin-top: 1.25rem; }
.exv-page > .admin-flash { margin-bottom: 1rem; }

/* ---------- list, new room, results ---------- */
.exv-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; justify-content: space-between; margin-bottom: .5rem; }
.exv-head .exv-quiet { margin: .75rem 0 0; }
.exv-quiet { color: var(--muted); font-size: .9rem; }
.exv-subhead { margin: 2.25rem 0 .9rem; font-family: var(--font-display); font-size: 1.3rem; }
.exv-subhead-row { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; justify-content: space-between; margin: 2.25rem 0 .9rem; }
.exv-subhead-row .exv-subhead { margin: 0; }
.exv-search { display: flex; gap: .5rem; align-items: center; }
.exv-search input { width: 16rem; }
.exv-search .cta { padding: .55rem 1.1rem; }
.exv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.exv-item .cta { padding: .55rem 1.1rem; }
.exv-item { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; padding: .75rem 1rem; border: 1px solid var(--border); border-radius: .75rem; background: var(--surface); }
.exv-item-main { flex: 1 1 14rem; display: grid; gap: .1rem; min-width: 0; }

.exv-form { display: grid; gap: 1rem; margin-top: 1.25rem; }
.exv-choices { display: grid; gap: .5rem; }
.exv-choice { display: grid; grid-template-columns: auto 1fr; gap: .75rem; align-items: start; padding: .75rem .9rem; border: 1px solid var(--border); border-radius: .6rem; background: var(--bg); cursor: pointer; }
.exv-choice:has(input:checked) { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 8%, var(--surface)); }
.exv-choice input { margin-top: .25rem; accent-color: var(--blue); }
.exv-choice b { display: block; font-family: var(--font-display); }
.exv-choice small, .exv-module small { display: block; color: var(--muted); font-size: .84rem; margin-top: .15rem; }
.exv-modules { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.exv-estimate { margin: .75rem 0 0; color: var(--ink-soft); }
.exv-who { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-bottom: 1rem; }

.exv-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .75rem; margin: 1.5rem 0; }
.exv-kpi { display: grid; gap: .25rem; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: .75rem; background: var(--surface); }
.exv-kpi > span { display: flex; gap: .4rem; align-items: center; font: 600 .72rem/1.2 var(--font-sans); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.exv-kpi b { font: 700 1.7rem/1.05 var(--font-display); color: var(--ink); }
.exv-kpi small { color: var(--muted); font-size: .78rem; }
.exv-results-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.exv-factors td { vertical-align: middle; }
.exv-minibar { display: inline-block; width: 4.5rem; height: .4rem; margin-left: .5rem; background: var(--surface-2); border-radius: 999px; vertical-align: middle; overflow: hidden; }
.exv-minibar i { display: block; height: 100%; background: var(--blue); border-radius: 999px; }
.exv-prio { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.exv-prio-item { display: grid; gap: .5rem; align-content: start; padding-top: .75rem; border-top: 1px solid var(--border); }
.exv-prio-item h3 { margin: 0; font-size: 1.1rem; }
.exv-prio-item ul { margin: 0; padding-left: 1.1rem; display: grid; gap: .25rem; font-size: .92rem; }
.exv-answers { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.exv-answers details { border: 1px solid var(--border); border-radius: .6rem; background: var(--surface); }
.exv-answers summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: .75rem; align-items: center; padding: .6rem .8rem; cursor: pointer; }
.exv-answer-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exv-answer-body { display: grid; gap: .75rem; padding: 0 .9rem .9rem; }
.exv-answer-body > p { margin: 0; }
.exv-remark { display: grid; gap: .75rem; }
.exv-score-pick { display: flex; flex-wrap: wrap; gap: .4rem 1rem; border: 0; margin: 0; padding: 0; }
.exv-score-pick legend { font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.exv-remark > .cta { justify-self: start; }
.exv-checks-read li { display: grid; grid-template-columns: 1.6rem 1fr; gap: .5rem; }
.exv-checks-read li.hit .exm-mark { background: var(--green); border: 0; color: #fff; }

/* ---------- the console ---------- */
/* On a desktop-sized window the console is an app shell: it fills exactly the space under the
   site header, and the question list, the stage and the marking panel each scroll on their own,
   so nothing the examiner needs is ever below the fold. Smaller windows fall back to one page
   that scrolls (the media queries at the end of this file). */
.exv-room { background: var(--bg); }
.exv-console { display: flex; flex-direction: column; height: calc(100dvh - var(--header-h) - 1px); }
.exv-bar { flex: none; z-index: 5; display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between;
    padding: .6rem max(1rem, env(safe-area-inset-right)); background: var(--surface); border-bottom: 1px solid var(--border); }
.exv-bar-side { display: flex; flex-wrap: wrap; gap: .9rem; align-items: center; }
.exv-back { font-size: 1.2rem; text-decoration: none; color: var(--ink-soft); }
.exv-who-name { display: block; font-family: var(--font-display); }
.exv-clock { padding: .25rem .6rem; border-radius: .4rem; background: var(--ink); color: var(--surface); }
.exv-status { font-size: .88rem; color: var(--muted); }
.exv-status.is-bad { color: var(--red-ink); font-weight: 600; }

.exv-lobby { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: start center; padding: 2rem 1rem 4rem; }
.exv-lobby-card { width: min(44rem, 100%); display: grid; gap: 1rem; padding: 1.5rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--surface); box-shadow: var(--shadow); }
.exv-steps { margin: 0; padding-left: 1.2rem; }
.exv-invite { display: flex; gap: .5rem; }
.exv-invite input { flex: 1; min-width: 0; padding: .65rem .75rem; border: 1px solid var(--border); border-radius: .5rem; background: var(--bg); color: var(--ink); font-family: ui-monospace, monospace; font-size: .9rem; }
.exv-ready-row { display: flex; flex-wrap: wrap; gap: 1rem 2.5rem; padding: .75rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.exv-ready { display: grid; gap: .2rem; }

.exv-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: clamp(13rem, 14vw, 19rem) minmax(0, 1fr) clamp(21rem, 22vw, 30rem); }
.exv-nav, .exv-stage, .exv-panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.exv-nav { padding: .75rem .5rem 1.5rem .75rem; border-right: 1px solid var(--border); }
.exv-nav-head { margin: .9rem .4rem .35rem; font: 600 .72rem/1.2 var(--font-sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.exv-nav ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.exv-nav button { width: 100%; display: grid; grid-template-columns: 1.35rem minmax(0, 1fr) auto; gap: .5rem; align-items: center; padding: .35rem .4rem; border: 0; border-radius: .4rem; background: none; text-align: left; font: 500 .85rem/1.25 var(--font-sans); color: var(--ink-soft); cursor: pointer; }
.exv-nav button:hover { background: var(--surface-2); }
.exv-nav button.on { background: color-mix(in srgb, var(--blue) 12%, var(--surface)); color: var(--ink); }
.exv-nav-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exv-stage { padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 2rem; align-content: start; }
.exv-stage-nav { display: flex; justify-content: space-between; gap: .75rem; margin-top: .5rem; }
.exv-panel { display: grid; gap: .7rem; align-content: start;
    padding: 1rem 1.1rem 0; background: var(--surface); border-left: 1px solid var(--border); }
.exv-panel h3 { margin: .4rem 0 0; font: 600 .78rem/1.2 var(--font-sans); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.exv-panel-head { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; font-weight: 600; }
.exv-modtag { font: 600 .66rem/1 var(--font-sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border: 1px solid var(--border); border-radius: .3rem; padding: .25rem .35rem; }
.exv-reveal { display: flex; gap: .55rem; align-items: center; padding: .55rem .7rem; border-radius: .5rem; background: var(--amber-bg); color: var(--amber-ink); font-size: .88rem; font-weight: 600; cursor: pointer; }
.exv-reveal input { accent-color: var(--amber-ink); }
.exv-checks, .exv-probes, .exv-sources { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.exv-checks label { display: grid; grid-template-columns: 1.1rem 1fr; gap: .55rem; align-items: start; font-size: .9rem; color: var(--ink-soft); cursor: pointer; }
.exv-checks input { margin-top: .2rem; accent-color: var(--green); }
.exv-checks input:checked + span { color: var(--ink); }
.exv-probes { list-style: disc; padding-left: 1.1rem; }
.exv-probes li { font-size: .88rem; color: var(--ink-soft); }
.exv-probes li::marker { color: var(--muted); }
.exv-sources li { font-size: .8rem; color: var(--muted); }
.exv-scores { display: grid; gap: .35rem; }
.exv-score { display: grid; grid-template-columns: 2rem 1fr; gap: .6rem; align-items: center; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: .5rem; background: var(--bg); text-align: left; font: 400 .8rem/1.3 var(--font-sans); color: var(--ink-soft); cursor: pointer; }
.exv-score b { font: 700 1.4rem/1 var(--font-display); color: var(--ink); text-align: center; }
.exv-score[aria-checked="true"] { color: var(--ink); font-weight: 600; }
.exv-score.s0[aria-checked="true"] { border-color: var(--red-ink); background: color-mix(in srgb, var(--red) 10%, var(--surface)); }
.exv-score.s1[aria-checked="true"] { border-color: var(--amber-ink); background: var(--amber-bg); }
.exv-score.s2[aria-checked="true"] { border-color: var(--blue-ink); background: color-mix(in srgb, var(--blue) 10%, var(--surface)); }
.exv-score.s3[aria-checked="true"] { border-color: var(--green-ink); background: color-mix(in srgb, var(--green) 12%, var(--surface)); }
.exv-notes { display: grid; gap: .3rem; font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.exv-notes textarea { width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: .5rem; background: var(--bg); color: var(--ink); font: 400 .9rem/1.4 var(--font-sans); resize: vertical; }
.exv-note { font-size: .86rem; padding: .6rem .7rem; border-radius: .5rem; background: var(--amber-bg); color: var(--ink); }
.exv-note[hidden] { display: none; }
.exv-keys { font-size: .76rem; }
.exv-keys kbd { font-size: .74rem; padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); color: var(--ink); }
/* Finish stays in reach at the foot of the panel however far the marking scrolls. */
.exv-finish { position: sticky; bottom: 0; display: grid; gap: .5rem; margin: .75rem -1.1rem 0; padding: .9rem 1.1rem 1rem;
    border-top: 1px solid var(--border); background: var(--surface); }

/* ---------- the driver's screen ----------
   Sized from the window, not fixed: the question, its prompt and its media share exactly the
   height under the site header, and type scales with the screen, so a 1080p laptop, a 1440p
   monitor and a 4K screen all show the whole question without scrolling. The media takes
   whatever height is left and each kind shrinks to fit it (contain, never crop). Phones and
   very short windows fall back to a page that scrolls (end of file). */
.exr-page { background: var(--bg); }
.exr {
    display: flex; flex-direction: column;
    height: calc(100dvh - var(--header-h) - 1px);
    width: min(100%, 96vw); margin: 0 auto;
    padding: clamp(.75rem, 2.2vh, 2.5rem) clamp(1rem, 3vw, 4.5rem) clamp(.5rem, 1.2vh, 1.25rem);
}
.exr-wait { flex: 1; min-height: 0; overflow: auto; display: grid; gap: clamp(.75rem, 2vh, 1.5rem); align-content: center; justify-items: center; text-align: center; }
.exr-wait .section-title { font-size: clamp(2rem, 1.4vw + 1.8vh, 4.25rem); }
.exr-wait .section-lede { max-width: 42rem; font-size: clamp(1rem, .45vw + .8vh, 1.6rem); }
.exr-lights { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: center; font-size: clamp(.9rem, .3vw + .7vh, 1.3rem); }
.exr-ready { font-size: clamp(1.05rem, .4vw + .8vh, 1.6rem); padding: .9em 2.2em; }
.exr-hint { max-width: 38rem; color: var(--muted); font-size: clamp(.9rem, .3vw + .7vh, 1.25rem); margin: 0; }

.exr-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: clamp(.4rem, 1.4vh, 1.5rem); }
.exr-stage[hidden] { display: none; }
.exr-stage > .exm-qhead, .exr-stage > .exm-qtitle, .exr-stage > .exm-prompt { flex: none; }
.exr-stage .exm-qnum { font-size: clamp(.85rem, .3vw + .6vh, 1.35rem); }
.exr-stage .exm-qtitle { font-size: clamp(1.75rem, 1.2vw + 1.9vh, 4.75rem); }
.exr-stage .exm-prompt { font-size: clamp(1.05rem, .55vw + 1.05vh, 2.5rem); max-width: 80ch; line-height: 1.4; }

/* Media and (when revealed) the model answer share the rest; the answer sits beside the media. */
.exr-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(.75rem, 1.5vw, 2rem); }
.exr-body.has-answer { grid-template-columns: minmax(0, 1.5fr) minmax(18rem, 1fr); }
.exr-body > .exm-media-list { min-height: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: clamp(.75rem, 1.5vw, 2rem); }
.exr-body > .exm-media-list:empty { display: none; }
.exr-body > .exm-answer { min-height: 0; overflow: auto; align-content: start; }
.exr .exm-answer ul { font-size: clamp(1rem, .45vw + .8vh, 1.7rem); }
.exr-answer-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }
.exr-status { flex: none; margin: 0; text-align: center; color: var(--muted); font-size: .9rem; min-height: 1.4em; }

/* Each item is a column: what it shows fills the height, the caption sits under it. */
.exr-body .exm-media { display: flex; flex-direction: column; min-height: 0; height: 100%; max-width: none; }
.exr-body .exm-media > figcaption, .exr-body .exm-media > .exm-only-tag { flex: none; font-size: clamp(.8rem, .25vw + .6vh, 1.15rem); }
.exr-body .exm-media > :not(figcaption):not(.exm-only-tag) { flex: 1 1 0; min-height: 0; }
.exr-body .exm-media img { width: 100%; height: 100%; max-height: none; object-fit: contain; }
.exr-body .exm-vis { display: flex; align-items: center; justify-content: center; overflow: hidden; padding: clamp(.5rem, 1vh, 1rem); }
.exr-body .exm-vis svg.vis { width: 100%; height: 100%; }
.exr-body .exm-list { display: block; overflow: auto; max-width: none; align-self: stretch; columns: 2 26rem; column-gap: clamp(1rem, 2vw, 2.5rem); font-size: clamp(1rem, .5vw + .9vh, 2rem); }
.exr-body .exm-list li { break-inside: avoid; margin-bottom: .5em; }
.exr-body .exm-card { overflow: auto; align-content: start; font-size: clamp(1rem, .45vw + .85vh, 1.8rem); max-width: none; }
.exr-body .exm-card div { grid-template-columns: minmax(7rem, 12em) 1fr; }
.exr-body .exm-card b { font-size: .7em; }
/* Video and embeds keep 16:9 at the largest size the space allows (container units). */
.exr-body .exm-video { container-type: size; display: grid; place-items: center; }
.exr-body .exm-video .vplayer-wrap { width: min(100cqw, 100cqh * 16 / 9); }
.exr-body .exm-video .vplayer { width: 100%; height: auto; }
.exr-body .exm-video .exm-embed { width: min(100cqw, 100cqh * 16 / 9); }
/* Animations: the canvas fills the stage (library.js sizes it to the stage in fill mode). */
.exr-body .anim { height: 100%; max-width: none; display: flex; flex-direction: column; }
.exr-body .anim > .anim-stage { flex: 1 1 0; min-height: 0; }
.exr-body .anim-stage canvas { position: absolute; inset: 0; }
.exr-body .anim-tabs button, .exr-body .anim-ctrl { font-size: clamp(.84rem, .25vw + .6vh, 1.2rem); }
/* Telemetry: the chart scales to the box, keeping its proportions. */
.exr-body .exm-tele { display: flex; }
.exr-body .tele { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.exr-body .tele-scroll { flex: 1 1 0; min-height: 0; overflow: hidden; }
.exr-body .tele-svg { width: 100%; height: 100%; min-width: 0; }

/* ---------- smaller windows: one page that scrolls ---------- */
@media (max-width: 999px), (max-height: 559px) {
    .exv-console { height: auto; }
    .exv-grid { grid-template-columns: 13rem minmax(0, 1fr); }
    .exv-nav, .exv-stage, .exv-panel { overflow: visible; }
    .exv-nav { max-height: min(70vh, 36rem); overflow-y: auto; }
    .exv-panel { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); }
    .exv-finish { position: static; }

    .exr { height: auto; min-height: calc(100dvh - var(--header-h) - 1px); }
    .exr-body, .exr-body.has-answer { grid-template-columns: minmax(0, 1fr); }
    .exr-body > .exm-media-list { grid-auto-flow: row; }
    .exr-body .exm-media { height: auto; }
    .exr-body .exm-media > :not(figcaption):not(.exm-only-tag) { flex: none; }
    .exr-body .exm-media img { height: auto; max-height: 70vh; }
    .exr-body .exm-vis svg.vis { height: auto; }
    .exr-body .exm-video { container-type: normal; display: block; }
    .exr-body .exm-video .vplayer-wrap, .exr-body .exm-video .exm-embed { width: 100%; }
    .exr-body .anim { height: auto; }
    .exr-body .anim > .anim-stage { flex: none; }
    .exr-body .anim-stage canvas { position: static; }
    .exr-body .tele-scroll { overflow-x: auto; }
    .exr-body .tele-svg { height: auto; min-width: 640px; }
}
@media (max-width: 860px) {
    .exv-grid, .exv-results-grid { grid-template-columns: minmax(0, 1fr); }
    .exv-nav { max-height: 14rem; border-right: 0; border-bottom: 1px solid var(--border); }
    .exv-invite { flex-direction: column; }
}
