/*
 * Perennius colour tokens, computed from a theme's raw colours.
 *
 * Raw inputs (--o-*) use the key names of Omarchy's colors.toml. On Linux the app writes them
 * from ~/.config/omarchy/current/theme/colors.toml and sets data-mode from its `mode` key.
 * Elsewhere the built-in palettes below apply (Tokyo Night dark, Catppuccin Latte light).
 * Mix percentages follow docs/design/README.md "Theme mapping". No component hard-codes a colour.
 */

/* ---- Built-in palettes ---------------------------------------------------------------- */
:root,
[data-theme="tokyo-night"] {
  --o-background: #1a1b26;
  --o-foreground: #a9b1d6;
  --o-bright-foreground: #c0caf5;
  --o-accent: #7aa2f7;
  --o-selection: #292e42;
  --o-red: #f7768e;
  --o-yellow: #e0af68;
  --o-green: #9ece6a;
  --o-cyan: #449dab;
  --o-magenta: #ad8ee6;
  --o-bright-red: #ff7a93;
  --o-bright-yellow: #ff9e64;
  --o-bright-green: #b9f27c;
  --o-bright-cyan: #0db9d7;
  --o-bright-magenta: #bb9af7;
}

[data-theme="catppuccin-latte"] {
  --o-background: #eff1f5;
  --o-foreground: #4c4f69;
  --o-bright-foreground: #4c4f69;
  --o-accent: #1e66f5;
  --o-selection: #ccd0da;
  --o-red: #d20f39;
  --o-yellow: #df8e1d;
  --o-green: #40a02b;
  --o-cyan: #179299;
  --o-magenta: #8839ef;
  --o-bright-red: #d20f39;
  --o-bright-yellow: #df8e1d;
  --o-bright-green: #40a02b;
  --o-bright-cyan: #179299;
  --o-bright-magenta: #8839ef;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --o-background: #eff1f5;
    --o-foreground: #4c4f69;
    --o-bright-foreground: #4c4f69;
    --o-accent: #1e66f5;
    --o-selection: #ccd0da;
    --o-red: #d20f39;
    --o-yellow: #df8e1d;
    --o-green: #40a02b;
    --o-cyan: #179299;
    --o-magenta: #8839ef;
    --o-bright-red: #d20f39;
    --o-bright-yellow: #df8e1d;
    --o-bright-green: #40a02b;
    --o-bright-cyan: #179299;
    --o-bright-magenta: #8839ef;
  }
}

/* ---- Mode parameters ------------------------------------------------------------------ */
:root,
[data-mode="dark"] {
  --m-surface-1: 6%;
  --m-surface-2: 10%;
  --m-line: 14%;
  --m-line-strong: 55%;
  --m-muted: 15%;
  --m-accent-ink: 0%;
  --m-ink: 0%;
  --m-tint: 12%;
  --o-success: var(--o-bright-green);
  --o-warning: var(--o-bright-yellow);
  --o-danger: var(--o-bright-red);
  --o-info: var(--o-bright-cyan);
  --o-ai: var(--o-bright-magenta);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-mode]) {
    --m-surface-1: 4%;
    --m-surface-2: 8%;
    --m-line: 14%;
    --m-line-strong: 70%;
    --m-muted: 12%;
    --m-accent-ink: 15%;
    --m-ink: 35%;
    --m-tint: 14%;
    --o-success: var(--o-green);
    --o-warning: var(--o-yellow);
    --o-danger: var(--o-red);
    --o-info: var(--o-cyan);
    --o-ai: var(--o-magenta);
    color-scheme: light;
  }
}

[data-mode="light"] {
  --m-surface-1: 4%;
  --m-surface-2: 8%;
  --m-line: 14%;
  --m-line-strong: 70%;
  --m-muted: 12%;
  --m-accent-ink: 15%;
  --m-ink: 35%;
  --m-tint: 14%;
  --o-success: var(--o-green);
  --o-warning: var(--o-yellow);
  --o-danger: var(--o-red);
  --o-info: var(--o-cyan);
  --o-ai: var(--o-magenta);
  color-scheme: light;
}

/* ---- Tokens (names match docs/design/tokens.json) -------------------------------------- */
:root,
[data-theme],
[data-mode] {
  --background: var(--o-background);
  --surface-1: color-mix(in oklab, var(--o-foreground) var(--m-surface-1), var(--o-background));
  --surface-2: color-mix(in oklab, var(--o-foreground) var(--m-surface-2), var(--o-background));
  --line: color-mix(in oklab, var(--o-foreground) var(--m-line), var(--o-background));
  --line-strong: color-mix(in oklab, var(--o-foreground) var(--m-line-strong), var(--o-background));
  --ink: var(--o-foreground);
  --ink-muted: color-mix(in oklab, var(--o-background) var(--m-muted), var(--o-foreground));
  --accent: var(--o-accent);
  --accent-ink: color-mix(in oklab, var(--o-foreground) var(--m-accent-ink), var(--o-accent));
  --on-accent: var(--o-background);
  --accent-tint: color-mix(in srgb, var(--o-accent) 12%, transparent);
  --selection: var(--o-selection);
  --selection-ink: var(--o-bright-foreground);
  --cursor: var(--o-bright-foreground);

  --success: var(--o-success);
  --success-ink: color-mix(in oklab, var(--o-foreground) var(--m-ink), var(--o-success));
  --success-tint: color-mix(in srgb, var(--o-success) var(--m-tint), transparent);
  --warning: var(--o-warning);
  --warning-ink: color-mix(in oklab, var(--o-foreground) var(--m-ink), var(--o-warning));
  --warning-tint: color-mix(in srgb, var(--o-warning) var(--m-tint), transparent);
  --danger: var(--o-danger);
  --danger-ink: color-mix(in oklab, var(--o-foreground) var(--m-ink), var(--o-danger));
  --danger-tint: color-mix(in srgb, var(--o-danger) var(--m-tint), transparent);
  --info: var(--o-info);
  --info-ink: color-mix(in oklab, var(--o-foreground) var(--m-ink), var(--o-info));
  --info-tint: color-mix(in srgb, var(--o-info) var(--m-tint), transparent);
  --ai: var(--o-ai);
  --ai-ink: color-mix(in oklab, var(--o-foreground) var(--m-ink), var(--o-ai));
  --ai-tint: color-mix(in srgb, var(--o-ai) var(--m-tint), transparent);
}
