/* Exam-page styling (M1–M5, design pass 2026-08-15). The palette is
   Catppuccin Macchiato — dark, low-contrast-comfortable for long exam
   sessions. Sections render as cards; status colors are review aids,
   never verdicts (ADR-0007). */

:root {
  --crust: #11111b;
  --mantle: #181825;
  --base: #1e1e2e;
  --surface0: #313244;
  --surface1: #45475a;
  --text: #cdd6f4;
  --subtext: #a6adc8;
  --blue: #89b4fa;
  --red: #f38ba8;
  --yellow: #f9e2af;
  --green: #a6e3a1;
  --peach: #fab387;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15.5px;
  line-height: 1.55;
  margin: 0;
  background: var(--crust);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

main {
  /* Full-width layout (2026-08-30 teacher request — both views were
     compacted into a centered 1100px column). */
  max-width: none;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

/* -- header ------------------------------------------------------------ */

.app-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 1.1rem 0 0.9rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--surface0);
}

.app-header .brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--blue);
}

.app-header .tagline {
  color: var(--subtext);
  font-size: 0.9rem;
}

.app-header .page-switch {
  margin-left: auto;
  display: flex;
  gap: 0.25rem;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 999px;
  padding: 0.2rem;
}

.app-header .page-switch button,
.app-header .page-switch a {
  border: none;
  border-radius: 999px;
  background: transparent;
  margin: 0;
  padding: 0.3rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: inherit;
}

.app-header .page-switch button.active,
.app-header .page-switch a:hover {
  background: var(--surface0);
  color: var(--text);
}

/* -- headings ------------------------------------------------------------ */

h2 {
  font-size: 1.3rem;
  margin: 1.4rem 0 0.6rem;
}

h3 {
  font-size: 1.05rem;
  color: var(--subtext);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0.4rem 0 0.6rem;
}

/* -- cards ---------------------------------------------------------------- */

section {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 0.8rem 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Nested sections (dashboard panels) read as flat panels, not cards in
   cards. */
section section {
  background: transparent;
  box-shadow: none;
  border-color: var(--surface0);
  padding: 0.6rem 0.9rem;
}

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

button {
  margin: 0.15rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--surface1);
  border-radius: 6px;
  background: var(--surface0);
  color: var(--text);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--surface1);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

button.active {
  border-color: var(--blue);
  background: var(--surface1);
}

input, textarea {
  background: var(--base);
  color: inherit;
  border: 1px solid var(--surface1);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
}

label {
  display: block;
  margin: 0.4rem 0;
}

a {
  color: var(--blue);
}

pre {
  background: var(--crust);
  border: 1px solid var(--surface0);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  overflow-x: auto;
}

details summary {
  cursor: pointer;
  font-weight: 600;
}

details summary:hover {
  color: var(--blue);
}

/* -- banner / notices ------------------------------------------------------ */

.watermark {
  position: sticky;
  top: 0;
  /* Sticky alone doesn't lift paint order: xterm's absolutely-positioned
     rows are later in the DOM and would paint OVER the banner on scroll. */
  z-index: 10;
  background: rgba(49, 50, 68, 0.9);
  backdrop-filter: blur(6px);
  border-radius: 0 0 8px 8px;
  padding: 0.35rem 0.8rem;
  font-weight: 600;
}

.error {
  color: var(--red);
}

.recording-notice, .phone-warning, .reload-note {
  border: 1px solid var(--yellow);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
}

/* -- quiz ------------------------------------------------------------------- */

.quiz .choice {
  display: block;
  padding: 0.25rem 0;
}

fieldset.question {
  border: 1px solid var(--surface1);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin: 0.8rem 0;
}

/* Answered question: the panel itself signals it, not just the ✓
   (2026-08-30 teacher request). Color ONLY — a box-shadow "second border"
   does not gap around the legend and struck through the "Question N"
   text. */
fieldset.question.answered {
  border-color: var(--green);
}

fieldset.question legend {
  font-weight: 600;
  padding: 0 0.4rem;
}

/* The statement lives in the fieldset BODY (not the legend, which
   straddles the border — the answered border struck through the text). */
.question-statement {
  margin: 0.3rem 0 0.6rem;
}

/* The "Je ne sais pas" pseudo-choice: visibly not a real answer. */
.choice.jns-pas {
  color: var(--subtext);
  border-top: 1px dashed var(--surface1);
  margin-top: 0.4rem;
  padding-top: 0.4rem;
}

/* -- workspace -------------------------------------------------------------- */

.workspace {
  margin-top: 1rem;
  border-top: 1px solid var(--surface1);
  padding-top: 0.5rem;
}

.exercise-tabs, .file-tabs {
  margin: 0.3rem 0;
}

.statement-text {
  display: block;
  white-space: pre-wrap;
  line-height: 1.6;
  margin: 0.6rem 0;
}

/* KaTeX display math: breathing room (KaTeX centers it itself). */
.statement-text .katex-display,
.choice-text .katex-display,
.question-text .katex-display {
  margin: 0.8rem 0;
}

.editor-pane {
  border: 1px solid var(--surface1);
  border-radius: 8px;
  min-height: 240px;
  overflow: hidden;
}

.editor-pane .cm-editor {
  height: 320px;
}

.conflict-banner {
  border: 2px solid var(--red);
  border-radius: 6px;
  padding: 0.5rem 0.8rem;
  margin: 0.4rem 0;
}

.terminal-host {
  height: 300px;
  border: 1px solid var(--surface1);
  border-radius: 8px;
  margin-top: 0.3rem;
  overflow: hidden;
}

.terminal-status, .venue-note, .playground-note, .queue-status, .paste-note,
.truncated, .quiz-status {
  color: var(--subtext);
  font-size: 0.9rem;
}

.playground-outcome .stderr {
  color: var(--peach);
}

.submit-pane, .playground-pane, .terminal-pane {
  margin-top: 0.8rem;
}

/* -- teacher cohort grid ------------------------------------------------------
   One tile per student, colored by signal bucket. The colors are review
   aids, not verdicts (ADR-0007) — the page legend says so next to the
   grid. */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.6rem;
}

.tile {
  border: 1px solid var(--surface1);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  background: var(--base);
  transition: transform 120ms ease;
}

.tile:hover {
  transform: translateY(-1px);
}

.tile.bucket-green {
  border-left-color: var(--green);
}

.tile.bucket-amber {
  border-left-color: var(--yellow);
}

.tile.bucket-red {
  border-left-color: var(--red);
}

.tile .tile-line, .legend {
  color: var(--subtext);
  font-size: 0.9rem;
  margin: 0.2rem 0;
}

.tile .tile-tail {
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.8rem;
}

.tile .tile-events {
  margin: 0.2rem 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}

.drill, .replay {
  border: 1px solid var(--surface1);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  margin-top: 0.8rem;
}

.replay input[type="range"] {
  width: 40%;
  vertical-align: middle;
}

/* -- lists -------------------------------------------------------------------- */

ul {
  padding-left: 1.3rem;
}

li {
  margin: 0.3rem 0;
}

/* -- roster status grid (2026-08-24, teacher request) -----------------------
   One line per student, color-coded by state. */

.status-grid {
  list-style: none;
  padding-left: 0;
}

.status-grid li {
  border: 1px solid var(--surface1);
  border-left-width: 4px;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  margin: 0.35rem 0;
  background: var(--base);
}

.status-grid li.status-pending {
  border-left-color: var(--yellow);
}

.status-grid li.status-working {
  border-left-color: var(--blue);
}

.status-grid li.status-submitted {
  border-left-color: var(--green);
}

.status-grid li.status-offline {
  border-left-color: var(--surface1);
  color: var(--subtext);
}

.status-grid li.status-rejected {
  border-left-color: var(--red);
  color: var(--subtext);
}

.status-chip {
  display: inline-block;
  min-width: 7.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--subtext);
}

/* -- results grid (grades teacher-only, doc 05 §9 errata 50/51) -------------- */

.results-grid {
  border-collapse: collapse;
  width: 100%;
  margin-top: 0.6rem;
}

.results-grid th,
.results-grid td {
  text-align: left;
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--surface0);
}

.results-grid th {
  color: var(--subtext);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.results-grid .grade-cell {
  font-weight: 700;
  color: var(--crust);
  border-radius: 6px;
  text-align: center;
  min-width: 3.5rem;
}

/* -- teacher quiz analysis (doc 05 §9 erratum 53) --------------------------- */

/* Per-student answer review: green = correct (solid when picked, outlined
   when missed), red = a picked wrong choice. */
.review-choice {
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  margin: 0.2rem 0;
}

.review-choice .review-marker {
  font-weight: 700;
  display: inline-block;
  min-width: 1rem;
}

.review-choice.correct.picked {
  background: color-mix(in srgb, var(--green) 25%, transparent);
  outline: 1px solid var(--green);
}

.review-choice.correct.missed {
  outline: 1px dashed var(--green);
}

.review-choice.correct .review-marker {
  color: var(--green);
}

.review-choice.wrong.picked {
  background: color-mix(in srgb, var(--red) 25%, transparent);
  outline: 1px solid var(--red);
}

.review-choice.wrong.picked .review-marker {
  color: var(--red);
}

.review-question legend {
  font-size: 0.85rem;
  color: var(--subtext);
}

.review-score {
  font-weight: 600;
}

/* Cohort quiz analysis: per-question average bar + choice chips. */
.quiz-stats .stats-title {
  font-weight: 600;
}

.stats-question {
  border-top: 1px solid var(--surface0);
  padding: 0.5rem 0;
}

.stats-head {
  margin: 0.2rem 0;
}

.stats-bar {
  background: var(--surface0);
  border-radius: 4px;
  height: 0.7rem;
  max-width: 32rem;
  overflow: hidden;
}

.stats-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.stats-line {
  color: var(--subtext);
  font-size: 0.85rem;
  margin: 0.25rem 0;
}

.stats-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.25rem 0;
}

.choice-chip {
  background: var(--surface0);
  border-radius: 999px;
  font-size: 0.8rem;
  padding: 0.1rem 0.6rem;
}

.choice-chip.correct {
  outline: 1px solid var(--green);
  color: var(--green);
}

/* Expandable legend details (signal-colors explanation on the cohort grid). */
.legend-details {
  color: var(--subtext);
  font-size: 0.85rem;
  margin: 0.2rem 0 0.6rem;
}

.legend-details summary {
  cursor: pointer;
  text-decoration: underline dotted;
}
