/* ============================================================
   xmesh DS · md3/_color.css — Material Design 3 color roles.

   Canonical MD3 system tokens (`--md-sys-color-*`) sourced from
   `--x-*` primitives in `_primitives.css`. Components reference
   ONLY these `--md-sys-*` tokens (or `--xm-*` extensions) — never
   raw `--x-*`. Theme switching happens at the primitive layer; the
   role names below stay constant.

   Surface ramp mapping (theme-following card stack — see ADR 0006):
     dark:  surface = canvas-0 (the dark "desk")
            inverse-surface = canvas-2 (a lifted DARK card, one step up)
     light: surface = canvas-0 (the cream "desk")
            inverse-surface = surface-0 (the white card stack)
   The card stack follows the theme (dark card on dark, white card on
   cream) rather than staying white in both — superseding AD-13.

   The `error*` family is defined for canonical compliance; POLICIES.md
   forbids components from referencing it (severity is icon + copy).
   ============================================================ */

/* ---------- DARK (default) ---------- */
:root {
  /* Primary — coral accent */
  --md-sys-color-primary:              var(--x-accent);
  --md-sys-color-on-primary:           var(--x-accent-ink);
  --md-sys-color-primary-container:    var(--x-accent-soft);
  --md-sys-color-on-primary-container: var(--x-ink-0);

  /* Secondary — deep olive (defined; components do not reference) */
  --md-sys-color-secondary:              var(--x-secondary);
  --md-sys-color-on-secondary:           var(--x-secondary-ink);
  --md-sys-color-secondary-container:    var(--x-secondary-soft);
  --md-sys-color-on-secondary-container: var(--x-ink-0);

  /* Tertiary — alias of secondary; reserved for future categorical accent */
  --md-sys-color-tertiary:              var(--x-secondary);
  --md-sys-color-on-tertiary:           var(--x-secondary-ink);
  --md-sys-color-tertiary-container:    var(--x-secondary-soft);
  --md-sys-color-on-tertiary-container: var(--x-ink-0);

  /* Error — defined for canonicality; FORBIDDEN in components.
     Severity is communicated by icon and copy (POLICIES.md rule 3a). */
  --md-sys-color-error:              oklch(0.62 0.18 25);
  --md-sys-color-on-error:           #ffffff;
  --md-sys-color-error-container:    oklch(0.30 0.10 25);
  --md-sys-color-on-error-container: oklch(0.92 0.05 25);

  /* Background + surface ramp. The 7-tier MD3 surface family lives on
     the canvas (the dark "desk"). Cards are the inverse tier. */
  --md-sys-color-background:                var(--x-canvas-deep);
  --md-sys-color-on-background:             var(--x-ink-canvas-1);
  --md-sys-color-surface:                   var(--x-canvas-0);
  --md-sys-color-on-surface:                var(--x-ink-canvas-1);
  --md-sys-color-surface-variant:           var(--x-canvas-2);
  --md-sys-color-on-surface-variant:        var(--x-ink-canvas-2);
  --md-sys-color-surface-dim:               var(--x-canvas-deep);
  --md-sys-color-surface-bright:            var(--x-canvas-4);
  --md-sys-color-surface-container-lowest:  var(--x-canvas-deep);
  --md-sys-color-surface-container-low:     var(--x-canvas-0);
  --md-sys-color-surface-container:         var(--x-canvas-1);
  --md-sys-color-surface-container-high:    var(--x-canvas-2);
  --md-sys-color-surface-container-highest: var(--x-canvas-3);

  /* Outline */
  --md-sys-color-outline:         var(--x-canvas-5);
  --md-sys-color-outline-variant: var(--x-canvas-4);

  /* Inverse — the card stack. Theme-following (ADR 0006): a lifted DARK
     surface in dark theme (canvas-2, one step above the desk), white in
     light theme. Ink follows: light ink on the dark card. */
  --md-sys-color-inverse-surface:    var(--x-canvas-2);
  --md-sys-color-inverse-on-surface: var(--x-ink-canvas-1);
  --md-sys-color-inverse-primary:    var(--x-accent-strong);

  /* Scrim + shadow */
  --md-sys-color-scrim:  oklch(0 0 0);
  --md-sys-color-shadow: oklch(0 0 0);
}

/* ---------- LIGHT theme ----------
   The `--x-*` primitives flip to the cream/white palette in
   _primitives.css; the role names below stay identical. We only
   re-declare a small set where the asymmetric mapping requires it
   (surface-container-lowest collapses with inverse-surface in dark
   theme; light theme needs the inverse tier to remain near-white). */
:root[data-theme="light"] {
  /* Background sits below cream canvas (near-white inverse).
     surface-dim deepens cream slightly; surface-bright is near-white. */
  --md-sys-color-background:                var(--x-surface-0);
  --md-sys-color-surface-dim:               var(--x-canvas-3);
  --md-sys-color-surface-bright:            var(--x-canvas-deep);
  --md-sys-color-surface-container-lowest:  var(--x-canvas-deep);

  /* Card stack stays white in light theme (the dark-card flip is dark-only) */
  --md-sys-color-inverse-surface:    var(--x-surface-0);
  --md-sys-color-inverse-on-surface: var(--x-ink-0);

  /* Outline shifts onto cream tones */
  --md-sys-color-outline:         oklch(0.82 0.014 85);
  --md-sys-color-outline-variant: oklch(0.90 0.012 85);
}
