/* Atlas OS colour palettes — the seven themes and the legacy-token bridge.
 *
 * Moved out of atlas-themes.css so the login screen can run the same palette
 * the app does. It used to carry its own copy of this table in a <script>,
 * which is why the Background designs rendered as nothing there: they compose
 * from --atlas-primary, --atlas-secondary, --atlas-background and
 * --atlas-grid, and the login copy defined --atlas-accent, --atlas-bg and
 * --atlas-fg instead. Every var() in those gradients was unresolved, the
 * declarations were invalid at computed-value time, and the backdrop painted
 * nothing at all -- the "darker" login screen.
 *
 * The rest of atlas-themes.css styles app chrome that the login screen has
 * none of, so only the palette travels.
 */

/* The six presets, regraded on the design system (docs/design-system.md,
 * Colour). They were neon on navy -- #00ff66 on #020804, #4de7ff on #040c12 --
 * the cyber-noir the brief asked to move past. Each is now a charcoal ground
 * with a whisper of its hue, a silver ink, and the HIG's dark system colour
 * as its one accent: emerald rather than neon green, the system's blue,
 * cyan, orange and pink, and a controlled violet. Status reads the same on
 * every one of them -- the system's green and yellow; mint where green is
 * already the accent. */

/* ── Blue (default) ── */
body.atlas-os[data-atlas-theme="default-blue"],
html[data-atlas-theme="default-blue"] body.atlas-os {
  --atlas-primary: #0091ff;
  --atlas-secondary: #0a6fd6;
  --atlas-border: rgba(0, 145, 255, 0.22);
  --atlas-text: #e8edf6;
  --atlas-glow: rgba(0, 145, 255, 0.36);
  --atlas-button: rgba(0, 145, 255, 0.34);
  --atlas-card: rgba(20, 24, 32, 0.6);
  --atlas-hover: rgba(0, 145, 255, 0.12);
  --atlas-grid: rgba(0, 145, 255, 0.04);
  --atlas-background: #0b0d12;
  --atlas-success: rgb(48 209 88);
  --atlas-warning: rgb(255 214 0);
  --atlas-rgb: 0, 145, 255;
  --atlas-accent: var(--atlas-primary);
  --atlas-border-glow: var(--atlas-border);
  --atlas-globe-tint: rgba(0, 145, 255, 0.6);
}

/* ── Green ── */
body.atlas-os[data-atlas-theme="matrix-green"],
html[data-atlas-theme="matrix-green"] body.atlas-os {
  --atlas-primary: #30d158;
  --atlas-secondary: #22a447;
  --atlas-border: rgba(48, 209, 88, 0.22);
  --atlas-text: #e6f1ea;
  --atlas-glow: rgba(48, 209, 88, 0.36);
  --atlas-button: rgba(48, 209, 88, 0.34);
  --atlas-card: rgba(18, 26, 22, 0.62);
  --atlas-hover: rgba(48, 209, 88, 0.12);
  --atlas-grid: rgba(48, 209, 88, 0.04);
  --atlas-background: #0a0e0c;
  --atlas-success: rgb(0 218 195);
  --atlas-warning: rgb(255 214 0);
  --atlas-rgb: 48, 209, 88;
  --atlas-accent: var(--atlas-primary);
  --atlas-border-glow: var(--atlas-border);
  --atlas-globe-tint: rgba(48, 209, 88, 0.6);
}

/* ── Purple ── */
body.atlas-os[data-atlas-theme="purple"],
html[data-atlas-theme="purple"] body.atlas-os {
  --atlas-primary: #a57cff;
  --atlas-secondary: #8157e8;
  --atlas-border: rgba(165, 124, 255, 0.22);
  --atlas-text: #ebe8f6;
  --atlas-glow: rgba(165, 124, 255, 0.36);
  --atlas-button: rgba(165, 124, 255, 0.34);
  --atlas-card: rgba(24, 22, 34, 0.6);
  --atlas-hover: rgba(165, 124, 255, 0.12);
  --atlas-grid: rgba(165, 124, 255, 0.04);
  --atlas-background: #0d0c14;
  --atlas-success: rgb(48 209 88);
  --atlas-warning: rgb(255 214 0);
  --atlas-rgb: 165, 124, 255;
  --atlas-accent: var(--atlas-primary);
  --atlas-border-glow: var(--atlas-border);
  --atlas-globe-tint: rgba(165, 124, 255, 0.6);
}

/* ── Orange ── */
body.atlas-os[data-atlas-theme="red-gold"],
html[data-atlas-theme="red-gold"] body.atlas-os {
  --atlas-primary: #ff9230;
  --atlas-secondary: #e07418;
  --atlas-border: rgba(255, 146, 48, 0.22);
  --atlas-text: #f5ede5;
  --atlas-glow: rgba(255, 146, 48, 0.36);
  --atlas-button: rgba(255, 146, 48, 0.34);
  --atlas-card: rgba(30, 24, 18, 0.62);
  --atlas-hover: rgba(255, 146, 48, 0.12);
  --atlas-grid: rgba(255, 146, 48, 0.04);
  --atlas-background: #100d0a;
  --atlas-success: rgb(48 209 88);
  --atlas-warning: rgb(255 214 0);
  --atlas-rgb: 255, 146, 48;
  --atlas-accent: var(--atlas-primary);
  --atlas-border-glow: var(--atlas-border);
  --atlas-globe-tint: rgba(255, 146, 48, 0.6);
}

/* ── Cyan ── */
body.atlas-os[data-atlas-theme="cyan"],
html[data-atlas-theme="cyan"] body.atlas-os {
  --atlas-primary: #3cd3fe;
  --atlas-secondary: #1aa8d4;
  --atlas-border: rgba(60, 211, 254, 0.22);
  --atlas-text: #e5f2f6;
  --atlas-glow: rgba(60, 211, 254, 0.36);
  --atlas-button: rgba(60, 211, 254, 0.34);
  --atlas-card: rgba(18, 26, 30, 0.6);
  --atlas-hover: rgba(60, 211, 254, 0.12);
  --atlas-grid: rgba(60, 211, 254, 0.04);
  --atlas-background: #0a0e11;
  --atlas-success: rgb(48 209 88);
  --atlas-warning: rgb(255 214 0);
  --atlas-rgb: 60, 211, 254;
  --atlas-accent: var(--atlas-primary);
  --atlas-border-glow: var(--atlas-border);
  --atlas-globe-tint: rgba(60, 211, 254, 0.6);
}

/* ── Pink ── */
body.atlas-os[data-atlas-theme="pink"],
html[data-atlas-theme="pink"] body.atlas-os {
  --atlas-primary: #ff375f;
  --atlas-secondary: #e0244b;
  --atlas-border: rgba(255, 55, 95, 0.22);
  --atlas-text: #f6e8ee;
  --atlas-glow: rgba(255, 55, 95, 0.36);
  --atlas-button: rgba(255, 55, 95, 0.34);
  --atlas-card: rgba(32, 20, 26, 0.6);
  --atlas-hover: rgba(255, 55, 95, 0.12);
  --atlas-grid: rgba(255, 55, 95, 0.04);
  --atlas-background: #110b0e;
  --atlas-success: rgb(48 209 88);
  --atlas-warning: rgb(255 214 0);
  --atlas-rgb: 255, 55, 95;
  --atlas-accent: var(--atlas-primary);
  --atlas-border-glow: var(--atlas-border);
  --atlas-globe-tint: rgba(255, 55, 95, 0.6);
}

/* ── Custom color wheel ──
 * Two inputs feed this theme, in priority order:
 *   1. --user-* — the theme customizer's own palette (Background, Text, Panel,
 *      Border, Accent), mirrored to :root by theme.js applyColors.
 *   2. --atlas-custom-color — the single hue from the swatch beside the radio.
 * Each token takes the customizer value when the user has set one and falls
 * back to the swatch-derived shade otherwise, so the swatch alone still works
 * exactly as before. The mirrors exist because this block cannot read
 * --bg/--panel directly — the bridge below also defines those on the same
 * element, which would be a circular reference. */
body.atlas-os[data-atlas-theme="custom"],
html[data-atlas-theme="custom"] body.atlas-os {
  --atlas-primary: var(--user-accent, var(--atlas-custom-color, #4de7ff));
  --atlas-secondary: color-mix(in srgb, var(--atlas-primary) 74%, #102040);
  --atlas-border: var(--user-border, color-mix(in srgb, var(--atlas-primary) 30%, transparent));
  --atlas-text: var(--user-fg, color-mix(in srgb, var(--atlas-primary) 18%, white));
  --atlas-glow: color-mix(in srgb, var(--atlas-primary) 44%, transparent);
  --atlas-button: color-mix(in srgb, var(--atlas-primary) 36%, transparent);
  --atlas-card: var(--user-panel, color-mix(in srgb, var(--atlas-primary) 9%, rgba(3, 7, 16, 0.66)));
  --atlas-hover: color-mix(in srgb, var(--atlas-primary) 14%, transparent);
  --atlas-grid: color-mix(in srgb, var(--atlas-primary) 5%, transparent);
  --atlas-background: var(--user-bg, color-mix(in srgb, var(--atlas-primary) 7%, #03060d));
  --atlas-success: #64f5c8;
  --atlas-warning: #ffd166;
  --atlas-rgb: var(--user-accent-rgb, var(--atlas-custom-rgb, 77, 231, 255));
  --atlas-accent: var(--atlas-primary);
  --atlas-border-glow: var(--atlas-border);
  --atlas-globe-tint: color-mix(in srgb, var(--atlas-primary) 62%, transparent);
}

/* A light palette's status colours. The custom theme's success and warning
   are a mint and a gold made for a dark ground, and on a light one they are
   2:1 at best. On light glass (design-system.css, data-os-appearance) they
   are the HIG's increased-contrast green and orange, which hold 4.5:1. */
html[data-os-appearance="light"] body.atlas-os[data-atlas-theme="custom"] {
  --atlas-success: rgb(0 137 50);
  --atlas-warning: rgb(197 83 0);
  /* And a filled control -- send, the mode pill, conversation mode -- is the
     solid accent under white ink, colour on the action's background rather
     than its label (Colour). The dark palettes' translucent accent is a pale
     wash on light glass: white on it measured 1.8:1. */
  --atlas-button: var(--atlas-primary);
}

/* ── Global bridge: themed Atlas OS surfaces ── */
body.atlas-os[data-atlas-theme],
html[data-atlas-theme] body.atlas-os {
  /* Keep the legacy shell/chat tokens pointed at the active Atlas palette.
   * Spatial already consumes the `--atlas-*` appearance tokens directly;
   * Workspace and Assistant still use these older aliases in their shared
   * navigation and composer styles. Keeping the bridge here makes all three
   * home modes switch together without maintaining parallel palettes. */
  --atlas-bg: var(--atlas-background);
  --atlas-panel: var(--atlas-card);
  --atlas-cyan: var(--atlas-primary);
  --atlas-blue: var(--atlas-secondary);
  /* Legacy modal/tool modules still consume the original shell variables.
   * Define them on the Atlas body so every nested window inherits the active
   * palette instead of falling back to the old blue GUI. */
  --bg: var(--atlas-background);
  --fg: var(--atlas-text);
  --panel: color-mix(in srgb, var(--atlas-card) 92%, var(--atlas-background));
  --border: var(--atlas-border);
  --red: var(--atlas-primary);
  --green: var(--atlas-success);
  --warn: var(--atlas-warning);
  --select-bg: color-mix(in srgb, var(--atlas-card) 94%, var(--atlas-background));
  --select-option-bg: var(--atlas-background);
  --select-option-active-bg: var(--atlas-hover);
  --input-bg: color-mix(in srgb, var(--atlas-card) 88%, var(--atlas-background));
  --input-border: var(--atlas-border);
  --brand-color: var(--atlas-primary);
  --accent: var(--atlas-primary);
  --send-btn-bg: var(--atlas-primary);
  --send-btn-hover: var(--atlas-secondary);
  /* Window/panel surfaces, derived from the active palette so no chrome stays
   * blue under a non-blue theme. --atlas-surface is the base window fill;
   * --atlas-surface-lift is the slightly raised fill for cards, inputs and
   * buttons stacked on top of it. Call sites apply their own alpha via
   * color-mix, so the depth hierarchy survives the theme swap. */
  --atlas-surface: var(--atlas-background);
  --atlas-surface-lift: color-mix(in srgb, var(--atlas-background) 90%, var(--atlas-primary));
  /* The globe's node discs.
   *
   * --atlas-surface is --atlas-background, so a node's fill composites to the
   * page colour exactly: measured on the midnight palette, the focused disc is
   * (4, 7, 18) on a (4, 7, 18) page. The fill has never been what separates a
   * node from the globe in any theme -- the border, the icon and the ring are.
   *
   * Those three were hardcoded white, which is correct only while the page is
   * dark. Every built-in palette is, so the assumption held until a custom
   * theme set a light --user-bg: then the white border and white icon landed
   * on a near-white disc on a near-white page. Measured there, 1.2:1 for both.
   *
   * --atlas-node-ink is the theme's own text colour -- the one the user picks
   * alongside the background -- so it flips with it. --atlas-node-glass gives
   * the fill one owner: it had two, a hardcoded near-black for the dim state
   * and --atlas-surface for the focused one, which is why a node changed
   * colour on focus under a light theme and not under a dark one. */
  --atlas-node-glass: var(--atlas-surface);
  --atlas-node-ink: var(--atlas-text);
  background-color: var(--atlas-background);
}
