/* ================================================================
   TOKENS.CSS — the canonical design-token layer (issue #1211)

   THE single source of truth for colour, spacing, radius, shadows,
   font stacks and the type scale. Loaded immediately after
   ss-main.css in every layout, so anything declared here wins over
   the sed-patched vendor :root block without forking it — edit
   HERE, never in ss-main.css.

   Rules of the road:
   - Components (components.css and everything else) reference these
     variables; no non-vendor CSS should hardcode a brand colour or
     font stack.
   - Legacy variable names (--ss-*, --badge-*, --text-color, …) are
     kept as aliases so existing CSS keeps working, but they resolve
     to the canonical tokens below.
   - Review surface: /admin/styleguide renders every token.
   ================================================================ */

:root {
    /* ---------------------------------------------------------
       1. Brand palette (S&S coral) — mirrors ss-main.css values;
          this copy is authoritative.
       --------------------------------------------------------- */
    --color-coral-base: #fd515b;
    --color-coral-base-rgb: 253, 81, 91;
    --color-coral-50: #ffe5e6;
    --color-coral-100: #fed2d4;
    --color-coral-200: #fd999d;
    --color-coral-300: #ed4650;
    --color-coral-400: #d60b27;
    /* Channel triplet for coral-400, so a translucent wash of the strong shade
       composes as `rgba(var(--color-coral-400-rgb), .05)` instead of restating
       the channels (#1567 — coral-base had one, coral-400 didn't, which is why
       two `rgba(214,11,39,…)` literals had nowhere to go). Add the same for
       another shade the first time a wash of it is needed. */
    --color-coral-400-rgb: 214, 11, 39;
    --color-coral-500: #950518;
    --color-coral-600: #5a020a;
    --color-coral-700: #2c0002;

    /* The one brand accent. Historically base.css carried a second,
       competing "brand red" (#ee0310). Resolved (#1211): the accent
       is coral, and the strong/hover shade is coral-400. */
    --lx-brand: var(--color-coral-base);
    --lx-brand-strong: var(--color-coral-400);
    --ss-brand-red: var(--lx-brand-strong);   /* legacy alias */
    --ss-coral: var(--color-coral-base);      /* legacy alias (stride.css) */
    --ss-red: var(--lx-brand-strong);         /* legacy alias (stride.css) */
    --ss-cyan: #53c2e5;                       /* S&S secondary cyan */

    /* ---------------------------------------------------------
       2. Neutrals — mirrors ss-main.css; authoritative copy.
       --------------------------------------------------------- */
    --color-neutral-white: #fff;
    --color-neutral-50: #f5f5f5;
    --color-neutral-100: #ececec;
    --color-neutral-200: #d9d9d9;
    --color-neutral-300: silver;
    --color-neutral-400: #989898;
    --color-neutral-500: #646464;
    --color-neutral-600: #303030;
    --color-neutral-700: #1e1e1e;
    --color-neutral-black: #000;

    --ss-dark: #111111;               /* page text / heading ink */
    --ss-gray: #777777;               /* mid grey */
    --ss-light-gray: #d8d8d8;         /* hairlines (was stride.css-only) */
    --text-color: #333333;            /* body copy on dense pages */

    /* Common surface + hairline shades used across admin pages */
    --lx-surface: var(--color-neutral-white);
    --lx-surface-muted: #f8f9fa;      /* card/table-header wash */
    --lx-surface-inset: #e9ecef;      /* hover wash / wells */
    --lx-border: #dee2e6;             /* standard hairline */
    --lx-border-strong: #ced4da;
    --lx-text-muted: #6c757d;         /* secondary text */

    /* On-brand band vocabulary (#1461). Full-bleed coral sections
       (.section--primary-bg — hero, enquiry band, feature band) invert:
       ink and fills go white, and the "muted"/"hairline"/"wash" roles
       have to be translucent white rather than the grey tokens above,
       which vanish on coral. Use these instead of writing #fff /
       rgba(255,255,255,…) into page CSS. */
    --lx-on-brand: var(--color-neutral-white);        /* ink + solid fills */
    --lx-on-brand-muted: rgba(255, 255, 255, 0.92);   /* secondary copy */
    --lx-on-brand-subtle: rgba(255, 255, 255, 0.88);  /* tertiary/footnote copy */
    --lx-on-brand-line: rgba(255, 255, 255, 0.65);    /* ghost-button hairline */
    --lx-on-brand-wash: rgba(255, 255, 255, 0.12);    /* ghost-button hover fill */
    /* The white card/sheet a coral band's content floats on — not ink, a
       SURFACE, which is why the muted/subtle ink steps don't fit it. Named in
       #1567: it was written literally five times across four files (the
       features cards, the why-LLM panels and pricing block, the
       AI-transparency sheet), so it was already a role, just an unnamed one. */
    --lx-on-brand-sheet: rgba(255, 255, 255, 0.97);   /* card on a coral band */

    /* ---------------------------------------------------------
       3. Semantic status colours — soft chip trios (bg / fg /
          border) + strong solids. These are what badges, pills,
          chips, alerts and RAG markers compose from.
       --------------------------------------------------------- */
    --lx-success-bg: #d1e7dd;  --lx-success-fg: #0f5132;  --lx-success-border: #a3cfbb;
    --lx-warning-bg: #fff3cd;  --lx-warning-fg: #664d03;  --lx-warning-border: #ffe69c;
    --lx-danger-bg: #f8d7da;   --lx-danger-fg: #842029;   --lx-danger-border: #f1aeb5;
    --lx-info-bg: #cff4fc;     --lx-info-fg: #055160;     --lx-info-border: #9eeaf9;
    --lx-neutral-bg: #e2e3e5;  --lx-neutral-fg: #41464b;  --lx-neutral-border: #c4c8cb;
    --lx-brand-bg: var(--color-coral-50);
    --lx-brand-fg: var(--color-coral-500);
    --lx-brand-border: var(--color-coral-100);
    --lx-accent-bg: #e2d9f3;   --lx-accent-fg: #432874;   --lx-accent-border: #c5b3e6;

    --lx-neutral-solid: #6c757d;  /* the neutral trio had no solid (#1514) */
    --lx-success-solid: #198754;
    --lx-warning-solid: #ffc107;  /* pairs with dark text */
    --lx-danger-solid: #dc3545;
    --lx-info-solid: #0dcaf0;
    --lx-blue-solid: #0d6efd;   /* Bootstrap primary; progress bars, docs */
    --lx-purple-solid: #7928ca; /* manual/curated markers */

    /* Chart roles (#3470). Read by assets/js/analytics_charts.js through
       getComputedStyle, so a chart never carries its own hex. Categorical
       slots in fixed order (validated: adjacent and all-pairs CVD ΔE ≥ 9.2 on
       white; slot 3 is under 3:1, so every chart ships a legend and a table
       view). The ordinal ramp is one hue for ordered steps (funnels). */
    --lx-chart-1: #2a78d6;
    --lx-chart-2: #eb6834;
    --lx-chart-3: #1baf7a;
    --lx-chart-context: #b8bcc2;      /* de-emphasis: prior period, context lines */
    --lx-chart-grid: #eceef0;         /* hairline gridlines */
    --lx-chart-axis: var(--lx-text-muted);
    --lx-chart-band: rgba(108, 117, 125, 0.16);  /* benchmark reference band */
    --lx-chart-band-edge: rgba(108, 117, 125, 0.45);
    --lx-chart-seq-1: #86b6ef;
    --lx-chart-seq-2: #3987e5;
    --lx-chart-seq-3: #256abf;
    --lx-chart-seq-4: #104281;

    /* ---------------------------------------------------------
       4. Font stacks — authoritative copies of the ss-main stacks
          plus the mono stack (#716).
       --------------------------------------------------------- */
    --font-stack-1: "ff-real-text-pro", sans-serif;
    --font-stack-2: "ff-real-text-pro-2", sans-serif;
    --font-stack-3: "Merriweather", "Merriweather Fallback", serif;  /* fallback: base.css (#3580) */
    --font-stack-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    --ss-font-primary: var(--font-stack-1);  /* sans — headings/UI */
    --ss-font-serif: var(--font-stack-3);    /* serif — body copy */
    --old-style-font: var(--ss-font-serif);  /* legacy alias */

    /* NOTE: the --bs-font-sans-serif / --bs-body-font-family overrides live
       in base.css, NOT here — tokens.css loads BEFORE bootstrap.min.css, so
       Bootstrap's own :root would win over any --bs-* set here. */

    /* Canonical badge typography (#716) — every badge/chip takes
       font + weight from these. */
    --badge-font: var(--font-stack-mono);
    --badge-font-weight: 500;
    /* Optical centring for a badge in that face (#2672). JetBrains Mono's
       caps sit 0.094em high in its line box (measured: space below the
       baseline minus space above the cap height, the same per em at every
       badge size), so a flex badge moves its content down by half of it
       and pulls its ::before dot back up by the same. Re-measure if
       --badge-font changes. */
    --badge-optical-shift: 0.047em;

    /* ---------------------------------------------------------
       5. Type scale — one heading + body scale for the app
          (headings render in --ss-font-primary at weight 300;
          see components.css).
       --------------------------------------------------------- */
    /* Two h1 tiers: application pages (legislation-title scale — what a
       plain <h1> renders) and landing/display (the home hero "Lex-Ray"
       treatment: bigger, one weight lighter, tighter leading; use
       .lx-h1--display). */
    --lx-h1: 3rem;                 /* application pages (matches .heading-title) */
    --lx-h1-display: 4.375rem;     /* landing display, 70px (home hero desktop) */
    --lx-h1-display-sm: 2.5rem;    /* landing display below 768px (40px) */
    --lx-display-weight: 200;
    --lx-h2: 2rem;
    --lx-h3: 1.5rem;
    --lx-h4: 1.25rem;
    --lx-h5: 1.1rem;
    --lx-h6: 1rem;
    --lx-heading-weight: 300;
    --lx-heading-tracking: -0.025em;

    --font-size-small: 12px;
    --font-size-normal: 14px;
    --font-size-large: 18px;
    --font-size-xlarge: 24px;
    --font-size-xxlarge: 42px;

    /* ---------------------------------------------------------
       6. Spacing — ss-main's --space-1…14 is the canonical scale;
          the legacy --ss-space-* names map onto it exactly.
       --------------------------------------------------------- */
    --ss-space-xs: var(--space-3);   /* 10px */
    --ss-space-sm: var(--space-5);   /* 20px */
    --ss-space-md: var(--space-6);   /* 30px */
    --ss-space-lg: var(--space-8);   /* 50px */
    --ss-space-xl: var(--space-10);  /* 70px */
    --section-spacing: 2rem;
    --content-padding: 1rem;

    /* ---------------------------------------------------------
       7. Radii — the app's rounded-corner scale (S&S itself is
          square; Lexray uses gentle rounding).
       --------------------------------------------------------- */
    --lx-radius-xs: 3px;
    --lx-radius-sm: 0.25rem;   /* 4px — buttons, badges */
    --lx-radius-md: 0.5rem;    /* 8px — cards, panels, menus */
    --lx-radius-lg: 12px;      /* modals, large cards */
    --lx-radius-pill: 9999px;

    /* ---------------------------------------------------------
       8. Shadows + transitions
       --------------------------------------------------------- */
    --lx-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --lx-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --lx-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    /* "Floating" pair for a pill button lifted off a coloured band — the
       resting drop and its hover lift (#1461). */
    /* The coral "pop": a lifted drop shadow, a 4px coral ring and a coral glow.
       ONE definition for every floating surface that wears it (the definition
       popover, the nsx correction modal). */
    --lx-shadow-coral-pop:
        0 16px 40px rgba(15, 23, 42, 0.2),
        0 0 0 4px rgba(var(--color-coral-base-rgb), 0.2),
        0 0 34px rgba(var(--color-coral-base-rgb), 0.3);
    --lx-shadow-float: 0 4px 14px rgba(0, 0, 0, 0.12);
    --lx-shadow-float-hover: 0 6px 20px rgba(0, 0, 0, 0.18);
    --ss-transition-fast: 0.2s ease;
    --ss-transition-normal: 0.3s ease;

    /* ---------------------------------------------------------
       8a. Stacking: the recovery layer
       --------------------------------------------------------- */
    /* What must stay reachable over an open modal (#4971): the service
       worker's "This page needs reloading" notice. Above Bootstrap's modal
       (1060 in the shipped 5.0.1 sheet, 1055 in the newer one beside it that
       nothing links) and its popovers (1070); below its tooltips (1080) and
       the impersonation banner (2000). */
    --lx-z-recovery: 1075;

    /* ---------------------------------------------------------
       9. Legacy aliases (kept for backward compatibility)
       --------------------------------------------------------- */
    --background-color: #ffffff;
    --primary-color: var(--lx-blue-solid);
    --secondary-color: var(--lx-text-muted);

    /* Defined-term links. A defined term is drawn the same way on every
       surface that renders one — the reader, the FCA glossary page, a popover —
       so the decision lives here rather than in a page sheet (it was in
       celex.css, which the glossary page does not load, #2046). `none` is not a
       placeholder: a defined term is marked by its colour, and the underline is
       reserved for the one case that has to look different, our own inference
       on a document carrying the regulator's (celex.css, #1663). */
    --definition-link-color: var(--lx-brand);
    --definition-link-decoration: none;
    --definition-link-decoration-style: none;

    /* ---------------------------------------------------------
       10. Seasonal: the advent calendar's "Broadsheet" (#4449)
       A newsprint page with ink rules. One new value (the paper);
       the rest are composed from the tokens above. Used only by
       advent.css.
       --------------------------------------------------------- */
    --advent-paper: #f7f2e8;
    --advent-paper-deep: color-mix(in srgb, var(--advent-paper) 88%, var(--ss-dark));
    --advent-rule: var(--ss-dark);
    --advent-mark: var(--color-coral-50);
}
