/* ExamForge — "graded ledger" design system
   Palette: cool paper, ink, ledger green (correct/primary),
   stamp red (wrong/flags), annotation amber (bookmarks/review). */

:root {
  --paper: #f6f7f5;
  --sheet: #ffffff;
  --ink: #20272f;
  --muted: #5d6874;
  --line: #dce1e5;
  --line-strong: #b9c2c9;
  --ledger: #1e6b52;
  --ledger-deep: #124a38;
  --ledger-tint: #e7f1ec;
  --stamp: #b23a2e;
  --stamp-tint: #f8ebe9;
  --amber: #9a6b15;
  --amber-tint: #f7efdd;
  --radius: 10px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino,
    "Book Antiqua", Georgia, serif;
  --font-ui: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    linear-gradient(rgba(30, 107, 82, 0.025) 1px, transparent 1px) 0 0 / 100% 28px,
    var(--paper);
  font-size: 16px;
  line-height: 1.55;
}

.boot { padding: 4rem; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------- top bar */
.topbar {
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.wordmark {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.22em;
  font-weight: 600;
  padding: 0.9rem 0;
  color: var(--ledger-deep);
  cursor: pointer;
  user-select: none;
}
.wordmark span { color: var(--stamp); }
.topnav { display: flex; gap: 0.25rem; }
.topnav button {
  background: none;
  border: none;
  font: inherit;
  font-size: 0.9rem;
  color: var(--muted);
  padding: 1rem 0.75rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.topnav button.active { color: var(--ink); border-bottom-color: var(--ledger); }
.topnav button:hover { color: var(--ink); }

.shell { max-width: 880px; margin: 0 auto; padding: 1.5rem 1rem 5rem; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.7rem; margin: 0.5rem 0 0.25rem; }
h2 { font-size: 1.25rem; }
.sub { color: var(--muted); font-size: 0.9rem; margin: 0 0 1.25rem; }

/* ------------------------------------------------------------ cards */
.card {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1rem;
}
.packcard { display: flex; flex-direction: column; gap: 0.35rem; }
.packcard h2 { margin: 0; }
.packcard .source { font-size: 0.78rem; color: var(--muted); }
.packstats {
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted);
  margin: 0.35rem 0 0.6rem;
}
.packstats b { color: var(--ink); font-weight: 600; }
.cardactions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.notice {
  border-left: 3px solid var(--amber);
  background: var(--amber-tint);
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  border-radius: 0 6px 6px 0;
  margin: 0.5rem 0;
}
.notice.green { border-left-color: var(--ledger); background: var(--ledger-tint); }
.notice.red { border-left-color: var(--stamp); background: var(--stamp-tint); }

/* ---------------------------------------------------------- buttons */
button.btn {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 1.1rem;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: var(--sheet);
  color: var(--ink);
  cursor: pointer;
}
button.btn:hover { border-color: var(--ink); }
button.btn.primary {
  background: var(--ledger);
  border-color: var(--ledger);
  color: #fff;
  font-weight: 600;
}
button.btn.primary:hover { background: var(--ledger-deep); }
button.btn.quiet { border-color: transparent; color: var(--muted); }
button.btn.quiet:hover { color: var(--ink); }
button.btn:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, .bubble:focus-visible {
  outline: 2px solid var(--ledger);
  outline-offset: 2px;
}

/* ------------------------------------------------------ setup forms */
.field { margin-bottom: 1rem; }
.field > label.fl {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.checkrow { display: flex; align-items: center; gap: 0.5rem; font-size: 0.92rem; padding: 0.15rem 0; }
.checkrow input { accent-color: var(--ledger); width: 1rem; height: 1rem; }
.checkrow .cnt { color: var(--muted); font-family: var(--font-mono); font-size: 0.78rem; }
.topicgroup { margin-left: 1.4rem; }
.grouplabel { font-weight: 600; font-size: 0.92rem; padding: 0.3rem 0 0.1rem; }
.inline-inputs { display: flex; gap: 1.5rem; flex-wrap: wrap; }
input[type="number"], input[type="text"], input[type="date"] {
  font: inherit;
  font-family: var(--font-mono);
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  width: 6.5rem;
  background: var(--sheet);
}

/* ----------------------------------------------------- question sheet
   Styled like an exam page: numbered tab, serif stem, scantron bubbles. */
.qsheet {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem 1.5rem;
  position: relative;
  box-shadow: 0 1px 2px rgba(32, 39, 47, 0.05);
}
.qmeta {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.6rem; margin-bottom: 1rem;
}
.qnum { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); }
.qtags { font-size: 0.75rem; color: var(--muted); text-align: right; }
.stem {
  font-family: var(--font-display);
  font-size: 1.08rem;
  white-space: pre-wrap;
  margin-bottom: 1.4rem;
}

/* Signature element: scantron answer bubbles */
.choices { display: flex; flex-direction: column; gap: 0.4rem; }
.choice {
  display: flex; align-items: baseline; gap: 0.8rem;
  padding: 0.45rem 0.6rem;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid transparent;
}
.choice:hover { background: var(--paper); }
.bubble {
  flex: none;
  width: 1.7rem; height: 1.7rem;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--sheet);
  transform: translateY(0.35rem);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.choice.selected .bubble {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--sheet);
}
.choice.selected { border-color: var(--line-strong); background: var(--paper); }
.choice.reveal-correct .bubble { background: var(--ledger); border-color: var(--ledger); color: #fff; }
.choice.reveal-correct { background: var(--ledger-tint); border-color: var(--ledger); }
.choice.reveal-wrong .bubble { background: var(--stamp); border-color: var(--stamp); color: #fff; }
.choice.reveal-wrong { background: var(--stamp-tint); border-color: var(--stamp); }
.choice .ctext { white-space: pre-wrap; }
.choices.locked .choice { cursor: default; }
.choices.locked .choice:hover { background: none; }
.choices.locked .choice.reveal-correct:hover { background: var(--ledger-tint); }
.choices.locked .choice.reveal-wrong:hover { background: var(--stamp-tint); }

/* graded stamp */
.stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.35rem 0.8rem;
  border: 2.5px solid currentColor;
  border-radius: 6px;
  transform: rotate(-2deg);
  margin: 1rem 0 0.25rem;
  animation: stampin 0.18s ease-out;
}
.stamp.ok { color: var(--ledger-deep); }
.stamp.no { color: var(--stamp); }
@keyframes stampin { from { transform: rotate(-2deg) scale(1.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .stamp { animation: none; }
  .bubble { transition: none; }
}

/* solution stepper + method cards */
.solution { border-top: 1px dashed var(--line-strong); margin-top: 1.25rem; padding-top: 1rem; }
.solution h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.step {
  display: flex; gap: 0.9rem;
  padding: 0.6rem 0;
}
.stepnum {
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ledger-deep);
  border: 1px solid var(--ledger);
  border-radius: 50%;
  width: 1.5rem; height: 1.5rem;
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 0.15rem;
}
.steptext { white-space: pre-wrap; }
.calcnote {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin-top: 0.75rem;
}
.calcnote::before { content: "⌨ "; }
.methodcard {
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-top: 0.6rem;
  overflow: hidden;
}
.methodcard > button {
  width: 100%;
  text-align: left;
  background: var(--ledger-tint);
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ledger-deep);
  padding: 0.55rem 0.9rem;
  cursor: pointer;
}
.methodbody { padding: 0.75rem 0.9rem; font-size: 0.92rem; white-space: pre-wrap; }
.methodbody ul { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.methodbody .pitfall-label {
  font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--stamp); font-weight: 700; margin-top: 0.75rem;
}

.drillfoot { display: flex; justify-content: space-between; align-items: center; margin-top: 1.25rem; gap: 0.5rem; flex-wrap: wrap; }
.bookmark { color: var(--amber); }

/* ------------------------------------------------------- mock exam */
.mockbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem;
  position: sticky; top: 0; z-index: 5;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.timer { font-family: var(--font-mono); font-size: 1.15rem; font-weight: 600; }
.timer.low { color: var(--stamp); }
.navgrid { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 1rem; }
.navgrid button {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  width: 2.1rem; height: 2.1rem;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--sheet);
  cursor: pointer;
  position: relative;
}
.navgrid button.answered { background: var(--ink); color: #fff; border-color: var(--ink); }
.navgrid button.current { outline: 2px solid var(--ledger); outline-offset: 1px; }
.navgrid button.flagged::after {
  content: "";
  position: absolute; top: -3px; right: -3px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--stamp);
}
.scoreline { font-family: var(--font-display); font-size: 2.4rem; margin: 0.25rem 0; }
.scoreline small { font-size: 1.1rem; color: var(--muted); }
table.topics { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin: 0.75rem 0; }
table.topics th, table.topics td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); }
table.topics th { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
table.topics td.num { font-family: var(--font-mono); }
.bar { background: var(--line); border-radius: 4px; height: 8px; overflow: hidden; min-width: 90px; }
.bar > i { display: block; height: 100%; background: var(--ledger); }
.bar.low > i { background: var(--stamp); }
.reviewitem { margin-bottom: 0.75rem; }
.reviewitem > button {
  width: 100%; text-align: left; font: inherit; cursor: pointer;
  background: var(--sheet); border: 1px solid var(--line); border-radius: 7px;
  padding: 0.6rem 0.9rem; display: flex; gap: 0.75rem; align-items: baseline;
}
.reviewitem .mark { font-family: var(--font-mono); font-weight: 700; }
.reviewitem .mark.ok { color: var(--ledger); }
.reviewitem .mark.no { color: var(--stamp); }
.reviewitem .qpeek { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* -------------------------------------------------------- progress */
.statgrid { display: flex; gap: 2rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.bigstat .n { font-family: var(--font-display); font-size: 1.9rem; }
.bigstat .l { font-size: 0.72rem; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); }
.attempts { font-size: 0.85rem; }
.attempts td { padding: 0.3rem 0.6rem 0.3rem 0; border-bottom: 1px solid var(--line); }

/* ------------------------------------------------------ responsive */
@media (max-width: 560px) {
  .qsheet { padding: 1.1rem 1rem; }
  .shell { padding: 1rem 0.6rem 4rem; }
  .stem { font-size: 1.02rem; }
}

/* ----------------------------------------------------------- print */
#print-root { display: none; }
@media print {
  body { background: #fff; }
  #app, .topbar { display: none !important; }
  #print-root { display: block; font-family: var(--font-display); color: #000; }
  .p-cover { page-break-after: always; }
  .p-cover h1 { font-size: 1.5rem; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
  .p-cover .p-sub { font-family: var(--font-ui); font-size: 0.85rem; margin-bottom: 2rem; }
  .p-lines { margin: 1.5rem 0; font-family: var(--font-ui); font-size: 0.95rem; }
  .p-lines div { margin-bottom: 1.1rem; }
  .p-lines span { display: inline-block; border-bottom: 1px solid #000; width: 260px; height: 1rem; vertical-align: bottom; }
  .p-instructions { border: 1.5px solid #000; padding: 0.75rem 1rem; font-family: var(--font-ui); font-size: 0.88rem; }
  .p-q { page-break-inside: avoid; margin-bottom: 1.6rem; }
  .p-q .p-stem { white-space: pre-wrap; font-size: 0.98rem; }
  .p-q ol.p-choices { list-style: none; padding-left: 1.5rem; margin: 0.5rem 0 0; }
  .p-q ol.p-choices li { margin-bottom: 0.15rem; white-space: pre-wrap; font-size: 0.95rem; }
  .p-sheet { page-break-before: always; }
  .p-sheet h2, .p-key h2, .p-sols h2 { font-size: 1.15rem; border-bottom: 1.5px solid #000; padding-bottom: 0.3rem; }
  .p-sheet-grid { column-count: 2; column-gap: 3rem; font-family: var(--font-ui); }
  .p-sheet-row { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 0.45rem; break-inside: avoid; }
  .p-sheet-row .n { font-family: var(--font-mono); font-size: 0.8rem; width: 2rem; text-align: right; }
  .p-bub {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.15rem; height: 1.15rem; border-radius: 50%;
    border: 1.2px solid #000; font-size: 0.55rem; font-family: var(--font-ui);
  }
  .p-key { page-break-before: always; }
  .p-key-grid { column-count: 4; font-family: var(--font-mono); font-size: 0.9rem; }
  .p-key-grid div { margin-bottom: 0.25rem; }
  .p-sols { page-break-before: always; }
  .p-sol { page-break-inside: avoid; margin-bottom: 1.4rem; }
  .p-sol .p-steps { white-space: pre-wrap; font-size: 0.92rem; }
  .p-footer { font-family: var(--font-ui); font-size: 0.7rem; color: #444; margin-top: 2rem; }
}

/* phase 3: numeric entry + print write-in line */
.numentry input { width: 12rem; font-size: 1rem; }
@media print {
  .p-answerline { margin-top: 0.5rem; font-family: var(--font-ui); font-size: 0.95rem; }
  .p-writein { display: inline-block; border-bottom: 1px solid #000; width: 9rem; height: 1rem; }
}
