/* Transition Logic — practice test demo
   Palette and type follow brand/brand-guide.md §2a (web, dark) and §3.
   Mono is the machine's voice: counters, values, pin labels, code, chips.
   Poppins is ours: headings and prose. */

:root {
  --ground: #121212;
  --panel: #1c1c1c;
  --panel-up: #242424;
  --bone: #e8e6e1;
  --ash: #a0a09b;
  --slate: #6e6e6a;
  --teal: #14b8a6;
  --teal-deep: #0f766e;
  --hairline: #2e2e2e;
  --amber: #f59e0b;

  --sans: 'Poppins', 'Montserrat', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  --col: 44rem;
  --r: 4px;

  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Author display rules (.figure is flex) outrank the UA rule for [hidden]. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Kill the translucent blue tap flash — it reads as a rendering fault on a
   dark ground — and the 300ms delay older mobile browsers add before click. */
button, .choice, summary, select, input {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--bone);
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.65;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#cr-measure {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}

main {
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 20px 72px;
}

h1, h2, h3 { font-weight: 600; margin: 0; }

::selection { background: var(--teal-deep); color: var(--bone); }

:where(a, button, input, select, summary):focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: baseline;
  gap: 12px;
  max-width: var(--col);
  margin: 0 auto;
  padding: calc(22px + env(safe-area-inset-top, 0px)) 20px 30px;
}

.wordmark {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--bone);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* The block cursor — the mark rests at the point where the next state gets written. */
.cursor {
  display: inline-block;
  width: 9px;
  height: 17px;
  background: var(--teal);
  transform: translateY(2px);
}

.masthead-tag {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
}

/* ---------- intro ---------- */

.screen { animation: fade 240ms ease-out; }

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
  margin: 0 0 14px;
}

.hero h1 {
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin-bottom: 20px;
}

.hero-dim { color: var(--slate); }

.lede {
  color: var(--ash);
  margin: 0;
  max-width: 62ch;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 34px;
  margin: 34px 0;
  padding: 20px 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.fact { margin: 0; }

.fact dt {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
  margin-bottom: 3px;
}

.fact dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--bone);
}

.fact-topics {
  font-size: 13px !important;
  color: var(--ash) !important;
  max-width: 34ch;
  line-height: 1.5;
}

/* ---------- panels & forms ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 26px;
  margin-bottom: 20px;
}

.panel-title { font-size: 18px; margin-bottom: 4px; }

.panel-note {
  color: var(--slate);
  font-size: 13px;
  margin: 0 0 20px;
}

.field-group {
  border: 0;
  padding: 0;
  margin: 0 0 28px;
}

.field-group legend {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
  padding: 0;
  margin-bottom: 14px;
}

.timer-choice { display: flex; gap: 12px; }

.choice { flex: 1; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }

.choice-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 18px;
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  background: var(--ground);
  transition: border-color 140ms, background 140ms;
}

.choice-value { font-family: var(--mono); font-size: 20px; color: var(--bone); }

.choice-note {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
}

.choice:hover .choice-body { border-color: var(--slate); }

.choice input:checked + .choice-body {
  border-color: var(--teal);
  background: var(--panel-up);
}

.choice input:checked + .choice-body .choice-value { color: var(--teal); }
.choice input:focus-visible + .choice-body { outline: 2px solid var(--teal); outline-offset: 3px; }

/* auto-fit rather than a fixed pair: the columns collapse whenever they'd get
   too narrow, which covers the 461-719px band no breakpoint was catching. */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 7px; }

.field-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
}

input[type='text'], select {
  font-family: var(--mono);
  /* 16px minimum: iOS Safari zooms the whole page on focus below this, and
     never zooms back out. Do not lower it for looks. */
  font-size: 16px;
  color: var(--bone);
  background: var(--ground);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 12px 14px;
  width: 100%;
  transition: border-color 140ms;
}

input[type='text']::placeholder { color: var(--slate); }
input[type='text']:hover, select:hover { border-color: var(--slate); }
input[type='text']:focus, select:focus { border-color: var(--teal); outline: none; }

select { appearance: none; cursor: pointer; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ash) 50%),
                    linear-gradient(135deg, var(--ash) 50%, transparent 50%);
  background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.hint { font-size: 13px; color: var(--slate); margin: 12px 0 0; }

kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel-up);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--ash);
}

/* ---------- buttons ---------- */

.btn {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--r);
  padding: 13px 26px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 140ms, border-color 140ms, color 140ms;
}

.btn-primary { background: var(--teal-deep); color: var(--bone); }
.btn-primary:hover { background: var(--teal); color: var(--ground); }

.btn-ghost { background: transparent; color: var(--ash); border-color: var(--hairline); }
.btn-ghost:hover { color: var(--bone); border-color: var(--slate); }

.btn-lg { width: 100%; padding: 16px 26px; }

/* ---------- resume + notices ---------- */

.resume, .notice {
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--amber);
  background: var(--panel);
  border-radius: var(--r);
  padding: 18px 20px;
  margin-bottom: 26px;
  font-size: 15px;
}

.resume p, .notice { margin: 0; }
.resume-actions { display: flex; gap: 10px; margin-top: 14px; }
.resume-actions .btn { padding: 9px 18px; font-size: 14px; }
.notice code { font-family: var(--mono); font-size: 13px; color: var(--ash); }

/* ---------- test screen ---------- */

.test-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.counter {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--bone);
}

.chip {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ash);
  border: 1px solid var(--hairline);
  border-radius: 2px;
  padding: 3px 9px;
}

.timer {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--ash);
  display: flex;
  align-items: baseline;
  gap: 1px;
  transition: color 200ms;
}

.timer-unit { font-size: 11px; color: var(--slate); }
.timer.is-urgent { color: var(--amber); }
.timer.is-urgent .timer-unit { color: var(--amber); }

/* A depleting hairline, not an anxious number. */
.timer-track {
  height: 2px;
  background: var(--hairline);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 24px;
}

.timer-fill {
  display: block;
  height: 100%;
  background: var(--teal);
  transform-origin: left center;
  transform: scaleX(1);
}

.timer-fill.is-urgent { background: var(--amber); }

.question-card { padding: 30px 26px; }
.question-card.is-expired { border-color: var(--amber); }

.figure {
  background: var(--ground);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 20px 16px;
  margin-bottom: 26px;
  display: flex;
  justify-content: center;
}

.figure-svg { width: 100%; height: auto; display: block; }
.figure-img { max-width: 100%; height: auto; }

.question {
  font-size: 20px;
  line-height: 1.4;
  margin-bottom: 26px;
}

.options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.option {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  text-align: left;
  background: var(--ground);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 15px 18px;
  color: var(--bone);
  font-family: var(--sans);
  font-size: 17px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms, transform 120ms;
}

.option:hover { border-color: var(--slate); background: var(--panel-up); }
.option:active { transform: scale(0.995); }

.option-key {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--slate);
  border: 1px solid var(--hairline);
  border-radius: 2px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: none;
  transition: color 120ms, border-color 120ms;
}

.option:hover .option-key { color: var(--ash); }

.option.is-chosen {
  border-color: var(--teal);
  background: var(--panel-up);
}

.option.is-chosen .option-key {
  color: var(--ground);
  background: var(--teal);
  border-color: var(--teal);
}

.kbd-hint { text-align: center; margin-top: 22px; }

/* ---------- circuit rendering ---------- */

.cr-stroke {
  stroke: var(--bone);
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cr-fill-none { fill: none; }
.cr-dot { fill: var(--bone); }

.cr-value, .cr-node-label, .cr-pin, .cr-polarity, .cr-box-label {
  font-family: var(--mono);
  font-size: 14px;
  fill: var(--ash);
  stroke: none;
}

.cr-node-label, .cr-box-label { fill: var(--bone); }

/* The value being asked for is the one thing worth an accent. */
.cr-unknown { fill: var(--teal); }

.cr-box { fill: var(--panel-up); stroke: var(--hairline); stroke-width: 2; }
.cr-arrowhead { fill: var(--bone); stroke: none; }

/* ---------- results ---------- */

.score-block { text-align: center; padding: 18px 0 36px; }

.score {
  font-family: var(--mono);
  font-size: 68px;
  line-height: 1;
  color: var(--teal);
  margin: 0 0 12px;
}

.score-total { color: var(--slate); font-size: 30px; }

.score-caption {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--slate);
  margin: 0;
}

.breakdown { display: flex; flex-direction: column; gap: 14px; }

.topic-row {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) 2fr auto;
  align-items: center;
  gap: 14px;
  opacity: 0;
  animation: fade 400ms ease-out forwards;
}

.topic-name { font-size: 15px; color: var(--bone); }

.topic-track {
  height: 6px;
  background: var(--ground);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  overflow: hidden;
}

.topic-fill {
  display: block;
  height: 100%;
  width: var(--w);
  background: var(--teal);
  animation: grow 620ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.topic-score { font-family: var(--mono); font-size: 14px; color: var(--ash); }

.review { display: flex; flex-direction: column; }

.review-item { border-top: 1px solid var(--hairline); }
.review-item:first-child { border-top: 0; }

.review-item summary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 0;
  cursor: pointer;
  font-size: 15px;
  line-height: 1.45;
  list-style: none;
}

.review-item summary::-webkit-details-marker { display: none; }

.review-mark { font-family: var(--mono); font-size: 14px; flex: none; }
.is-correct .review-mark { color: var(--teal); }
.is-wrong .review-mark { color: var(--amber); }

.review-num { font-family: var(--mono); font-size: 13px; color: var(--slate); flex: none; }
.review-q { color: var(--ash); }
.review-item[open] .review-q { color: var(--bone); }

.review-body {
  padding: 4px 0 20px 34px;
  font-size: 15px;
  color: var(--ash);
}

.review-body p { margin: 0 0 8px; }

.review-tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
  margin-right: 8px;
}

.review-exp {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--slate);
  border-left: 1px solid var(--hairline);
  padding-left: 14px;
  margin-top: 12px !important;
}

/* ---------- code blocks (brand §2a: no syntax rainbow) ---------- */

.code-block {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  color: var(--bone);
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 18px 20px;
  margin: 0;
  width: 100%;
  overflow-x: auto;
  text-align: left;
}

.tok-kw, .tok-pre { color: var(--teal); }
.tok-comment { color: var(--ash); }
.tok-str { color: var(--ash); }

/* ---------- footer ---------- */

.foot {
  border-top: 1px solid var(--hairline);
  max-width: var(--col);
  margin: 0 auto;
  padding: 22px 20px calc(30px + env(safe-area-inset-bottom, 0px));
}

.foot p { margin: 0; font-size: 13px; color: var(--slate); }
.mono { font-family: var(--mono); }

/* ---------- motion ---------- */

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes grow {
  from { width: 0; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.question-card.is-entering .figure,
.question-card.is-entering .question,
.question-card.is-entering .options li {
  opacity: 0;
  animation: rise 360ms cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.question-card.is-entering .question { animation-delay: 40ms; }
.question-card.is-entering .options li:nth-child(1) { animation-delay: 90ms; }
.question-card.is-entering .options li:nth-child(2) { animation-delay: 130ms; }
.question-card.is-entering .options li:nth-child(3) { animation-delay: 170ms; }
.question-card.is-entering .options li:nth-child(4) { animation-delay: 210ms; }
.question-card.is-entering .options li:nth-child(5) { animation-delay: 250ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .topic-fill { width: var(--w); }
}

/* ---------- wider screens ---------- */

@media (min-width: 720px) {
  body { font-size: 19px; }
  .hero h1 { font-size: 44px; }
  .question { font-size: 22px; }
  .panel { padding: 32px; }
  .question-card { padding: 36px 32px; }
  .score { font-size: 84px; }
}

@media (max-width: 620px) {
  .facts { gap: 14px 26px; }
  .topic-row { grid-template-columns: 1fr auto; grid-template-areas: 'name score' 'track track'; }
  .topic-name { grid-area: name; font-size: 16px; }
  .topic-score { grid-area: score; }
  .topic-track { grid-area: track; }
  .kbd-hint { display: none; }

  /* Reclaim width for the drawings: main + panel + figure padding was eating
     ~120px of a 390px screen, which is what shrank the schematics. */
  main { padding-left: 14px; padding-right: 14px; }
  .panel { padding: 22px 16px; }
  .question-card { padding: 22px 14px; }
  .figure { padding: 12px 6px; margin-bottom: 20px; }

  /* Diagram text is sized in viewBox units, so it scales down with the
     drawing. Bump it so labels stay legible once the circuit is scaled. */
  .cr-value, .cr-node-label, .cr-pin, .cr-polarity, .cr-box-label { font-size: 17px; }
  .cr-stroke { stroke-width: 2.8; }
  .figure-svg { max-height: 46vh; }

  /* Bigger, not smaller: these are thumb targets on a phone. */
  .option { font-size: 17px; padding: 17px 16px; gap: 13px; }
  .option-key { width: 26px; height: 26px; font-size: 13px; }
  .question { font-size: 21px; }
  .hint { font-size: 14px; }
  .chip { font-size: 12px; }
  .review-item summary { font-size: 16px; padding: 16px 0; }
  .score-caption { font-size: 14px; }
  .btn-lg { padding: 18px 26px; font-size: 17px; }
}
