/* The original light palette stays in site.css/leads.css as each token's fallback. */
:root {
    color-scheme: light;
    --brand-light-display: block;
    --brand-dark-display: none;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --paper: #1b1c1e;
    --ink: #edf1e8;
    --muted: #bcc6b8;
    --green: #acd080;
    --sage: #30382f;
    --line: #454d46;
    --theme-text: #bcc6b8;
    --theme-accent: #bad79d;
    --theme-heading-accent: #adc891;
    --theme-card: #25282a;
    --theme-raised: #2b2e30;
    --theme-section: #212426;
    --theme-sidebar: #242829;
    --theme-panel: #303536;
    --theme-soft: #30392f;
    --theme-selected: #3b4c34;
    --theme-header: #1b1c1ef5;
    --theme-footer: #181a1b;
    --theme-line: #454d46;
    --theme-line-strong: #7f976a;
    --theme-input-border: #82907e;
    --theme-placeholder: #aebbaa;
    --theme-illustration-line: #485141;
    --theme-glow: #43533933;
    --theme-shadow: #00000060;
    --theme-backdrop: #080b0ce0;
    --theme-focus: #c2e193;
    --theme-error: #ffb7ad;
    --theme-error-surface: #3c282b;
    --theme-error-border: #de958b;
    --brand-light-display: none;
    --brand-dark-display: block;
}

/* No JavaScript is required to honor the operating-system preference. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
        --paper: #1b1c1e;
        --ink: #edf1e8;
        --muted: #bcc6b8;
        --green: #acd080;
        --sage: #30382f;
        --line: #454d46;
        --theme-text: #bcc6b8;
        --theme-accent: #bad79d;
        --theme-heading-accent: #adc891;
        --theme-card: #25282a;
        --theme-raised: #2b2e30;
        --theme-section: #212426;
        --theme-sidebar: #242829;
        --theme-panel: #303536;
        --theme-soft: #30392f;
        --theme-selected: #3b4c34;
        --theme-header: #1b1c1ef5;
        --theme-footer: #181a1b;
        --theme-line: #454d46;
        --theme-line-strong: #7f976a;
        --theme-input-border: #82907e;
        --theme-placeholder: #aebbaa;
        --theme-illustration-line: #485141;
        --theme-glow: #43533933;
        --theme-shadow: #00000060;
        --theme-backdrop: #080b0ce0;
        --theme-focus: #c2e193;
        --theme-error: #ffb7ad;
        --theme-error-surface: #3c282b;
        --theme-error-border: #de958b;
        --brand-light-display: none;
        --brand-dark-display: block;
    }
}

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

/* Artwork swaps without recoloring the illustrations or the original video. */
.brand.brand-header .brand-logo-light,
.brand.brand-footer .brand-logo-light,
.preview-brand .brand-logo-light { display: var(--brand-light-display); }
.brand.brand-header .brand-logo-dark,
.brand.brand-footer .brand-logo-dark,
.preview-brand .brand-logo-dark { display: var(--brand-dark-display); }

.header-inner { gap: 24px; }
.main-nav { min-width: 0; gap: 18px; }
.nav-actions { gap: 18px; }
.header-controls { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 38px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--ink);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    flex-shrink: 0;
    white-space: nowrap;
}
.theme-toggle:hover { background: var(--theme-raised, #eef0eb); border-color: var(--muted); }
.theme-toggle:active { background: var(--theme-panel, #e5e8e2); }
.theme-toggle .icon,
.theme-toggle .theme-icon-sun,
.theme-toggle .theme-icon-moon { width: 14px; height: 14px; flex-shrink: 0; }
.theme-switch-track {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 16px;
    flex-shrink: 0;
    border: 1px solid currentColor;
    border-radius: 999px;
    background: transparent;
}
.theme-switch-thumb {
    position: absolute;
    left: 3px;
    top: 3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    transition: transform .18s ease;
}
.theme-toggle[aria-checked="true"] .theme-switch-track { background: var(--ink); }
.theme-toggle[aria-checked="true"] .theme-switch-thumb { background: var(--paper); transform: translateX(12px); }
.theme-toggle[aria-checked="false"] .theme-icon-moon,
.theme-toggle[aria-checked="true"] .theme-icon-sun { opacity: .85; }

/* Native controls follow color-scheme; their visible state stays explicit. */
.lead-choice input,
.lead-consent input { accent-color: var(--mx-green); }
.lead-choice:has(input:checked) { border-color: var(--green); }
input:focus-visible,
.theme-toggle:focus-visible { outline: 3px solid var(--theme-focus, #987130); outline-offset: 4px; }
.theme-toggle:focus-visible { outline-color: var(--ink); }

@media (min-width: 1100px) and (max-width: 1360px) {
    .header-inner { gap: 16px; }
    .brand.brand-header .brand-logo { width: 176px; }
    .main-nav { gap: 12px; }
    .main-nav > a, .login-link { font-size: 11px; }
    .nav-actions { gap: 12px; }
    .nav-actions .button-small { padding-inline: 12px; gap: 8px; font-size: 11px; }
}
@media (min-width: 1100px) and (max-width: 1240px) {
    .theme-label { display: none; }
    .header-inner { gap: 12px; }
    .main-nav, .nav-actions { gap: 10px; }
    .brand.brand-header .brand-logo { width: 164px; }
}
@media (max-width: 1099px) {
    .header-inner { column-gap: 16px; }
    .header-inner > .brand { order: 1; }
    .header-controls { order: 2; margin-left: auto; gap: 10px; }
    .main-nav { order: 3; }
    .theme-label { display: none; }
    html.js .header-controls .menu-toggle { margin-left: 0; }
}
@media (max-width: 559px) {
    .header-inner { column-gap: 10px; }
    .header-controls { gap: 7px; }
    .brand.brand-header .brand-logo { width: 160px; }
    .theme-toggle { padding: 7px; min-height: 38px; }
}
@media (max-width: 379px) {
    .brand.brand-header .brand-logo { width: clamp(138px, 44vw, 160px); }
    .header-inner { column-gap: 8px; }
    .header-controls { gap: 6px; }
    .theme-toggle { padding-inline: 5px; gap: 3px; }
    .theme-toggle .icon,
    .theme-toggle .theme-icon-sun,
    .theme-toggle .theme-icon-moon { width: 12px; height: 12px; }
}
@media (prefers-reduced-motion: reduce) {
    .theme-switch-thumb { transition: none; }
}

/* A dark screen preference must not leave pale text on a paper printout. */
@media print {
    :root[data-theme], :root:not([data-theme]) {
        color-scheme: light;
        --paper: #fff;
        --ink: #203b34;
        --muted: #5b6962;
        --green: #254d40;
        --sage: #e9eee4;
        --line: #dce2d6;
        --theme-text: initial;
        --theme-accent: initial;
        --theme-heading-accent: initial;
        --theme-card: initial;
        --theme-raised: initial;
        --theme-section: initial;
        --theme-sidebar: initial;
        --theme-panel: initial;
        --theme-soft: initial;
        --theme-selected: initial;
        --theme-header: initial;
        --theme-footer: initial;
        --theme-line: initial;
        --theme-line-strong: initial;
        --theme-input-border: initial;
        --theme-placeholder: initial;
        --theme-illustration-line: initial;
        --theme-glow: initial;
        --theme-shadow: initial;
        --theme-backdrop: initial;
        --theme-focus: initial;
        --theme-error: initial;
        --theme-error-surface: initial;
        --theme-error-border: initial;
        --brand-light-display: block;
        --brand-dark-display: none;
    }
    .theme-toggle { display: none !important; }
}
