/* ---- Self-hosted fonts ---- */
/* Instrument Sans + JetBrains Mono (variable, OFL-1.1) bundled as woff2 so
   the design system works offline without Google Fonts. The family names
   match --font-sans / --font-mono in typography.css. */

@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/instrument-sans-latin-wght-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Instrument Sans';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/instrument-sans-latin-wght-italic.woff2') format('woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/jetbrains-mono-latin-wght-italic.woff2') format('woff2');
}

/* ─────────────────────────────────────────────────────────────────────────
 * Akamai brand palette — the raw, theme-invariant color scale.
 *
 * These values come straight from the official brand document
 * (docs/brand/akamai-brand-guidelines.pdf, summarised in BRAND_REFERENCE.md).
 * Nothing here is chosen for contrast or legibility — that is the job of
 * semantic.css, which maps these to roles.
 *
 * Do NOT reference these tokens from component CSS. Use the semantic tier so
 * components follow the active theme. The only sanctioned exceptions are
 * --color-brand-chrome and --color-on-brand (see semantic.css) and the
 * --color-chart-* data-viz series.
 * ───────────────────────────────────────────────────────────────────────── */

:root {
  /* Primary brand colors */
  --color-brand-blue:     #00A4EB; /* PMS 299C */
  --color-brand-orange:   #FF8B00; /* PMS 144C */
  --color-brand-navy:     #002F6C; /* PMS 294C */

  /* Secondary / data-visualization colors */
  --color-brand-lavender: #7A7CFF; /* PMS 2124  */
  --color-brand-violet:   #201547; /* PMS 2765C */
  --color-brand-green:    #00CD63; /* PMS 2420C */
  --color-brand-electric: #0050FF; /* PMS 2132C */
  --color-brand-sand:     #FAE6C3;
  --color-brand-red:      #F02B1F; /* PMS 485C  */

  /* Greyscale */
  --color-grey-1: #2A2A2B;
  --color-grey-2: #4B4A4D;
  --color-grey-3: #7C7B7F;
  --color-grey-4: #A9A7AD;
  --color-grey-5: #CECECE;
  --color-grey-6: #F5F5F5;
  --color-white:  #FFFFFF;
  --color-black:  #000000;

  /* Data-visualization series.
     The brand mandates a maximum of 6 colors per chart; past six, use tints of
     these rather than new hues. Theme-invariant by design — a chart's series
     colors must stay stable when the surface under them changes. */
  --color-chart-1: #00A4EB; /* Akamai Blue  */
  --color-chart-2: #FF8B00; /* Orange       */
  --color-chart-3: #00CD63; /* Green        */
  --color-chart-4: #7A7CFF; /* Lavender     */
  --color-chart-5: #0050FF; /* Electric Blue*/
  --color-chart-6: #F02B1F; /* Red          */
}

/* ─────────────────────────────────────────────────────────────────────────
 * Semantic color roles — LIGHT THEME (the default).
 *
 * This is the tier component CSS should consume. Every token here is also
 * declared in theme-dark.css; the two files are a contract and must stay in
 * lockstep. scripts/check-contrast.py enforces both the pairing ratios and
 * the "declared in both themes" invariant.
 *
 * Values are committed as LITERAL hex, not live color-mix(), so they are
 * greppable, auditable and machine-checkable. Where a value is derived, the
 * formula is in a comment.
 *
 * Contrast ratios in comments are computed against the token's intended
 * pairing. Targets: 4.5:1 normal text (WCAG AA), 3:1 large text and non-text
 * UI boundaries (SC 1.4.11).
 * ───────────────────────────────────────────────────────────────────────── */

:root,
[data-theme="light"] {
  color-scheme: light;
  accent-color: var(--color-primary);

  /* ── Surfaces ───────────────────────────────────────────────────────── */
  /* Outer app canvas: neutrals-5. The greys in this theme come from the same
     `neutrals` ramp Akamai Cloud Manager ships, so light and dark are two ends
     of one scale. It is a faintly COOL neutral (blue channel runs 3-6 points
     hot), which is why it does not need the brand wash the old #F5F7F9 had. */
  --color-canvas:         #F7F7FA; /* neutrals-5                              */
  --color-surface:        #FFFFFF;
  --color-surface-raised: #FFFFFF;
  --color-muted:          #EDEDF2; /* neutrals-10 — muted SURFACE, not text   */
  --color-inverse:        #232326; /* neutrals-black — code blocks, tooltips  */

  /* ── Foreground ─────────────────────────────────────────────────────── */
  --color-foreground:          #343438; /* neutrals-100 12.39 on surface — AAA */
  --color-muted-foreground:    #515157; /* neutrals-80   7.88 on surface — AAA */
  --color-subtle-foreground:   #696970; /* neutrals-70   5.45 on surface — AA  */
  /* 2.50 on surface — deliberately fails AA. WCAG 1.4.3 exempts the text of
     disabled controls; this token must never be used for enabled content. */
  --color-disabled-foreground: #A3A3AB; /* neutrals-50 */
  --color-inverse-foreground:  #FFFFFF; /*              15.67 on inverse — AAA */

  /* ── Brand chrome (theme-invariant) ─────────────────────────────────── */
  /* The app-shell layer, and Akamai Navy in BOTH themes: it is brand chrome,
     not a themed surface, so it does not ride the neutrals ramp the surfaces
     use. The dark theme repeats these two lines verbatim.
     --color-on-brand is the only correct foreground on it. */
  --color-brand-chrome: #002F6C;
  --color-on-brand:     #FFFFFF; /* 12.94 on brand-chrome — AAA */

  /* ── Borders & focus ────────────────────────────────────────────────── */
  /* Decorative dividers only (1.45 on surface). SC 1.4.11 does not apply to
     purely decorative separators — but it DOES apply to control boundaries,
     which must use --color-border-strong. */
  --color-border:        #D6D6DD; /* neutrals-30 */
  --color-border-strong: #83838C; /* neutrals-60 3.76 on surface — ✓ 1.4.11 */
  --color-border-hover:  #515157; /* neutrals-80 7.88 on surface */
  --color-border-subtle: #EDEDF2; /* neutrals-10 — hairlines in tinted surfaces */
  /* Navy, not Akamai Blue: blue-on-white is 2.80, below the 3:1 that SC 1.4.11
     requires of a focus indicator. Navy is 12.94. Blue-ish returns as the ring
     in the dark theme, where brand-60 measures 4.67 on neutrals-90. */
  --color-ring:          #002F6C; /*             12.94 on surface — ✓ 1.4.11 */

  /* ── Status roles ───────────────────────────────────────────────────── */
  /* Each role ships four tokens:
       --color-X                    solid fill / icon / accent border
       --color-X-foreground         text on that solid fill
       --color-X-subtle             tinted surface
       --color-X-subtle-foreground  text on that tint
     Light tints:  color-mix(in srgb, <brand> 12%, #FFFFFF)
     Light tint fg: color-mix(in srgb, <brand> 55%, #000000) */

  --color-primary:                   #002F6C; /* Akamai Navy */
  --color-primary-foreground:        #FFFFFF; /* 12.94 on primary — AAA */
  --color-primary-subtle:            #D9E0EA;
  --color-primary-subtle-foreground: #002F6C; /* 10.85 on subtle  — AAA */

  /* Hover for the solid primary fill. This has to be a token rather than the
     usual color-mix toward --color-foreground, because navy (L*≈18) and the
     light foreground #2A2A2B (L*≈16) are the same darkness — that mix is
     mathematically a hover and visually nothing at all.
     Lightening along the navy→Akamai-Blue axis (80/20) instead gives a clearly
     perceptible change and stays inside the brand's navy+blue pairing. */
  --color-primary-hover:             #004685; /* 9.48 with primary-foreground */

  /* Akamai Blue, demoted from `primary` to an accent. Named `highlight` to
     match the brand document's own wording, and deliberately NOT `accent`
     (in shadcn vocabulary `accent` is a subtle hover surface, so that name
     would invite bg-accent misuse). Never body text on a light surface —
     2.80 on white. Large display text on navy, or non-text use. */
  --color-highlight:            #00A4EB;
  --color-highlight-foreground: #002F6C; /* 4.63 on highlight — AA */

  --color-success:                   #00CD63;
  --color-success-foreground:        #002F6C; /* 6.11 on success — AA */
  --color-success-subtle:            #E0F9EC;
  --color-success-subtle-foreground: #007136; /* 5.54 on subtle  — AA */

  --color-warning:                   #FF8B00;
  --color-warning-foreground:        #002F6C; /* 5.51 on warning — AA */
  --color-warning-subtle:            #FFF1E0;
  --color-warning-subtle-foreground: #8C4C00; /* 6.01 on subtle  — AA */

  /* Brand red (#F02B1F) is 4.14:1 under white text — short of AA for a
     .btn--danger label. Darkened 8% toward black:
     color-mix(in srgb, #F02B1F 92%, #000000). The palette keeps the exact
     brand red for data-viz; only this semantic fill moves. Mirrors the dark
     theme, which lightens red for the same reason. */
  --color-error:                     #DD281D;
  --color-error-foreground:          #FFFFFF; /* 4.79 on error — AA */
  --color-error-subtle:              #FDE6E4;
  --color-error-subtle-foreground:   #841811; /* 8.31 on subtle — AAA */

  --color-info:                      #00A4EB;
  --color-info-foreground:           #002F6C; /* 4.63 on info   — AA */
  --color-info-subtle:               #E0F4FD;
  --color-info-subtle-foreground:    #005A81; /* 6.67 on subtle — AA */

  /* ── Overlay & shadow ───────────────────────────────────────────────── */
  --color-overlay: rgb(35 35 38 / 0.5); /* modal / drawer / palette scrims —
                                           tracks --color-inverse */

  /* Space-separated RGB so spacing.css can derive several alphas from one
     color. Navy-tinted rather than neutral black: it reads intentional
     against the cool canvas. */
  --color-shadow-rgb: 0 47 108;
  --shadow-strength:  1;
}

/* ─────────────────────────────────────────────────────────────────────────
 * Semantic color roles — DARK THEME.
 *
 * Must be imported AFTER semantic.css. Both blocks below carry the same
 * specificity as semantic.css's `:root` (0-1-0), so source order is what
 * makes dark win when it applies.
 *
 * ┌─ WHY TWO IDENTICAL BLOCKS ─────────────────────────────────────────────┐
 * │ CSS cannot put part of a selector list inside an @media rule, so the   │
 * │ system-preference case and the explicit opt-in case must each carry a  │
 * │ full copy of the values.                                               │
 * │                                                                        │
 * │ THE TWO BLOCKS MUST STAY BYTE-IDENTICAL BELOW THE SELECTOR LINE.       │
 * │ scripts/check-contrast.py fails the build if they drift.               │
 * └────────────────────────────────────────────────────────────────────────┘
 *
 * The @media block is scoped to :root and excludes BOTH explicit values, so
 * it only ever applies when the user has expressed no preference — giving a
 * correct three-state system | light | dark. It is also the no-JS path: a
 * consumer who skips the pre-paint script still gets the right theme for the
 * `system` case with no flash.
 *
 * The [data-theme="dark"] block is NOT scoped to :root, so it works on any
 * element — that is what makes a dark island inside a light page possible.
 *
 * Dark surfaces are NEUTRAL GREY, on the same `neutrals` ramp Akamai Cloud
 * Manager ships (its dark mode sets --paper-background-color: #3d3d42 and
 * --paper-border-color: #515157; those are neutrals-90 and neutrals-80).
 * They used to be navy-tinted, which made --color-surface the same hex as the
 * light theme's --color-primary: every panel and Card painted in brand navy,
 * and the result read as a blue app rather than a dark one.
 *
 * Brand navy survives here as an accent, as the -foreground that sits on
 * bright status fills, and as --color-brand-chrome: the app-shell navbar and
 * drawer stay navy in both themes. They are brand chrome, not a surface, so
 * they are the one thing in this file that does not ride the neutrals ramp.
 * ───────────────────────────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    accent-color: var(--color-primary);

    /* ── Surfaces ───────────────────────────────────────────────────────── */
    /* Note raised is LIGHTER than surface, and muted sits below canvas: cards
       and popovers lift, recessed things sink. Same direction as light. */
    --color-canvas:         #343438; /* neutrals-100 — the page              */
    --color-surface:        #3D3D42; /* neutrals-90  — Akamai's "paper"      */
    --color-surface-raised: #47474D; /* neutrals-85  — dropdowns, popovers   */
    --color-muted:          #2E2E32; /* recessed: table headers, input fills */
    --color-inverse:        #F7F7FA; /* neutrals-5                           */

    /* ── Foreground ─────────────────────────────────────────────────────── */
    --color-foreground:          #FFFFFF; /* 10.80 on surface — AAA     */
    --color-muted-foreground:    #D6D6DD; /*  7.47 on surface — AAA     */
    --color-subtle-foreground:   #C2C2CA; /*  6.10 surface, 5.21 raised */
    --color-disabled-foreground: #83838C; /*  2.87 — 1.4.3 exempt       */
    --color-inverse-foreground:  #232326; /* 14.66 on inverse — AAA     */

    /* ── Brand chrome (theme-invariant) ─────────────────────────────────── */
    /* The app-shell layer is Akamai Navy in BOTH themes — it is brand chrome,
       not a themed surface, so it does not ride the neutrals ramp with the
       rest of this file. Akamai Cloud Manager greys its own dark rail out to
       #232326, but near-black reads as an absence rather than as the brand,
       and navy is already 3.70:1 off --color-surface here, so the rail is a
       distinct plane without it. This is the one token that stays put. */
    --color-brand-chrome: #002F6C;
    --color-on-brand:     #FFFFFF; /* 12.94 on brand-chrome — AAA */

    /* ── Borders & focus ────────────────────────────────────────────────── */
    --color-border:        #515157; /* neutrals-80, Akamai's paper border;
                                       decorative dividers only          */
    --color-border-strong: #A3A3AB; /* 4.31 on surface — ✓ 1.4.11 */
    --color-border-hover:  #C2C2CA; /* 6.10 on surface            */
    --color-border-subtle: #47474D;
    --color-ring:          #5BB3EA; /* 4.67 on surface — ✓ 1.4.11 */

    /* ── Status roles ───────────────────────────────────────────────────── */
    /* Dark tints: color-mix(in srgb, <fill> 18%, #232326) — the chrome value,
       NOT --color-canvas. Mixing into the canvas leaves the tinted panel too
       light and drops all five -subtle-foreground pairings to ~4.2, below AA.
       Committed as literals because check-contrast.py only parses #rrggbb. */

    /* Akamai Blue #00A4EB is 3.86 on neutrals-90 — under AA, and this token
       backs .link, which is body text. brand-60 is Akamai's own dark accent. */
    --color-primary:                   #5BB3EA; /* 4.67 on surface — AA     */
    --color-primary-foreground:        #002F6C; /* 5.59 on primary — AA     */
    --color-primary-subtle:            #2D3D49;
    --color-primary-subtle-foreground: #A8D9F5; /* 7.42 on primary-subtle   */

    /* Lightened, mirroring the light theme's token. The hover has to exist as
       a token in both themes or the light one has nothing to override. */
    --color-primary-hover:             #8FCDF2; /* 6.26 on surface, 7.51
                                                   with primary-foreground  */

    --color-highlight:            #00A4EB; /* stays Akamai Blue: a decorative
                                              fill that carries only its own
                                              -foreground, never body text  */
    --color-highlight-foreground: #002F6C; /* 4.63 on highlight — AA */

    --color-success:                   #00CD63; /* 5.10 on surface        */
    --color-success-foreground:        #002F6C; /* 6.11 on success — AA   */
    --color-success-subtle:            #1D4231;
    --color-success-subtle-foreground: #00CD63; /* 5.28 on success-subtle */

    /* Brand orange lightened 15% toward white so it clears AA on every dark
       substrate, raised included. */
    --color-warning:                   #FF9C26; /* 5.16 on surface        */
    --color-warning-foreground:        #002F6C; /* 6.18 on warning — AA   */
    --color-warning-subtle:            #4B3926;
    --color-warning-subtle-foreground: #FF9C26; /* 5.25 on warning-subtle */

    /* Brand red #F02B1F is 2.61 on neutrals-90, and Akamai's own red-60
       #EB9091 reaches only 4.59 — a 0.09 margin. Lifted further for headroom. */
    --color-error:                     #F09A94; /* 5.02 on surface — AA */
    --color-error-foreground:          #002F6C; /* 6.01 on error — AA   */
    --color-error-subtle:              #48383A;
    --color-error-subtle-foreground:   #F09A94; /* 5.13 on error-subtle */

    --color-info:                      #40BBF0; /* 4.93 on surface — AA */
    --color-info-foreground:           #002F6C; /* 5.90 on info — AA    */
    --color-info-subtle:               #283E4A;
    --color-info-subtle-foreground:    #40BBF0; /* 5.10 on info-subtle  */

    /* ── Overlay & shadow ───────────────────────────────────────────────── */
    /* Heavier than light: the page underneath is already dark. */
    --color-overlay: rgb(0 0 0 / 0.7);

    /* Neutral black, and 4× the alpha — these surfaces are mid-greys, so a
       navy-tinted 10% shadow would not register against them. */
    --color-shadow-rgb: 0 0 0;
    --shadow-strength:  4;
  }
}

[data-theme="dark"] {
    color-scheme: dark;
    accent-color: var(--color-primary);

    /* ── Surfaces ───────────────────────────────────────────────────────── */
    /* Note raised is LIGHTER than surface, and muted sits below canvas: cards
       and popovers lift, recessed things sink. Same direction as light. */
    --color-canvas:         #343438; /* neutrals-100 — the page              */
    --color-surface:        #3D3D42; /* neutrals-90  — Akamai's "paper"      */
    --color-surface-raised: #47474D; /* neutrals-85  — dropdowns, popovers   */
    --color-muted:          #2E2E32; /* recessed: table headers, input fills */
    --color-inverse:        #F7F7FA; /* neutrals-5                           */

    /* ── Foreground ─────────────────────────────────────────────────────── */
    --color-foreground:          #FFFFFF; /* 10.80 on surface — AAA     */
    --color-muted-foreground:    #D6D6DD; /*  7.47 on surface — AAA     */
    --color-subtle-foreground:   #C2C2CA; /*  6.10 surface, 5.21 raised */
    --color-disabled-foreground: #83838C; /*  2.87 — 1.4.3 exempt       */
    --color-inverse-foreground:  #232326; /* 14.66 on inverse — AAA     */

    /* ── Brand chrome (theme-invariant) ─────────────────────────────────── */
    /* The app-shell layer is Akamai Navy in BOTH themes — it is brand chrome,
       not a themed surface, so it does not ride the neutrals ramp with the
       rest of this file. Akamai Cloud Manager greys its own dark rail out to
       #232326, but near-black reads as an absence rather than as the brand,
       and navy is already 3.70:1 off --color-surface here, so the rail is a
       distinct plane without it. This is the one token that stays put. */
    --color-brand-chrome: #002F6C;
    --color-on-brand:     #FFFFFF; /* 12.94 on brand-chrome — AAA */

    /* ── Borders & focus ────────────────────────────────────────────────── */
    --color-border:        #515157; /* neutrals-80, Akamai's paper border;
                                       decorative dividers only          */
    --color-border-strong: #A3A3AB; /* 4.31 on surface — ✓ 1.4.11 */
    --color-border-hover:  #C2C2CA; /* 6.10 on surface            */
    --color-border-subtle: #47474D;
    --color-ring:          #5BB3EA; /* 4.67 on surface — ✓ 1.4.11 */

    /* ── Status roles ───────────────────────────────────────────────────── */
    /* Dark tints: color-mix(in srgb, <fill> 18%, #232326) — the chrome value,
       NOT --color-canvas. Mixing into the canvas leaves the tinted panel too
       light and drops all five -subtle-foreground pairings to ~4.2, below AA.
       Committed as literals because check-contrast.py only parses #rrggbb. */

    /* Akamai Blue #00A4EB is 3.86 on neutrals-90 — under AA, and this token
       backs .link, which is body text. brand-60 is Akamai's own dark accent. */
    --color-primary:                   #5BB3EA; /* 4.67 on surface — AA     */
    --color-primary-foreground:        #002F6C; /* 5.59 on primary — AA     */
    --color-primary-subtle:            #2D3D49;
    --color-primary-subtle-foreground: #A8D9F5; /* 7.42 on primary-subtle   */

    /* Lightened, mirroring the light theme's token. The hover has to exist as
       a token in both themes or the light one has nothing to override. */
    --color-primary-hover:             #8FCDF2; /* 6.26 on surface, 7.51
                                                   with primary-foreground  */

    --color-highlight:            #00A4EB; /* stays Akamai Blue: a decorative
                                              fill that carries only its own
                                              -foreground, never body text  */
    --color-highlight-foreground: #002F6C; /* 4.63 on highlight — AA */

    --color-success:                   #00CD63; /* 5.10 on surface        */
    --color-success-foreground:        #002F6C; /* 6.11 on success — AA   */
    --color-success-subtle:            #1D4231;
    --color-success-subtle-foreground: #00CD63; /* 5.28 on success-subtle */

    /* Brand orange lightened 15% toward white so it clears AA on every dark
       substrate, raised included. */
    --color-warning:                   #FF9C26; /* 5.16 on surface        */
    --color-warning-foreground:        #002F6C; /* 6.18 on warning — AA   */
    --color-warning-subtle:            #4B3926;
    --color-warning-subtle-foreground: #FF9C26; /* 5.25 on warning-subtle */

    /* Brand red #F02B1F is 2.61 on neutrals-90, and Akamai's own red-60
       #EB9091 reaches only 4.59 — a 0.09 margin. Lifted further for headroom. */
    --color-error:                     #F09A94; /* 5.02 on surface — AA */
    --color-error-foreground:          #002F6C; /* 6.01 on error — AA   */
    --color-error-subtle:              #48383A;
    --color-error-subtle-foreground:   #F09A94; /* 5.13 on error-subtle */

    --color-info:                      #40BBF0; /* 4.93 on surface — AA */
    --color-info-foreground:           #002F6C; /* 5.90 on info — AA    */
    --color-info-subtle:               #283E4A;
    --color-info-subtle-foreground:    #40BBF0; /* 5.10 on info-subtle  */

    /* ── Overlay & shadow ───────────────────────────────────────────────── */
    /* Heavier than light: the page underneath is already dark. */
    --color-overlay: rgb(0 0 0 / 0.7);

    /* Neutral black, and 4× the alpha — these surfaces are mid-greys, so a
       navy-tinted 10% shadow would not register against them. */
    --color-shadow-rgb: 0 0 0;
    --shadow-strength:  4;
}

/* ─────────────────────────────────────────────────────────────────────────
 * DEPRECATED token aliases — scheduled for removal in 0.6.0.
 *
 * Every token name that existed before the semantic restructure is kept here,
 * pointing at its canonical replacement. This is what makes the rename a
 * non-breaking change: the 44 component CSS files, the override recipe in
 * docs/STYLING.md and every existing consumer keep working untouched.
 *
 * ┌─ WHY THE SELECTOR IS `:root, [data-theme]` ────────────────────────────┐
 * │ A custom property's value is substituted at computed-value time on the │
 * │ element where it is DECLARED. Declared only on :root, `var(--color-    │
 * │ surface)` would resolve against :root's value and then inherit down    │
 * │ already-resolved — so a nested [data-theme="dark"] island would never  │
 * │ re-resolve it, and every alias would silently stay light.              │
 * │                                                                        │
 * │ `[data-theme]` matches any element carrying the attribute — i.e. every │
 * │ theme root, at any depth — so the indirection re-resolves there.       │
 * └────────────────────────────────────────────────────────────────────────┘
 *
 * ┌─ DO NOT ADD THESE TO tailwind.css ─────────────────────────────────────┐
 * │ Registering them in @theme would regenerate exactly the stuttering     │
 * │ utilities this rename exists to remove (bg-bg-primary, text-text-...). │
 * │ scripts/check-tokens.sh asserts the intersection is empty.             │
 * └────────────────────────────────────────────────────────────────────────┘
 * ───────────────────────────────────────────────────────────────────────── */

:root,
[data-theme] {
  /* Backgrounds → surfaces */
  --color-bg-primary:   var(--color-surface);
  --color-bg-content:   var(--color-surface);
  --color-bg-secondary: var(--color-muted);
  --color-bg-inverse:   var(--color-inverse);
  --color-bg-page:      var(--color-canvas);

  /* Text → foregrounds */
  --color-text-primary:   var(--color-foreground);
  --color-text-secondary: var(--color-muted-foreground);
  /* Was referenced by code.css but never declared anywhere — 2 broken
     declarations before this restructure. */
  --color-text-muted:     var(--color-subtle-foreground);
  --color-text-disabled:  var(--color-disabled-foreground);
  --color-text-inverse:   var(--color-inverse-foreground);

  /* Borders */
  --color-border-default: var(--color-border);
  --color-border-focus:   var(--color-ring);

  /* `secondary` meant "secondary text color", which reads as a background in
     Tailwind (`bg-secondary`). Canonical name is --color-muted-foreground. */
  --color-secondary: var(--color-muted-foreground);

  /* Off-brand inventions, absent from the brand document. Both were used as
     the outer app canvas; --color-canvas is the brand-derived replacement. */
  --color-brand-blue-tint: var(--color-canvas);
  --color-grey-7:          var(--color-canvas);
}

:root {
  /* Font Families
     Arial is the brand's only approved fallback for Instrument Sans — the
     system-ui / -apple-system stack that used to sit here is off-brand. */
  --font-sans: 'Instrument Sans', Arial, sans-serif;
  /* The brand specifies no monospace typeface; this is a library choice for
     code surfaces, not a brand mandate. */
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  /* CJK typefaces, per the brand document. Applied via :lang() below. */
  --font-cjk-sc: 'DFhei', 'Microsoft YaHei', var(--font-sans);      /* 简体中文 */
  --font-cjk-tc: 'DFPhei W5', 'Microsoft JhengHei', var(--font-sans); /* 繁體中文 */
  --font-ja:     'Meiryo', 'Hiragino Sans', var(--font-sans);       /* 日本語   */
  --font-ko:     'Malgun Gothic', 'Apple SD Gothic Neo', var(--font-sans); /* 한국어 */

  /* Font Sizes */
  --text-2xs:  0.625rem;  /* 10px — .badge--sm only */
  --text-xs:   0.75rem;   /* 12px */
  --text-sm:   0.875rem;  /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg:   1.125rem;  /* 18px */
  --text-xl:   1.25rem;   /* 20px */
  --text-2xl:  1.5rem;    /* 24px */
  --text-3xl:  1.875rem;  /* 30px */
  --text-4xl:  2.25rem;   /* 36px */
  --text-5xl:  3rem;      /* 48px */

  /* Minimum size for Akamai Blue used as highlight text (brand rule, p.26).
     Advisory — see docs/brand/BRAND_REFERENCE.md: blue on white is 2.80:1 and
     does not reach WCAG large-text AA even at this size, so --color-highlight
     is for large display text on navy, or for non-text use. */
  --text-highlight-min: 1.25rem; /* 20px ≈ 15pt */

  /* Font Weights — Instrument Sans is a variable font carrying 100–900. */
  --font-light:     300;
  --font-normal:    400;
  --font-medium:    500;
  --font-semibold:  600;
  --font-bold:      700;
  --font-extrabold: 800;
  --font-black:     900;

  /* Line Heights */
  --leading-tight:  1.25;
  --leading-snug:   1.375;
  --leading-normal: 1.5;
  --leading-relaxed:1.625;

  /* Letter Spacing */
  --tracking-tight:  -0.025em;
  --tracking-normal:  0em;
  --tracking-wide:    0.025em;

  /* Border Radius */
  --radius-sm:   2px;
  --radius-base: 4px;
  --radius-md:   6px;
  --radius-lg:   8px;
  --radius-xl:   12px;
  --radius-full: 9999px;
}

/* Route CJK content to the brand's per-script typefaces. */
:lang(zh-Hans) { font-family: var(--font-cjk-sc); }
:lang(zh-Hant) { font-family: var(--font-cjk-tc); }
:lang(ja)      { font-family: var(--font-ja); }
:lang(ko)      { font-family: var(--font-ko); }

:root {
  /* Spacing Scale (4px base) */
  --space-0:  0;
  --space-px: 1px;
  --space-0-5: 0.125rem;  /* 2px */
  --space-1:   0.25rem;   /* 4px */
  --space-1-5: 0.375rem;  /* 6px */
  --space-2:   0.5rem;    /* 8px */
  --space-2-5: 0.625rem;  /* 10px */
  --space-3:   0.75rem;   /* 12px */
  --space-3-5: 0.875rem;  /* 14px */
  --space-4:   1rem;      /* 16px */
  --space-5:   1.25rem;   /* 20px */
  --space-6:   1.5rem;    /* 24px */
  --space-7:   1.75rem;   /* 28px */
  --space-8:   2rem;      /* 32px */
  --space-10:  2.5rem;    /* 40px */
  --space-12:  3rem;      /* 48px */
  --space-16:  4rem;      /* 64px */
  --space-20:  5rem;      /* 80px */
  --space-24:  6rem;      /* 96px */
  --space-32:  8rem;      /* 128px */

  /* Semantic inset (default component padding) */
  --space-inset-sm: var(--space-3); /* 12px — compact */
  --space-inset:    var(--space-4); /* 16px — default branded padding */
  --space-inset-lg: var(--space-6); /* 24px — roomy */

  /* Container horizontal inset — responsive page-shell padding */
  --container-inset-x: var(--space-4); /* 16px < 640px */

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-base:   200ms ease;
  --transition-slow:   300ms ease;

  /* Z-index — ordered, no collisions. Previously --z-dropdown and --z-tooltip
     were both 400 and --z-modal (300) sat *below* both, so a modal could not
     cover an open dropdown. */
  --z-sticky:   200;
  --z-dropdown: 300;
  --z-modal:    400;
  --z-tooltip:  500;
}

/* ── Shadows ───────────────────────────────────────────────────────────────
 * Driven by --color-shadow-rgb / --shadow-strength from the semantic tier, so
 * they follow the theme. A neutral 10%-black shadow is invisible on a navy
 * dark surface; the dark theme swaps to black at 4× the alpha.
 *
 * Declared on `:root, [data-theme]` rather than `:root` alone for the same
 * reason as the alias tier: a var() declared only on :root resolves there and
 * inherits already-resolved, which would freeze the light shadow inside a
 * nested dark island. See aliases.css for the full explanation.
 * ───────────────────────────────────────────────────────────────────────── */
:root,
[data-theme] {
  --shadow-sm:
    0 1px 2px 0 rgb(var(--color-shadow-rgb) / calc(0.05 * var(--shadow-strength)));
  --shadow-md:
    0 4px 6px -1px rgb(var(--color-shadow-rgb) / calc(0.10 * var(--shadow-strength))),
    0 2px 4px -1px rgb(var(--color-shadow-rgb) / calc(0.06 * var(--shadow-strength)));
  --shadow-lg:
    0 10px 15px -3px rgb(var(--color-shadow-rgb) / calc(0.10 * var(--shadow-strength))),
    0 4px 6px -2px  rgb(var(--color-shadow-rgb) / calc(0.05 * var(--shadow-strength)));
  --shadow-xl:
    0 20px 25px -5px rgb(var(--color-shadow-rgb) / calc(0.10 * var(--shadow-strength))),
    0 10px 10px -5px rgb(var(--color-shadow-rgb) / calc(0.04 * var(--shadow-strength)));
}

/* Container horizontal inset grows with the screen */
@media (min-width: 640px)  { :root { --container-inset-x: var(--space-6); } } /* 24px ≥ 640px */
@media (min-width: 1024px) { :root { --container-inset-x: var(--space-8); } } /* 32px ≥ 1024px */
