/* ---------------------------------------------------------------------------
   My Health Records design system.

   This is ConnectAble's stylesheet (soniccombinator/ConnectAble src/index.css,
   itself a port of AdmitPath's), with their brand green swapped for MHI's
   official logo blue value for value. Only the hue changes: the spacing scale,
   radii, shadows, motion curves, focus ring and type scale are theirs.

   Green → blue map, applied everywhere below:
     #34613D primary        → #045184   MHI blue
     #264830 primary-hover  → #003361   MHI navy
     #EAF1EC primary-light  → #E6EEF5
     #CFE0D4 primary-border → #C7D8E8
     #17301F primary-deep   → #00223F
     #D8E5DC page bg        → #DBE6F0
     #EEF4F0 surface        → #EDF3F8
     rgba(52,97,61,a)       → rgba(4,81,132,a)

   MHI has no green anywhere, including status colors: a reading inside the
   normal range reads blue, not green (Mia G, MHI, Sep 2026).
--------------------------------------------------------------------------- */

:root {
  /* Brand — official MHI logo blues */
  --color-primary: #045184;
  --color-primary-hover: #003361;
  --color-primary-light: #E6EEF5;
  --color-primary-border: #C7D8E8;
  --color-primary-deep: #00223F;
  --color-primary-glow: rgba(4, 81, 132, 0.22);
  --color-primary-mid: #5F88C2;
  --color-primary-pale: #B5C6E0;

  /* Surfaces */
  --color-bg: #DBE6F0;
  --color-surface: #EDF3F8;
  --color-surface-raised: #FFFFFF;
  --color-surface-sunken: #E2EBF3;

  /* Text — contrast checked against both --color-bg and --color-surface */
  --color-text-primary: #1B2030;
  --color-text-secondary: #454B5E;
  --color-text-muted: #5A6275;
  /* Text on fills. On the brand gradient, which stays deep blue in both
     themes: white. On --color-primary, which lightens in dark mode: white
     in light, near-black in dark. On fixed light fills (the category
     table): near-black in both. --white is a surface, never a text colour:
     using it for text made every primary button 1.23:1 in dark mode (F12). */
  /* Field and control borders a low-vision reader can find: 3:1 or more on
     the card surface in both themes (F66). */
  --color-border-input: #7A8496;
  --color-on-brand: #FFFFFF;
  --color-on-primary: #FFFFFF;
  --color-ink: #0F172A;
  /* The logo blues, for brand surfaces (header, Home summary, landing hero,
     toasts) that stay deep blue in both themes, and a red fill that white
     text can sit on in both. Not redefined for dark mode, on purpose. */
  --brand-navy: #003361;
  --brand-blue: #045184;
  --color-error-strong: #B91C1C;
  --color-text-faint: #6B748A;

  --color-border: rgba(0, 0, 0, 0.06);
  --color-border-medium: rgba(0, 0, 0, 0.09);
  --color-border-strong: rgba(0, 0, 0, 0.13);

  /* Status. "Good" is blue here, not green. */
  --color-ok: #045184;
  --color-ok-light: #DBE6F4;
  --color-error: #DC2626;
  --color-error-light: #FEE2E2;
  --color-warning: #B45309;
  --color-warning-light: #FEF3C7;

  /* Type */
  --font-sans: 'Inter', 'Inter Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Lora', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;

  /* Spacing — 4px base grid */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* Radius — interactive elements stay at md/lg; xl+ reads as marketing */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  --shadow-xs: 0 1px 1px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.10), 0 4px 10px rgba(0,0,0,0.06);
  --shadow-primary: 0 8px 24px rgba(4, 81, 132, 0.20);

  /* Motion — 150–250ms ease-out for hover, never spring */
  --duration-fast: 150ms;
  --duration-hover: 200ms;
  --duration-normal: 300ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);

  --focus-ring-color: var(--color-primary);
  --focus-ring-width: 2px;
  --focus-ring-offset: 2px;
}

/* ---------------------------------------------------------------------------
   The three faces, self hosted (merged from fonts.css, F50, F52).

   Self hosted rather than fetched from fonts.googleapis.com: one fewer party
   receiving a visitor's address, and no font handshake on the critical path.

   Inter and JetBrains Mono are variable fonts: the files that were listed
   once per weight were byte-identical copies, so a page downloaded the same
   font up to five times. Each family is now declared once, with its weight
   range. latin-ext is kept, once, for accented names typed into the app;
   the browser downloads it only when such a character is on the page.

   "Inter Fallback" is Arial sized to Inter's metrics, so text does not jump
   when Inter arrives (F51).
--------------------------------------------------------------------------- */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-normal-400-latin.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: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-normal-400-latin-ext.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial');
  ascent-override: 90.2%;
  descent-override: 22.48%;
  line-gap-override: 0%;
  size-adjust: 107.4%;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-normal-600-latin.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: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-normal-600-latin-ext.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Lora';
  font-style: italic;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/lora-italic-600-latin.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: 'Lora';
  font-style: italic;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/lora-italic-600-latin-ext.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-text-primary);
  background: var(--color-bg);
}

/* Emphasis stays in the reading face: a serif italic made every em, in
   headings and body alike, read as decoration (A4-01). */
em { font-style: italic; }
.script { font-family: var(--font-serif); font-style: italic; }

button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--color-primary); }

/* iOS Safari zooms the page when a focused field is under 16px. */
@media (pointer: coarse) {
  input, textarea, select { font-size: max(1rem, 1em); }
}

/* One focus ring for every interactive element, brand colored rather than
   the browser's default stripe. */
:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}
/* Form controls, scrollbars and the default canvas follow the theme. */
:root { color-scheme: light dark; }
::placeholder { color: var(--color-text-muted); opacity: 1; }

/* The brand ring disappears on brand-colored surfaces, so it flips there. */
[data-surface='brand'] :focus-visible { outline-color: #E6EEF5; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 12px 20px;
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-radius: 0 0 var(--radius-md) 0;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

.hidden { display: none !important; }
/* The hidden attribute means hidden: a rule such as .btn { display: inline-flex }
   or .stats-row { display: grid } otherwise outranks the browser's own [hidden]. */
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration-hover) var(--ease-standard),
              box-shadow var(--duration-hover) var(--ease-standard),
              border-color var(--duration-hover) var(--ease-standard),
              color var(--duration-hover) var(--ease-standard),
              transform var(--duration-hover) var(--ease-standard);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; pointer-events: none; }
.btn:active:not(:disabled) { transform: scale(0.98); }

.btn-primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: none;
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}
.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-secondary {
  background: rgba(255,255,255,0.7);
  color: var(--color-text-primary);
  border: 1.5px solid rgba(0,0,0,0.08);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.95);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  font-weight: 500;
  padding: 8px 16px;
  border: 1px solid rgba(0,0,0,0.06);
}
.btn-ghost:hover:not(:disabled) { background: rgba(4,81,132,0.06); color: var(--color-primary); }

.btn-sm { padding: 6px 14px; font-size: 0.7812rem; border-radius: 10px; }
.btn-lg { padding: 12px 28px; font-size: 0.9375rem; border-radius: 14px; }
.btn-xl { padding: 16px 36px; font-size: 1rem; font-weight: 700; border-radius: var(--radius-xl); }

/* === ACCESSIBILITY LAYER ===
   Three text sizes and one "easier to read" switch, both restored before the
   first paint by the inline script in each page's <head> so type never jumps.
   Every value is relative, so a reader who already enlarged type in their own
   browser keeps that increase multiplied rather than overwritten (WCAG 1.4.4). */
html[data-text-size='default'] { font-size: 100%; }
html[data-text-size='larger']  { font-size: 112.5%; }
html[data-text-size='largest'] { font-size: 125%; }

html[data-reading-comfort='on'] body {
  letter-spacing: 0.04em;
  word-spacing: 0.14em;
  line-height: 1.9;
}
/* Running text only. A heading, a table or a row of controls is not running
   text, and capping those moves layout rather than helping anybody read. */
html[data-reading-comfort='on'] p,
html[data-reading-comfort='on'] li {
  max-width: 52ch;
  line-height: 1.9;
}
html[data-reading-comfort='on'] h1,
html[data-reading-comfort='on'] h2,
html[data-reading-comfort='on'] h3,
html[data-reading-comfort='on'] h4 { line-height: 1.35; }
html[data-reading-comfort='on'] button,
html[data-reading-comfort='on'] [role='button'],
html[data-reading-comfort='on'] input,
html[data-reading-comfort='on'] select { line-height: 1.45; }

/* The a11y control strip, used on both pages. */
.a11y-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.a11y-group {
  display: inline-flex;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--color-border-medium);
  border-radius: var(--radius-full);
  padding: 3px;
}
.a11y-btn {
  min-height: 44px;
  padding: 5px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  border-radius: var(--radius-full);
  transition: background var(--duration-hover) var(--ease-standard),
              color var(--duration-hover) var(--ease-standard);
}
.a11y-btn[aria-pressed='true'] { background: var(--color-primary); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------------------------------------------------------------------
   Dark mode. Follows the device setting; there is no in-app switch, because a
   reader who wants dark has already said so at the OS level.

   Only the tokens change. The app's own stylesheet reads every surface and
   text color through these, so the whole product follows. The brand blue is
   lightened for dark surfaces: #045184 on near-black fails contrast, and the
   logo blues were chosen against white.
--------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-primary: #5F96CE;
    --color-primary-hover: #7FB0E0;
    --color-primary-light: rgba(95, 150, 206, 0.16);
    --color-primary-border: rgba(95, 150, 206, 0.30);
    --color-primary-deep: #B5CEE8;
    --color-primary-mid: #7FB0E0;
    --color-primary-pale: #2A4466;

    --color-bg: #0F1420;
    --color-surface: #161C2A;
    --color-surface-raised: #1B2332;
    --color-surface-sunken: #0B0F18;

    --color-text-primary: #EEF2F8;
    --color-text-secondary: #B3BCCB;
    --color-text-muted: #94A0B2;
    --color-on-primary: #0F1420;
    --color-border-input: #7D879A;
    --color-text-faint: #78859A;

    --color-border: rgba(255, 255, 255, 0.10);
    --color-border-medium: rgba(255, 255, 255, 0.14);
    --color-border-strong: rgba(255, 255, 255, 0.20);

    --color-ok: #7FB0E0;
    --color-ok-light: rgba(95, 150, 206, 0.18);
    --color-error: #F87171;
    --color-error-light: rgba(248, 113, 113, 0.16);
    --color-warning: #FBBF24;
    --color-warning-light: rgba(251, 191, 36, 0.16);
  }
}

/* The translucent white surfaces are the one thing the token swap cannot carry
   into dark mode: a white glass fill stays white while the text on it turns
   light. Measured at 1.12:1 before these rules. */
@media (prefers-color-scheme: dark) {
  .btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text-primary);
    border-color: rgba(255, 255, 255, 0.16);
  }
  .btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.14);
    border-color: var(--color-primary);
    color: var(--color-primary);
  }
  .a11y-group { background: rgba(255, 255, 255, 0.06); }
  .a11y-btn[aria-pressed='true'] { color: #0F1420; }
}

/* Windows contrast themes replace every author colour, so a chosen mood, day,
   tab, text size or answer looked exactly like the others, and the header's
   gradient went see-through over the page (A3-04). System colours keep the
   person's theme while still marking what is chosen. */
@media (forced-colors: active) {
  [aria-pressed='true'], .selected, .day-chip.selected, .nav-btn[aria-current] {
    forced-color-adjust: none;
    background: Highlight;
    color: HighlightText;
    border: 3px solid Highlight;
  }
  /* :root outranks the surface rules in styles.css, which load later. */
  :root .app-header, :root .modal-sheet, :root .bottom-nav, :root .toast {
    background: Canvas;
    border: 1px solid CanvasText;
  }
}
