/* =========================================================================
   Oyster Egg design tokens — dark and light
   -------------------------------------------------------------------------
   Derived from the ecosystem design system ("A Game Designer's View"), using
   the surface ramp as shipped in the Game Design Brain app.

   ── The two themes ────────────────────────────────────────────────────────

   DARK (default). The near-black violet-neutral ramp the app renders:
   #110E16 page, #19141F panels, #201B27 cards, cream #FAF1CC ink, amber
   #EE9A3A accent.

   LIGHT. The system's own light layer (§2.8), which is exactly the inversion
   the design calls for: cream becomes the field and Depth becomes the ink.
   Values are the system's, not invented:

     light-surface-0 #FAF1CC   base background
     light-surface-1 #F3E7BD   cards, panels
     light-surface-2 #EBDCAB   popovers, hover
     light-border    #D9C99A   borders, dividers
     light-text      #23074B   primary text (= Depth)
     light-text-muted #680E7A  muted text (= Structure)

   ── The rule that shapes the light theme ──────────────────────────────────

   "Amber & Pink on light are fill-only, never text." So amber stays as a
   FILL (buttons, badges) but any amber TEXT becomes Structure in light mode.
   That is what --text-accent exists for: components never use --accent for
   text, only for fills.

   ── How the theme is selected ─────────────────────────────────────────────

   Three cases, in priority order:
     1. html[data-theme="light"|"dark"] — an explicit choice, stored.
     2. No attribute — follow prefers-color-scheme.
     3. Anything unsupported — the dark values, declared first as a fallback.

   The mechanism is the CSS light-dark() function, which resolves against
   color-scheme. Each themed token is declared twice: once with the dark value
   (a safe fallback for engines without light-dark()), once with light-dark().
   ========================================================================= */

:root {
  /* ---- Brand palette (theme-independent) ------------------------------- */
  --color-depth: #23074b; /* the vivid wash: logo field, endcard */
  --color-cream: #faf1cc;
  --color-amber: #ee9a3a;
  --color-structure: #680e7a;
  --color-pink: #ee8389;
  --color-cream-dim: #c9bd9a;

  --color-depth-900: #1a0538;
  --color-depth-700: #2c0d5c;
  --color-depth-600: #3a1570;
  --color-amber-600: #d98421;
  --color-amber-300: #f4b66e;
  --color-pink-600: #e2666d;

  --color-success: #3fa37a;
  --color-warning: #ee9a3a;
  --color-error: #e5544e;
  --color-info: #6e8bef;

  /* ---- Surfaces -------------------------------------------------------- */
  --surface-base: #110e16;
  --surface-base: light-dark(#faf1cc, #110e16);

  --surface-panel: #19141f;
  --surface-panel: light-dark(#f3e7bd, #19141f);

  --surface-raised: #201b27;
  --surface-raised: light-dark(#f3e7bd, #201b27);

  --surface-hover: #2a2432;
  --surface-hover: light-dark(#ebdcab, #2a2432);

  --surface-footer: #19141f;
  --surface-footer: light-dark(#f3e7bd, #19141f);

  /* ---- Lines -----------------------------------------------------------
     Two weights.

     line-faint is the decorative hairline: card edges and dividers, kept as
     faint as the design system specifies.

     line-strong draws the boundary of interactive controls (the secondary
     button, hover outlines). Those boundaries are the only thing identifying
     the control, so WCAG 1.4.11 requires 3:1 against the page. The system's
     literal value here is solid cream, which measures 16.9:1 and reads as a
     heavy outline on a button; 40% cream measures 3.5:1 and still reads as a
     secondary border. Verified by scripts/check-contrast.mjs. */
  --line-faint: rgba(250, 241, 204, 0.08);
  --line-faint: light-dark(#d9c99a, rgba(250, 241, 204, 0.08));

  --line-strong: rgba(250, 241, 204, 0.4);
  --line-strong: light-dark(#23074b, rgba(250, 241, 204, 0.4));

  --line-input: rgba(250, 241, 204, 0.16);
  --line-input: light-dark(#d9c99a, rgba(250, 241, 204, 0.16));

  /* ---- Text ------------------------------------------------------------ */
  --text-strong: #faf1cc;
  --text-strong: light-dark(#23074b, #faf1cc);

  --text-body: #faf1cc;
  --text-body: light-dark(#23074b, #faf1cc);

  /**
   * Muted text.
   *
   * The app uses cream at 38%, which measures about 3.3:1 on the near-black
   * field and fails WCAG AA for body copy. This is a website with real prose,
   * so the accessible value wins: cream-dim on dark, Structure on light
   * (the system's own light-layer muted token).
   */
  --text-muted: #c9bd9a;
  --text-muted: light-dark(#680e7a, #c9bd9a);

  --text-subhead: #b07bd1;
  --text-subhead: light-dark(#680e7a, #b07bd1);

  /**
   * Text that carries the accent hue.
   *
   * Dark: the shared Amber text role.
   * Light: Structure. Amber is fill-only on light, per the system, so it can
   * never be used for text there.
   */
  --text-accent: #ee9a3a;
  --text-accent: light-dark(#680e7a, #ee9a3a);

  --text-on-accent: #110e16;
  --text-on-accent: light-dark(#23074b, #110e16);

  /* ---- Accent (fills only) --------------------------------------------- */
  --accent: var(--color-amber);
  --accent-pressed: var(--color-amber-600);

  /* ---- Status badges ---------------------------------------------------
     Three semantic groups, each with its own background and foreground so
     contrast holds in both themes. */
  --badge-released-bg: rgba(63, 163, 122, 0.22);
  --badge-released-bg: light-dark(rgba(63, 163, 122, 0.16), rgba(63, 163, 122, 0.22));
  --badge-released-fg: #8fd6b6;
  --badge-released-fg: light-dark(#1f6b4a, #8fd6b6);

  --badge-active-bg: rgba(238, 154, 58, 0.18);
  --badge-active-bg: light-dark(rgba(238, 154, 58, 0.2), rgba(238, 154, 58, 0.18));
  --badge-active-fg: #f4b66e;
  --badge-active-fg: light-dark(#7a4e0a, #f4b66e);

  --badge-neutral-bg: rgba(250, 241, 204, 0.08);
  --badge-neutral-bg: light-dark(rgba(35, 7, 75, 0.06), rgba(250, 241, 204, 0.08));
  --badge-neutral-fg: #c9bd9a;
  --badge-neutral-fg: light-dark(#680e7a, #c9bd9a);

  /* ---- Controls -------------------------------------------------------- */
  /* Subtle fill behind ghost/quiet buttons on hover. */
  --control-hover-bg: rgba(250, 241, 204, 0.08);
  --control-hover-bg: light-dark(rgba(35, 7, 75, 0.06), rgba(250, 241, 204, 0.08));

  /* Focus ring: Amber on dark, Depth on light. */
  --focus-ring: #ee9a3a;
  --focus-ring: light-dark(#23074b, #ee9a3a);

  /* ---- Type ------------------------------------------------------------ */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* Monospace is technical scaffolding only: versions, IDs, patch notes.
     Never body copy or headings. */
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 0.9375rem;
  --text-md: 1.0625rem;
  --text-lg: 1.3125rem;
  --text-xl: 1.625rem;
  --text-2xl: 2rem;
  --text-3xl: 2.5rem;

  --leading-tight: 1.1;
  --leading-snug: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.6;

  --tracking-label: 0.12em;
  --tracking-mono: 0.04em;
  --tracking-tight: -0.02em;

  /* ---- Space, radii, borders ------------------------------------------- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;

  --radius-sm: 4px;
  --radius-md: 8px; /* base for cards and buttons */
  --radius-lg: 12px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --content-width: 72rem;
  --reading-width: 42rem;

  /* ---- Motion: calm, no bounce ----------------------------------------- */
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-slow: 320ms;
  --duration-slower: 480ms;
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- Texture ---------------------------------------------------------
     The signature dot grid, tuned per theme so it stays barely visible
     rather than either vanishing or becoming noise. */
  --dot-color: rgba(250, 241, 204, 0.055);
  --dot-color: light-dark(rgba(35, 7, 75, 0.07), rgba(250, 241, 204, 0.055));
  --dot-grid: radial-gradient(var(--dot-color) 1px, transparent 1px);
  --dot-grid-size: 24px 24px;

  /* ---- Elevation -------------------------------------------------------
     Card glow matches the supplied DesignSystem/tokens.json export. */
  --glow-accent: var(--glow-amber);
  --glow-halo-blur: 24px;
  --glow-amber: 0 0 0 1px light-dark(rgba(224, 120, 20, 0.8), rgba(238, 154, 58, 0.5)), 0 0 var(--glow-halo-blur) 4px light-dark(rgba(224, 120, 20, 0.75), rgba(238, 154, 58, 0.55));
  --glow-pink: 0 0 0 1px light-dark(rgba(222, 70, 90, 0.8), rgba(238, 131, 137, 0.5)), 0 0 var(--glow-halo-blur) 4px light-dark(rgba(222, 70, 90, 0.7), rgba(238, 131, 137, 0.55));
  /* Flat cards; elevation is reserved for anchored surfaces. */
  --shadow-anchored: 0 0 0 1px light-dark(rgba(35,7,75,0.10), rgba(250,241,204,0.08)), 0 6px var(--shadow-anchored-blur) light-dark(rgba(35,7,75,0.12), rgba(250,241,204,0.06));
  --shadow-anchored-blur: 16px;
  --shadow-xs: 0 1px 2px light-dark(rgba(35,7,75,0.12), rgba(250,241,204,0.06));
}

/* ---- Theme selection ----------------------------------------------------
   Declared after :root so these win. Only color-scheme changes here; every
   token above resolves from it through light-dark(). */

/* Follow the operating system when the visitor has not chosen. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --glow-halo-blur: 36px;
    --shadow-anchored-blur: 14px;
  }
}

/* An explicit choice wins over the operating system, in both directions. */
:root[data-theme='light'] {
  color-scheme: light;
  --glow-halo-blur: 36px;
  --shadow-anchored-blur: 14px;
}

:root[data-theme='dark'] {
  color-scheme: dark;
}

/* Default when nothing is set and the OS is dark. */
:root {
  color-scheme: dark;
}

/* Pink accent scope. Apply to flip one composition to the soft accent.
   Amber and pink are never mixed within a single composition. */
[data-accent='pink'] {
  --accent: var(--color-pink);
  --accent-pressed: var(--color-pink-600);
  --glow-accent: var(--glow-pink);
}

[data-accent='amber'] {
  --accent: var(--color-amber);
  --accent-pressed: var(--color-amber-600);
}

/**
 * Forced-light subtree.
 *
 * The system's light layer applied to a region rather than the whole page.
 * Used for mark-on-light and any light placement (a social card, a print
 * block) that must stay light regardless of the page theme.
 */
.theme-light {
  color-scheme: light;

  --surface-base: #faf1cc;
  --surface-panel: #f3e7bd;
  --surface-raised: #f3e7bd;
  --surface-hover: #ebdcab;
  --surface-footer: #f3e7bd;
  --line-faint: #d9c99a;
  --line-strong: #23074b;

  --text-strong: #23074b;
  --text-body: #23074b;
  --text-muted: #680e7a;
  --text-subhead: #680e7a;
  --text-accent: #680e7a;
  --text-on-accent: #23074b;

  --control-hover-bg: rgba(35, 7, 75, 0.06);
  --focus-ring: #23074b;
  --dot-color: rgba(35, 7, 75, 0.07);
  --glow-halo-blur: 36px;
  --shadow-anchored-blur: 14px;
}
