/* CramNight: a dark desk at night, one lamp-lit card of paper for the question in front of you.
   Fonts are bundled (assets/fonts, SIL OFL); no external requests. */

@font-face { font-family: "Bricolage Grotesque"; font-weight: 600; font-display: swap; src: url("../fonts/bricolage-grotesque-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 800; font-display: swap; src: url("../fonts/bricolage-grotesque-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); }

:root {
  color-scheme: dark;
  --night: #0e1a2b;        /* the desk */
  --night-2: #152539;      /* raised panels */
  --night-3: #1d3049;      /* hover, inputs */
  --line: #2a3f5c;
  --text: #e8edf4;
  --muted: #93a3b8;
  --lamp: #f2b441;         /* the one accent */
  --lamp-ink: #2a1c00;
  --paper: #f7f2e6;        /* the question card */
  --paper-line: #e3dbc8;
  --ink: #1c2533;
  --ink-muted: #5b6676;
  --right: #2f9e6e;
  --right-bg: #e3f1e8;
  --wrong: #d4574e;
  --wrong-bg: #f8e3df;
  --focus: #f2b441;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", ui-sans-serif, system-ui, sans-serif;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--night); color: var(--text);
  font: 17px/1.55 var(--body);
}
img { max-width: 100%; height: auto; }
a { color: var(--lamp); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 28px; padding-bottom: 64px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); color: var(--ink); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

/* header and footer: quiet */
.site-header { border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font: 800 1.25rem/1 var(--display); letter-spacing: -0.01em; }
.brand-mark { width: 22px; height: 22px; color: var(--lamp); flex: none; }
.site-header nav { display: flex; gap: 2px; }
.site-header nav a { color: var(--muted); text-decoration: none; font-weight: 700; padding: 8px 12px; border-radius: 10px; }
.site-header nav a:hover { color: var(--text); background: var(--night-2); }
.site-header nav a[aria-current="page"] { color: var(--text); }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 20px 0 32px; }

/* type */
h1, h2, h3, .page-title { font-family: var(--display); font-weight: 800; letter-spacing: -0.015em; line-height: 1.15; }
.page-title { font-size: clamp(1.8rem, 5.5vw, 2.6rem); margin: 0 0 10px; }
h2 { font-size: 1.3rem; margin: 0 0 10px; }
h3 { font-size: 1.1rem; margin: 0; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 34em; margin-bottom: 32px; }
.notice { background: var(--night-2); border-left: 4px solid var(--lamp); padding: 14px 16px; border-radius: 0 10px 10px 0; }
.crumbs { font-size: .9rem; color: var(--muted); margin: 0 0 14px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }

/* panels (everything that is not the question) */
.card { background: var(--night-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 16px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--night-3); color: var(--text);
  font: 700 1rem/1 var(--body); cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--lamp); border-color: var(--lamp); color: var(--lamp-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.danger { background: transparent; color: #f0a39c; border-color: #5a2f33; }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: .92rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.nav-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: .95rem; margin: 0 0 14px; }
select, input[type="number"], input[type="password"], input[type="search"] {
  font: 400 1rem var(--body); min-height: 48px; padding: 8px 12px; border-radius: 10px; width: 100%;
  border: 1px solid var(--line); background: var(--night); color: var(--text);
}
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; margin: 0 0 6px; }
.check input { width: 20px; height: 20px; accent-color: var(--lamp); }

/* home: a plain list of exams, not a grid of cards */
.group-title { font-size: 1rem; color: var(--muted); font-family: var(--body); font-weight: 700; letter-spacing: 0; margin: 28px 0 8px; }
.group-title a { color: inherit; text-decoration: none; }
.exam-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.exam-list li { border-bottom: 1px solid var(--line); }
.exam-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; padding: 18px 4px; color: var(--text); text-decoration: none; }
.exam-row:hover .exam-title { color: var(--lamp); }
.exam-title { font: 800 1.35rem/1.2 var(--display); letter-spacing: -0.01em; }
.exam-meta { color: var(--muted); grid-column: 1; }
.exam-count { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--muted); text-align: right; font-size: .95rem; }
.lock { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); font: 700 .75rem/1.4 var(--body); vertical-align: middle; }

/* exam home */
.stat-grid { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 6px 0 14px; }
.stat { display: flex; align-items: baseline; gap: 6px; }
.stat-num { font: 800 1.5rem/1 var(--display); }
.stat-label { color: var(--muted); }
.boxes { display: flex; height: 6px; border-radius: 999px; overflow: hidden; background: var(--night-3); margin: 0 0 24px; }
.box { display: block; min-width: 3px; }
.box-0 { background: var(--night-3); } .box-1 { background: #c1584f; } .box-2 { background: #d38a3f; }
.box-3 { background: #d9b84a; } .box-4 { background: #6fae73; } .box-5 { background: var(--right); }
.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.mode { display: flex; flex-direction: column; margin: 0; }
.mode .btn { margin-top: auto; align-self: flex-start; }
.badge-draft { display: inline-block; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 3px 10px; font-size: .85rem; margin: 0 0 12px; }
.badge-ok { display: inline-block; color: var(--right); border: 1px solid currentColor; border-radius: 8px; padding: 1px 8px; font-size: .8rem; font-weight: 700; }

/* password gate */
#gate { max-width: 440px; }
.gate-msg { min-height: 1.5em; margin: 12px 0 0; color: var(--muted); }

/* ------------------------------------------------------------------------- the question: lamp-lit paper */
.quiz-head { margin-bottom: 14px; }
.quiz-title { font-weight: 700; color: var(--muted); }
.quiz-meta { color: var(--muted); font-size: .92rem; }

article[data-qid] {
  position: relative; background: var(--paper); color: var(--ink); border: 0; border-radius: 6px;
  padding: 26px 26px 24px; margin: 0 0 18px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), 0 30px 80px -10px rgba(242, 180, 65, .28), 0 0 120px 10px rgba(242, 180, 65, .10);
}
article[data-qid] .muted { color: var(--ink-muted); }
.q-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; font-size: .9rem; color: var(--ink-muted); }
.q-num { margin-right: auto; }
.chip { color: var(--ink-muted); }
.chip::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--lamp); margin-right: 8px; vertical-align: middle; }
.q-text { font: 700 clamp(1.2rem, 3.6vw, 1.45rem)/1.4 var(--body); margin: 0 0 20px; color: var(--ink); white-space: pre-line; max-width: 38em; }
.q-figure { margin: 0 0 20px; text-align: center; background: #fff; border: 1px solid var(--paper-line); border-radius: 4px; padding: 10px; }
.q-figure img { max-height: 320px; width: auto; }
.q-figure figcaption { color: var(--ink-muted); margin-top: 6px; }

/* answers: lines on an answer sheet */
.multi-hint { color: var(--ink-muted); font-size: .95rem; margin: -8px 0 12px; }
.options { display: flex; flex-direction: column; border-top: 1px solid var(--paper-line); }
.opt {
  display: grid; grid-template-columns: 36px 1fr; gap: 6px 14px; align-items: center; text-align: left; width: 100%;
  min-height: 58px; padding: 10px 6px; border: 0; border-bottom: 1px solid var(--paper-line); background: transparent;
  color: var(--ink); font: 400 1.05rem/1.4 var(--body); cursor: pointer;
}
.opt:hover:not(:disabled) { background: rgba(242, 180, 65, .12); }
.opt.selected { background: rgba(242, 180, 65, .22); }
.opt:disabled { cursor: default; }
.opt-letter { display: inline-flex; width: 32px; height: 32px; border-radius: 50%; align-items: center; justify-content: center; border: 1.5px solid var(--ink-muted); color: var(--ink-muted); font-weight: 700; font-size: .92rem; }
.opt.selected .opt-letter { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.opt-text { white-space: pre-line; }
.opt.correct { background: var(--right-bg); }
.opt.correct .opt-letter { background: var(--right); border-color: var(--right); color: #fff; }
.opt.wrong { background: var(--wrong-bg); }
.opt.wrong .opt-letter { background: var(--wrong); border-color: var(--wrong); color: #fff; }
.opt.correct:not(.selected) { background: transparent; }
.opt.correct:not(.selected) .opt-letter { background: transparent; color: var(--right); border: 2px dashed var(--right); }
.opt-exp { grid-column: 2; font-size: .92rem; color: var(--ink-muted); }

/* feedback: written on the same paper */
.feedback { margin-top: 18px; padding: 14px 16px; border-radius: 4px; border-left: 4px solid; color: var(--ink); }
.feedback.ok { background: var(--right-bg); border-color: var(--right); }
.feedback.bad { background: var(--wrong-bg); border-color: var(--wrong); }
.fb-title { font: 800 1.15rem/1.3 var(--display); margin-bottom: 4px; }
.fb-answer { font-weight: 700; }
.fb-ref { color: var(--ink-muted); }
.fb-exp { color: var(--ink); white-space: pre-line; }
.feedback .small.muted { color: var(--ink-muted); margin-top: 6px; }
.reference-links { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid rgba(0, 0, 0, .1); }
.reference-links ul { margin: 4px 0 0; padding-left: 1.2rem; }
.reference-links a { color: #8a5a00; font-weight: 700; }

/* mock exam clock: an amber strip, the one loud thing on the screen */
.clock {
  position: sticky; top: 0; z-index: 6; background: var(--lamp); color: var(--lamp-ink); border-radius: 12px;
  margin: 0 0 18px; padding: 12px 18px 14px; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px;
}
.clock-main { display: flex; align-items: baseline; gap: 12px; }
.clock-label { font-weight: 700; }
.clock-digits { font: 800 clamp(2.1rem, 9vw, 2.9rem)/1 var(--display); font-variant-numeric: tabular-nums; }
.clock-sub { font-weight: 700; }
.clock-track { flex-basis: 100%; height: 5px; background: rgba(42, 28, 0, .2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.clock-fill { display: block; height: 100%; width: 100%; background: var(--lamp-ink); transition: width 1s linear; }
.clock.warn { background: #f08a3c; }
.clock.urgent { background: var(--wrong); color: #fff; animation: clock-pulse 1s ease-in-out infinite; }
.clock.urgent .clock-fill { background: #fff; }
@keyframes clock-pulse { 50% { box-shadow: 0 0 0 6px rgba(212, 87, 78, .35); } }
.qtime { font-variant-numeric: tabular-nums; }

/* results */
.summary .big-score { font: 800 clamp(3rem, 14vw, 4.5rem)/1 var(--display); margin: 6px 0 10px; color: var(--lamp); }
.verdict { font-weight: 700; }
.verdict.ok { color: #6fd0a0; } .verdict.bad { color: #f0a39c; }
.timing { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 14px 0 0; }
.timing dt { color: var(--muted); }
.timing dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.missed-list { padding-left: 1.3rem; margin: 0; }
.missed-list li { margin-bottom: 18px; }
.m-q { font-weight: 700; margin-bottom: 4px; }
.m-yours { color: #f0a39c; margin: 0; } .m-right { color: #6fd0a0; margin: 0; } .m-ref { color: var(--muted); margin: 0; font-size: .92rem; }

/* reference pages */
.reference .card { padding: 24px; }
.ref-summary { font-size: 1.15rem; color: var(--muted); max-width: 36em; margin-bottom: 22px; }
.reference .q-figure { background: #fff; }
.reference p { max-width: 38em; }

@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  article[data-qid] { padding: 20px 16px 18px; margin-left: -4px; margin-right: -4px; }
  .exam-row { grid-template-columns: 1fr; }
  .exam-count { grid-column: 1; grid-row: auto; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  .clock.urgent { animation: none; }
  .clock-fill { transition: none; }
}
