/* 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;
  /* The shadow of anything that floats over the page (dialogs, the admin section card): short, with a border. */
  --shadow-float: 0 2px 6px rgb(29 36 51 / 0.2);

  --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-3) var(--space-2) var(--space-4);
}

.site-logo { display: flex; justify-content: center; margin-bottom: var(--space-3); }
.site-logo img { height: clamp(80px, 20vw, 112px); width: auto; }

[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); }
.title-full { display: block; margin-top: var(--space-1); font-size: clamp(1.2rem, 4vw, 1.6rem); font-weight: 400; color: var(--ink-soft); }
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"], select {
  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"], select[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);
}

/* The test set's label, so the researcher can check the set (PLAN.md §9 D38). */
.set-tag {
  display: inline-block;
  border: 1.5px solid var(--blue);
  color: var(--blue);
  font-weight: 700;
  padding: 0.2rem 0.7rem;
  border-radius: var(--radius-control);
  margin: 0 0 var(--space-3);
}

.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; }
/* "Sesi Latihan 1 dari 2" and "Akhiri tes" both fit on one line, even at 320px wide. */
.test-bar .practice-tag, .test-bar button { white-space: nowrap; }
.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.color-red { color: #c4161c; }
/* Pure yellow (#f6d106) is 1.4:1 on the page background, so the yellow digit is a mustard
   that reaches 3:1, the WCAG minimum for large text. */
.stimulus.color-yellow { color: #b58900; }
.stimulus.color-blue { color: #1a56db; }
.stimulus.feedback { font-size: clamp(2.5rem, 12vw, 4.5rem); }
/* The mask is a fixed size, about a normal digit's height, whatever the digit size was. */
.mask {
  width: calc(clamp(6rem, 28vw, 11rem) * 0.75);
  height: calc(clamp(6rem, 28vw, 11rem) * 0.75);
}
.mask svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--ink);
  stroke-width: 6;
}
.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 { position: relative; text-align: center; }
/* "Tes dimulai dalam..." sits above the countdown number without moving it, so the number
   stays where the digits will appear. */
.stimulus-lead {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 2rem);
  margin: 0 0 var(--space-1);
  font-size: clamp(1.25rem, 5vw, 1.75rem);
  font-weight: 700;
  color: var(--blue);
}
.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 */
.identity {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem var(--space-2);
  margin: 0 0 var(--space-3);
}
.identity dt { color: var(--ink-soft); }
.identity dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.accuracy { margin-bottom: var(--space-4); }
.accuracy-label { color: var(--ink-soft); margin-bottom: 0.25rem; }
.accuracy-value {
  font-size: clamp(3.5rem, 14vw, 5rem);
  font-weight: 700;
  line-height: 1;
  color: var(--blue);
  margin-bottom: var(--space-1);
}
.accuracy-hint { color: var(--ink-soft); font-size: 0.95rem; margin: 0; }

/* Dialog: a raised surface, with a short shadow and a border (--shadow-float). */
dialog {
  border: 1.5px solid var(--edge);
  border-radius: var(--radius-panel);
  padding: var(--space-3);
  max-width: min(26rem, calc(100vw - 2rem));
  color: var(--ink);
  box-shadow: var(--shadow-float);
}
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); }

.result-actions { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.closing-note { font-size: 1.125rem; font-weight: 700; color: var(--blue); margin: 0; }
