/* =====================================================================================================
   Moe Money → AI Systems Group token bridge (Review-4 ground-up rebuild, P0.5)
   -----------------------------------------------------------------------------------------------------
   Rebinds Moe Money's default (midnight) theme onto the SHARED AISG tokens (aisg-tokens.css) so the
   default experience renders the ONE uniform company theme, and CONSUMES the shared layout/type tokens
   (font, nav width, content width, spacing) — not just the color tokens (P0.5 review Blocker 5). Moe
   Money overlays ONLY its product accent; the accessible text-accent is used on light surfaces so gold
   links/active-nav meet WCAG AA (Blocker 4). Loaded AFTER moemoney.css so these bindings win.
   ===================================================================================================== */
/* Product-wide overlay: Moe Money's one restrained accent (gold) + the shared layout/radius tokens. This
   is intentionally NOT mixed with the per-theme palette mapping below — a bare :root that also mapped the
   palette would leak the default (dark) surfaces into EVERY theme and make the result depend on the OS
   (that was the R8 #4 defect). --product-accent = fills + dark-mode text; --product-accent-text =
   accessible text/links (overridden per LIGHT theme so gold clears AA as small text). */
:root{
  --product-accent:      #f3b944;
  --product-accent-text: #f3b944;
  --accent:    var(--product-accent);
  --rail:      var(--aisg-nav-w);
  --radius:    var(--aisg-radius-md);

  /* LIGHT IS THE BASE HERE TOO (directive §2). The vendored `aisg-tokens.css` puts its DARK set on
     bare `:root`, and that file is byte-locked to shared/aisg-design-system by
     tests/test_aisg_design_system.py — so it cannot be edited in place. The remap therefore happens
     here, in the product bridge, which loads last.
     Without this, Light inherited the dark elevation shadows (black at 30-45% opacity on white cards
     — the classic dark-retrofit smell) and the bright semantic FILLS as text: warn at ~1.8:1, info at
     2.6:1, success at ~3.0:1 on white. All of those are WCAG failures the directive forbids. */
  --aisg-elev-1:0 1px 2px rgba(27,45,71,.08);
  --aisg-elev-2:0 4px 14px rgba(27,45,71,.10);
  --aisg-elev-3:0 10px 30px rgba(27,45,71,.14);
  /* a FULL box-shadow value, not a colour: `.trust-badge:focus-visible` and friends do
     `box-shadow:var(--aisg-focus-ring)`, so a bare rgba() makes the declaration invalid and the focus
     ring silently disappears. Caught by tests/test_pr5_a11y_matrix.py the first time I got this wrong. */
  --aisg-focus-ring:0 0 0 3px rgba(31,95,191,.45);
}

/* The DARK family restores the shared dark elevation + focus ring that `:root` above no longer carries.
   Ocean/Forest/Gold are dark too, so they are named here alongside midnight — silence would have left
   them wearing light shadows on a dark ground. */
[data-theme="midnight"],[data-theme="ocean"],[data-theme="forest"],[data-theme="gold"]{
  --aisg-elev-1:0 1px 2px rgba(0,0,0,.30);
  --aisg-elev-2:0 4px 14px rgba(0,0,0,.35);
  --aisg-elev-3:0 10px 30px rgba(0,0,0,.45);
  --aisg-focus-ring:0 0 0 3px rgba(109,124,255,.55);   /* exactly the vendored dark value */
  /* danger AS TEXT on the dark surfaces: the vendored default (-text = the #ef4444 fill) reads
     4.2–4.3:1 on the Ocean/Forest cards (Batch-4 sweep) — lift to the AA red the dark .neg/.chip.bad
     fixes already standardized on. */
  --aisg-danger-text:#f87171;
}

/* midnight: the shared DARK token set drives the product palette (the one uniform theme). */
[data-theme="midnight"]{
  /* PR#5 a11y contrast pass (2026-07-21): the shared tertiary-text token (--aisg-text-3 #7688a8) rendered
     at 4.42:1 on the #16223a surface — a hair under AA — for the nav "Preview/Soon" badges and the
     aisg-state tertiary labels. Lighten it one product step to clear 4.5:1 (5.3:1 on surface, 6.4:1 on
     bg); it flows to --muted below so nav-badge + state text both pass. Vendored DS file left untouched. */
  --aisg-text-3:#8496b4;
  --bg:var(--aisg-bg); --surface:var(--aisg-surface-1); --surface2:var(--aisg-surface-2);
  --border:var(--aisg-border); --ink:var(--aisg-text); --ink2:var(--aisg-text-2); --muted:var(--aisg-text-3);
  --good:var(--aisg-success); --warn:var(--aisg-warn); --bad:var(--aisg-danger); --purple:var(--aisg-ai);
  --loud:var(--aisg-success); --loud2:var(--aisg-success); --loud-ink:var(--aisg-success-ink); --info:var(--aisg-info);
}

/* Every OTHER theme keeps its own product palette (defined in moemoney.css) and FEEDS it into the shared
   tokens, so the shared shell + state badges wear the SELECTED theme. Because a concrete data-theme is
   always present, the choice — never the OS color-scheme — decides light vs dark (R8 #4). These blocks
   follow the midnight mapping so they win for their own theme. */
[data-theme="ocean"],[data-theme="forest"],[data-theme="gold"]{
  --aisg-bg:var(--bg); --aisg-surface-1:var(--surface); --aisg-surface-2:var(--surface2);
  --aisg-surface-3:var(--surface2); --aisg-border:var(--border); --aisg-border-strong:var(--border);
  --aisg-text:var(--ink); --aisg-text-2:var(--ink2); --aisg-text-3:var(--muted);
}
/* daylight is the LIGHT theme: feed its light palette in AND darken the semantic TEXT tokens so small
   badge/label text clears WCAG AA on light surfaces (the bright dark-theme fills fail as small text). */
[data-theme="daylight"]{
  /* PR#5 a11y contrast pass (2026-07-21): the light-theme product text tokens were tuned a hair below
     WCAG AA on white/near-white — darken them here (product layer) so muted/label/nav text, links and
     positive numbers clear 4.5:1. Measured on #fff, #f3f6fb and the #edf2f8 surface. Dark themes are
     untouched (each keeps its own palette). */
  --muted:#5a6b82;   /* was #6e8198 (4.0:1) -> 5.4:1 on white, 4.8:1 on the surface-2 chip bg */
  --s2:#1f5fbf;      /* light-theme link/info blue: was the dark-theme #5f9dff (2.7:1) -> 6.1:1 */
  /* positive numbers/chips. #0B8A5C -> #0a7d53 cleared 4.5:1 on #fff and the #edf2f8 surface, but the
     measurement missed the case that actually ships: `.chip.good` lays its OWN tint,
     rgba(16,185,129,.09), over the surface, which composites to rgb(217,237,237) — greener and
     therefore LOWER contrast than the bare surface. #0a7d53 measured 4.25:1 there. Caught by
     tests/test_pr5_a11y_matrix.py on owner/light/today ("Connected — last trading day"), 2026-07-29.
     #097048 measures 5.05:1 on that composited chip background, 5.45:1 on the surface and 6.14:1 on
     white — so the strictest real background is now the one it was tuned against, not the easiest. */
  --good:#097048;
  --aisg-bg:var(--bg); --aisg-surface-1:var(--surface); --aisg-surface-2:var(--surface2);
  --aisg-surface-3:var(--surface2); --aisg-border:var(--border); --aisg-border-strong:var(--border);
  --aisg-text:var(--ink); --aisg-text-2:var(--ink2); --aisg-text-3:var(--muted);
  --aisg-success-text:#0a6157; --aisg-warn-text:#8a5a12; --aisg-danger-text:#b42318;
  --aisg-info-text:#1f5fbf; --aisg-ai-text:#3d4bc4;
  /* the *-ink tokens are the state chips' BACKGROUNDS. The vendored dark set (e.g. danger-ink
     #2a0606, a near-black maroon) survived under Light, so `.aisg-state.s-error` was dark-red text
     on near-black — 2.83:1 (Batch-4 sweep). On Light the inks become pale tints of each state. */
  --aisg-success-ink:#e4f5ee; --aisg-warn-ink:#fbf0dc; --aisg-danger-ink:#fdeceb;
  --aisg-info-ink:#e8f0fb; --aisg-ai-ink:#ebecfb;
  --product-accent-text:#7a5a00;
}

/* consume the shared font + content width */
body{font-family:var(--aisg-font)}
.wrap{max-width:var(--aisg-content-max)}

/* Shared shell.css owns the active-nav treatment via [aria-current="page"] (product accent, so desktop +
   mobile identity match). This is only a belt-and-suspenders alias for the .active CLASS on the SHARED
   rail — it does not reintroduce the legacy .rail selector (R8 #2). */
.aisg-rail .nav.active{
  background:linear-gradient(90deg,color-mix(in srgb,var(--product-accent) 18%,var(--surface-1,var(--surface))),transparent);
  color:var(--ink);
}

/* the mobile bottom-nav STRUCTURE now lives in the shared shell.css (aisg-shell.css) — the product
   overlay only sets the accent color for the active tab via --product-accent-text (see shell.css).
   Product-specific: keep the app content clear of the bottom bar + lift the chat FAB above it. */
@media(max-width:899px){ body:not(.public) .wrap{ padding-bottom:calc(24px + env(safe-area-inset-bottom)); } }
@media(max-width:899px){ .chat-fab{bottom:calc(16px + env(safe-area-inset-bottom))} }

/* --- hub tool cards (shared destination-hub pattern) --- */
.toolcard{display:flex; flex-direction:column; gap:var(--aisg-space-1); text-decoration:none; color:var(--ink);
  transition:border-color var(--aisg-motion), transform var(--aisg-motion)}
.toolcard:hover{border-color:var(--aisg-border-strong); transform:translateY(-1px); text-decoration:none}
.toolcard:focus-visible{outline:none; box-shadow:var(--aisg-focus-ring)}
.toolcard h2{margin:0 0 2px; font-size:1.05rem}
.toolcard .toolgo{margin-top:auto; padding-top:var(--aisg-space-2); color:var(--product-accent-text); font-weight:800; font-size:.85rem}
.toolcard.owner{border-color:color-mix(in srgb,var(--aisg-ai) 30%,var(--aisg-border))}
.toolcard.owner .toolgo{color:var(--aisg-ai)}
.owner-eyebrow{color:var(--aisg-ai)!important}

/* =====================================================================================================
   PR#5 a11y contrast pass (2026-07-21) — LIGHT-THEME text-accent overrides.
   The product accent scale (gold #f3b944 / AI purple #6d7cff) is a FILL color; when it lands as small
   TEXT on the light (daylight) surfaces it fails WCAG AA (gold 1.8:1, purple 3.2:1). On light, route
   those TEXT usages to the already-defined accessible text tokens (--product-accent-text #7a5a00 6.4:1,
   --aisg-ai-text #3d4bc4 7.0:1, --aisg-danger-text #b42318). Dark themes keep the bright accent as text
   (it clears AA on dark), so these overrides are scoped to [data-theme="daylight"] only.
   ===================================================================================================== */
[data-theme="daylight"] .chip.accent,
[data-theme="daylight"] .chip.lock,
[data-theme="daylight"] .hero .tag,
[data-theme="daylight"] .aisg-rail .owner-group .nav-group-label{ color:var(--product-accent-text); }
[data-theme="daylight"] .aisg-rail .nav .nav-badge-paid{ color:var(--product-accent-text); }
[data-theme="daylight"] .toolcard.owner .toolgo{ color:var(--aisg-ai-text); }
[data-theme="daylight"] .owner-eyebrow{ color:var(--aisg-ai-text)!important; }
[data-theme="daylight"] .chip.bad{ color:var(--aisg-danger-text); }
/* dark-theme danger CHIP text (red-on-dark tint) sat at 4.29:1 — lift it one step to clear AA. */
[data-theme="midnight"] .chip.bad{ color:#f87171; }
/* dark-theme .neg text (negative %/$ numbers — e.g. the top ticker tape) used --bad=#ef4444, which
   sat at 4.21:1 on the lighter card/ticker surface (rgb(22,34,58)). Lift to the same AA red (5.7:1). */
[data-theme="midnight"] .neg{ color:#f87171; }
/* daylight .neg used --bad=#DC2626 = 4.29:1 on the light card surface — use the AA danger TEXT token
   (#b42318, 5.8:1), matching the chip.bad daylight fix above. */
[data-theme="daylight"] .neg{ color:var(--aisg-danger-text); }
/* the LIVE-armed badge is white text on the raw danger FILL (#ef4444/#d13636), which never cleared
   AA in ANY theme (3.3–4.3:1, Batch-4 sweep) — on the one badge that announces real money is armed.
   Deepen the fill to the AA danger-text red (5.7–6.0:1 for white) in every theme; the vendored
   states file is byte-locked, so the override lives here in the product bridge. */
.aisg-state.s-live_armed,
.aisg-state.s-verified.s-live_armed{ background:#b42318; border-color:#7f1d1d; }
