/* exam.css — the exam layer, loaded after styles.css.
 *
 * Direction: instrument panel. The practice page is a calm classroom; this is a
 * bench test under load. Same material system, deliberately a different register.
 *
 * Teal is the practice accent and reads as safe and instructional, so the exam
 * takes amber — live, recording, this one counts. Red is held back entirely for
 * the last ten seconds and for expiry, so it never appears unless time is
 * actually running out.
 *
 * Spec: pm/6-delivery/final-exam-spec.md §8
 */

:root {
  --live: var(--amber);
  --live-deep: #b45309;
  --danger: #f87171;
  --danger-deep: #7f1d1d;
}

/* Every numeral in this page sits in a slot that changes once a second.
   Tabular figures stop the clock jittering as digits swap. */
.mono,
.qtimer-digits,
.hud-clock,
.hud-pos,
.done-score,
.done-pct {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

.exam-body { background: var(--ground); }

.screen { max-width: var(--col); margin: 0 auto; padding: 0 20px 72px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- brief ---------- */

.exam-head {
  display: flex; align-items: baseline; gap: 12px;
  padding: 28px 0 40px;
}

.exam-tag {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--live);
}

.brief-title { font-size: clamp(30px, 7vw, 46px); line-height: 1.08; margin: 0 0 32px; }
.brief-dim { color: var(--slate); }

.brief-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 20px; margin: 0 0 40px; padding: 22px 0;
  border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
}
.brief-facts dt {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--slate); margin-bottom: 6px;
}
.brief-facts dd { margin: 0; font-family: var(--mono); font-size: 19px; color: var(--bone); }

.rules { margin: 0 0 40px; }
.rules-title {
  font-size: 15px; margin: 0 0 16px;
  font-family: var(--mono); font-weight: 400; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--live);
}
.rules-list { margin: 0; padding-left: 22px; color: var(--ash); }
.rules-list li { margin-bottom: 11px; line-height: 1.55; }
.rules-list b { color: var(--bone); font-weight: 600; }

/* A readout, not a control. Styled like the brief's facts rather than like the
   identity fields, so it does not invite a click. */
.set-assigned {
  /* Flex, not grid: a grid's auto track took its width from the note spanning
     both columns and pushed the panel wider than the phone. */
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 14px;
  border-top: 1px solid var(--hairline);
  padding: 18px 0 0; margin: 4px 0 22px;
}
.set-assigned-label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--slate);
}
.set-assigned-value { font-size: 26px; line-height: 1; color: var(--live); }
.set-assigned-note {
  flex: 0 0 100%; margin-top: 8px;
  font-size: 13px; line-height: 1.5; color: var(--slate);
}

.start-warn {
  font-family: var(--mono); font-size: 13px; color: var(--live);
  border-left: 2px solid var(--live-deep); padding-left: 12px; margin: 0 0 22px;
}

.btn-exam {
  background: var(--live); color: #231a04; border-color: var(--live);
  font-weight: 600;
}
.btn-exam:hover:not(:disabled) { background: #fbbf24; border-color: #fbbf24; }
.btn-exam:disabled { opacity: 0.35; }

/* ---------- head-up display ---------- */

.hud {
  position: sticky; top: 0; z-index: 10;
  background: var(--ground);
  padding: 0 0 14px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 26px;
}

/* 90 cells. A map on a laptop, a texture on a phone, and the index for the
   revisit pass — at a glance: how far in, and what is still outstanding. */
.ribbon {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  /* box-sizing is border-box globally, so this height must carry the padding
     too — 20px with 20px of padding left the cells 0px tall and invisible. */
  height: 36px;
  padding: 14px 0 8px;
}
.ribbon i {
  display: block; height: 100%;
  background: var(--hairline);
  border-radius: 1px;
  transition: background 160ms, box-shadow 160ms;
}
.ribbon i.is-locked { background: var(--live); }
.ribbon i.is-deferred { background: transparent; box-shadow: inset 0 0 0 1.5px var(--live-deep); }
.ribbon i.is-current { background: var(--bone); }

.hud-row { display: flex; align-items: center; gap: 12px; }
.hud-pos { font-size: 14px; color: var(--bone); }
.hud-dim { color: var(--slate); }

.hud-phase {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--live);
  border: 1px solid var(--live-deep); border-radius: 2px; padding: 3px 8px;
}

.hud-clock { margin-left: auto; font-size: 15px; color: var(--ash); }
.hud-clock.is-low { color: var(--live); }
.hud-clock.is-critical { color: var(--danger); }

/* ---------- question card ---------- */

.qcard {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 0 clamp(16px, 4vw, 28px) clamp(20px, 4vw, 28px);
  overflow: hidden;
}

/* Fused to the card's top edge rather than floating in the page furniture,
   so it reads as *this question's* time. */
.qtimer {
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--hairline);
}
.qtimer-fill {
  display: block; height: 100%; width: 100%;
  background: var(--live);
  transform-origin: left center;
  transition: background 220ms linear;
}
.qcard.is-low .qtimer-fill { background: #fbbf24; }
.qcard.is-critical .qtimer-fill { background: var(--danger); }

@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.qhead { display: flex; align-items: center; gap: 12px; padding: 20px 0 16px; }

.qtimer-digits { font-size: 15px; color: var(--slate); }
.qcard.is-low .qtimer-digits { color: var(--live); }
.qcard.is-critical .qtimer-digits { color: var(--danger); }

/* The last five seconds get a pulse as well as a colour, so the warning does
   not depend on colour alone. */
.qcard.is-critical .qtimer-digits { animation: tick 1s steps(2, jump-none) infinite; }
@keyframes tick { 0%, 60% { opacity: 1; } 61%, 100% { opacity: 0.45; } }

.qhint { font-family: var(--mono); font-size: 12px; color: var(--slate); margin-left: auto; }

.qcard .question { font-size: clamp(18px, 3.6vw, 21px); line-height: 1.45; margin: 0 0 20px; }
.qcard .question:focus { outline: none; }
.qcard .figure { margin: 0 0 22px; }

.opts { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }

.opt {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  /* Bigger than practice: this gets taken on phones, under time pressure. */
  padding: 16px 18px; min-height: 56px;
  background: var(--ground);
  border: 1px solid var(--hairline); border-radius: var(--r);
  color: var(--ash); text-align: left; font-size: 16px; cursor: pointer;
  transition: border-color 140ms, background 140ms, color 140ms;
}
.opt:hover { border-color: var(--slate); }
.opt:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; }

.opt-key {
  font-family: var(--mono); font-size: 13px; color: var(--slate);
  border: 1px solid var(--hairline); border-radius: 2px;
  width: 26px; height: 26px; flex: 0 0 26px;
  display: grid; place-items: center;
}
.opt-label { flex: 1; }

.opt.is-chosen {
  border-color: var(--live); background: rgba(245, 158, 11, 0.08); color: var(--bone);
}
.opt.is-chosen .opt-key { color: var(--live); border-color: var(--live-deep); }

/* Says plainly that the choice is reversible — the one rule students are most
   likely to assume works the other way. */
.opt.is-chosen::after {
  content: 'tap to clear';
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--live-deep);
}

/* The lock. One deliberate moment with weight, rather than micro-interactions
   scattered everywhere — submitting is irreversible and should feel it. */
.qcard.is-sealing { pointer-events: none; }
.qcard.is-sealing .opts { opacity: 0.35; filter: grayscale(1); transition: opacity 160ms, filter 160ms; }
.qcard.is-sealing::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0; bottom: 0;
  border-top: 2px solid var(--live);
  animation: seal 180ms ease-out forwards;
}
@keyframes seal { from { transform: translateY(-100%); } to { transform: translateY(0); } }

.actions { margin-top: 24px; display: flex; flex-direction: column; gap: 12px; }
.kbd-note { text-align: center; color: var(--slate); font-size: 12px; margin-top: 20px; }

/* ---------- done ---------- */

.done-wrap { padding: clamp(60px, 18vh, 160px) 0; text-align: center; }
.done-eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--slate); margin: 0 0 24px;
}
.done-score { font-size: clamp(56px, 16vw, 96px); line-height: 1; margin: 0; color: var(--bone); }
.done-total { color: var(--slate); }
.done-pct { font-size: clamp(20px, 5vw, 26px); color: var(--live); margin: 14px 0 0; }
.done-note { color: var(--slate); margin-top: 36px; font-size: 14px; }

.recovery {
  margin: 28px auto 0; max-width: 100%; overflow-x: auto; text-align: left;
  background: var(--panel); border: 1px solid var(--live-deep); border-radius: var(--r);
  padding: 14px; font-size: 11px; color: var(--ash); white-space: pre-wrap; word-break: break-all;
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .qtimer-fill { animation: none !important; }
  .qcard.is-critical .qtimer-digits { animation: none; }
  .qcard.is-sealing::after { animation: none; }
  .ribbon i { transition: none; }
}

/* ---------- narrow ---------- */

@media (max-width: 620px) {
  .screen { padding: 0 16px 64px; }
  .ribbon { gap: 1px; height: 30px; padding: 12px 0 6px; }
  .opt { font-size: 17px; padding: 18px 16px; min-height: 60px; }
  .opt.is-chosen::after { content: '✕'; font-size: 13px; }
  .hud-pos, .hud-clock { font-size: 14px; }
}
