/* =====================================================================
   FaStep Diagnostics — design system
   ---------------------------------------------------------------------
   Built from the platform design research (Oct 2026). Principles:
     · Restraint. One accent (FaStep blue), near-black ink, hairlines.
     · Official grammar. Official strip, arms-first co-branding,
       GOV.UK-grade focus ring, 24px+ targets, WCAG 2.2 AA throughout.
     · Periwinkle (#C8CFE9) is a SURFACE and RULE colour. Never text.
     · Shadows only on floating layers (menus, dialogs, drawers).

   Type roles
     Inter Tight      display and headings
     Inter            interface and body
     Source Serif 4   verdicts and certificate voice (sparingly)
     IBM Plex Mono    references, lot numbers, tokens
   ===================================================================== */

:root {
  /* Brand */
  --brand-600: #055AAD;   /* actions, links, active state — 6.84:1 on white */
  --brand-700: #04447F;   /* text on periwinkle, hover — 6.34:1 on peri-300 */
  --brand-800: #033A6E;   /* deep bands — white text 11.45:1 */
  --brand-900: #021F3D;   /* deepest ground */
  --brand-500: #2A74C0;
  --brand-100: #DCE7F5;
  --peri-300:  #C8CFE9;   /* rules, borders, decorative washes — never text */
  --peri-200:  #DCE1F1;
  --peri-100:  #EEF1F9;   /* selected row, info surface, tag wash */

  /* Neutrals — cool, tuned to the blue */
  --ink:     #0B1F33;     /* body text 16.69:1 */
  --ink-2:   #4A5A6E;     /* secondary 7.05:1 */
  --ink-3:   #5B6577;     /* captions 5.88:1 */
  --ink-4:   #8792A3;     /* placeholders, disabled (non-essential only) */
  --line:        #DDE2EE;
  --line-soft:   #E9ECF4;
  --line-strong: #B9C2D8;
  --canvas:  #F6F7FB;
  --surface: #FFFFFF;
  --sunken:  #EFF2F8;

  /* Semantic — text-on-tint pairs all >= 4.7:1 */
  --ok:   #0F7A52;  --ok-bg:   #E7F4EE;  --ok-line:   #A9D8C3;
  --warn: #8A5300;  --warn-bg: #FFF4E0;  --warn-line: #EBCB8F;
  --bad:  #B42318;  --bad-bg:  #FDECEA;  --bad-line:  #F1B7B0;
  --info: var(--brand-700); --info-bg: var(--peri-100); --info-line: var(--peri-300);
  --focus: #FFDD00; --focus-ink: #0B0C0C;

  /* Specimen hues — used only as small accents next to a word */
  --sp-saliva: #0F7A52; --sp-urine: #A16207; --sp-hair: #6D4FA3; --sp-blood: #B42318; --sp-unknown: #6B7686;

  /* Type */
  --f-display: "Inter Tight", Inter, system-ui, -apple-system, sans-serif;
  --f-ui:      Inter, system-ui, -apple-system, sans-serif;
  --f-serif:   "Source Serif 4", Georgia, "Times New Roman", serif;
  --f-mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Space — 4px base */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

  /* Radius varies by size */
  --r-xs: 4px; --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-pill: 999px;

  /* Elevation — floating layers only */
  --shadow-pop:   0 2px 4px -2px rgba(5,40,90,.10), 0 12px 24px -6px rgba(5,40,90,.12);
  --shadow-float: 0 4px 10px -4px rgba(5,40,90,.12), 0 28px 56px -16px rgba(5,40,90,.24);
  --shadow-hair:  0 1px 0 rgba(5,40,90,.04);

  --ease: cubic-bezier(.2,.8,.2,1);
  --t-fast: 150ms; --t-med: 250ms;
}

/* ── Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font: 400 1rem/1.55 var(--f-ui);
  font-feature-settings: "cv11", "ss01";
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 { margin: 0; font-family: var(--f-display); font-weight: 600; color: var(--ink); text-wrap: balance; }
h1 { font-size: clamp(1.875rem, 1.3rem + 1.8vw, 2.5rem); line-height: 1.15; letter-spacing: -0.02em; }
h2 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -0.015em; }
h3 { font-family: var(--f-ui); font-size: 1.25rem; line-height: 1.4; letter-spacing: -0.01em; }
h4 { font-family: var(--f-ui); font-size: 1rem; line-height: 1.4; }
p  { margin: 0; text-wrap: pretty; }

a { color: var(--brand-600); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-700); text-decoration-thickness: 2px; }

img { max-width: 100%; }
code, kbd, samp, .mono { font-family: var(--f-mono); font-size: .875em; letter-spacing: 0; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; }
table { font-variant-numeric: tabular-nums; }

/* Focus — the GOV.UK pattern: unmistakable, official, works on any ground */
:focus-visible {
  outline: 3px solid transparent;
  box-shadow: 0 0 0 3px var(--focus), 0 0 0 6px var(--focus-ink);
  border-radius: var(--r-xs);
}
a:focus-visible { background: var(--focus); color: var(--focus-ink); box-shadow: 0 -2px var(--focus), 0 4px var(--focus-ink); text-decoration: none; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: var(--s4); top: -100px; z-index: 999; padding: var(--s3) var(--s4); background: var(--focus); color: var(--focus-ink); font-weight: 600; }
.skip-link:focus { top: var(--s4); }

::selection { background: var(--brand-100); color: var(--ink); }

/* ── Official strip — on every page ───────────────────────────────── */
.fs-official { background: var(--peri-100); border-bottom: 1px solid var(--peri-300); font-size: 13px; color: var(--ink-2); }
.fs-official__in { display: flex; align-items: center; gap: var(--s3); min-height: 36px; padding: 0 var(--s5); max-width: 1320px; margin: 0 auto; }
.fs-official__arms { height: 20px; width: auto; flex-shrink: 0; }
.fs-official__txt b { color: var(--ink); font-weight: 600; }
.fs-official details { margin-left: auto; }
.fs-official summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  color: var(--brand-700); font-weight: 500; padding: 6px 2px; border-radius: var(--r-xs);
}
.fs-official summary::-webkit-details-marker { display: none; }
.fs-official summary i { font-size: 11px; transition: transform var(--t-fast) var(--ease); }
.fs-official details[open] summary i { transform: rotate(180deg); }
.fs-official__panel {
  position: absolute; left: 0; right: 0; z-index: 70; background: var(--peri-100);
  border-bottom: 1px solid var(--peri-300); box-shadow: var(--shadow-pop);
}
.fs-official__grid { max-width: 1320px; margin: 0 auto; padding: var(--s5); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s5); }
.fs-official__item { display: flex; gap: var(--s3); align-items: flex-start; }
.fs-official__item i { color: var(--brand-600); font-size: 18px; width: 22px; margin-top: 2px; text-align: center; }
.fs-official__item b { display: block; color: var(--ink); font-size: 14px; margin-bottom: 2px; }
.fs-official__item p { font-size: 13px; line-height: 1.5; color: var(--ink-2); }
@media (max-width: 760px) {
  .fs-official__txt span { display: none; }
  .fs-official__grid { grid-template-columns: 1fr; }
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.fs-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s5);
  font: 500 15px/1 var(--f-ui); letter-spacing: -0.005em;
  border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform 80ms var(--ease);
}
.fs-btn:hover { text-decoration: none; }
.fs-btn:active { transform: translateY(1px); }
.fs-btn i { font-size: .95em; }
.fs-btn--lg { min-height: 52px; padding: 0 var(--s6); font-size: 16px; }
.fs-btn--sm { min-height: 34px; padding: 0 var(--s3); font-size: 13px; }
.fs-btn--block { width: 100%; }

.fs-btn--primary { background: var(--brand-600); color: #fff; }
.fs-btn--primary:hover { background: var(--brand-700); color: #fff; }
.fs-btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.fs-btn--secondary:hover { border-color: var(--ink-3); color: var(--ink); background: var(--surface); }
.fs-btn--ghost { background: transparent; color: var(--brand-600); }
.fs-btn--ghost:hover { background: var(--peri-100); color: var(--brand-700); }
.fs-btn--inverse { background: #fff; color: var(--brand-800); }
.fs-btn--inverse:hover { background: var(--peri-100); color: var(--brand-800); }
.fs-btn--danger { background: var(--bad); color: #fff; }
.fs-btn--danger:hover { background: #8F1C13; color: #fff; }

/* ── Fields ───────────────────────────────────────────────────────── */
.fs-field { display: grid; gap: 6px; }
.fs-label { font-size: 15px; font-weight: 500; color: var(--ink); }
.fs-hint  { font-size: 13px; color: var(--ink-2); }
.fs-input, .fs-select, .fs-textarea {
  width: 100%; min-height: 48px; padding: 0 var(--s4);
  font: 400 16px/1.4 var(--f-ui); color: var(--ink);
  background: var(--surface); border: 2px solid var(--ink); border-radius: var(--r-sm);
  transition: box-shadow var(--t-fast) var(--ease);
}
.fs-textarea { padding: var(--s3) var(--s4); min-height: 96px; }
.fs-input::placeholder { color: var(--ink-4); }
.fs-input:focus, .fs-select:focus, .fs-textarea:focus { outline: 3px solid transparent; box-shadow: 0 0 0 3px var(--focus); }
.fs-input--mono { font-family: var(--f-mono); font-size: 15px; letter-spacing: .01em; }
.fs-field--error .fs-input { border-color: var(--bad); }
.fs-field--error { border-left: 4px solid var(--bad); padding-left: var(--s4); }
.fs-error-msg { color: var(--bad); font-weight: 600; font-size: 14px; }

.fs-icon-input { position: relative; }
.fs-icon-input > i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; font-size: 15px; }
.fs-icon-input .fs-input { padding-left: 44px; }

/* ── Status tag — dot + word, never colour alone ──────────────────── */
.fs-tag {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border-radius: var(--r-sm); font: 600 12px/1 var(--f-ui); letter-spacing: .01em; white-space: nowrap;
  background: var(--sunken); color: var(--ink-2); border: 1px solid var(--line);
}
.fs-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.fs-tag--ok   { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-line); }
.fs-tag--warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.fs-tag--bad  { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad-line); }
.fs-tag--info { background: var(--peri-100); color: var(--brand-700); border-color: var(--peri-300); }
.fs-tag--plain::before { display: none; }

/* Specimen tag: neutral chip with a coloured glyph */
.fs-spec { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 7px;
  border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line);
  font: 500 12px/1 var(--f-ui); color: var(--ink); white-space: nowrap; }
.fs-spec i { font-size: 11px; color: var(--spec, var(--ink-3)); }

/* Legacy alias kept for older templates */
.fs-pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 7px;
  border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line);
  font: 500 12px/1 var(--f-ui); color: var(--ink); white-space: nowrap; }
.fs-pill i { font-size: 11px; color: var(--pill, var(--ink-3)); }

/* ── Cards ────────────────────────────────────────────────────────── */
.fs-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.fs-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line-soft); }
.fs-card__head h2, .fs-card__head h3 { font-family: var(--f-ui); font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.fs-card__body { padding: var(--s5); }

/* ── Notification banners ─────────────────────────────────────────── */
.fs-alert { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s4) var(--s5);
  border-radius: var(--r-md); border: 1px solid; border-left-width: 4px; font-size: 15px; line-height: 1.5; }
.fs-alert > i { margin-top: 3px; }
.fs-alert--ok     { background: var(--ok-bg);   border-color: var(--ok-line);   border-left-color: var(--ok);   color: #0A5A3C; }
.fs-alert--error  { background: var(--bad-bg);  border-color: var(--bad-line);  border-left-color: var(--bad);  color: #8F1C13; }
.fs-alert--notice { background: var(--warn-bg); border-color: var(--warn-line); border-left-color: var(--warn); color: #6B4100; }
.fs-alert--info   { background: var(--peri-100); border-color: var(--peri-300); border-left-color: var(--brand-600); color: var(--brand-800); }

/* ── Eyebrow / overline ───────────────────────────────────────────── */
.fs-overline { font: 600 12px/1.3 var(--f-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--brand-600); }

/* ── Keyboard key ─────────────────────────────────────────────────── */
kbd.fs-kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  font: 500 11px/1 var(--f-mono); color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: var(--r-xs); }

/* ── Motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
