/* ==========================================================================
   tokens.css: the one token source for Moat (audit DS-01).
   Custom properties only. Every other Moat stylesheet aliases these names
   (moat.css, moat_shared.css, type-system.css via moat_product.css, moat-theme.css,
   profile/assets/css/style.css, the Task 7 profile view/list CSS) and the CDN
   widgets read them as var(--twc-*, fallback).

   Names follow the TWC core vocabulary (twc_core.css, constitution 13.2:
   --twc-bg, --twc-surface, --twc-text, --twc-accent, ...) so a partner page
   that already ships those tokens themes Moat widgets without new names.
   Type roles, weights, leading and spacing follow font_best.md Parts 2 and 4.

   Every block is wrapped in :where(), so it has zero specificity: when this
   file renders inside a host page (club embeds), any value the host declares
   on :root, html or an ancestor wins (DS-04/DS-07: host value wins).

   Contrast (WCAG 2, computed 2026-10-22, see DESIGN_OVERRIDES.md):
   text 16.95:1 on bg, muted 6.15:1, subtle 4.63:1 (>=16px, bg/surface only),
   white on accent 5.80:1, accent text 5.55:1 on bg.
   ========================================================================== */

:where(:root) {
  /* Brand. --moat-accent is the logo blue: decoration and text >= 24px only
     (3.84:1). Text, links and fills use --moat-accent-ink. */
  --moat-accent: #007AFF;
  --moat-accent-ink: #0062CC;
  --moat-accent-hover: #0052AD;
  --moat-accent-soft: rgba(0, 122, 255, 0.08);
  --moat-accent-line: rgba(0, 122, 255, 0.3);
  /* Warm secondary and subtle ink for the warm marketing and blog paper
     (6.16:1 and 5.14:1 on #FAFAF8; 5.75:1 and 4.8:1 on #F3F2EF). */
  --moat-ink-secondary: #5F5F58;
  --moat-ink-subtle: #6B6B63;

  /* Surfaces */
  --twc-bg: #FAFAF8;
  --twc-bg-alt: #F3F2EF;
  --twc-surface: #FFFFFF;
  --twc-surface-2: #F7F6F3;
  --twc-surface-hover: #F3F2EF;

  /* Ink (font_best 3.2/3.3). secondary = muted, muted = subtle: the TWC core
     names, with values that pass. Secondary ink passes AA at any size on every
     Moat ground; subtle (--twc-text-muted) only on bg and surface. */
  --twc-text: #18181B;
  --twc-text-secondary: #595F69;
  --twc-text-muted: #6B7280;
  --twc-text-inverse: #FAFAF8;

  /* Accent: fills carry white text at >= 4.5:1 (DS-03). */
  --twc-accent: var(--moat-accent-ink);
  --twc-accent-hover: var(--moat-accent-hover);
  --twc-accent-light: #E8F1FE;
  --twc-on-accent: #FFFFFF;
  --twc-link: var(--moat-accent-ink);

  /* Readable-text tokens. TWC core (twc_core.css) defines --twc-accent,
     --twc-success/-warning/-error and --twc-text-muted as pastels that fail
     4.5:1 with text; hosts that ship it keep theming borders, rings and tints
     through those names, while anything that carries text (white text on a
     fill, status words, secondary text) reads these names, which twc_core does
     not define. A host opts in by defining them. */
  --twc-accent-fill: var(--moat-accent-ink);
  --twc-accent-fill-hover: var(--moat-accent-hover);
  --twc-success-fill: #15803D;
  --twc-warning-fill: #B45309;
  --twc-error-fill: #DC2626;
  --twc-secondary-text: #595F69;

  /* Status. Fills are the 700 shades (white text >= 4.5:1); *-text is the
     ink for status words on soft fills or on the page (>= 7:1). */
  --twc-success: #15803D;
  --twc-success-text: #14532D;
  --twc-success-light: #E4F1E8;
  --twc-warning: #B45309;
  --twc-warning-text: #713F12;
  --twc-warning-light: #F7EED8;
  --twc-error: #DC2626;
  --twc-error-hover: #B91C1C;
  --twc-error-text: #991B1B;
  --twc-error-light: #FEF2F2;

  /* Lines. --twc-border-strong is the 3:1 boundary for form controls. */
  --twc-border: rgba(20, 20, 19, 0.14);
  --twc-divider: rgba(20, 20, 19, 0.08);
  --twc-border-strong: #858B94;

  /* Focus ring (DS-06): 2px accent outline, 2px offset; 5.55:1 on bg. */
  --twc-focus-color: var(--moat-accent-ink);
  --twc-focus-ring: 2px solid var(--twc-focus-color);
  --twc-focus-offset: 2px;

  /* Family. "Inter Fallback" is the metric-matched local Arial face declared
     in assets/moat/fonts.css, so the swap does not shift layout. */
  --twc-font: "Inter", "Inter Fallback", system-ui, -apple-system, "Segoe UI", sans-serif;
  --twc-font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --twc-font-display: "Playfair Display", Georgia, "Times New Roman", serif;

  /* Type roles (font_best Part 2). Nothing is smaller than caption. */
  --twc-font-size-caption: 0.75rem;
  --twc-font-size-small: 0.875rem;
  --twc-font-size-body: 1rem;
  --twc-font-size-lead: 1.125rem;
  --twc-font-size-sub: 1.25rem;
  --twc-font-size-heading: 1.5rem;
  --twc-font-size-title: clamp(2rem, 1.75rem + 1vw, 2.5rem);
  --twc-font-size-display: clamp(2.75rem, 2.4rem + 1.4vw, 3.75rem);
  --twc-weight-regular: 400;
  --twc-weight-medium: 500;
  --twc-weight-semibold: 600;
  --twc-leading-display: 1.05;
  --twc-leading-title: 1.1;
  --twc-leading-heading: 1.2;
  --twc-leading-sub: 1.3;
  --twc-leading-body: 1.55;
  --twc-leading-small: 1.5;
  --twc-leading-caption: 1.45;
  --twc-leading-label: 1.3;
  --twc-tracking-caps: 0.06em;
  --twc-measure: 65ch;

  /* Space: 4px base, numbered like twc_core (space-N = N x 0.25rem). */
  --twc-space-1: 0.25rem;
  --twc-space-2: 0.5rem;
  --twc-space-3: 0.75rem;
  --twc-space-4: 1rem;
  --twc-space-6: 1.5rem;
  --twc-space-8: 2rem;
  --twc-space-12: 3rem;
  --twc-space-16: 4rem;
  --twc-space-24: 6rem;
  --twc-space-32: 8rem;

  /* Shape: pill for buttons and chips, 16px cards, 10px controls. */
  --twc-radius-sm: 6px;
  --twc-radius-control: 10px;
  --twc-radius-card: 16px;
  --twc-radius-pill: 999px;

  /* Elevation */
  --twc-shadow-sm: 0 1px 2px rgba(20, 40, 70, 0.06);
  --twc-shadow: 0 1px 2px rgba(20, 40, 70, 0.04), 0 8px 28px rgba(20, 40, 70, 0.06);
  --twc-shadow-lg: 0 2px 4px rgba(20, 40, 70, 0.05), 0 18px 48px rgba(20, 40, 70, 0.09);

  /* Layers (DS-08), on Bootstrap's scale so they interleave with a host's:
     dropdowns and popovers stay under a fixed nav (1020/1030); a modal's scrim
     and dialog sit above it (1050/1055); toasts on top. A host that needs a
     different order sets these on its :root. */
  --twc-z-raised: 10;
  --twc-z-sticky: 100;
  --twc-z-dropdown: 1000;
  --twc-z-overlay: 1050;
  --twc-z-modal: 1055;
  --twc-z-toast: 1090;

  /* Motion. Stylesheets collapse durations under prefers-reduced-motion. */
  --twc-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --twc-duration-fast: 150ms;
  --twc-duration: 250ms;
  --twc-duration-slow: 400ms;
}

/* Dark set (font_best 3.4, every pair checked for AA in DESIGN_OVERRIDES.md).
   This file stays OS-neutral on purpose: partner pages link it (club copies of
   profile/integration/index.php), and a partner page must not change with the
   visitor's OS (DS-05). Here a page opts in with data-theme="auto" (follow the
   OS) or data-theme="dark". Moat's own pages follow the OS through
   assets/moat/moat_dark.css / moat_dark_app.css, generated from the
   data-theme="dark" block below by scripts/moat_dark_css.php. */
@media (prefers-color-scheme: dark) {
  :where(:root[data-theme="auto"]) {
    --moat-accent: #5AA9FF;
    --moat-accent-ink: #7DBBFF;
    --moat-accent-hover: #8CC4FF;
    --moat-accent-soft: rgba(90, 169, 255, 0.12);
    --moat-accent-line: rgba(90, 169, 255, 0.4);
    --twc-bg: #121214;
    --twc-bg-alt: #18181B;
    --twc-surface: #1A1A1D;
    --twc-surface-2: #232327;
    --twc-surface-hover: #232327;
    --twc-text: #EDEDEF;
    --twc-text-secondary: #A5A5AC;
    --twc-text-muted: #8A8A92;
    --twc-text-inverse: #121214;
    --twc-accent: #5AA9FF;
    --twc-accent-hover: #8CC4FF;
    --twc-accent-light: #15253D;
    --twc-on-accent: #121214;
    --twc-link: #7DBBFF;
    --twc-accent-fill: #5AA9FF;
    --twc-accent-fill-hover: #8CC4FF;
    --twc-success-fill: #4ADE80;
    --twc-warning-fill: #FBBF24;
    --twc-error-fill: #F87171;
    --twc-secondary-text: #A5A5AC;
    --moat-ink-secondary: #A5A5AC;
    --moat-ink-subtle: #8A8A92;
    --twc-success: #4ADE80;
    --twc-success-text: #86EFAC;
    --twc-success-light: #12291C;
    --twc-warning: #FBBF24;
    --twc-warning-text: #FDE68A;
    --twc-warning-light: #2B2210;
    --twc-error: #F87171;
    --twc-error-hover: #FCA5A5;
    --twc-error-text: #FCA5A5;
    --twc-error-light: #2D1416;
    --twc-border: rgba(237, 237, 239, 0.16);
    --twc-divider: rgba(237, 237, 239, 0.08);
    --twc-border-strong: #6B6B74;
    --twc-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --twc-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.35);
    --twc-shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.45), 0 18px 48px rgba(0, 0, 0, 0.5);
  }
}
:where(:root[data-theme="dark"]) {
  --moat-accent: #5AA9FF;
  --moat-accent-ink: #7DBBFF;
  --moat-accent-hover: #8CC4FF;
  --moat-accent-soft: rgba(90, 169, 255, 0.12);
  --moat-accent-line: rgba(90, 169, 255, 0.4);
  --twc-bg: #121214;
  --twc-bg-alt: #18181B;
  --twc-surface: #1A1A1D;
  --twc-surface-2: #232327;
  --twc-surface-hover: #232327;
  --twc-text: #EDEDEF;
  --twc-text-secondary: #A5A5AC;
  --twc-text-muted: #8A8A92;
  --twc-text-inverse: #121214;
  --twc-accent: #5AA9FF;
  --twc-accent-hover: #8CC4FF;
  --twc-accent-light: #15253D;
  --twc-on-accent: #121214;
  --twc-link: #7DBBFF;
  --twc-accent-fill: #5AA9FF;
  --twc-accent-fill-hover: #8CC4FF;
  --twc-success-fill: #4ADE80;
  --twc-warning-fill: #FBBF24;
  --twc-error-fill: #F87171;
  --twc-secondary-text: #A5A5AC;
  --moat-ink-secondary: #A5A5AC;
  --moat-ink-subtle: #8A8A92;
  --twc-success: #4ADE80;
  --twc-success-text: #86EFAC;
  --twc-success-light: #12291C;
  --twc-warning: #FBBF24;
  --twc-warning-text: #FDE68A;
  --twc-warning-light: #2B2210;
  --twc-error: #F87171;
  --twc-error-hover: #FCA5A5;
  --twc-error-text: #FCA5A5;
  --twc-error-light: #2D1416;
  --twc-border: rgba(237, 237, 239, 0.16);
  --twc-divider: rgba(237, 237, 239, 0.08);
  --twc-border-strong: #6B6B74;
  --twc-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --twc-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.35);
  --twc-shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.45), 0 18px 48px rgba(0, 0, 0, 0.5);
}

/* More contrast on request: secondary and muted ink become primary ink. */
@media (prefers-contrast: more) {
  :where(:root) {
    --twc-text-secondary: var(--twc-text);
    --twc-text-muted: var(--twc-text);
    --twc-secondary-text: var(--twc-text);
    --moat-ink-secondary: var(--twc-text);
    --moat-ink-subtle: var(--twc-text);
  }
}
