/* Oral exams — "blue book" styling.
   Paper-white ground, blue-black ink, blue-book cover blue for actions,
   Stanford cardinal reserved for recording and destructive actions. */

:root {
  --paper: #fbfcfe;
  --sheet: #ffffff;
  --ink: #1d2433;
  --ink-soft: #4a5368;
  --ink-faint: #7a8297;
  --rule: #c9d6ea;
  --rule-soft: #e6edf7;
  --blue: #3e64a8;
  --blue-deep: #2c4b85;
  --blue-wash: #e8eff9;
  --cardinal: #8c1515;
  --cardinal-wash: #f8e9e9;
  --green: #2f7d4f;
  --green-wash: #e6f3eb;
  --amber: #8a5a00;
  --amber-wash: #fbf1dc;

  --ui: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, serif;

  --r-small: 4px;
  --r: 8px;
  --gap: 1rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { font-size: 16px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-deep); text-underline-offset: 0.15em; }
a:hover { color: var(--blue); }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: var(--r-small); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 700; }
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; margin-top: 1.6em; }
h3 { font-size: 1.05rem; margin-top: 1.2em; }
p { margin: 0 0 0.8em; }
small, .muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- frame */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.6rem 1.5rem;
  background: var(--blue-deep);
  color: #fff;
}
.topbar a { color: #fff; text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.topbar .course { font-weight: 700; font-size: 1.05rem; }
.topbar nav { display: flex; gap: 1.2rem; flex: 1; }
.topbar .who { font-size: 0.9rem; opacity: 0.9; }

.banner { padding: 0.6rem 1.5rem; display: flex; gap: 1rem; align-items: center; }
.banner.viewas { background: var(--amber-wash); color: var(--amber); }
.banner form { margin: 0; }

main { max-width: 1180px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
main.narrow { max-width: 760px; }
main.wide { max-width: none; }

.crumbs { font-size: 0.92rem; margin-bottom: 0.4rem; color: var(--ink-soft); }
.crumbs a { color: var(--ink-soft); }

.flash { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.flash li { padding: 0.7rem 1rem; border-radius: var(--r); background: var(--green-wash); color: var(--green); margin-bottom: 0.5rem; }
.flash li.error { background: var(--cardinal-wash); color: var(--cardinal); }

/* ---------------------------------------------------------------- controls */

button, .button {
  font: inherit;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.5rem 1rem;
  border-radius: var(--r);
  border: 1.5px solid var(--blue);
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
}
button:hover, .button:hover { background: var(--blue-deep); border-color: var(--blue-deep); color: #fff; }
button.secondary, .button.secondary { background: var(--sheet); color: var(--blue-deep); }
button.secondary:hover, .button.secondary:hover { background: var(--blue-wash); color: var(--blue-deep); }
button.danger, .button.danger { background: var(--sheet); color: var(--cardinal); border-color: var(--cardinal); }
button.danger:hover { background: var(--cardinal-wash); }
button.big { font-size: 1.15rem; padding: 0.75rem 1.5rem; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.link { background: none; border: none; color: var(--blue-deep); padding: 0; font-weight: 400; text-decoration: underline; }

input[type=text], input[type=number], input[type=file], select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--sheet);
  border: 1.5px solid var(--rule);
  border-radius: var(--r-small);
  padding: 0.45rem 0.6rem;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; }
textarea { width: 100%; min-height: 4.5rem; resize: vertical; line-height: 1.45; }
label { display: block; font-weight: 700; margin-bottom: 0.25rem; }
.field { margin-bottom: 1rem; }
.inline { display: flex; gap: 0.75rem; align-items: end; flex-wrap: wrap; }
.inline .field { margin-bottom: 0; }
form.plain { margin: 0; display: inline; }

/* ---------------------------------------------------------------- content blocks */

.panel {
  background: var(--sheet);
  border: 1.5px solid var(--rule);
  border-radius: var(--r);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }

table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
th { font-weight: 700; color: var(--ink-soft); border-bottom: 1.5px solid var(--rule); }
td.r, th.r { text-align: right; }
tr:hover td { background: #f7f9fd; }
.scroll { overflow-x: auto; }

.pill {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--rule-soft);
  color: var(--ink-soft);
  white-space: nowrap;
}
.pill.scheduled { background: var(--blue-wash); color: var(--blue-deep); }
.pill.in_progress { background: var(--cardinal-wash); color: var(--cardinal); }
.pill.completed { background: var(--green-wash); color: var(--green); }
.pill.no_show { background: var(--amber-wash); color: var(--amber); }
.pill.ok { background: var(--green-wash); color: var(--green); }
.pill.warn { background: var(--amber-wash); color: var(--amber); }
.pill.bad { background: var(--cardinal-wash); color: var(--cardinal); }

.messages { margin: 0 0 1rem; padding-left: 1.2rem; }
.messages.errors li { color: var(--cardinal); }
.messages.warnings li { color: var(--amber); }

pre.example {
  background: var(--blue-wash);
  border-radius: var(--r-small);
  padding: 0.75rem 1rem;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.45;
}

/* ---------------------------------------------------------------- setup checklist (a real sequence) */

ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; }
ol.steps > li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  gap: 0.25rem 0.9rem;
  align-items: start;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule-soft);
}
ol.steps > li::before {
  content: counter(step);
  width: 1.9rem; height: 1.9rem;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.95rem;
}
ol.steps > li.done::before { content: "✓"; background: var(--green); border-color: var(--green); color: #fff; }
ol.steps > li.attention::before { border-color: var(--amber); color: var(--amber); }
ol.steps .what { font-weight: 700; }
ol.steps .detail { color: var(--ink-soft); font-size: 0.95rem; }
ol.steps .act { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: end; }

/* ---------------------------------------------------------------- schedule grid */

.day { margin-bottom: 2rem; }
.columns { display: flex; gap: 0.9rem; overflow-x: auto; padding-bottom: 0.5rem; align-items: start; }
.column { min-width: 13rem; flex: 0 0 13rem; }
.column > .head { font-weight: 700; padding-bottom: 0.25rem; }
.block { border: 1.5px solid var(--rule); border-radius: var(--r); background: var(--sheet); margin-bottom: 0.6rem; overflow: hidden; }
.block > .room { font-size: 0.85rem; color: var(--ink-soft); padding: 0.3rem 0.6rem; background: var(--rule-soft); }
.cell { display: flex; gap: 0.5rem; padding: 0.3rem 0.6rem; border-top: 1px solid var(--rule-soft); min-height: 2.1rem; align-items: baseline; font-size: 0.92rem; }
.cell .t { color: var(--ink-faint); width: 2.6rem; flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell.free .who { color: var(--ink-faint); }
.cell.taken { background: var(--blue-wash); }
.cell.taken .who a { text-decoration: none; color: var(--ink); font-weight: 700; }
.cell.taken .who a:hover { text-decoration: underline; }
.cell .lock { color: var(--ink-faint); font-size: 0.8rem; }
.cell.st-in_progress { background: var(--cardinal-wash); }
.cell.st-completed { background: var(--green-wash); }
.cell.st-no_show { background: var(--amber-wash); }

/* ---------------------------------------------------------------- staff console */
/* Today: the examiner's day, one student after another */
.day-nav { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0.2rem 0 1rem; }
.day-strip { list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0; padding: 0; }
.day-strip a {
  display: inline-flex; gap: 0.35rem; align-items: baseline;
  padding: 0.25rem 0.6rem; border: 1.5px solid var(--rule); border-radius: var(--r);
  color: var(--ink); text-decoration: none; font-size: 0.9rem; background: var(--sheet);
}
.day-strip a:hover { border-color: var(--blue); background: var(--blue-wash); }
.day-strip a[aria-current] { border-color: var(--blue); background: var(--blue); color: #fff; font-weight: 700; }
.day-strip .t { font-variant-numeric: tabular-nums; opacity: 0.75; }
.day-strip .m { font-size: 0.8rem; font-weight: 700; }
.day-strip .ds-completed .m { color: var(--green); }
.day-strip .ds-todo .m, .day-strip .ds-in_progress .m { color: var(--amber); }
.day-strip .ds-no_show { color: var(--ink-soft); }
.day-strip a[aria-current] .m { color: #fff; }
.look-back { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.big-line { font-size: 1.2rem; }
.share-links dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1rem; margin: 0; }
.share-links dt { font-weight: 700; }
.share-links dd { margin: 0; }
.share-links dd .muted { display: block; font-size: 0.9rem; margin-top: 0.2rem; }
.share-links code { word-break: break-all; }

.console { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 1.5rem; align-items: start; }
@media (max-width: 1000px) { .console { grid-template-columns: 1fr; } }

.student-line { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.student-line h1 { margin: 0; }

.controls { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin: 0.75rem 0 1rem; }

.timer { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.timer.over { color: var(--cardinal); }
.timer-wrap { display: flex; align-items: baseline; gap: 0.75rem; }

.health { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.95rem; margin: 0.5rem 0 1rem; }
.health .row { display: flex; gap: 0.5rem; align-items: center; }
.dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--ink-faint); flex: none; }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--cardinal); }
.dot.warn { background: #d29a1c; }
.dot.rec { background: var(--cardinal); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .dot.rec { animation: none; } }

.question {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.6;
  max-width: 68ch;
}
.question img { max-width: 100%; height: auto; }
.question pre { background: var(--blue-wash); border-radius: var(--r-small); padding: 0.6rem 0.9rem; overflow-x: auto; font-size: 0.82em; line-height: 1.45; }
.question code { font-size: 0.9em; }
.question pre code { font-size: 1em; }
.question .part + .part { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1.5px dashed var(--rule); }
.question .part.hidden-part { opacity: 0.45; }
.notes { background: var(--amber-wash); border-radius: var(--r); padding: 0.9rem 1.1rem; margin-top: 1rem; }
.notes summary { cursor: pointer; font-weight: 700; color: var(--amber); }

/* rubric: the one bold element */
.rubric .criterion { padding: 1rem 0 1.1rem; border-bottom: 1.5px solid var(--rule-soft); }
.rubric .criterion:first-child { padding-top: 0; }
.rubric .cname { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.rubric .cname h3 { margin: 0; font-size: 1.1rem; }
.rubric .cscore { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-soft); white-space: nowrap; }
.rubric .cdesc { color: var(--ink-soft); font-size: 0.92rem; margin: 0.15rem 0 0; }
.rubric .cside { display: flex; align-items: baseline; gap: 0.75rem; flex-shrink: 0; }
/* "Review later": the alternative to a score, in amber, so it never reads as one */
.later {
  font-size: 0.85rem; font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--sheet); color: var(--amber);
  border: 1.5px dashed var(--amber);
}
.later:hover { background: var(--amber-wash); color: var(--amber); border-color: var(--amber); }
.later[aria-pressed=true] { background: var(--amber); border-style: solid; color: #fff; }
.later[aria-pressed=true]::before { content: "✓ "; }
.rubric .criterion.later-on .levels { opacity: 0.55; }
.rubric .criterion.needs-score { box-shadow: inset 4px 0 0 var(--cardinal); padding-left: 0.85rem; }
.review-note { font-weight: 700; color: var(--amber); }
.later-mark { font-size: 0.85rem; font-weight: 700; color: var(--amber); }
.levels { display: flex; gap: 0.5rem; margin: 0.65rem 0 0.6rem; flex-wrap: wrap; }
.level {
  flex: 1 1 0;
  min-width: 6.5rem;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem;
  padding: 0.55rem 0.75rem 0.6rem;
  background: var(--sheet);
  color: var(--ink);
  border: 2px solid var(--rule);
  border-radius: var(--r);
  font-weight: 400;
  text-align: left;
}
.level:hover { background: var(--blue-wash); border-color: var(--blue); color: var(--ink); }
.level .pts { font-size: 1.45rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.level .lbl { font-weight: 700; font-size: 0.92rem; }
.level .ldesc { font-size: 0.8rem; color: var(--ink-soft); line-height: 1.3; }
.level[aria-pressed=true] { background: var(--blue); border-color: var(--blue); color: #fff; }
.level[aria-pressed=true] .ldesc { color: #dfe8f7; }
.level kbd { font-family: var(--ui); font-size: 0.72rem; color: var(--ink-faint); float: right; }
.level[aria-pressed=true] kbd { color: #dfe8f7; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.chip {
  font-weight: 400;
  font-size: 0.9rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--sheet);
  color: var(--ink);
  border: 1.5px solid var(--rule);
  text-align: left;
}
.chip:hover { background: var(--blue-wash); color: var(--ink); border-color: var(--blue); }
.chip[aria-pressed=true] { background: var(--blue-wash); border-color: var(--blue); color: var(--blue-deep); font-weight: 700; }
.chip[aria-pressed=true]::before { content: "✓ "; }
.rubric textarea { min-height: 2.6rem; font-size: 0.95rem; }

.rubric-foot { position: sticky; bottom: 0; background: var(--paper); padding: 0.9rem 0; border-top: 1.5px solid var(--rule); display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.total { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.saved { font-size: 0.9rem; color: var(--ink-soft); }
.saved.err { color: var(--cardinal); }

/* ---------------------------------------------------------------- exam page (student laptop) */

body.exam { background: var(--paper); }
.cover {
  background: var(--blue);
  color: #fff;
  padding: 1rem 2rem 1.1rem;
  display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; align-items: center;
}
.cover .title { font-size: 1.35rem; font-weight: 700; }
.cover .name, .cover .when { font-size: 1rem; opacity: 0.92; }
.cover .rec { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; font-weight: 700; }
.cover .rec .dot { background: #ffd2d2; }
.cover .rec.on .dot { background: #ff5a5a; animation: pulse 1.6s ease-in-out infinite; }
.cover a, .cover button.link { color: #fff; }

.exam-body { padding: 2rem 2rem 4rem; max-width: 900px; margin: 0; }
.exam-body .question { font-size: 1.35rem; max-width: 62ch; }
.waiting { font-size: 1.3rem; max-width: 40ch; }
.waiting p.big { font-size: 1.7rem; font-weight: 700; margin-bottom: 0.4rem; }
.notice { border-left: 4px solid var(--cardinal); background: var(--cardinal-wash); padding: 1rem 1.25rem; border-radius: 0 var(--r) var(--r) 0; margin: 1.25rem 0; max-width: 60ch; }
.notice.calm { border-color: var(--blue); background: var(--blue-wash); }

/* ---------------------------------------------------------------- student results */

.result-total { font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-total small { font-size: 1.1rem; font-weight: 400; }
.fb-criterion { padding: 0.9rem 0; border-bottom: 1px solid var(--rule-soft); }
.fb-criterion .top { display: flex; justify-content: space-between; gap: 1rem; font-weight: 700; }
.fb-criterion ul { margin: 0.35rem 0 0; padding-left: 1.2rem; }

.appt-card { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1.25rem; font-size: 1.1rem; }
.appt-card dt { color: var(--ink-soft); }
.appt-card dd { margin: 0; font-weight: 700; }

/* ---------------------------------------------------------------- live board */

.live .appt { padding: 0.45rem 0.6rem; border-top: 1px solid var(--rule-soft); font-size: 0.9rem; display: grid; grid-template-columns: 2.6rem 1fr; gap: 0.1rem 0.5rem; }
.live .appt .t { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.live .appt .sig { grid-column: 2; display: flex; gap: 0.4rem; align-items: center; color: var(--ink-soft); font-size: 0.82rem; }
.live .appt.st-in_progress { background: var(--cardinal-wash); }
.live .appt.st-completed { background: var(--green-wash); }
.live .appt.st-no_show { background: var(--amber-wash); }
.live .appt.late { box-shadow: inset 4px 0 0 #d29a1c; }

video { width: 100%; max-height: 70vh; background: #000; border-radius: var(--r); }

.devbar { position: fixed; bottom: 0.75rem; right: 0.75rem; font-size: 0.85rem; background: var(--amber-wash); color: var(--amber); padding: 0.35rem 0.75rem; border-radius: var(--r); }
.devbar a { color: var(--amber); }

/* ---------------------------------------------------------------- student's screen (console) */

.live img { display: block; width: 100%; height: auto; border: 1.5px solid var(--rule); border-radius: var(--r-small); background: #fff; cursor: zoom-in; }
.live p { margin: 0.5rem 0 0; }
.live p.err { color: var(--cardinal); }
.screen-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 2vh 2vw; background: rgba(29, 36, 51, 0.92); cursor: zoom-out; }
.screen-overlay img { max-width: 100%; max-height: 100%; background: #fff; border-radius: var(--r-small); }
.live-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 0.6rem; }
.live-head h2 { margin: 0; }
.switch { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 400; margin: 0; cursor: pointer; white-space: nowrap; }
.switch input { width: 1.1rem; height: 1.1rem; accent-color: var(--blue); }

/* ---------------------------------------------------------------- exam page: getting ready */

.ready-checks { list-style: none; padding: 0; margin: 1rem 0; font-size: 1.1rem; }
.ready-checks li { display: flex; align-items: center; gap: 0.6rem; margin: 0.4rem 0; flex-wrap: wrap; }
.ready-checks meter { width: 9rem; }
.health .row.own { color: var(--ink-soft); font-size: 0.9rem; padding-left: 1.2rem; display: block; }

/* ---------------------------------------------------------------- exams and grades dashboard */

.filters a[aria-current] { font-weight: 700; }
.filters #refreshed { margin-left: 0.75rem; }
.dash-counts { font-size: 1.05rem; margin-top: 0; }
.live-line { display: inline-flex; gap: 0.45rem; align-items: baseline; }
.live-line .dot { position: relative; top: 0.05rem; }
table.dash tr.st-in_progress td { background: var(--cardinal-wash); }
table.dash tr.st-no_show td { color: var(--ink-soft); }
