/*
 * NEXTA semantic color system.
 * Light tokens preserve the approved Stage 1 palette.
 * Dark mode is selected through html[data-nexta-theme="dark"] or system preference.
 */
:root {
    color-scheme: light;

    /* Semantic foundations — LIGHT */
    --nexta-page-bg: #f5f7fb;
    --nexta-surface: #ffffff;
    --nexta-surface-raised: #ffffff;
    --nexta-text: #192439;
    --nexta-text-muted: #637087;
    --nexta-text-subtle: #637087;
    --nexta-border: #dfe5ee;
    --nexta-border-strong: #7b879a;
    --nexta-link: #003399;
    --nexta-link-hover: #002b82;
    --nexta-brand-surface: #003399;
    --nexta-brand-control-hover: #f0f3f9;
    --nexta-on-brand: #ffffff;
    --nexta-accent: #ee1a0f;
    --nexta-accent-text: #c5160d;
    --nexta-focus: #1944f6;
    --nexta-control-bg: #ffffff;
    --nexta-control-border: #6f7d91;
    --nexta-placeholder: #637087;
    --nexta-selection-bg: #dce8ff;
    --nexta-selection-text: #192439;
    --nexta-overlay: rgb(0 20 51 / 60%);
    --nexta-dialog-bg: #ffffff;
    --nexta-card-bg: #ffffff;
    --nexta-support-bg: #eaf0fb;
    --nexta-support-text: #192439;
    --nexta-support-text-muted: #59677d;
    --nexta-video-stage-bg: #071b42;
    --nexta-disabled-text: #637087;
    --nexta-disabled-bg: #eef1f6;
    --nexta-error: #b42318;
    --nexta-success: #176b3a;
    --nexta-nav-glass: rgb(255 255 255 / 93%);
    --nexta-nav-text: #33445f;
    --nexta-nav-icon: #5d6e8d;
    --nexta-nav-active-bg: #eef3fc;
    --nexta-dialog-shadow: 0 18px 70px rgb(0 20 51 / 15%);

    /* Approved legacy aliases — keep old snippets compatible. */
    --brand: #003399;
    --accent: var(--nexta-accent);
    --ink: var(--nexta-text);
    --muted: var(--nexta-text-muted);
    --line: var(--nexta-border);
    --surface: var(--nexta-page-bg);
    --soft-surface: #eef1f6;
    --support-surface: var(--nexta-support-bg);
    --video-stage: var(--nexta-video-stage-bg);
    --radius: 12px;
    --focus: var(--nexta-focus);
}

:root[data-nexta-theme="light"] {
    color-scheme: light;
}

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

    --nexta-page-bg: #101722;
    --nexta-surface: #151f2d;
    --nexta-surface-raised: #1c2a3b;
    --nexta-text: #f2f5f9;
    --nexta-text-muted: #c3cfdd;
    --nexta-text-subtle: #a8b6c8;
    --nexta-border: #65758d;
    --nexta-border-strong: #8292a8;
    --nexta-link: #a8c7ff;
    --nexta-link-hover: #c5d9ff;
    --nexta-brand-surface: #003399;
    --nexta-brand-control-hover: #263b57;
    --nexta-on-brand: #ffffff;
    --nexta-accent: #ff6b63;
    --nexta-accent-text: #ff8b84;
    --nexta-focus: #ffe082;
    --nexta-control-bg: #111b29;
    --nexta-control-border: #7b8ca4;
    --nexta-placeholder: #aebccc;
    --nexta-selection-bg: #315b91;
    --nexta-selection-text: #ffffff;
    --nexta-overlay: rgb(2 8 18 / 78%);
    --nexta-dialog-bg: #192638;
    --nexta-card-bg: #172334;
    --nexta-support-bg: #1c314b;
    --nexta-support-text: #f2f5f9;
    --nexta-support-text-muted: #c3cfdd;
    --nexta-video-stage-bg: #071b42;
    --nexta-disabled-text: #a4afbe;
    --nexta-disabled-bg: #2a3545;
    --nexta-error: #ff938a;
    --nexta-success: #75d69b;
    --nexta-nav-glass: rgb(21 31 45 / 96%);
    --nexta-nav-text: #e7edf5;
    --nexta-nav-icon: #a8b6c8;
    --nexta-nav-active-bg: #263b57;
    --nexta-dialog-shadow: 0 18px 70px rgb(0 0 0 / 48%);

    /* Legacy aliases follow semantic values, except the fixed brand surface. */
    --brand: #003399;
    --accent: var(--nexta-accent);
    --ink: var(--nexta-text);
    --muted: var(--nexta-text-muted);
    --line: var(--nexta-border);
    --surface: var(--nexta-page-bg);
    --soft-surface: var(--nexta-surface);
    --support-surface: var(--nexta-support-bg);
    --video-stage: var(--nexta-video-stage-bg);
    --focus: var(--nexta-focus);
}

/* First visit / system mode follows the user's OS without waiting for JavaScript. */
@media (prefers-color-scheme: dark) {
    :root:not([data-nexta-theme]) {
        color-scheme: dark;

        --nexta-page-bg: #101722;
        --nexta-surface: #151f2d;
        --nexta-surface-raised: #1c2a3b;
        --nexta-text: #f2f5f9;
        --nexta-text-muted: #c3cfdd;
        --nexta-text-subtle: #a8b6c8;
        --nexta-border: #65758d;
        --nexta-border-strong: #8292a8;
        --nexta-link: #a8c7ff;
        --nexta-link-hover: #c5d9ff;
        --nexta-brand-surface: #003399;
        --nexta-brand-control-hover: #263b57;
        --nexta-on-brand: #ffffff;
        --nexta-accent: #ff6b63;
        --nexta-accent-text: #ff8b84;
        --nexta-focus: #ffe082;
        --nexta-control-bg: #111b29;
        --nexta-control-border: #7b8ca4;
        --nexta-placeholder: #aebccc;
        --nexta-selection-bg: #315b91;
        --nexta-selection-text: #ffffff;
        --nexta-overlay: rgb(2 8 18 / 78%);
        --nexta-dialog-bg: #192638;
        --nexta-card-bg: #172334;
        --nexta-support-bg: #1c314b;
        --nexta-support-text: #f2f5f9;
        --nexta-support-text-muted: #c3cfdd;
        --nexta-video-stage-bg: #071b42;
        --nexta-disabled-text: #a4afbe;
        --nexta-disabled-bg: #2a3545;
        --nexta-error: #ff938a;
        --nexta-success: #75d69b;
        --nexta-nav-glass: rgb(21 31 45 / 96%);
        --nexta-nav-text: #e7edf5;
        --nexta-nav-icon: #a8b6c8;
        --nexta-nav-active-bg: #263b57;
        --nexta-dialog-shadow: 0 18px 70px rgb(0 0 0 / 48%);

        --brand: #003399;
        --accent: var(--nexta-accent);
        --ink: var(--nexta-text);
        --muted: var(--nexta-text-muted);
        --line: var(--nexta-border);
        --surface: var(--nexta-page-bg);
        --soft-surface: var(--nexta-surface);
        --support-surface: var(--nexta-support-bg);
        --video-stage: var(--nexta-video-stage-bg);
        --focus: var(--nexta-focus);
    }
}
