/* ==========================================================================
   Fovea — components
   Every interactive target is >=44px on its primary axis (WCAG 2.2 SC 2.5.8
   asks for 24px; we take 44 because a mis-tap here is a wrong answer in a
   measurement, not just a nuisance).
   ========================================================================== */

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

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text-1);
  --btn-border: transparent;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  letter-spacing: var(--tracking-snug);
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: var(--border-width) solid var(--btn-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-instant) var(--ease-out);
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  --btn-bg: var(--btn-primary-bg);
  --btn-fg: var(--btn-primary-fg);
  --btn-border: var(--btn-primary-bg);
  box-shadow: var(--shadow-xs);
}
.btn--primary:hover:not(:disabled) {
  --btn-bg: var(--btn-primary-bg-hov);
  --btn-border: var(--btn-primary-bg-hov);
}

.btn--secondary {
  --btn-bg: var(--surface-0);
  --btn-fg: var(--text-1);
  --btn-border: var(--border-2);
}
.btn--secondary:hover:not(:disabled) {
  --btn-bg: var(--surface-1);
  --btn-border: var(--border-3);
}

.btn--ghost { --btn-fg: var(--text-2); }
.btn--ghost:hover:not(:disabled) { --btn-bg: var(--surface-1); --btn-fg: var(--text-1); }

.btn--danger {
  --btn-bg: var(--error-bg);
  --btn-fg: var(--error-fg);
  --btn-border: var(--error-border);
}

.btn--lg { min-height: 52px; padding: var(--space-4) var(--space-8); font-size: var(--text-lg); }
.btn--sm { min-height: 36px; padding: var(--space-2) var(--space-3); font-size: var(--text-sm); }
.btn--block { width: 100%; }
.btn--icon { padding: var(--space-3); min-width: 44px; }

.btn .icon { flex: none; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface-0);
  border: var(--border-width) solid var(--border-1);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.card--raised { box-shadow: var(--shadow-sm); }
.card--sunken { background: var(--surface-1); border-color: transparent; }
.card--flush  { padding: 0; overflow: hidden; }

/* A test in the suite grid. The whole card is one link target. */
.test-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--surface-0);
  border: var(--border-width) solid var(--border-1);
  border-radius: var(--radius-lg);
  color: inherit;
  text-decoration: none;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.test-card:hover {
  border-color: var(--border-3);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.test-card__icon {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--text-brand);
  flex: none;
}

/* A live miniature of the test's own stimulus, rather than an icon. */
.test-card__media {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  flex: none;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-1);
  border: var(--border-width) solid var(--border-1);
}
.test-card__media .preview { display: block; }

.test-card__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-snug);
}

.test-card__desc { color: var(--text-2); font-size: var(--text-sm); flex: 1; }

.test-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  font-size: var(--text-xs);
  color: var(--text-3);
}

/* ----------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.2em 0.6em;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.5;
  border-radius: var(--radius-full);
  border: var(--border-width) solid var(--border-1);
  background: var(--surface-1);
  color: var(--text-2);
  white-space: nowrap;
}

/* Status is never carried by colour alone — each variant also gets an icon
   from the sprite and a text label, so a colour-blind user (our core audience)
   reads the same information. */
.badge--ok    { background: var(--ok-bg);    color: var(--ok-fg);    border-color: var(--ok-border); }
.badge--watch { background: var(--watch-bg); color: var(--watch-fg); border-color: var(--watch-border); }
.badge--error { background: var(--error-bg);  color: var(--error-fg);  border-color: var(--error-border); }
.badge--info  { background: var(--info-bg);  color: var(--info-fg);  border-color: var(--info-border); }

.badge--lg { font-size: var(--text-sm); padding: 0.35em 0.8em; }

/* -------------------------------------------------------------- callouts */

.callout {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-5);
  border: var(--border-width) solid var(--border-1);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  background: var(--surface-1);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.callout__icon { flex: none; margin-top: 2px; }
.callout__body { flex: 1; }
.callout__title {
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  margin-bottom: var(--space-1);
}

.callout--info  { background: var(--info-bg);  border-color: var(--info-border);  color: var(--info-fg); }
.callout--ok    { background: var(--ok-bg);    border-color: var(--ok-border);    color: var(--ok-fg); }
.callout--watch { background: var(--watch-bg); border-color: var(--watch-border); color: var(--watch-fg); }
.callout--error { background: var(--error-bg);  border-color: var(--error-border);  color: var(--error-fg); }

/* The medical disclaimer. Deliberately not dismissible and not collapsible —
   it sits in the reading path directly above every result headline. */
.disclaimer {
  border: 2px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  background: var(--surface-1);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--text-1);
}
.disclaimer strong { font-weight: var(--weight-bold); }
.disclaimer p + p { margin-top: var(--space-3); }

/* ----------------------------------------------------------------- inputs */

.field { display: flex; flex-direction: column; gap: var(--space-2); }

.field__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-1);
}

.field__hint { font-size: var(--text-sm); color: var(--text-2); }
.field__error { font-size: var(--text-sm); color: var(--error-fg); font-weight: var(--weight-medium); }

.input {
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-0);
  color: var(--text-1);
  border: var(--border-width) solid var(--border-2);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease-out);
  width: 100%;
}
.input:hover { border-color: var(--border-3); }
.input::placeholder { color: var(--text-3); }

/* Choice chips — the answer buttons during a test. */
.chip-group { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.chip {
  min-width: 52px;
  min-height: 52px;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  background: var(--surface-0);
  border: 2px solid var(--border-2);
  border-radius: var(--radius-md);
  transition: all var(--dur-fast) var(--ease-out);
}
.chip:hover  { border-color: var(--brand-500); background: var(--surface-1); }
.chip[aria-pressed="true"] {
  border-color: var(--brand-600);
  background: var(--brand-600);
  color: #fff;
}

/* Inside a test surface the chips must stay neutral — no brand hue anywhere
   near a colour plate. */
:root[data-test-mode] .chip {
  color: var(--test-fg);
  background: var(--test-panel);
  border-color: var(--test-border);
}
:root[data-test-mode] .chip:hover { border-color: var(--test-fg); background: var(--test-bg); }
:root[data-test-mode] .chip[aria-pressed="true"] {
  background: var(--test-fg);
  color: var(--test-bg);
  border-color: var(--test-fg);
}

/* Toggle switch. */
.switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  position: relative;
  width: 44px; height: 26px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  border: var(--border-width) solid var(--border-2);
  transition: background var(--dur-fast) var(--ease-out);
  flex: none;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface-0);
  box-shadow: var(--shadow-xs);
  transition: transform var(--dur-fast) var(--ease-out);
}
.switch input:checked + .switch__track { background: var(--brand-600); border-color: var(--brand-600); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--brand-500); outline-offset: 2px; }

/* Checkbox used by the validity gate — larger than default, never pre-checked. */
.check {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  min-height: 44px;
  transition: background var(--dur-fast) var(--ease-out);
}
.check:hover { background: var(--surface-1); }
.check input[type="checkbox"] {
  width: 22px; height: 22px;
  margin-top: 1px;
  flex: none;
  accent-color: var(--brand-600);
  cursor: pointer;
}

/* --------------------------------------------------------------- progress */

.progress {
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--brand-600);
  border-radius: inherit;
  transition: width var(--dur-normal) var(--ease-out);
}

:root[data-test-mode] .progress { background: var(--test-border); }
:root[data-test-mode] .progress__bar { background: var(--test-fg); }

/* Step rail for the full screening. */
.rail { display: flex; gap: var(--space-1); }
.rail__step {
  flex: 1;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
}
.rail__step[data-state="done"]    { background: var(--ok-fg); }
.rail__step[data-state="current"] { background: var(--brand-600); }

/* ------------------------------------------------------------------ table */

.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: var(--border-width) solid var(--border-1);
  vertical-align: top;
}
.table th {
  font-weight: var(--weight-semibold);
  color: var(--text-2);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}
.table tbody tr:last-child td { border-bottom: none; }
.table__num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }

/* ------------------------------------------------------------------ chrome */

.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  height: var(--header-height);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--surface-0) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: var(--border-width) solid var(--border-1);
}

/* ---------------------------------------------------------------------------
   TEST MODE CHROME
   Everything tinted is suppressed the moment a measurement starts. This is not
   a stylistic preference: a saturated button beside a colour plate shifts the
   plate's perceived hue through simultaneous contrast, and navigation next to a
   stimulus invites the eye away from it mid-trial. The chrome collapses to a
   single exit affordance in the plate's own neutral grey.
   --------------------------------------------------------------------------- */
:root[data-test-mode] .site-header {
  background: var(--test-panel);
  border-bottom-color: var(--test-border);
  backdrop-filter: none;
}
:root[data-test-mode] .site-footer,
:root[data-test-mode] .site-nav--main,
:root[data-test-mode] #theme-toggle,
:root[data-test-mode] .site-nav__menu { display: none; }

:root[data-test-mode] body { background: var(--test-bg); color: var(--test-fg); }

/* No brand colour may reach a test surface — buttons included. */
:root[data-test-mode] .btn--primary {
  --btn-bg: var(--test-fg);
  --btn-fg: var(--test-bg);
  --btn-border: var(--test-fg);
  box-shadow: none;
}
:root[data-test-mode] .btn--primary:hover:not(:disabled) {
  --btn-bg: var(--test-fg-2);
  --btn-border: var(--test-fg-2);
}
:root[data-test-mode] .btn--secondary {
  --btn-bg: var(--test-panel);
  --btn-fg: var(--test-fg);
  --btn-border: var(--test-border);
}
:root[data-test-mode] .btn--secondary:hover:not(:disabled) {
  --btn-bg: var(--test-bg);
  --btn-border: var(--test-fg);
}
:root[data-test-mode] .btn--ghost { --btn-fg: var(--test-fg); }
:root[data-test-mode] .btn--ghost:hover:not(:disabled) { --btn-bg: var(--test-panel); }

.site-header__inner { display: flex; align-items: center; gap: var(--space-5); width: 100%; }

.site-nav { display: flex; align-items: center; gap: var(--space-1); }

.site-nav a {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}
.site-nav a:hover { background: var(--surface-1); color: var(--text-1); }
.site-nav a[aria-current="page"] { color: var(--text-1); background: var(--surface-2); }

@media (max-width: 52rem) {
  .site-nav--main { display: none; }
}

.site-footer {
  margin-top: var(--space-24);
  padding-block: var(--space-10);
  border-top: var(--border-width) solid var(--border-1);
  background: var(--surface-1);
  font-size: var(--text-sm);
  color: var(--text-2);
}

/* ------------------------------------------------------------------ misc */

.divider { height: 1px; background: var(--divider-color, var(--border-1)); border: 0; }

.kbd {
  display: inline-block;
  padding: 0.15em 0.45em;
  font-family: var(--font-mono);
  font-size: 0.85em;
  border: var(--border-width) solid var(--border-2);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  background: var(--surface-1);
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-2);
  border-top-color: var(--brand-600);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
