/* Capaciteo trainer — visual identity: exam paper.
   Squared notebook paper, highlighter yellow, ballpoint blue, teacher's red/green
   pen, and hard "paper on paper" shadows instead of soft blurs. */
@font-face {
  font-family: 'Bricolage Grotesque Variable';
  src: url('../fonts/bricolage-grotesque-wght.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('../fonts/atkinson-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('../fonts/atkinson-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --paper: #fbfaf6;
  --paper-raised: #ffffff;
  --ink: #1f2421;
  --ink-soft: #5f6a63;
  --rule: #1f2421;
  --grid: #ecefef;
  --marker: #ffd84d;
  --marker-deep: #f0b800;
  --pen: #2b4eff;
  --pen-deep: #1636d4;
  --good: #16794a;
  --good-soft: #dff2e6;
  --bad: #d6453d;
  --bad-soft: #fce4e2;
  --figure-bg: #fffdf2; /* light behind SVG figures in both themes */
  --figure-white: #ffffff;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --display: 'Bricolage Grotesque Variable', 'Bricolage Grotesque', Georgia, serif;
  --body: 'Atkinson Hyperlegible', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15181a;
    --paper-raised: #1e2225;
    --ink: #f2efe6;
    --ink-soft: #a6b0aa;
    --rule: #454e50;
    --grid: #1d2225;
    --marker: #ffd84d;
    --marker-deep: #ffe27a;
    --pen: #8fa6ff;
    --pen-deep: #b3c2ff;
    --good: #5fd39b;
    --good-soft: #16321f;
    --bad: #ff8b83;
    --bad-soft: #3a1f1d;
    --shadow: 4px 4px 0 var(--rule);
    --shadow-sm: 3px 3px 0 var(--rule);
  }
}

:root[data-theme="dark"] {
  --paper: #15181a;
  --paper-raised: #1e2225;
  --ink: #f2efe6;
  --ink-soft: #a6b0aa;
  --rule: #454e50;
  --grid: #1d2225;
  --marker: #ffd84d;
  --marker-deep: #ffe27a;
  --pen: #8fa6ff;
  --pen-deep: #b3c2ff;
  --good: #5fd39b;
  --good-soft: #16321f;
  --bad: #ff8b83;
  --bad-soft: #3a1f1d;
  --shadow: 4px 4px 0 var(--rule);
  --shadow-sm: 3px 3px 0 var(--rule);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  line-height: 1.6;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 26px 26px;
  background-position: -1px -1px;
}

.screen {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: balance;
}
h1 { font-size: 2.2rem; margin: 0 0 6px; }
h2 { font-size: 1.55rem; margin: 10px 0 8px; }
h3 {
  font-size: 1.02rem;
  margin: 24px 0 8px;
  display: inline-block;
  border-bottom: 3px solid var(--marker);
  padding-bottom: 1px;
}
.sub, .instruction { color: var(--ink-soft); margin: 6px 0 14px; max-width: 62ch; }
.footer { color: var(--ink-soft); font-size: 0.8rem; margin-top: 36px; max-width: 62ch; }

/* ---------- cards (home) ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
@media (max-width: 640px) { .cards { grid-template-columns: 1fr; } }

.card {
  display: flex; gap: 14px; align-items: flex-start; text-align: left;
  background: var(--paper-raised); border: 2px solid var(--rule); border-radius: 2px;
  padding: 16px; cursor: pointer; box-shadow: var(--shadow);
  font: inherit; color: inherit; width: 100%;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.card:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.card-icon {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 2px;
  background: var(--marker); color: var(--ink); border: 2px solid var(--rule);
  display: grid; place-items: center;
  font-family: var(--display); font-size: 1.35rem; font-weight: 800;
}
.card-body { display: flex; flex-direction: column; gap: 3px; }
.card-title { font-family: var(--display); font-weight: 700; font-size: 1.08rem; }
.card-short { color: var(--ink-soft); font-size: 0.9rem; }
.card-stats {
  color: var(--ink); font-size: 0.78rem; margin-top: 6px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sim-card { margin-top: 16px; }

/* ---------- buttons ---------- */
.back {
  background: none; border: none; color: var(--ink); font: inherit;
  cursor: pointer; padding: 0; margin-bottom: 10px; font-weight: 700;
  text-decoration: underline; text-decoration-color: var(--marker-deep);
  text-decoration-thickness: 3px; text-underline-offset: 3px;
}
.back:hover, .back:active { text-decoration-color: var(--ink); }

.primary, .secondary {
  font: inherit; font-weight: 700; border-radius: 2px; cursor: pointer;
  padding: 12px 24px; border: 2px solid var(--rule); color: var(--ink);
  box-shadow: var(--shadow); transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.primary { background: var(--marker); }
.secondary { background: var(--paper-raised); }
.primary:hover, .secondary:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.start-row { display: flex; gap: 14px; margin-top: 24px; flex-wrap: wrap; }
.set-name { color: var(--ink-soft); font-size: 0.82rem; margin-top: 12px; }

.setup-group { margin-top: 10px; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.choice {
  font: inherit; background: var(--paper-raised); border: 2px solid var(--rule);
  border-radius: 2px; padding: 10px 18px; cursor: pointer; color: var(--ink);
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; font-weight: 700;
}
.choice small { color: var(--ink-soft); font-weight: 400; font-size: 0.78rem; }
.choice.active { background: var(--marker); box-shadow: var(--shadow-sm); }

/* ---------- quiz ---------- */
.quiz-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 12px; }
.quiz-head .back { margin: 0; }
.quiz-title { font-family: var(--display); font-weight: 700; }
.quiz-counter {
  margin-left: auto; color: var(--ink-soft); font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.block-counter { color: var(--ink); font-weight: 700; margin: 4px 0 0; }

.time-bar {
  height: 10px; background: var(--paper-raised); border: 2px solid var(--rule);
  border-radius: 2px; overflow: hidden; margin-bottom: 16px;
}
.time-bar-fill { height: 100%; width: 100%; background: var(--marker); }
.time-bar-fill.low { background: var(--bad); }

.question-card {
  background: var(--paper-raised); border: 2px solid var(--rule); border-radius: 2px;
  padding: 24px; box-shadow: var(--shadow);
}
.stim-text {
  font-family: var(--display);
  font-size: 1.35rem; font-weight: 700; letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  background: var(--figure-bg); border: 2px solid var(--rule); border-radius: 2px;
  padding: 16px 18px; white-space: pre-wrap; color: var(--ink);
}
.stim-svg, .stim-html { text-align: center; padding: 8px 0; }
.stim-html .ana { font-size: 1.25rem; }
.diagram-words { display: flex; gap: 26px; justify-content: center; font-size: 1.15rem; flex-wrap: wrap; }
.fig-row { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.fig-cell {
  background: var(--figure-bg); border: 2px solid var(--rule); border-radius: 2px; padding: 6px;
  display: inline-flex;
}
.fig-q { border-style: dashed; }

.prompt { font-weight: 700; margin: 18px 0 12px; }

.options { display: flex; flex-direction: column; gap: 10px; }
.options-svg { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.option {
  font: inherit; display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--paper-raised); border: 2px solid var(--rule); border-radius: 2px;
  padding: 11px 14px; cursor: pointer; color: var(--ink);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.options-svg .option { flex-direction: column; gap: 6px; }
.option:hover:not(:disabled) { box-shadow: var(--shadow-sm); transform: translate(-1px, -1px); }
.option:disabled { cursor: default; }
.option.correct { border-color: var(--good); background: var(--good-soft); box-shadow: 3px 3px 0 var(--good); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: 3px 3px 0 var(--bad); }
.opt-letter {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 2px;
  background: var(--marker); color: var(--ink); border: 2px solid var(--rule);
  font-family: var(--display); font-weight: 800; font-size: 0.85rem;
  display: grid; place-items: center;
}
.opt-text { font-weight: 700; font-variant-numeric: tabular-nums; }
.opt-svg { display: inline-flex; background: var(--figure-white); border-radius: 2px; padding: 2px; }

/* double analogies: two separate choice columns */
.dual-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 560px) { .dual-columns { grid-template-columns: 1fr; } }
.dual-column { display: flex; flex-direction: column; gap: 8px; }
.dual-column h4 {
  font-family: var(--display);
  margin: 0 0 2px; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink); border-bottom: 3px solid var(--marker); padding-bottom: 2px;
}
.option.selected { background: var(--marker); box-shadow: var(--shadow-sm); }

.feedback { margin-top: 8px; }
.fb { border-radius: 2px; padding: 13px 15px; margin: 14px 0; border: 2px solid; }
.fb-correct { background: var(--good-soft); border-color: var(--good); }
.fb-wrong { background: var(--bad-soft); border-color: var(--bad); }

/* ---------- results ---------- */
.score-card {
  background: var(--paper-raised); border: 3px solid var(--rule); border-radius: 2px;
  padding: 26px; text-align: center; box-shadow: 6px 6px 0 var(--ink); margin: 16px 0 8px;
}
.score-big {
  font-family: var(--display); font-size: 3rem; font-weight: 800;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.score-pct {
  display: inline-block; font-weight: 700;
  background: linear-gradient(var(--marker), var(--marker)) left 70% / 100% 0.5em no-repeat;
  padding: 0 6px;
}
.score-verdict { color: var(--ink-soft); margin: 10px 0 0; }

.review {
  background: var(--paper-raised); border: 2px solid var(--rule); border-radius: 2px;
  margin-bottom: 10px; overflow: hidden;
}
.review summary {
  display: flex; justify-content: space-between; padding: 12px 16px;
  cursor: pointer; font-weight: 700; list-style: none;
}
.review summary::-webkit-details-marker { display: none; }
.review-correct summary { color: var(--good); }
.review-wrong summary { color: var(--bad); }
.review-body { padding: 6px 16px 16px; border-top: 2px dashed var(--rule); }
.review-options { display: flex; gap: 18px; flex-wrap: wrap; margin: 12px 0; align-items: center; }
.review-opt { display: flex; align-items: center; gap: 8px; }
.tag {
  font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  border-radius: 2px; padding: 3px 8px; border: 2px solid;
}
.tag-correct { background: var(--good-soft); color: var(--good); border-color: var(--good); }
.tag-wrong { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.review-explanation { color: var(--ink-soft); margin: 8px 0 0; }

/* ---------- simulation report ---------- */
.sim-table { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.sim-row {
  display: grid; grid-template-columns: 140px 1fr 62px; gap: 14px; align-items: center;
  background: var(--paper-raised); border: 2px solid var(--rule); border-radius: 2px;
  padding: 11px 14px; font-variant-numeric: tabular-nums;
}
.sim-bar {
  height: 12px; background: var(--paper); border: 2px solid var(--rule);
  border-radius: 2px; overflow: hidden; display: block;
}
.sim-bar-fill { display: block; height: 100%; background: var(--marker); }
