/* ============================================================
   PapersLearn design tokens v6 — "Academic Modernism, Umami skin".
   Palette = @umami/react-zen "neutral" (Tailwind neutral ramp, blue
   primary), mapped onto our roles; text variants stepped to AA.
   Layout: MIT OCW discipline, Springer typography, Swiss hierarchy.
   No gamification.

   Type: Source Serif 4 (reading serif — pairs with KaTeX's
   Computer Modern heritage) / IBM Plex Sans (UI + headings) /
   IBM Plex Mono (technical meta). Self-hosted variable faces.

   Measure is law: reading text never exceeds --measure (72ch);
   lessons run --measure-prose (68ch). Body >= 18px on prose.

   Contrast: every fg/bg pair >= 4.85:1 (AA+), computed table —
   docs/CONTRAST.md. Motion: 150ms fades, no springs, no physics.
   ============================================================ */
:root {
  /* — typography — */
  --font-sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-display: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif; /* Swiss: sans headings, serif reading */
  --font-read: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  --text-xs: 0.78rem;    /* meta, chips — sans or mono, tracked */
  --text-sm: 0.88rem;    /* secondary UI copy */
  --text-base: 1.0625rem;/* 17px UI body */
  --text-read: 1.125rem; /* 18px reading body (serif) */
  --text-lg: clamp(1.1rem, 0.4vw + 1rem, 1.25rem);
  --text-xl: clamp(1.3rem, 0.9vw + 1.1rem, 1.6rem);    /* h2 */
  --text-2xl: clamp(1.6rem, 1.6vw + 1.15rem, 2.1rem);  /* h1 */
  --text-3xl: clamp(1.6rem, 1.6vw + 1.15rem, 2.1rem);  /* stat numbers ride as h-sizes */

  --leading-snug: 1.25;
  --leading-normal: 1.65;   /* UI body */
  --leading-read: 1.7;      /* serif reading text — directive: >= 1.6 */

  /* — measure (the anti-wall law) — */
  --measure: 72ch;          /* hard cap for any reading text */
  --measure-prose:40rem; /* 640px ≈ 70 ink-ch at 18px serif */    /* lesson prose */
  --measure-math:42rem; /* 672px ≈ 73 ink-ch; statements carry math */     /* problem statements with block math */

  /* — spacing rhythm — */
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2.25rem;
  --sp-7: 3.25rem;
  --para-gap: 1.2rem;       /* paragraph margins — directive */

  /* — radii: scholarly, flat — */
  --radius-sm: 4px;
  --radius-md: 6px;                  /* zen rounded/rounded-md */
  --radius-lg: 8px;                  /* zen rounded-lg — panels/modals */
  --radius-pill: 999px;     /* retired from chrome; count badges only */

  /* — motion: quiet 150ms fades only — */
  --dur-1: 150ms;
  --dur-2: 150ms;
  --dur-3: 150ms;
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  /* — light palette: Umami/react-zen "neutral", primary blue —
     Token values = @umami/react-zen styles.css (palette=neutral),
     mapped onto our roles. Text-bearing variants nudged to AA-safe
     steps (zen ships blue-500 at 3.65:1 for body links; we ride
     blue-600 #2563eb). Surfaces: page = palette-50, cards = white,
     inputs/chips = palette-100, hover = palette-200. — */
  --bg: #fafafa;                     /* zen surface-raised = body */
  --surface: #ffffff;                /* zen surface */
  --surface-2: #f5f5f5;              /* palette-100 */
  --surface-3: #e5e5e5;              /* palette-200 */
  --border: #d4d4d4;                 /* palette-300 */
  --border-muted: #e5e5e5;           /* palette-200 — zen hairlines */
  --border-strong: #a3a3a3;          /* palette-400 */
  --hover: #f5f5f5;                  /* row/control hover */
  --fg: #171717;                     /* palette-900 */
  --fg-soft: #404040;                /* palette-700 */
  --muted: #6e6e6e;                  /* AA-safe neutral (4.85:1 bg, 4.65:1 surface-2) */
  --accent: #2563eb;                 /* AA-safe sibling of zen blue-500 */
  --accent-hover: #1e40af;
  --accent-ink: #ffffff;
  --accent-deep: #1e40af;
  --accent-soft: #eff6ff;            /* blue-50 */
  --accent-soft-fg: #1e3a8a;         /* blue-900 */
  --success: #15803d;                /* green-700 */
  --success-soft: #f0fdf4;           /* green-50 */
  --success-fg: #14532d;             /* green-900 */
  --success-deep: #14532d;
  --warning: #a16207;                /* yellow-700 */
  --warning-soft: #fefce8;           /* yellow-50 */
  --warning-fg: #713f12;             /* yellow-900 */
  --error: #b91c1c;                  /* red-600 */
  --error-soft: #fef2f2;             /* red-50 */
  --error-fg: #7f1d1d;               /* red-900 */
  --error-deep: #7f1d1d;
  --highlight: transparent;
  --focus: #737373;                  /* zen focus ring is neutral */
  --ring: 0 0 0 3px color-mix(in srgb, var(--fg) 65%, transparent); /* ≥3:1 non-text on both surfaces */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .05);
  --scroll-thumb: rgba(23, 23, 23, .2);
  --scroll-thumb-hover: rgba(23, 23, 23, .42);
  --shadow-1: none;
  --shadow-2: none;
  --shadow-3: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); /* zen shadow-md */
  --maxw: 78rem;                     /* full-bleed tables/graphs container */
}

/* dark: true neutral zinc, same hierarchy */
:root[data-theme="dark"] {
  --bg: #262626;                /* zen dark body = palette-800 */
  --surface: #171717;             /* cards/inputs = palette-900 */
  --surface-2: #262626;
  --surface-3: #404040;           /* palette-700 hover */
  --border: #404040;              /* palette-700 */
  --border-muted: #303030;        /* zen gray-750 hairlines */
  --border-strong: #525252;       /* palette-600 */
  --hover: #303030;
  --fg: #f5f5f5;                  /* palette-100 */
  --fg-soft: #e5e5e5;
  --muted: #a3a3a3;               /* palette-400, 6:1 on bg */
  --accent: #60a5fa;              /* blue-400: AA text + dark ink on fill */
  --accent-hover: #93c5fd;
  --accent-ink: #0f172a;
  --accent-deep: #93c5fd;
  --accent-soft: #1e2c44;         /* blue-500 @ 20% on surface */
  --accent-soft-fg: #dbeafe;      /* blue-100 */
  --success: #4ade80;
  --success-soft: #193a25;
  --success-fg: #dcfce7;
  --success-deep: #166534;
  --warning: #facc15;
  --warning-soft: #413617;
  --warning-fg: #fef9c3;
  --error: #f87171;
  --error-soft: #422020;
  --error-fg: #fee2e2;
  --error-deep: #b91c1c;
  --focus: #a3a3a3;
  --ring: 0 0 0 3px color-mix(in srgb, var(--fg) 65%, transparent);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --scroll-thumb: rgba(245, 245, 245, .22);
  --scroll-thumb-hover: rgba(245, 245, 245, .48);
  --shadow-3: 0 4px 6px -1px rgb(0 0 0 / 0.35), 0 2px 4px -2px rgb(0 0 0 / 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #262626;                /* zen dark body = palette-800 */
  --surface: #171717;             /* cards/inputs = palette-900 */
  --surface-2: #262626;
  --surface-3: #404040;           /* palette-700 hover */
  --border: #404040;              /* palette-700 */
  --border-muted: #303030;        /* zen gray-750 hairlines */
  --border-strong: #525252;       /* palette-600 */
  --hover: #303030;
  --fg: #f5f5f5;                  /* palette-100 */
  --fg-soft: #e5e5e5;
  --muted: #a3a3a3;               /* palette-400, 6:1 on bg */
  --accent: #60a5fa;              /* blue-400: AA text + dark ink on fill */
  --accent-hover: #93c5fd;
  --accent-ink: #0f172a;
  --accent-deep: #93c5fd;
  --accent-soft: #1e2c44;         /* blue-500 @ 20% on surface */
  --accent-soft-fg: #dbeafe;      /* blue-100 */
  --success: #4ade80;
  --success-soft: #193a25;
  --success-fg: #dcfce7;
  --success-deep: #166534;
  --warning: #facc15;
  --warning-soft: #413617;
  --warning-fg: #fef9c3;
  --error: #f87171;
  --error-soft: #422020;
  --error-fg: #fee2e2;
  --error-deep: #b91c1c;
  --focus: #a3a3a3;
  --ring: 0 0 0 3px color-mix(in srgb, var(--fg) 65%, transparent);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --scroll-thumb: rgba(245, 245, 245, .22);
  --scroll-thumb-hover: rgba(245, 245, 245, .48);
  --shadow-3: 0 4px 6px -1px rgb(0 0 0 / 0.35), 0 2px 4px -2px rgb(0 0 0 / 0.35);
  }
}

/* wide screens: grow the reading size with the room available (75ch law holds:
   46rem at 20px serif = 73.6 ink-ch) */
@media (min-width:1400px){:root{--text-read:1.25rem;--measure-prose:46rem;--measure-math:46rem;--maxw:86rem}}
