/* The AI Masters — theme tokens (dark default, light opt-in).
 *
 * ONE source of truth for both the React site (linked from index.html) and any
 * static page under public/ (e.g. public/vip/<token>/index.html).
 *
 * How it works (mirrors spiritualtranslations.com's Day/Vigil switch, inverted:
 * TAM's canonical theme is dark):
 *   - Dark values live on :root. Light values apply when <html> has class "light".
 *   - The class is set pre-paint by /tam-theme.js from localStorage "tam-theme"
 *     ("light" | "dark"), so there is no flash of the wrong theme.
 *   - Add class "theme-dark" to any element to keep that subtree dark in both
 *     themes (the "jewel-box" surfaces: navigation, hero, footer). Because CSS
 *     variables cascade, the subtree simply re-declares the dark values.
 *
 * Every token is an RGB triplet, so it works with alpha:
 *     color: rgb(var(--tam-fg));            background: rgb(var(--tam-primary) / 0.9);
 * Tailwind maps them to: primary, secondary, primary-deep, panel, fg, accent-ink.
 */

:root,
.theme-dark {
  --tam-primary: 26 26 46;        /* #1a1a2e  page background */
  --tam-secondary: 22 33 62;      /* #16213e  alternate band / gradient stop */
  --tam-primary-deep: 20 20 40;   /* #141428  deepest band */
  --tam-panel: 15 23 42;          /* #0f172a  card / panel surface */
  --tam-fg: 255 255 255;          /* text, hairlines, translucent fills */
  --tam-accent-ink: 196 160 0;    /* #c4a000  gold used as TEXT */
  --tam-text-fade: 1;             /* 1 = text alpha used as written */
  --tam-tint-keep: 100%;          /* share of a hue kept when tinted text is mixed with ink */
  color-scheme: dark;
}

/* Light ("paper") — palette taken from spiritualtranslations.com Day mode,
 * with TAM's gold darkened (same hue) so gold text clears WCAG AA 4.5:1 on
 * every paper tone, including the darkest band. */
html.light {
  --tam-primary: 246 241 228;     /* #F6F1E4 */
  --tam-secondary: 237 229 209;   /* #EDE5D1 */
  --tam-primary-deep: 231 220 196;/* #E7DCC4 */
  --tam-panel: 251 247 236;       /* #FBF7EC */
  --tam-fg: 35 38 54;             /* #232636 ink */
  --tam-accent-ink: 115 93 0;     /* #735d00  4.7:1 on #E7DCC4, 5.7:1 on #F6F1E4 */
  /* Faded text (e.g. text-fg/60) is lifted toward full ink on paper: the
     effective alpha becomes 1 - (1 - a) * 0.6, so /60 reads at ~0.76. */
  --tam-text-fade: 0.6;
  --tam-tint-keep: 50%;
  color-scheme: light;
}

/* Re-assert dark inside jewel-box subtrees when the page is light. (The
   `.theme-dark` selector above already does this by cascade; this rule only
   restores color-scheme for native controls/scrollbars in that subtree.) */
html.light .theme-dark {
  color-scheme: dark;
}

html {
  background: rgb(var(--tam-primary));
  color: rgb(var(--tam-fg));
}

/* Soft radial reveal from the toggle (native View Transitions; no-op where
   unsupported or under reduced motion). Origin set by tam-theme.js. */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) {
    animation: none;
  }
  ::view-transition-new(root) {
    animation: tam-theme-sweep 0.45s ease-out;
  }
}

@keyframes tam-theme-sweep {
  from {
    clip-path: circle(0% at var(--vt-x, 50%) var(--vt-y, 0%));
  }
  to {
    clip-path: circle(150% at var(--vt-x, 50%) var(--vt-y, 0%));
  }
}
