/*
 * AgentPM brand token bridge for django-brickwork (ADR-023; docs/plans/
 * registry/PLAN-brickwork-adoption.md Phase 0).
 *
 * SEED-AND-DERIVE, not flatten. brickwork (0.10 through the 3.2.1 upgrade,
 * issue #217, docs/plans/registry/PLAN-brickwork-3.2-upgrade.md) is a
 * self-deriving token system (brickwork/static/brickwork/dist/tokens.css):
 * a small set of SEED
 * colours (surface, fg, accent, danger, warning, success, border) and every
 * other semantic token, roughly forty of them, is derived from those seeds
 * via `color-mix`: tints (`-subtle`/`-border`/`-strong`/`-fg`), the
 * surface-sunken/surface-raised elevation pair, nav-active, breadcrumb,
 * skeleton, focus ring. A card floats because `--bw-color-surface-raised`
 * sits at visible contrast against `--bw-color-surface-sunken`, the page
 * canvas; the elevation shadow ladder (`--bw-elevation-*`) does the rest.
 *
 * The previous version of this file hard-overrode roughly thirty tokens
 * with FLAT values, including collapsing surface, surface-sunken, and
 * surface-raised all to one colour (paper in light, ink in dark). That
 * flattening was the direct cause of a flat-looking dashboard: cards sat at
 * the same colour as the page underneath them, so they did not float and
 * the elevation shadows had no contrast to read against. It also hard-
 * pinned derived tints (accent-subtle, danger-subtle, nav-item-active-*,
 * skeleton-*) to flat brand values, defeating brickwork's colour-mix
 * derivation and leaving those tints muddier and less coherent than
 * brickwork's own maths. And it covered only around thirty of brickwork's
 * fifty-one semantic tokens, so the rest (info, info-*, danger-fg,
 * success-strong, border-control, breadcrumb-*, fg-subtle) still carried
 * brickwork's blue-seeded defaults, clashing against AgentPM's green/coral
 * brand.
 *
 * This version sets ONLY the true seeds to AgentPM's brand and lets
 * brickwork derive the rest, restoring the depth brickwork ships by
 * default. The two exceptions are `surface-sunken` and `surface-raised`:
 * these are themselves derived tokens in brickwork, but the derivation
 * needs a decision this bridge must make explicitly (dark mode raises
 * lighter than its base surface, which no formula can infer from a single
 * "surface" seed alone) so they are set here too, using brickwork's own
 * `color-mix` ratios verbatim (read from tokens.css directly; not guessed).
 * Every other non-seed token below is DELETED so it derives.
 *
 * Hand-written and linked directly via {% static %} rather than folded into
 * the Vite-built app.css: AgentPM's deploy has no build step (issue #118),
 * so a token change here is visible without an `npm run build` + commit
 * round trip. This file is committed as-is; there is no build step to run
 * after editing it.
 *
 * No component-level CSS lives here: this is a token bridge only. Loaded
 * AFTER brickwork's own dist CSS (which pulls in tokens.css) and AFTER
 * app.css (whose `@theme` block defines the AgentPM `--color-*`/`--font-*`
 * custom properties referenced below), per templates/registry/
 * _brickwork_shell.html's head ordering, so these declarations both see
 * AgentPM's tokens and win the cascade over brickwork's own defaults.
 */

[data-theme="light"] {
  /* Surface seed: Paper is the card/raised colour. */
  --bw-color-surface: var(--color-paper);

  /* Derived surface scale, brickwork's own light-mode ratios (tokens.css
     [data-theme="light"]): the page canvas sits very slightly darker than
     the surface (96.5% surface mixed with black), and raised (cards) is
     the surface itself, so cards float via the sunken/raised contrast plus
     the elevation shadow, not via a colour difference from their own base. */
  --bw-color-surface-sunken: color-mix(in oklab, var(--bw-color-surface) 96.5%, black);
  --bw-color-surface-raised: var(--bw-color-surface);

  /* Foreground seed: Ink. fg-muted/fg-subtle derive (color-mix of fg into
     surface at brickwork's own 62%/37% ratios). */
  --bw-color-fg: var(--color-ink);

  /* Accent seed: Signal green, AgentPM's only brand accent (docs/brand/
     BRAND.md), standing in for brickwork's blue-seeded accent. Hover one
     step darker. accent-subtle deletes and derives (color-mix(accent 7%,
     surface)) rather than pinning to Signal 400, which read muddier. */
  --bw-color-accent: var(--color-signal-600);
  --bw-color-accent-hover: var(--color-signal-700);

  /* Status seeds: coral for danger, amber for warning, Signal for success.
     Every -subtle/-border/-strong/-fg tint for these three deletes and
     derives from the seed via brickwork's own color-mix ratios. */
  --bw-color-danger: var(--color-coral-600);
  --bw-color-warning: var(--color-amber-600);
  --bw-color-success: var(--color-signal-600);

  /* Info: deliberately left UNSET, keeping brickwork's packaged blue
     default. AgentPM's BRAND.md defines no info hue (its palette is
     ink/paper/signal/amber/coral only). Seeding info to Signal would make
     an info banner and a success banner render identically, erasing a real
     semantic distinction the info-* tokens exist to carry; blue read as
     "informational" is also the one place a cool hue is correct against an
     otherwise warm/green brand, precisely because it does NOT compete with
     Signal's meaning of live/success. */

  /* Border seed: the AgentPM hairline. border-strong and border-control
     delete and derive (mixed darker toward fg at brickwork's own ratios). */
  --bw-color-border: var(--color-line-on-light);

  /* Focus ring: DELETED, left to derive (issue #217, docs/plans/registry/
     PLAN-brickwork-3.2-upgrade.md "focus-ring reconciliation"). This bridge
     used to pin --bw-color-focus-ring flat to --color-signal-500
     (#19be73); brickwork 3.2.1 (icvoss/django-brickwork#134) made the token
     a WCAG-AA color-mix derivation from --bw-color-accent instead
     (`color-mix(in oklab, var(--bw-color-accent) 95%, black)` light,
     `82%` dark), and the flat Signal-500 pin was measured against this
     file's own real light-mode surfaces and FAILS WCAG 3:1 non-text
     contrast there: 2.07:1 against the page canvas
     (--bw-color-surface-sunken, #eeede8) and 2.29:1 against a raised card
     (--bw-color-surface-raised = --color-paper, #faf8f3). Dark mode alone
     would have passed (7.96:1 page, 6.16:1 card against #171a21-derived
     surfaces), but a ring that fails in one theme fails the requirement.
     Deleting the pin lets brickwork derive from THIS file's own accent
     seeds (Signal 600 light / Signal 500 dark, set above), verified to
     clear 3:1 in both themes and both surfaces: light ring #0d9258 measures
     3.40:1 (page) / 3.75:1 (card); dark ring #109157 measures 4.79:1 (page)
     / 3.71:1 (card). This keeps the ring on-brand (still Signal-derived,
     not brickwork's default blue) while meeting the contrast floor the flat
     pin missed. */

  /* nav-item-active, skeleton: deleted. Both derive from accent-subtle /
     surface-sunken respectively, which are now correctly Signal- and
     Paper-derived, so the active nav pill and skeleton loading state pick
     up AgentPM's brand for free and stay coherent with every other tint. */

  --bw-font-family-sans: var(--font-sans);
  --bw-font-family-display: var(--font-display);
  --bw-font-family-mono: var(--font-mono);
}

[data-theme="dark"] {
  /* Surface seed: Ink is the base surface. */
  --bw-color-surface: var(--color-ink);

  /* Derived surface scale, brickwork's own dark-mode ratios (tokens.css
     [data-theme="dark"]): sunken (the page canvas) mixes toward black for a
     darker backdrop; raised (cards) mixes toward WHITE, so cards are
     lighter than the page and catch light against it. This lighter-than-
     base raised step is the essential dark-mode depth cue: without it,
     dark-mode cards cannot visually separate from the page no matter what
     the shadow ladder does. */
  --bw-color-surface-sunken: color-mix(in oklab, var(--bw-color-surface) 76%, black);
  --bw-color-surface-raised: color-mix(in oklab, var(--bw-color-surface) 93%, white);

  /* Foreground seed: Paper. fg-muted/fg-subtle derive. */
  --bw-color-fg: var(--color-paper);

  /* Accent seed: Signal 500, one step lighter than light mode's Signal 600
     for contrast against the dark surface (matches the pre-brickwork
     component rules' own dark-mode Signal step in app.css's .live-line/
     .live-dot). accent-subtle deletes and derives. */
  --bw-color-accent: var(--color-signal-500);
  --bw-color-accent-hover: var(--color-signal-400);

  /* Status seeds, dark-appropriate step (one lighter than light mode, same
     pattern as accent above). Their tints delete and derive. */
  --bw-color-danger: var(--color-coral-400);
  --bw-color-warning: var(--color-amber-400);
  --bw-color-success: var(--color-signal-500);

  /* Info: left unset here too, for the same reason as light mode; see that
     block's comment. Keeps brickwork's packaged dark-mode blue default. */

  /* Border seed: the AgentPM dark hairline. border-strong/border-control
     derive. */
  --bw-color-border: var(--color-line-on-dark);

  /* Focus ring: DELETED here too, same verify-then-fallback reasoning as
     light mode's block above; see that comment for the measured contrast
     ratios in both themes. Dark mode's own flat-pin ratio (7.96:1/6.16:1)
     passed on its own, but the pin is removed uniformly since light mode's
     failure means the pin cannot be kept selectively. */

  /* nav-item-active, skeleton: deleted, same reasoning as light mode. */

  /* Fonts do not vary by theme; repeated here only because brickwork scopes
     its own token defaults per `[data-theme]` block, so an unset token
     under `[data-theme="dark"]` would fall through to its packaged default
     rather than this file's `[data-theme="light"]` rule. */
  --bw-font-family-sans: var(--font-sans);
  --bw-font-family-display: var(--font-display);
  --bw-font-family-mono: var(--font-mono);
}
