/*
 * ClashHub theme tokens ("Obsidian & Signal Teal" console design system).
 * This file defines the light and dark palettes, typography, spacing,
 * elevation, and motion tokens consumed by components.css and app.css.
 * The active theme is driven by the data-theme attribute on <html>:
 * "light", "dark", or "system" (system follows prefers-color-scheme).
 * theme.js sets the attribute before the stylesheets load to avoid flashing.
 */

:root {
    color-scheme: light;

    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
    --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", ui-monospace, monospace;

    /* Shared font-size ladder for titles, labels, and numerals; body copy
     * stays at --fs-md. Sizes are theme-invariant, so unlike the palette
     * they are declared once here. */
    --fs-xs: 0.75rem;
    --fs-sm: 0.8125rem;
    --fs-md: 0.875rem;
    --fs-lg: 1rem;
    --fs-xl: 1.375rem;
    --fs-2xl: 1.6875rem;
    --code-gutter-width: 4.5rem;
    --code-line-height: 1.6;
    --ring-stroke-width: 28;

    --text-1: #0b111e;
    --text-2: #334155;
    --text-3: #64748b;

    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #edf1f7;
    --surface-3: #e2e8f0;

    /* Static backdrop washes, grid hairlines, and border-glow accents. */
    --fx-grid-line: rgb(13 148 136 / 0.065);
    --fx-horizon: rgb(13 148 136 / 0.09);
    --fx-glow-a: rgba(13, 148, 136, 0.42);
    --fx-glow-b: rgba(79, 70, 229, 0.34);
    --fx-sheen: rgba(255, 255, 255, 0.50);
    --fx-title-accent: #4f46e5;
    --fx-aurora-1: rgb(20 184 166 / 0.20);
    --fx-aurora-2: rgb(79 70 229 / 0.14);
    --fx-aurora-3: rgb(14 165 233 / 0.16);
    --fx-card-glow: 0 18px 42px -18px rgb(13 148 136 / 0.20), 0 4px 14px -6px rgb(11 17 30 / 0.08);

    /* Blur is reserved for shell surfaces and floating controls. Content
     * panels use opaque surfaces to avoid nested backdrop filtering. */
    --glass-surface: rgb(255 255 255 / 0.78);
    --glass-surface-strong: rgb(255 255 255 / 0.90);
    --glass-surface-2: rgb(237 241 247 / 0.74);
    --glass-border: rgb(219 226 236 / 0.85);
    --glass-edge: inset 0 1px 0 rgb(255 255 255 / 0.85);
    --glass-filter: blur(8px);
    --glass-filter-strong: blur(12px);
    --button-sheen: linear-gradient(180deg, rgb(255 255 255 / 0.18), rgb(255 255 255 / 0) 55%);

    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-active: #115e59;
    --on-primary: #ffffff;
    --primary-container: #ccfbf1;
    --primary-container-hover: #99f6e4;
    --on-primary-container: #134e4a;

    --accent: #4f46e5;
    --accent-container: #e0e7ff;
    --on-accent-container: #1e1b4b;

    --success: #059669;
    --success-container: #d1fae5;
    --on-success-container: #064e3b;

    --warning: #d97706;
    --warning-container: #fef3c7;
    --on-warning-container: #78350f;

    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --on-danger: #ffffff;
    --danger-container: #fee2e2;
    --on-danger-container: #7f1d1d;

    --info: #0284c7;
    --info-container: #e0f2fe;
    --on-info-container: #0c4a6e;

    --border: #dbe2ec;
    --border-strong: #b8c4d6;

    --focus-ring: #0d9488;

    --state-hover: rgb(15 23 42 / 0.045);
    --state-press: rgb(15 23 42 / 0.085);
    --scrim: rgb(11 17 30 / 0.50);

    --code-bg: #0b0f17;
    --code-fg: #e2e8f0;
    --code-border: #1e293b;
    --code-gutter-bg: #070a10;
    --code-gutter-fg: #64748b;
    --code-selection: rgb(45 212 191 / 0.24);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 999px;

    --shadow-1: 0 1px 2px rgb(11 17 30 / 0.05), 0 2px 6px -2px rgb(11 17 30 / 0.04);
    --shadow-2: 0 2px 8px -2px rgb(11 17 30 / 0.07), 0 10px 24px -8px rgb(11 17 30 / 0.09);
    --shadow-3: 0 18px 44px -12px rgb(11 17 30 / 0.16), 0 4px 12px -4px rgb(11 17 30 / 0.08);
    --shadow-glow: 0 10px 30px -12px rgb(13 148 136 / 0.18), 0 2px 8px -4px rgb(11 17 30 / 0.05);
    --shadow-sticky-action: -8px 0 12px -8px rgb(11 17 30 / 0.18);
    --shadow-sticky-footer: 0 -4px 14px -6px rgb(11 17 30 / 0.20);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;

    --motion-fast: 120ms;
    --motion-md: 180ms;
    --motion-slow: 240ms;
    --ease-standard: cubic-bezier(0.2, 0, 0, 1);

    --header-height: 60px;
    --sidebar-width: 260px;
    --sidebar-rail-width: 72px;
    --page-max: 1480px;
}

[data-theme="dark"] {
    color-scheme: dark;

    --text-1: #f1f5f9;
    --text-2: #cbd5e1;
    --text-3: #7c8ba1;

    --bg: #080b11;
    --surface: #0e131d;
    --surface-2: #151c2a;
    --surface-3: #1e283a;

    /* Site-wide ambient effects (see :root for the color contract). */
    --fx-grid-line: rgb(45 212 191 / 0.05);
    --fx-horizon: rgb(45 212 191 / 0.09);
    --fx-glow-a: rgba(45, 212, 191, 0.42);
    --fx-glow-b: rgba(129, 140, 248, 0.30);
    --fx-sheen: rgba(255, 255, 255, 0.35);
    --fx-title-accent: #5eead4;
    --fx-aurora-1: rgb(20 184 166 / 0.14);
    --fx-aurora-2: rgb(99 102 241 / 0.10);
    --fx-aurora-3: rgb(14 165 233 / 0.08);
    --fx-card-glow: 0 14px 38px -14px rgb(0 0 0 / 0.65), 0 2px 10px -4px rgb(45 212 191 / 0.08);

    --glass-surface: rgb(14 19 29 / 0.74);
    --glass-surface-strong: rgb(14 19 29 / 0.88);
    --glass-surface-2: rgb(21 28 42 / 0.72);
    --glass-border: rgb(148 163 184 / 0.12);
    --glass-edge: inset 0 1px 0 rgb(255 255 255 / 0.06);
    --glass-filter: blur(8px);
    --glass-filter-strong: blur(12px);
    --button-sheen: linear-gradient(180deg, rgb(255 255 255 / 0.12), rgb(255 255 255 / 0) 55%);

    --primary: #2dd4bf;
    --primary-hover: #5eead4;
    --primary-active: #14b8a6;
    --on-primary: #042f2e;
    --primary-container: #113c3a;
    --primary-container-hover: #164e4b;
    --on-primary-container: #ccfbf1;

    --accent: #818cf8;
    --accent-container: #1e1b4b;
    --on-accent-container: #e0e7ff;

    --success: #34d399;
    --success-container: #064e3b;
    --on-success-container: #d1fae5;

    --warning: #fbbf24;
    --warning-container: #451a03;
    --on-warning-container: #fef3c7;

    --danger: #f87171;
    --danger-hover: #fca5a5;
    --on-danger: #450a0a;
    --danger-container: #5c1616;
    --on-danger-container: #fee2e2;

    --info: #38bdf8;
    --info-container: #0c4a6e;
    --on-info-container: #e0f2fe;

    --border: #1e293b;
    --border-strong: #334155;

    --focus-ring: #2dd4bf;

    --state-hover: rgb(241 245 249 / 0.055);
    --state-press: rgb(241 245 249 / 0.10);
    --scrim: rgb(2 6 12 / 0.68);

    --code-bg: #06090e;
    --code-fg: #e2e8f0;
    --code-border: #1e293b;
    --code-gutter-bg: #04060a;
    --code-gutter-fg: #64748b;
    --code-selection: rgb(45 212 191 / 0.26);

    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.50), 0 2px 6px -2px rgb(0 0 0 / 0.45);
    --shadow-2: 0 2px 8px -2px rgb(0 0 0 / 0.50), 0 10px 24px -8px rgb(0 0 0 / 0.55);
    --shadow-3: 0 18px 44px -12px rgb(0 0 0 / 0.68), 0 4px 12px -4px rgb(0 0 0 / 0.50);
    --shadow-glow: 0 12px 34px -14px rgb(0 0 0 / 0.60), 0 2px 8px -4px rgb(45 212 191 / 0.08);
    --shadow-sticky-action: -8px 0 12px -8px rgb(0 0 0 / 0.60);
    --shadow-sticky-footer: 0 -4px 14px -6px rgb(0 0 0 / 0.65);
}

@media (prefers-color-scheme: dark) {
    [data-theme="system"] {
        color-scheme: dark;

        --text-1: #f1f5f9;
        --text-2: #cbd5e1;
        --text-3: #7c8ba1;

        --bg: #080b11;
        --surface: #0e131d;
        --surface-2: #151c2a;
        --surface-3: #1e283a;

        /* Site-wide ambient effects (see :root for the color contract). */
        --fx-grid-line: rgb(45 212 191 / 0.05);
        --fx-horizon: rgb(45 212 191 / 0.09);
        --fx-glow-a: rgba(45, 212, 191, 0.42);
        --fx-glow-b: rgba(129, 140, 248, 0.30);
        --fx-sheen: rgba(255, 255, 255, 0.35);
        --fx-title-accent: #5eead4;
        --fx-aurora-1: rgb(20 184 166 / 0.14);
        --fx-aurora-2: rgb(99 102 241 / 0.10);
        --fx-aurora-3: rgb(14 165 233 / 0.08);
        --fx-card-glow: 0 14px 38px -14px rgb(0 0 0 / 0.65), 0 2px 10px -4px rgb(45 212 191 / 0.08);

        --glass-surface: rgb(14 19 29 / 0.74);
        --glass-surface-strong: rgb(14 19 29 / 0.88);
        --glass-surface-2: rgb(21 28 42 / 0.72);
        --glass-border: rgb(148 163 184 / 0.12);
        --glass-edge: inset 0 1px 0 rgb(255 255 255 / 0.06);
        --glass-filter: blur(8px);
        --glass-filter-strong: blur(12px);
        --button-sheen: linear-gradient(180deg, rgb(255 255 255 / 0.12), rgb(255 255 255 / 0) 55%);

        --primary: #2dd4bf;
        --primary-hover: #5eead4;
        --primary-active: #14b8a6;
        --on-primary: #042f2e;
        --primary-container: #113c3a;
        --primary-container-hover: #164e4b;
        --on-primary-container: #ccfbf1;

        --accent: #818cf8;
        --accent-container: #1e1b4b;
        --on-accent-container: #e0e7ff;

        --success: #34d399;
        --success-container: #064e3b;
        --on-success-container: #d1fae5;

        --warning: #fbbf24;
        --warning-container: #451a03;
        --on-warning-container: #fef3c7;

        --danger: #f87171;
        --danger-hover: #fca5a5;
        --on-danger: #450a0a;
        --danger-container: #5c1616;
        --on-danger-container: #fee2e2;

        --info: #38bdf8;
        --info-container: #0c4a6e;
        --on-info-container: #e0f2fe;

        --border: #1e293b;
        --border-strong: #334155;

        --focus-ring: #2dd4bf;

        --state-hover: rgb(241 245 249 / 0.055);
        --state-press: rgb(241 245 249 / 0.10);
        --scrim: rgb(2 6 12 / 0.68);

        --code-bg: #06090e;
        --code-fg: #e2e8f0;
        --code-border: #1e293b;
        --code-gutter-bg: #04060a;
        --code-gutter-fg: #64748b;
        --code-selection: rgb(45 212 191 / 0.26);

        --shadow-1: 0 1px 2px rgb(0 0 0 / 0.50), 0 2px 6px -2px rgb(0 0 0 / 0.45);
        --shadow-2: 0 2px 8px -2px rgb(0 0 0 / 0.50), 0 10px 24px -8px rgb(0 0 0 / 0.55);
        --shadow-3: 0 18px 44px -12px rgb(0 0 0 / 0.68), 0 4px 12px -4px rgb(0 0 0 / 0.50);
        --shadow-glow: 0 12px 34px -14px rgb(0 0 0 / 0.60), 0 2px 8px -4px rgb(45 212 191 / 0.08);
        --shadow-sticky-action: -8px 0 12px -8px rgb(0 0 0 / 0.60);
        --shadow-sticky-footer: 0 -4px 14px -6px rgb(0 0 0 / 0.65);
    }
}
