/*
 * Design tokens — three orthogonal dimensions.
 *
 *   Brightness  [data-theme="light" | "dark"]   → surfaces, text, borders,
 *                                                  shadows, feedback colours.
 *   Environment [data-env="local" | "development" | "qa" | "uat" | "production"]
 *                                               → a single fixed accent hue,
 *                                                  used only for small
 *                                                  functional elements.
 *   Brand       [data-brand="excise" | "asahi" | ...]
 *                                               → the tenant's primary +
 *                                                  secondary accent pair
 *                                                  (--color-accent* /
 *                                                  --color-gold*). Unlike
 *                                                  environment, this is
 *                                                  deliberately open-ended
 *                                                  and tenant-suppliable —
 *                                                  see docs/adr/0005.
 *                                                  No attribute set = the
 *                                                  Excise Tax default below.
 *
 * Components must consume the semantic --color-* / --env-* custom properties
 * below, never raw hex values. See docs/adr/0001-functional-styling-tokens.md
 * for the reasoning, and src/styles/AGENTS.md for the consumption rules.
 */

:root {
  /* ---- Environment identity — fixed, org-independent, theme-independent.
     This is the ONE place these hex values are allowed to live. ---- */
  --env-local: #64748b;
  --env-development: #3b82f6;
  --env-qa: #a855f7;
  --env-uat: #f59e0b;
  --env-production: #ef4444;

  /* ---- Typography ----
     Sans (Inter) drives titles, headers, labels, and UI chrome — the
     "stand out" text. Serif (Cormorant, a high-contrast opulent Garamond)
     drives body/paragraph prose. Both are self-hosted variable fonts — see
     src/styles/fonts.css and assets/fonts/AGENTS.md. System stacks are the
     fallback, not the default. */
  --font-sans: "Inter", -apple-system, "Segoe UI", ui-sans-serif, system-ui, Roboto, sans-serif;
  --font-serif: "Cormorant", ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --text-2xs: 0.6875rem;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --text-3xl: 2.75rem;

  --leading-tight: 1.25;
  --leading-normal: 1.5;

  /* ---- Spacing scale (4px base) ---- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.5rem;
  --space-8: 3rem;
  --space-10: 4rem;

  /* ---- Radius / borders ---- */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-full: 999px;
  --border-width: 1px;

  /* ---- Motion ---- */
  --duration-fast: 120ms;
  --duration-base: 180ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- Brand-scene overlays ----
     For UI placed directly ON the photographic brand scenes (login backdrop,
     slide caption). These are deliberately theme-INDEPENDENT: the art is dark
     in both brightness modes, so text/glass over it stays light either way.
     This is the one sanctioned exception to "surfaces follow the theme" — the
     surface here is a photograph, not a theme fill. */
  --scene-ink: #f2ede1;        /* primary text over scene art */
  --scene-ink-dim: #cfc7b6;    /* secondary text over scene art */
  --scene-ink-muted: #9c968a;  /* muted text over scene art */
  --scene-glass: rgb(9 12 10 / 72%);           /* frosted panel fill */
  --scene-gold-hairline: rgb(212 175 95 / 28%); /* gold edge on scene panels */
  --scene-scrim: linear-gradient(90deg, rgb(6 8 6 / 78%) 0%, rgb(6 8 6 / 30%) 55%, transparent 80%);
}

/* =========================================================================
   Brightness — theme tokens
   ========================================================================= */

[data-theme="dark"] {
  /* Cool dark neutrals — near-black surfaces, cool grey-blue text. Brand
     identity (accent + gold below) is what carries warmth or colour now,
     not the base surface — see docs/adr/0005-tenant-brand-accent.md. */
  --color-bg-canvas: #0b0d12;
  --color-bg-surface: #12151c;
  --color-bg-surface-raised: #181c26;
  --color-bg-sunken: #090b0f;
  --color-bg-overlay: rgb(5 6 9 / 72%);
  --color-bg-hover: rgb(255 255 255 / 5%);

  --color-border: #262b36;
  --color-border-strong: #39414f;

  --color-text-primary: #e7e9ee;
  --color-text-secondary: #a7adba;
  --color-text-muted: #6b7182;
  --color-text-inverse: #0b0d12;
  --color-text-link: #3fc3b4;

  /* Product-interactive colour — primary buttons, links, checked inputs.
     Deep teal, echoing the letter-rack. This is the Excise Tax BRAND's
     accent, not a fixed system colour like environment — a consuming app
     picks its own pair via [data-brand="..."] (see below); no attribute
     set falls back to this Excise Tax default. On the dark theme the teal
     is bright enough to carry dark espresso text at AA. */
  --color-accent: #2bb3a3;
  --color-accent-hover: #45c9b9;
  --color-accent-fg: #06110f;

  /* Gold — Excise Tax's decorative secondary accent (hero numerals,
     hairline rules, highlight chips). Not an interactive colour; never a
     button fill. Brand-scoped like --color-accent above. */
  --color-gold: #d4af5f;
  --color-gold-soft: #b8912f;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-md: 0 4px 16px rgb(0 0 0 / 45%);
  --shadow-lg: 0 16px 48px rgb(0 0 0 / 55%);

  /* Feedback tokens — data/validation state, deliberately distinct from the
     brand's primary/secondary accents (see ADR 0001, "why two accent
     systems"). Theme-scoped, not brand-scoped — the same in every brand. */
  --color-success: #34d399;
  --color-warning: #fbbf24;
  --color-danger: #f87171;
  --color-info: #60a5fa;

  /* Categorical palette for data-dense views (table provenance, chips) —
     not tied to environment, feedback, or brand semantics. */
  --data-1: #60a5fa;
  --data-2: #34d399;
  --data-3: #fbbf24;
  --data-4: #a78bfa;
  --data-5: #2dd4bf;
  --data-6: #f472b6;
}

[data-theme="light"] {
  /* Cool light neutrals — white surfaces, cool grey-blue text. Brand
     identity (accent + gold below) is what carries warmth or colour now,
     not the base surface — see docs/adr/0005-tenant-brand-accent.md. */
  --color-bg-canvas: #f4f5f7;
  --color-bg-surface: #ffffff;
  --color-bg-surface-raised: #ffffff;
  --color-bg-sunken: #eaecf0;
  --color-bg-overlay: rgb(15 18 25 / 45%);
  --color-bg-hover: rgb(15 18 25 / 4%);

  --color-border: #dee1e8;
  --color-border-strong: #c2c8d3;

  --color-text-primary: #14171f;
  --color-text-secondary: #4b5566;
  --color-text-muted: #7c8494;
  --color-text-inverse: #ffffff;
  --color-text-link: #0f7268;

  /* Deep teal-700 — white text at AA. Excise Tax's brand accent; see the
     dark-theme block above for the brand-scoping note. */
  --color-accent: #0f766e;
  --color-accent-hover: #0b5f58;
  --color-accent-fg: #fbf6ea;

  --color-gold: #9c7a24;
  --color-gold-soft: #b8912f;

  --shadow-sm: 0 1px 2px rgb(20 23 31 / 6%);
  --shadow-md: 0 4px 16px rgb(20 23 31 / 8%);
  --shadow-lg: 0 16px 48px rgb(20 23 31 / 14%);

  --color-success: #059669;
  --color-warning: #b45309;
  --color-danger: #dc2626;
  --color-info: #2563eb;

  --data-1: #2563eb;
  --data-2: #059669;
  --data-3: #b45309;
  --data-4: #7c3aed;
  --data-5: #0d9488;
  --data-6: #db2777;
}

/* Derived feedback surfaces — same in both themes structurally, but tinted
   against whichever surface colour the active theme provides. */
[data-theme] {
  --color-success-bg: color-mix(in srgb, var(--color-success) 15%, var(--color-bg-surface));
  --color-warning-bg: color-mix(in srgb, var(--color-warning) 15%, var(--color-bg-surface));
  --color-danger-bg: color-mix(in srgb, var(--color-danger) 15%, var(--color-bg-surface));
  --color-info-bg: color-mix(in srgb, var(--color-info) 15%, var(--color-bg-surface));
}

/* =========================================================================
   Environment — accent tokens (orthogonal to brightness)
   ========================================================================= */

[data-env="local"]       { --env-accent: var(--env-local); }
[data-env="development"] { --env-accent: var(--env-development); }
[data-env="qa"]          { --env-accent: var(--env-qa); }
[data-env="uat"]         { --env-accent: var(--env-uat); }
[data-env="production"]  { --env-accent: var(--env-production); }

/* Derived variants — computed against the active theme's surface, so the
   canonical --env-* hue above never itself changes across orgs or themes. */
[data-env] {
  --env-accent-fg: #ffffff;
  --env-accent-subtle-bg: color-mix(in srgb, var(--env-accent) 14%, var(--color-bg-surface));
  --env-accent-border: color-mix(in srgb, var(--env-accent) 48%, var(--color-border));
  --env-accent-ring: color-mix(in srgb, var(--env-accent) 55%, transparent);

  /* Ambient presence — a faint, pervasive wash of the environment hue across
     ordinary chrome (hairline borders, dividers, scrollbar) and the page
     background, distinct from --env-accent-border's stronger 48% mix (used
     for a handful of explicitly-environment elements like the env badge).
     This is deliberately subtle: large fills (page/card/table backgrounds,
     button fills) stay pure theme-neutral — only chrome and hairlines carry
     the tint. See docs/adr/0002-typography-and-ambient-environment-presence.md. */
  --env-border: color-mix(in srgb, var(--env-accent) 14%, var(--color-border));
  --env-border-strong: color-mix(in srgb, var(--env-accent) 20%, var(--color-border-strong));
  --env-ambient-wash: color-mix(in srgb, var(--env-accent) 5%, transparent);
}

/* =========================================================================
   Brand — tenant accent tokens (orthogonal to brightness AND environment)
   ========================================================================= */

/* No [data-brand="excise"] block exists: Excise Tax is simply whatever
   [data-theme] already defines above, so a consumer that never sets
   data-brand (nothing does yet) keeps that look with zero change. A brand
   override is a full pair (primary + secondary), crossed with brightness
   only because contrast against the surface needs different lightness in
   each theme — the hue identity is the same in both. See ADR 0005. */

[data-brand="asahi"][data-theme="light"] {
  /* Asahi Cobalt Blue — deep enough for white button/link text at AA. */
  --color-accent: #004099;
  --color-accent-hover: #002d6b;
  --color-accent-fg: #ffffff;
  --color-text-link: #004099;

  /* Secondary — the red from Asahi Super Dry's own wordmark. */
  --color-gold: #d20a11;
  --color-gold-soft: #b8453a;
}

[data-brand="asahi"][data-theme="dark"] {
  /* Brightened toward the same hue so it pops on a near-black canvas, same
     reason Excise Tax's dark accent is lighter than its light one. */
  --color-accent: #4f8fe8;
  --color-accent-hover: #74a8f0;
  --color-accent-fg: #06101f;
  --color-text-link: #6fa8f0;

  --color-gold: #d20a11;
  --color-gold-soft: #b8453a;
}
