/* Atkinson Hyperlegible 5.3.0 (Fontsource build), served from this site so the
   participant's browser never contacts Google. Licence: public/fonts/OFL.txt. */
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-latin-700-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-latin-400-italic.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-latin-ext-400-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-latin-ext-700-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-latin-ext-400-italic.woff2) format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* Institution colours from DESIGN.md. Yellow fails contrast on light backgrounds
   (1.5:1), so it is only ever a fill behind dark ink, never text or a border. */
:root {
  --blue: #093697;
  --yellow: #f6d106;
  --ink: #1d2433;
  --ink-soft: #4a5162;
  --paper: #fbf8f1;
  --surface: #ffffff;
  --edge: #8a8f9c;
  --error: #a3261b;

  --radius-control: 6px;
  --radius-panel: 12px;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
}

main {
  width: 100%;
  max-width: 38rem;
  margin: 0 auto;
  padding: var(--space-4) var(--space-2);
}

[hidden] { display: none !important; }

h1, h2 { line-height: 1.2; margin: 0 0 var(--space-2); }
h1 { font-size: clamp(1.6rem, 5vw, 2.1rem); color: var(--blue); }
h2 { font-size: 1.2rem; }
p { margin: 0 0 var(--space-2); }

.panel {
  background: var(--surface);
  border-radius: var(--radius-panel);
  padding: var(--space-4) clamp(var(--space-2), 5vw, var(--space-4));
}

.lead { color: var(--ink-soft); font-size: 1.125rem; margin-bottom: var(--space-4); }

/* Form */
.field { margin-bottom: var(--space-3); }
label { display: block; font-weight: 700; margin-bottom: 0.35rem; }

input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 0.6rem 0.75rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--edge);
  border-radius: var(--radius-control);
}
input[aria-invalid="true"] { border-color: var(--error); border-width: 2px; }

.field-error { color: var(--error); font-weight: 700; margin: 0.35rem 0 0; }
.field-error::before { content: "! "; }

.consent {
  border-top: 1px solid var(--edge);
  padding-top: var(--space-3);
  margin: var(--space-4) 0 var(--space-3);
}
.placeholder { color: var(--ink-soft); font-style: italic; }

.check { display: flex; gap: 0.75rem; align-items: flex-start; font-weight: 400; cursor: pointer; }
.check input { width: 24px; height: 24px; margin: 0.1rem 0 0; flex: none; accent-color: var(--blue); }

/* Buttons */
button {
  font: inherit;
  font-weight: 700;
  min-height: 48px;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius-control);
  cursor: pointer;
}
.btn-primary { background: var(--blue); color: #fff; border: 2px solid var(--blue); }
.btn-secondary { background: var(--surface); color: var(--blue); border: 2px solid var(--blue); }
/* Hover only on devices that really hover, so a tap does not leave a button stuck dark. */
@media (hover: hover) {
  .btn-primary:hover { background: var(--ink); border-color: var(--ink); }
  .btn-secondary:hover { background: var(--paper); }
}

/* Blue ring, because yellow on white would be invisible (1.5:1). */
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

/* Instructions */
.steps { padding-left: 1.4rem; margin: 0 0 var(--space-3); }
.steps li { margin-bottom: var(--space-1); padding-left: 0.25rem; }
.steps li::marker { color: var(--blue); font-weight: 700; }

/* The one highlighter mark: the rule participants must not miss. */
mark { background: var(--yellow); color: var(--ink); padding: 0 0.2em; border-radius: 3px; font-weight: 700; }

kbd {
  font: inherit;
  font-weight: 700;
  padding: 0.05rem 0.45rem;
  border: 1.5px solid var(--edge);
  border-bottom-width: 3px;
  border-radius: 5px;
  background: var(--surface);
}

.practice-tag {
  display: inline-block;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 700;
  padding: 0.2rem 0.7rem;
  border-radius: var(--radius-control);
  margin-bottom: var(--space-2);
}

.status { color: var(--ink-soft); }
.status-error { color: var(--error); font-weight: 700; }
.status-error p::before { content: "! "; }

/* Test: digit on a plain background, nothing else competing for attention. */
.test {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}
.test-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2);
}
.test-bar .practice-tag { margin: 0; }
.test-bar button { margin-left: auto; }
.test-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.test-area:focus { outline: none; }
.stimulus {
  margin: 0;
  /* --digit-scale is set per trial when random font size is on (PLAN.md §9 D26). */
  font-size: calc(clamp(6rem, 28vw, 11rem) * var(--digit-scale, 1));
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stimulus.feedback { font-size: clamp(2.5rem, 12vw, 4.5rem); }
.stimulus.feedback-wrong { color: var(--error); }
.stimulus.feedback-correct { color: var(--blue); }
/* The digit, or the feedback title plus its reason, is centred as one block.
   The reason is removed while empty, so it never pushes a digit off centre. */
.stimulus-box { text-align: center; }
.stimulus-reason {
  max-width: min(30rem, calc(100vw - 2rem));
  text-wrap: balance;
  margin: var(--space-2) auto 0;
  font-size: clamp(1.15rem, 4.5vw, 1.4rem);
  font-weight: 700;
  color: var(--ink);
}
.stimulus-reason:empty { display: none; }

/* Results */
.accuracy { margin-bottom: var(--space-4); }
.accuracy-value {
  font-size: clamp(3.5rem, 14vw, 5rem);
  font-weight: 700;
  line-height: 1;
  color: var(--blue);
  margin-bottom: var(--space-1);
}
.accuracy-label { color: var(--ink-soft); }

.metrics { margin: 0 0 var(--space-4); border-top: 1px solid var(--edge); }
.metrics > div {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--edge);
}
.metrics dt { font-weight: 700; }
.metrics dd { margin: 0; font-weight: 700; font-size: 1.4rem; grid-row: span 2; align-self: center; font-variant-numeric: tabular-nums; }
.metrics p { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }

/* Dialog: the only raised surface, so it is the only one with a shadow. */
dialog {
  border: none;
  border-radius: var(--radius-panel);
  padding: var(--space-3);
  max-width: min(26rem, calc(100vw - 2rem));
  color: var(--ink);
  box-shadow: 0 12px 40px rgb(29 36 51 / 0.25);
}
dialog::backdrop { background: rgb(29 36 51 / 0.45); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-3); }
