/* ==================================================================
   Screens
   ================================================================== */

/* ---- Home ---------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-xl);
  padding: var(--s-7) var(--s-5) var(--s-5);
  margin-bottom: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

/* A soft aurora behind the hero, clipped to its radius. Two blurred
   blobs rather than a flat gradient, so it has some depth to it. */
.hero::before {
  content: '';
  position: absolute;
  inset: -40% -20% auto -20%;
  height: 170%;
  background:
    radial-gradient(38% 46% at 18% 30%, color-mix(in srgb, var(--accent) 34%, transparent), transparent 70%),
    radial-gradient(34% 40% at 82% 18%, color-mix(in srgb, var(--g4) 30%, transparent), transparent 70%),
    radial-gradient(30% 38% at 60% 78%, color-mix(in srgb, var(--teal) 24%, transparent), transparent 70%);
  filter: blur(6px);
  opacity: 0.55;
  pointer-events: none;
}
.hero > * { position: relative; }

.hero .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
  padding: 4px var(--s-3);
  border-radius: var(--r-full);
  background: var(--glass-strong);
  border: 1px solid var(--line);
  font-size: var(--text-2xs);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-2);
}
.hero .eyebrow .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}

.hero h1 {
  font-size: clamp(1.75rem, 7vw, 2.25rem);
  margin-bottom: var(--s-2);
}
.hero > p {
  color: var(--ink-2);
  margin-bottom: var(--s-5);
  max-width: 36rem;
}
.hero .stats { margin-bottom: var(--s-5); }
.hero .stat {
  background: var(--glass-strong);
  border-color: color-mix(in srgb, var(--line) 70%, transparent);
  backdrop-filter: blur(8px);
}

.hero-actions { display: grid; gap: var(--s-2); grid-template-columns: 1fr; }
@media (min-width: 480px) { .hero-actions { grid-template-columns: 1.25fr 1fr; } }

/* The resume banner only exists when there is something to resume, so
   it is allowed to be loud. */
.resume {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4);
  border-radius: var(--r-lg);
  background: linear-gradient(120deg, var(--accent-soft), var(--surface) 140%);
  border: 1px solid var(--accent-soft-2);
  color: var(--accent-ink);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base);
}
.resume:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.resume .play {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}
.resume .play svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }
.resume .meter { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.resume strong { font-size: var(--text-sm); white-space: nowrap; }

.subject-grid { display: grid; gap: var(--s-3); }
@media (min-width: 640px) { .subject-grid { grid-template-columns: 1fr 1fr; } }

.subject-card { display: grid; gap: var(--s-2); }
.subject-card .title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
}
.subject-card h3 { margin: 0; font-size: var(--text-md); }
.subject-card .count {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--hue, var(--accent));
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-tight);
  white-space: nowrap;
}
.subject-card .breakdown {
  display: flex;
  gap: var(--s-2);
  font-size: var(--text-xs);
  color: var(--ink-3);
}
.subject-card .seen-bar { margin-top: var(--s-1); }

/* ---- Lists ------------------------------------------------------------ */
.list-card { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); }
.list-card .body { flex: 1; min-width: 0; }
.list-card h3 { margin: 0 0 3px; font-size: var(--text-base); font-weight: 620; }
.list-card p { margin: 0; font-size: var(--text-xs); color: var(--ink-3); }
.list-card .chevron { color: var(--ink-4); flex-shrink: 0; transition: transform var(--t-base) var(--ease-out), color var(--t-fast); }
.list-card:hover .chevron { transform: translateX(3px); color: var(--accent); }
.list-card .chevron svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

.section-pick {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.section-pick:last-child { border-bottom: 0; }
.section-pick:hover { background: var(--surface-2); }
.section-pick input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.section-pick .body { flex: 1; min-width: 0; }
.section-pick h4 { margin: 0 0 2px; font-size: var(--text-base); font-weight: 600; }

/* ---- Quiz --------------------------------------------------------------- */
.quiz-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
  font-size: var(--text-sm);
  color: var(--ink-2);
}
.quiz-head .counter {
  font-family: var(--font-sans);
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-snug);
}
.quiz-head .timer {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: var(--text-sm);
  padding: 4px var(--s-3);
  border-radius: var(--r-full);
  background: var(--surface-3);
}
.quiz-head .timer.low {
  background: var(--bad-soft);
  color: var(--bad-ink);
  animation: pulse-soft 1.4s ease-in-out infinite;
}
@keyframes pulse-soft { 50% { opacity: 0.6; } }

.question { animation: q-in var(--t-slow) var(--ease-out) both; }
@keyframes q-in { from { opacity: 0; transform: translateX(var(--q-from, 18px)); } to { opacity: 1; transform: none; } }
.question.back { --q-from: -18px; }

.q-path {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--ink-3);
  margin-bottom: var(--s-3);
}
/* A source can name several papers; the tag truncates rather than pushing
   the flag button off the row. */
.q-path .tag { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
.q-path > span:first-child { flex: 1 1 100%; }

.q-stem {
  font-family: var(--font-serif);
  font-size: clamp(1.0625rem, 4.4vw, 1.25rem);
  line-height: var(--leading-snug);
  letter-spacing: 0.002em;
  color: var(--ink);
  margin-bottom: var(--s-5);
}

/* A written or recall question is not a multiple choice, and looks enough
   like one to be mistaken for it. The hint says what to do with it. */
.q-hint {
  margin: calc(var(--s-4) * -1) 0 var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-inline-start: 3px solid var(--teal);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--teal-soft);
  color: var(--teal-ink);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}
[dir='rtl'] .q-hint { border-radius: var(--r-sm) 0 0 var(--r-sm); }

.self-mark-block { margin-top: var(--s-5); }
.mark-prompt {
  margin-bottom: var(--s-2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 620;
  color: var(--ink-2);
  text-align: center;
}

.options { display: grid; gap: var(--s-2); }

.option {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-3) var(--s-4);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  text-align: start;
  cursor: pointer;
  transition:
    border-color var(--t-fast),
    background var(--t-fast),
    transform var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.option:hover:not([disabled]) { border-color: var(--accent); background: var(--surface-2); }
.option:active:not([disabled]) { transform: scale(0.99); }

.option .key {
  display: grid;
  place-items: center;
  width: 27px; height: 27px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--line);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink-2);
  transition: all var(--t-fast);
}
.option .text { flex: 1; padding-top: 3px; }

.option.picked { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--ring); }
.option.picked .key { background: var(--accent); border-color: var(--accent); color: #fff; }

.option.right { border-color: var(--ok-line); background: var(--ok-soft); animation: pop var(--t-base) var(--ease-spring); }
.option.right .key { background: var(--ok); border-color: var(--ok); color: #fff; }

.option.wrong { border-color: var(--bad-line); background: var(--bad-soft); }
.option.wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }

.option[disabled] { cursor: default; }
.option[disabled]:not(.right):not(.wrong):not(.picked) { opacity: 0.55; }

@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.018); } 100% { transform: scale(1); } }

.parts { display: grid; gap: var(--s-2); }
.part {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.part .key { font-weight: 700; color: var(--accent); flex-shrink: 0; }

.recall-card {
  display: grid;
  place-items: center;
  gap: var(--s-3);
  min-height: 9.5rem;
  padding: var(--s-6) var(--s-4);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  text-align: center;
}
.recall-card .reveal {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--ok);
}

.answer-block {
  margin-top: var(--s-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface-2);
  overflow: hidden;
  animation: reveal var(--t-slow) var(--ease-out) both;
}
@keyframes reveal {
  from { opacity: 0; transform: translateY(-8px); max-height: 0; }
  to { opacity: 1; transform: none; max-height: 220vh; }
}
.answer-block .verdict-bar {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  font-family: var(--font-sans);
  font-weight: 650;
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}
.answer-block .verdict-bar svg { flex-shrink: 0; margin-top: 2px; }
.answer-block .verdict-bar .lead {
  flex-shrink: 0;
  opacity: 0.75;
  font-weight: 600;
}
.answer-block .verdict-bar .answer-text { flex: 1; min-width: 0; }
.answer-block.right .verdict-bar   { background: var(--ok-soft); color: var(--ok-ink); }
.answer-block.wrong .verdict-bar   { background: var(--bad-soft); color: var(--bad-ink); }
.answer-block.neutral .verdict-bar { background: var(--accent-soft); color: var(--accent-ink); }
.answer-block .why {
  padding: var(--s-4);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--ink-2);
  border-top: 1px solid var(--line);
}
.answer-block .why strong { color: var(--ink); }
.answer-block .why em {
  font-style: normal;
  background: var(--warn-soft);
  color: var(--warn-ink);
  padding: 0 4px;
  border-radius: var(--r-xs);
}

.quiz-actions {
  position: sticky;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  z-index: 20;
  margin-top: var(--s-5);
  padding: var(--s-4) 0 var(--s-2);
  background: linear-gradient(to top, var(--bg) 58%, transparent);
  display: flex;
  gap: var(--s-2);
}
@media (min-width: 900px) { .quiz-actions { bottom: 0; } }

.self-mark { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }

/* The question map: every question in the paper as a dot, so you can
   jump to anything you flagged without leaving the exam. */
.qmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: var(--s-2);
  margin-top: var(--s-4);
}
.qmap button {
  position: relative;
  aspect-ratio: 1;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: all var(--t-fast);
}
.qmap button:hover { border-color: var(--accent); transform: translateY(-2px); }
.qmap button.answered { background: var(--accent-soft); border-color: var(--accent-soft-2); color: var(--accent-ink); }
.qmap button.right { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-ink); }
.qmap button.wrong { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad-ink); }
.qmap button.current { border-color: var(--accent); box-shadow: var(--ring); }
.qmap button.flagged::after {
  content: '';
  position: absolute;
  top: 3px; inset-inline-end: 3px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--warn);
}

.qmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-top: var(--s-4);
  font-size: var(--text-xs);
  color: var(--ink-3);
}
.qmap-legend span { display: inline-flex; align-items: center; gap: 6px; }
.qmap-legend i { width: 10px; height: 10px; border-radius: 3px; border: 1.5px solid var(--line); }
.qmap-legend i.answered { background: var(--accent-soft); border-color: var(--accent-soft-2); }
.qmap-legend i.flagged { background: var(--warn); border-color: var(--warn); }

/* ---- Results -------------------------------------------------------------- */
.score-ring {
  display: grid;
  place-items: center;
  width: 156px; height: 156px;
  margin: 0 auto var(--s-4);
  border-radius: 50%;
  background: conic-gradient(var(--ring-color, var(--accent)) calc(var(--pct, 0) * 1%), var(--line) 0);
  position: relative;
  animation: ring-in var(--t-slower) var(--ease-out) both;
}
.score-ring::before {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}
.score-ring .value { position: relative; text-align: center; }
.score-ring b {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--text-3xl);
  font-weight: 720;
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
  line-height: var(--leading-none);
}
.score-ring span {
  font-size: var(--text-2xs);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  font-weight: 650;
}
@keyframes ring-in { from { transform: scale(0.88); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Progress --------------------------------------------------------------- */
.activity { display: flex; align-items: flex-end; gap: 3px; height: 76px; padding: var(--s-2) 0; }
.activity .day {
  flex: 1;
  min-width: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent-soft);
  position: relative;
  transition: background var(--t-fast);
}
.activity .day > i { position: absolute; inset: auto 0 0 0; border-radius: inherit; background: var(--accent); }
.activity .day.empty { background: var(--line-faint); }

.weak-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-1) var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.weak-row:last-child { border-bottom: 0; }
.weak-row h4 { margin: 0; font-size: var(--text-sm); font-weight: 620; }
.weak-row small { grid-column: 1; font-size: var(--text-xs); }
.weak-row .pct {
  grid-row: 1 / span 2;
  grid-column: 2;
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.weak-row .pct.low  { color: var(--bad); }
.weak-row .pct.mid  { color: var(--warn); }
.weak-row .pct.high { color: var(--ok); }
.weak-row .meter { grid-column: 1 / -1; }

.coverage-row { display: grid; gap: var(--s-1); padding: var(--s-2) 0; }
.coverage-row .label { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--text-sm); }
.coverage-row .label b { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 620; }

/* ---- Search -------------------------------------------------------------------- */
.search-result {
  display: block;
  width: 100%;
  text-align: start;
  padding: var(--s-3) var(--s-4);
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--t-fast);
}
.search-result:last-child { border-bottom: 0; }
.search-result:hover { background: var(--surface-2); }
.search-result .stem { font-size: var(--text-sm); margin-bottom: var(--s-1); }
.search-result mark { background: var(--warn-soft); color: var(--warn-ink); border-radius: var(--r-xs); padding: 0 3px; }
.search-result .path { font-size: var(--text-xs); color: var(--ink-3); }

/* ---- Combos --------------------------------------------------------------------- */
.combo-table + .combo-table { margin-top: var(--s-5); }
.combo-table > h3 { font-size: var(--text-base); margin-bottom: var(--s-2); }

/* ---- Settings ----------------------------------------------------------------------- */
.setting-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4); border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .body { flex: 1; min-width: 0; }
.setting-row h4 { margin: 0 0 3px; font-size: var(--text-base); }
.setting-row p { margin: 0; font-size: var(--text-xs); color: var(--ink-3); }

.sync-code {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-align: center;
  padding: var(--s-4);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  user-select: all;
}

/* ---- Setup sheet ---------------------------------------------------------------------- */
.setup-group { margin-bottom: var(--s-5); }
.setup-group > label {
  display: block;
  margin-bottom: var(--s-2);
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-3);
}
.count-display { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--s-2); }
.count-display b {
  font-family: var(--font-sans);
  font-size: var(--text-2xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-tight);
}
.count-display small { color: var(--ink-3); }

@media print {
  .topbar, .tabbar, .quiz-actions, .toast-host, .sheet-host, .icon-btn, .progress-rail { display: none !important; }
  body { padding: 0; background: #fff; }
  .card { break-inside: avoid; box-shadow: none; }
}
