/*
 * Enyverse design tokens — single source of truth for web/app/globals.css
 * and client/ui/src/theme.css. Do not fork the palette: change values here
 * and both surfaces update. See design/README.md for how to consume this
 * file and the UI QUALITY BAR it exists to support.
 *
 * Dark is the default. Light theme activates via [data-theme="light"] on
 * <html> (both surfaces already have a theme-toggle that sets this
 * attribute) or via @media (prefers-color-scheme: light) as a fallback
 * when the toggle has never run.
 *
 * Every token name that existed in web/app/globals.css and
 * client/ui/src/theme.css before this file is preserved byte-for-byte in
 * meaning, so no importing page needs to change.
 */

:root {
  /* ---- Ground — near-pure black with only a faint green-cool tint. ---- */
  --bg: #030607;
  --bg-2: #05090b;
  --bg-grad-a: #04090b;
  --bg-grad-b: #010304;

  /* ---- Surfaces / lines, translucent so they layer over the field. ---- */
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.072);
  --surface-inset: rgba(0, 0, 0, 0.36);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.17);

  /* ---- Text — a slightly green-warm white. ---- */
  --text: #e9f1ed;
  --text-muted: #93a29c;
  /* Pilot desk X6: raised to pass WCAG AA (>= 4.5:1) on --bg (5.45:1). */
  --text-faint: #7b8782;

  /* ---- Brand accent + supporting greens. ---- */
  --accent: #1ec789;
  --accent-bright: #2ee39f;
  --accent-ink: #04140d; /* text/icon color that sits on a solid green fill */
  /* Pilot desk X4: some components use --accent-contrast; alias it so they get the ink color in both themes
     (resolved per theme, since --accent-ink is redefined on the same element). */
  --accent-contrast: var(--accent-ink);
  --accent-soft: rgba(30, 199, 137, 0.12);
  --accent-softer: rgba(30, 199, 137, 0.07);
  --accent-line: rgba(30, 199, 137, 0.35);
  --accent-glow: rgba(30, 199, 137, 0.22);

  /* ---- A cool secondary for non-hero data marks + status colors. ---- */
  --info: #56b6ff;
  --info-soft: rgba(86, 182, 255, 0.16);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  /* Pilot desk P1 item 6: small TEXT in the accent / danger / info hue. Dark: the base hues already pass AA on
     --bg (accent 9.3:1, danger 7.3:1, info 9.2:1); light redefines them darker. Fills/borders keep the base tokens. */
  --accent-text: var(--accent);
  --danger-text: var(--danger);
  --info-text: var(--info);
  --warning: #f0b429;
  --warning-soft: rgba(240, 180, 41, 0.14);
  --warning-line: rgba(240, 180, 41, 0.35);
  /* Pilot desk X5: warning-colored TEXT (AA on --bg in both themes); --warning stays the fill/border hue. */
  --warning-text: #f0b429;

  /* ---- Radii. ---- */
  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 20px;

  /* ---- Spacing scale (4px base). ---- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* ---- Type scale (rem, 1rem = 16px base). Bumps one step at >=2560px
     via the --type-scale-up custom property below (see README). ---- */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-md: 1.125rem;
  --font-size-lg: 1.35rem;
  --font-size-xl: 1.75rem;
  --font-size-2xl: 2.25rem;
  --font-size-3xl: 3rem;

  /* ---- Breakpoints (documentation only — CSS custom properties cannot be
     used inside @media queries; consumers hard-code these px values in
     their own @media rules and must keep them numerically in sync):
       360px  — smallest supported phone width (UI QUALITY BAR floor)
       768px  — tablet / small-laptop
       1366px — common laptop
       1920px — desktop / 1080p
       2560px — 4K sanity check (type scale +1 step at >=2560px per
                docs/UX-FLOW-DESIGN-RC8.md)
  ---- */

  /* ---- Accessibility floor. ---- */
  --tap-min: 44px;

  /* ---- Shadows. ---- */
  --shadow-card: 0 1px 0 0 rgba(255, 255, 255, 0.04) inset,
    0 20px 40px -28px rgba(0, 0, 0, 0.9);

  /* ---- Focus ring (paired with the .eny-focus utility in each surface's
     own stylesheet, which references --accent + --bg). ---- */
  --focus-ring-width: 2px;
  --focus-ring-offset: 2px;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef3f0;
  --bg-2: #e4ece8;
  --bg-grad-a: #f2f7f4;
  --bg-grad-b: #e6efea;

  --surface: rgba(255, 255, 255, 0.72);
  --surface-2: rgba(255, 255, 255, 0.92);
  --surface-inset: rgba(9, 30, 22, 0.05);
  --border: rgba(9, 40, 28, 0.1);
  --border-strong: rgba(9, 40, 28, 0.18);

  --text: #0b1a14;
  --text-muted: #4c5c55;
  --text-faint: #5f6c66; /* X6: AA on --bg (4.89:1) and --bg-2 (4.57:1) */

  --accent: #0f9d6c;
  --accent-bright: #12b87e;
  --accent-ink: #04140d; /* P1 item 6: 5.45:1 on --accent #0f9d6c (white was 3.47:1) */
  --accent-soft: rgba(15, 157, 108, 0.12);
  --accent-softer: rgba(15, 157, 108, 0.06);
  --accent-line: rgba(15, 157, 108, 0.35);
  --accent-glow: rgba(15, 157, 108, 0.18);

  --info: #1f7fd0;
  --info-soft: rgba(31, 127, 208, 0.14);
  --danger: #d64545;
  --danger-soft: rgba(214, 69, 69, 0.1);
  /* P1 item 6: text tokens, AA on --bg #eef3f0 / --bg-2 #e4ece8 / cards: accent 5.92 / 5.52, danger 5.62 / 5.24, info 5.87 / 5.48. */
  --accent-text: #086a47;
  --danger-text: #b32d2d;
  --info-text: #1a5fa0;
  --warning: #b9790c;
  --warning-soft: rgba(185, 121, 12, 0.12);
  --warning-line: rgba(185, 121, 12, 0.32);
  --warning-text: #8a5a06; /* X5: 5.28:1 on --bg */

  --shadow-card: 0 1px 0 0 rgba(255, 255, 255, 0.6) inset,
    0 18px 36px -30px rgba(9, 40, 28, 0.5);

  color-scheme: light;
}

/* Fallback for a first paint before any theme-init script has set
   data-theme (both surfaces set it synchronously on load, so this only
   covers a no-JS edge case): respect the OS preference. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]) {
    --bg: #eef3f0;
    --bg-2: #e4ece8;
    --bg-grad-a: #f2f7f4;
    --bg-grad-b: #e6efea;

    --surface: rgba(255, 255, 255, 0.72);
    --surface-2: rgba(255, 255, 255, 0.92);
    --surface-inset: rgba(9, 30, 22, 0.05);
    --border: rgba(9, 40, 28, 0.1);
    --border-strong: rgba(9, 40, 28, 0.18);

    --text: #0b1a14;
    --text-muted: #4c5c55;
    --text-faint: #5f6c66; /* X6: AA on --bg (4.89:1) and --bg-2 (4.57:1) */

    --accent: #0f9d6c;
    --accent-bright: #12b87e;
    --accent-ink: #04140d; /* P1 item 6: 5.45:1 on --accent #0f9d6c (white was 3.47:1) */
    --accent-soft: rgba(15, 157, 108, 0.12);
    --accent-softer: rgba(15, 157, 108, 0.06);
    --accent-line: rgba(15, 157, 108, 0.35);
    --accent-glow: rgba(15, 157, 108, 0.18);

    --info: #1f7fd0;
    --info-soft: rgba(31, 127, 208, 0.14);
    --danger: #d64545;
    --danger-soft: rgba(214, 69, 69, 0.1);
    /* P1 item 6: text tokens, AA on --bg #eef3f0 / --bg-2 #e4ece8 / cards: accent 5.92 / 5.52, danger 5.62 / 5.24, info 5.87 / 5.48. */
    --accent-text: #086a47;
    --danger-text: #b32d2d;
    --info-text: #1a5fa0;
    --warning: #b9790c;
    --warning-soft: rgba(185, 121, 12, 0.12);
    --warning-line: rgba(185, 121, 12, 0.32);
    --warning-text: #8a5a06;

    --shadow-card: 0 1px 0 0 rgba(255, 255, 255, 0.6) inset,
      0 18px 36px -30px rgba(9, 40, 28, 0.5);

    color-scheme: light;
  }
}
