/**
 * ResolveVia — tokens.css  (DRIFT-755 Phase 0, canonical token layer)
 *
 * The single canonical token sheet, intended to load FIRST on every screen
 * surface (Class 1/2/3). Contains ONLY token definitions — :root canonical
 * defaults and the .rv-surface-* scope tags. NO component rules, so it is
 * safe to load inside wp-admin.
 *
 * Every value here EQUALS class ResolveVia_Design_Tokens::tokens() (the PHP
 * source of truth) — see TOKEN_ARCHITECTURE.md / verification "CSS<->PHP
 * value parity". A future optimisation may emit this file from that map; for
 * the zero-change guarantee Phase 0 keeps it static and authored-to-match.
 *
 * ─────────────────────────────────────────────────────────────────────────
 * THE ZERO-CHANGE CONTRACT (why each block is shaped as it is):
 *
 *  :root carries ONLY tokens that are currently defined-and-consistent at
 *  :root today (radius / spacing / transition / accent fallbacks). It does
 *  NOT define:
 *    - theme/buyer LIGHT neutrals (--rv-bg-*, --rv-text-*, --rv-border-*):
 *      fallback-
 *      carried per-usage with INCONSISTENT light fallbacks → a single :root
 *      value would change rendering (DEFERRED D1). DARK neutrals stay in
 *      niche-themes.css.
 *    - --rv-shadow-*: theme has only --rv-shadow-lg (dark-only, stays in
 *      main.css); admin's shadows are reproduced in the admin scope below.
 *    - SEMANTIC tokens (--rv-success/-warning/...): EMITTED as a global
 *      :root layer by DRIFT-756 Phase 1 (see the GLOBAL SEMANTIC LAYER
 *      section below). Phase 0 had deferred them because referral-center.css
 *      consumed var(--rv-success,#16a34a) MODE-BLIND (undefined -> #16a34a in
 *      light AND dark); defining --rv-success with a dark mirror (#4ade80)
 *      changes that surface in dark. Phase 1 emits the layer AND migrates
 *      referral-center off the mode-blind fallback in one atomic deploy, so
 *      that dark change is intended + signed off. Admin keeps its SEPARATE
 *      --rv-color-* set in the admin scope (it does NOT consume the global
 *      --rv-{status} layer — proven zero-delta).
 *
 *  .rv-surface-admin is a FAITHFUL RE-SELECTORING of admin.css's existing
 *  token machinery — same values, deeper selectors (:root -> body.rv-surface-
 *  admin; @media-dark/:root -> @media-dark/body.rv-surface-admin; html.rv-dark
 *  -> html.rv-dark body.rv-surface-admin; html.rv-light -> html.rv-light
 *  body.rv-surface-admin). MODE-DEPENDENT admin tokens (primary, primary-hover,
 *  all neutrals, shadows) are LITERALS in all four contexts — NOT aliases —
 *  because admin primary diverges from canonical accent in dark (#60a5fa) and
 *  admin neutrals diverge from theme neutrals in forced-light (#ffffff vs the
 *  theme's #f9fafb). Aliasing either would silently break a mode. Only the
 *  MODE-INDEPENDENT divergences (radius 4/6/8, spacing aliases, font-size,
 *  static accent) sit in a single plain-scope block.
 *
 * NOTE: This file is INERT until Part C enqueues it. Creating it changes no
 * rendered pixel. Do NOT enqueue until the computed-value parity proof passes,
 * and only together with Part B (definition moves) + Part D (body tags) as one
 * atomic set — Part B removes the old :root definitions these replace, so the
 * three parts must deploy together.
 * ─────────────────────────────────────────────────────────────────────────
 */

/* ============================================================
   CANONICAL :root — loaded on every surface, the default layer
   ============================================================ */
:root {
    /* Radius scale (theme values; admin overrides to 4/6/8 in its scope) */
    --rv-radius-xs:     4px;
    --rv-radius-sm:     6px;
    --rv-radius-md:     8px;
    --rv-radius-mlg:    10px;
    --rv-radius-lg:     12px;
    --rv-radius-xl:     20px;
    --rv-radius-pill:   999px;
    --rv-radius-circle: 50%;

    /* Spacing scale (numbered = canonical vocabulary) */
    --rv-space-1: 4px;
    --rv-space-2: 8px;
    --rv-space-3: 12px;
    --rv-space-4: 16px;
    --rv-space-5: 24px;
    --rv-space-6: 32px;
    --rv-space-7: 48px;

    /* Interaction */
    --rv-transition: 150ms ease;

    /* Accent fallbacks (safety-net default; the per-niche emitter overrides
       these at :root on public/buyer). Canonical single home for the accent
       family — the duplicate :root block in niche-themes.css is removed in
       Part B so this is the one defining site. */
    --rv-accent:        #2563eb;
    --rv-accent-dark:   #1d4ed8;
    --rv-accent-light:  #dbeafe;
    --rv-accent-text:   #ffffff;
    --rv-hero-gradient: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    --rv-badge-bg:      #dbeafe;
    --rv-surface-tint:  #f8fafc;

    /* ============================================================
       FOUNDATIONAL SCALE LAYER  (DRIFT-760 — additive, zero rendered change)
       Defined-but-UNCONSUMED: every token below is available globally yet
       nothing references it outside this token sheet. Per-surface migrations
       (later phases) repoint components onto these; this phase only completes
       the vocabulary. Mode-independent → defined once HERE, never duplicated
       into the dark / forced-light blocks. Units kept verbatim from the
       observed distribution so migration is 1:1 (px→rem normalisation is a
       separate deferred decision — see TOKEN_ARCHITECTURE).
       ============================================================ */

    /* --- Font-size scale: PROMOTED from admin-only to global ---------------
       12/14/16/18 were defined ONLY in body.rv-surface-admin, so public/buyer
       had no type scale (type DEBT was blocked there). The SAME values are
       now defined at :root → admin's own scoped block still resolves these
       identically (higher specificity; zero change on admin), and non-admin
       surfaces gain the tokens unconsumed (zero render change). Name kept as
       --rv-font-size-* (NOT --rv-text-*). Range extended for the other common
       sizes from the STEP-0 distribution (11:61, 13:132, 20:22, 22:21, 24:17).
       Off-scale odd sizes (15/26/etc.) are migration NEEDS-DECISION, not
       tokens here. */
    --rv-font-size-xs:    11px;
    --rv-font-size-sm:    12px;
    --rv-font-size-smd:   13px;
    --rv-font-size-base:  14px;
    --rv-font-size-md:    16px;
    --rv-font-size-lg:    18px;
    --rv-font-size-xl:    20px;
    --rv-font-size-2xl:   22px;
    --rv-font-size-3xl:   24px;
    --rv-font-size-2xs:   10px;
    --rv-font-size-bmd:   15px;

    /* --- Gray ramp (DEFINE; no prior tokens) -------------------------------
       Raw neutral SCALE. Tailwind values, CONFIRMED against the STEP-0
       distribution — every step is observed verbatim in the codebase
       (e5e7eb ×153, f3f4f6 ×87, f9fafb ×80, d1d5db ×35, 9ca3af ×55,
       6b7280 ×227, 4b5563 ×11, 374151 ×101, 1f2937 ×10, 111827 ×163), so
       no observed-vs-Tailwind divergence — the expected set wins as-is.
       May overlap admin's --rv-color-* neutrals; that is expected (a later
       phase can repoint the semantic neutrals onto this ramp — not here). */
    --rv-gray-50:  #f9fafb;
    --rv-gray-100: #f3f4f6;
    --rv-gray-200: #e5e7eb;
    --rv-gray-300: #d1d5db;
    --rv-gray-400: #9ca3af;
    --rv-gray-500: #6b7280;
    --rv-gray-600: #4b5563;
    --rv-gray-700: #374151;
    --rv-gray-800: #1f2937;
    --rv-gray-900: #111827;
    --rv-white:    #ffffff;
    --rv-black:    #000000;

    /* --- Font-weight scale (DEFINE) ----------------------------------------
       Confirmed against STEP-0 (600:229, 700:132, 500:34, 800:30, 400:3). */
    --rv-weight-normal:    400;
    --rv-weight-medium:    500;
    --rv-weight-semibold:  600;
    --rv-weight-bold:      700;
    --rv-weight-extrabold: 800;

    /* --- Line-height scale (DEFINE) ----------------------------------------
       Derived from STEP-0 (1.5:38, 1.6:28, 1.7:9, 1.2/1.25 cluster, 1:29).
       Unitless (the recommended form). The bare "1" stays a one-off (LEG). */
    --rv-leading-tight:   1.25;
    --rv-leading-normal:  1.5;
    --rv-leading-relaxed: 1.7;

    /* --- z-index scale (DEFINE; semantic layers) ---------------------------
       The current raw sprawl (1·5·10·50·100·200·999·1000·1001·1049·1050·
       9000·9100·9999·10000·99999·100000·100001) encodes a working stacking
       ORDER; migration maps each onto the layer that PRESERVES its relative
       position (NOT nearest-number snap) — see STEP-2 report. */
    --rv-z-base:     0;
    --rv-z-raised:   10;
    --rv-z-dropdown: 1000;
    --rv-z-sticky:   1100;
    --rv-z-overlay:  1200;
    --rv-z-modal:    1300;
    --rv-z-popover:  1400;
    --rv-z-toast:    1500;
    --rv-z-max:      9999;

    /* --- Duration / easing scale (DEFINE; ALONGSIDE --rv-transition) -------
       --rv-transition (150ms ease) is KEPT untouched above; this scale is
       added beside it, never over it. Confirmed against STEP-0 (0.15s/150ms
       dominant ×61, 0.1s ×8, 0.2s/0.3s present; ease ×41, linear ×10). */
    --rv-duration-fast: 100ms;
    --rv-duration-base: 150ms;
    --rv-duration-slow: 300ms;
    --rv-ease:     cubic-bezier(0.4, 0, 0.2, 1);
    --rv-ease-in:  cubic-bezier(0.4, 0, 1, 1);
    --rv-ease-out: cubic-bezier(0, 0, 0.2, 1);
}

/* ============================================================
   GLOBAL SEMANTIC LAYER  (DRIFT-756 Phase 1)
   Status colours are NICHE-INDEPENDENT and global, so they live at
   :root / html scope (NOT a surface scope). Three roles per status:
     --rv-<status>       accent  (borders, icons, badges, fills)
     --rv-<status>-text  text    (status text on its tint)
     --rv-<status>-bg    bg      (the tint behind a notice)
   Every value EQUALS ResolveVia_Design_Tokens::tokens()['semantic']
   (parity.php count-matched). Mode-dependent via the established
   4-context pattern. Composes alongside the per-niche accent emitter
   (resolvevia_build_theme_css emits --rv-accent* only, never
   --rv-<status>), so there is no collision.
   Text/bg are WCAG-AA verified (>=4.5:1 text-on-bg, all 4 modes;
   lowest 6.81:1). See DRIFT-756 contrast pass.
   ============================================================ */
:root {
    --rv-success:          #16a34a;
    --rv-success-text:     #166534;
    --rv-success-bg:       #f0fdf4;
    --rv-warning:          #c2620a;
    --rv-warning-text:     #92400e;
    --rv-warning-bg:       #fffbeb;
    --rv-error:            #dc2626;
    --rv-error-text:       #991b1b;
    --rv-error-bg:         #fef2f2;
    --rv-info:             #0891b2;
    --rv-info-text:        #155e75;
    --rv-info-bg:          #ecfeff;
    --rv-orange:           #ea580c;
    --rv-orange-text:      #7c2d12;
    --rv-orange-bg:        #fff7ed;
    --rv-purple:           #7c3aed;
    --rv-purple-text:      #4c1d95;
    --rv-purple-bg:        #f5f3ff;
    --rv-gold:             #b45309;
    --rv-gold-text:        #78350f;
    --rv-gold-bg:          #fefce8;
    --rv-storm:            #ea580c;
    --rv-storm-text:       #7c2d12;
    --rv-storm-bg:         #fff7ed;
}

@media (prefers-color-scheme: dark) {
    :root {
        --rv-success:          #4ade80;
        --rv-success-text:     #86efac;
        --rv-success-bg:       #052e16;
        --rv-warning:          #fbbf24;
        --rv-warning-text:     #fcd34d;
        --rv-warning-bg:       #2a1a00;
        --rv-error:            #f87171;
        --rv-error-text:       #fca5a5;
        --rv-error-bg:         #450a0a;
        --rv-info:             #22d3ee;
        --rv-info-text:        #a5f3fc;
        --rv-info-bg:          #083344;
        --rv-orange:           #fb923c;
        --rv-orange-text:      #fdba74;
        --rv-orange-bg:        #2d1305;
        --rv-purple:           #a78bfa;
        --rv-purple-text:      #c4b5fd;
        --rv-purple-bg:        #2e1065;
        --rv-gold:             #e3b341;
        --rv-gold-text:        #fcd34d;
        --rv-gold-bg:          #1a0e00;
        --rv-storm:            #fb923c;
        --rv-storm-text:       #fdba74;
        --rv-storm-bg:         #2d1305;
    }
}

html.rv-dark {
    --rv-success:          #4ade80;
    --rv-success-text:     #86efac;
    --rv-success-bg:       #052e16;
    --rv-warning:          #fbbf24;
    --rv-warning-text:     #fcd34d;
    --rv-warning-bg:       #2a1a00;
    --rv-error:            #f87171;
    --rv-error-text:       #fca5a5;
    --rv-error-bg:         #450a0a;
    --rv-info:             #22d3ee;
    --rv-info-text:        #a5f3fc;
    --rv-info-bg:          #083344;
    --rv-orange:           #fb923c;
    --rv-orange-text:      #fdba74;
    --rv-orange-bg:        #2d1305;
    --rv-purple:           #a78bfa;
    --rv-purple-text:      #c4b5fd;
    --rv-purple-bg:        #2e1065;
    --rv-gold:             #e3b341;
    --rv-gold-text:        #fcd34d;
    --rv-gold-bg:          #1a0e00;
    --rv-storm:            #fb923c;
    --rv-storm-text:       #fdba74;
    --rv-storm-bg:         #2d1305;
}

html.rv-light {
    --rv-success:          #16a34a;
    --rv-success-text:     #166534;
    --rv-success-bg:       #f0fdf4;
    --rv-warning:          #c2620a;
    --rv-warning-text:     #92400e;
    --rv-warning-bg:       #fffbeb;
    --rv-error:            #dc2626;
    --rv-error-text:       #991b1b;
    --rv-error-bg:         #fef2f2;
    --rv-info:             #0891b2;
    --rv-info-text:        #155e75;
    --rv-info-bg:          #ecfeff;
    --rv-orange:           #ea580c;
    --rv-orange-text:      #7c2d12;
    --rv-orange-bg:        #fff7ed;
    --rv-purple:           #7c3aed;
    --rv-purple-text:      #4c1d95;
    --rv-purple-bg:        #f5f3ff;
    --rv-gold:             #b45309;
    --rv-gold-text:        #78350f;
    --rv-gold-bg:          #fefce8;
    --rv-storm:            #ea580c;
    --rv-storm-text:       #7c2d12;
    --rv-storm-bg:         #fff7ed;
}

/* ============================================================
   SURFACE SCOPE — ADMIN  (.rv-surface-admin on <body>)
   Faithful re-selectoring of admin.css's token machinery onto the body scope.
   Overrides only where admin intentionally differs from canonical.
   ============================================================ */

/* ---- Mode-INDEPENDENT divergences (plain body scope; one value each) ---- */
body.rv-surface-admin {
    /* Admin radius (4/6/8 — divergent from canonical 6/8/12; no dark variant) */
    --rv-radius-sm: 4px;
    --rv-radius-md: 6px;
    --rv-radius-lg: 8px;

    /* Spacing aliases -> canonical numbered scale (mode-independent) */
    --rv-space-xs: var(--rv-space-1); /* 4px  */
    --rv-space-sm: var(--rv-space-2); /* 8px  */
    --rv-space-md: var(--rv-space-4); /* 16px */
    --rv-space-lg: var(--rv-space-5); /* 24px */
    --rv-space-xl: var(--rv-space-6); /* 32px */

    /* Static admin accent. admin.css never defines --rv-accent and no admin
       rule consumes it (admin uses --rv-color-*), so this is unobserved-but-
       safe: it documents that admin is never per-niche themed (verification
       item 7) and, sitting on <body>, would beat any stray :root emit. */
    --rv-accent:      #2563eb;
    --rv-accent-dark: #1d4ed8;

    /* Font-size scale (admin-only; mode-independent) */
    --rv-font-size-sm:   12px;
    --rv-font-size-base: 14px;
    --rv-font-size-md:   16px;
    --rv-font-size-lg:   18px;
}

/* ---- Mode-DEPENDENT divergences — LIGHT values (plain body scope) ----
   These reproduce admin.css's :root colour/shadow block verbatim, re-scoped.
   They are LITERALS (not aliases): admin primary diverges from canonical
   accent in dark, and admin neutrals diverge from theme neutrals in forced-
   light, so an alias would silently break a mode. The @media-dark / html.rv-*
   blocks below re-assert NEUTRAL/PRIMARY at scope specificity so no mode is
   frozen. SEMANTIC colours (the 8) are now ALIASES onto the global --rv-*
   layer (DRIFT-761) — single source; the non-base mode blocks no longer carry
   them (the global token supplies the mode-correct value through the alias). */
body.rv-surface-admin {
    --rv-color-primary:       #2563eb;
    --rv-color-primary-hover: #1d4ed8;

    /* DRIFT-761: admin semantic colours ALIAS the global --rv-* semantic layer
       (single source). The alias resolves --rv-X in whatever mode context the
       admin element is in, inheriting global's light/dark automatically. Two
       intended a11y deltas vs the old admin literals (the DRIFT-757 values now
       applied to admin): warning light/forced-light #d97706→#c2620a; info
       dark/forced-dark #38bdf8→#22d3ee. Every other resolution is identical. */
    --rv-color-success:       var(--rv-success);
    --rv-color-warning:       var(--rv-warning);
    --rv-color-error:         var(--rv-error);
    --rv-color-info:          var(--rv-info);
    --rv-color-orange:        var(--rv-orange);
    --rv-color-purple:        var(--rv-purple);
    --rv-color-gold:          var(--rv-gold);
    --rv-color-storm:         var(--rv-storm);
    --rv-color-muted:         #6b7280;
    --rv-color-border:        #e5e7eb;
    --rv-color-bg-surface:    #ffffff;
    --rv-color-bg-subtle:     #f9fafb;
    --rv-color-bg-hover:      #f3f4f6;
    --rv-color-text:          #111827;
    --rv-color-text-muted:    #6b7280;

    --rv-shadow-sm: 0 1px 2px rgba(0,0,0,.06);
    --rv-shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
    --rv-shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
}

/* ---- Mode-DEPENDENT — OS dark (@media) ---- */
@media (prefers-color-scheme: dark) {
    body.rv-surface-admin {
        --rv-color-primary:       #60a5fa;
        --rv-color-primary-hover: #3b82f6;
        /* DRIFT-761: the 8 semantic --rv-color-* removed here — the base-scope
           alias var(--rv-X) inherits this mode's global value automatically. */
        --rv-color-muted:         #94a3b8;
        --rv-color-border:        #2d3748;
        --rv-color-bg-surface:    #1a1d27;
        --rv-color-bg-subtle:     #22263a;
        --rv-color-bg-hover:      #2d3344;
        --rv-color-text:          #e2e8f0;
        --rv-color-text-muted:    #94a3b8;

        --rv-shadow-sm: 0 1px 2px rgba(0,0,0,.4);
        --rv-shadow-md: 0 4px 6px -1px rgba(0,0,0,.5), 0 2px 4px -2px rgba(0,0,0,.5);
        --rv-shadow-lg: 0 10px 15px -3px rgba(0,0,0,.6), 0 4px 6px -4px rgba(0,0,0,.5);
    }
}

/* ---- Mode-DEPENDENT — forced dark (html.rv-dark; mirrors @media) ---- */
html.rv-dark body.rv-surface-admin {
    --rv-color-primary:       #60a5fa;
    --rv-color-primary-hover: #3b82f6;
    /* DRIFT-761: the 8 semantic --rv-color-* removed here — base-scope alias
       var(--rv-X) inherits this mode's global value automatically. */
    --rv-color-muted:         #94a3b8;
    --rv-color-border:        #2d3748;
    --rv-color-bg-surface:    #1a1d27;
    --rv-color-bg-subtle:     #22263a;
    --rv-color-bg-hover:      #2d3344;
    --rv-color-text:          #e2e8f0;
    --rv-color-text-muted:    #94a3b8;

    --rv-shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --rv-shadow-md: 0 4px 6px -1px rgba(0,0,0,.5), 0 2px 4px -2px rgba(0,0,0,.5);
    --rv-shadow-lg: 0 10px 15px -3px rgba(0,0,0,.6), 0 4px 6px -4px rgba(0,0,0,.5);
}

/* ---- Mode-DEPENDENT — forced light (html.rv-light; re-asserts light to beat @media dark) ---- */
html.rv-light body.rv-surface-admin {
    --rv-color-primary:       #2563eb;
    --rv-color-primary-hover: #1d4ed8;
    /* DRIFT-761: the 8 semantic --rv-color-* removed here — base-scope alias
       var(--rv-X) inherits this mode's global value automatically. */
    --rv-color-muted:         #6b7280;
    --rv-color-border:        #e5e7eb;
    --rv-color-bg-surface:    #ffffff;
    --rv-color-bg-subtle:     #f9fafb;
    --rv-color-bg-hover:      #f3f4f6;
    --rv-color-text:          #111827;
    --rv-color-text-muted:    #6b7280;

    --rv-shadow-sm: 0 1px 2px rgba(0,0,0,.06);
    --rv-shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
    --rv-shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
}

/* ============================================================
   SURFACE SCOPE — BUYER / PUBLIC  (.rv-surface-buyer / -public on <body>)
   Canonical defaults only — no divergence found in STEP 0 capture.
   Per-niche --rv-accent injection (emitter, :root) still applies; these
   scopes deliberately do NOT override accent, so they inherit the niche
   colour. Kept as explicit (empty) anchors so the taxonomy is complete and
   later phases have a defined home for any buyer/public-only divergence.
   ============================================================ */
body.rv-surface-buyer {
    /* intentionally empty — inherits canonical + per-niche palette */
}
body.rv-surface-public {
    /* intentionally empty — inherits canonical + per-niche palette */
}
