/*
 * HC platform theme tokens, shared by every layout, plus the theme switcher control.
 * <html> carries data-theme (light | dark | system) and data-theme-resolved (light | dark).
 * Contrast targets: body text >= 4.5:1, muted text >= 4.5:1 on page and surface, control borders >= 3:1.
 */
:root {
    --hc-bg: #f1f5f9;
    --hc-bg-subtle: #e8eef5;
    --hc-surface: #ffffff;
    --hc-surface-2: #f8fafc;
    --hc-surface-elevated: #ffffff;
    --hc-text: #0f172a;
    --hc-text-2: #475569;
    --hc-muted: #5b6a7f;
    --hc-border: #dbe2ea;
    --hc-border-strong: #c3cdd9;
    --hc-input-bg: #ffffff;
    --hc-input-border: #8391a5;
    --hc-primary: #1d4ed8;
    --hc-primary-hover: #1e40af;
    --hc-primary-fg: #ffffff;
    --hc-primary-soft: #e8eefc;
    --hc-link: #1d4ed8;
    --hc-positive: #15803d;
    --hc-positive-soft: #dcfce7;
    --hc-negative: #b91c1c;
    --hc-negative-soft: #fee2e2;
    --hc-warning: #92400e;
    --hc-warning-soft: #fef3c7;
    --hc-info: #0369a1;
    --hc-info-soft: #e0f2fe;
    --hc-accent: #0f766e;
    --hc-focus: #2563eb;
    --hc-overlay: rgba(15, 23, 42, .55);
    --hc-table-head: #f1f5f9;
    --hc-table-hover: #f6f9fc;
    --hc-table-selected: #e8eefc;
    --hc-chart-grid: #e2e8f0;
    --hc-chart-axis: #475569;
    --hc-chart-tooltip: #0f172a;
    --hc-shell: #0f1b2d;
    --hc-shell-2: #16253b;
    --hc-shell-text: #d2dbe7;
    --hc-shell-muted: #8fa1b9;
    --hc-shell-border: rgba(255, 255, 255, .08);
    --hc-shell-accent: #60a5fa;
    --hc-shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --hc-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -14px rgba(15, 23, 42, .25);
    --hc-shadow-lg: 0 18px 44px -18px rgba(15, 23, 42, .35);
    --hc-radius-sm: 8px;
    --hc-radius: 12px;
    --hc-radius-lg: 16px;
    --hc-font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --hc-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
}

html[data-theme-resolved="dark"] {
    --hc-bg: #0b1220;
    --hc-bg-subtle: #111827;
    --hc-surface: #172133;
    --hc-surface-2: #1c283c;
    --hc-surface-elevated: #223047;
    --hc-text: #f1f5f9;
    --hc-text-2: #cbd5e1;
    --hc-muted: #9aa8bc;
    --hc-border: #2a3a52;
    --hc-border-strong: #3a4d68;
    --hc-input-bg: #111a2b;
    --hc-input-border: #64748b;
    --hc-primary: #2563eb;
    --hc-primary-hover: #1d4ed8;
    --hc-primary-fg: #ffffff;
    --hc-primary-soft: rgba(96, 165, 250, .14);
    --hc-link: #7cb4fb;
    --hc-positive: #4ade80;
    --hc-positive-soft: rgba(74, 222, 128, .13);
    --hc-negative: #f87171;
    --hc-negative-soft: rgba(248, 113, 113, .14);
    --hc-warning: #fbbf24;
    --hc-warning-soft: rgba(251, 191, 36, .13);
    --hc-info: #38bdf8;
    --hc-info-soft: rgba(56, 189, 248, .13);
    --hc-accent: #5eead4;
    --hc-focus: #60a5fa;
    --hc-overlay: rgba(2, 6, 15, .7);
    --hc-table-head: #131d2e;
    --hc-table-hover: #1b273a;
    --hc-table-selected: #1d2d4a;
    --hc-chart-grid: #2b3a52;
    --hc-chart-axis: #cbd5e1;
    --hc-chart-tooltip: #f1f5f9;
    --hc-shell: #0a1324;
    --hc-shell-2: #12203a;
    --hc-shell-text: #d2dbe7;
    --hc-shell-muted: #8fa1b9;
    --hc-shell-border: rgba(255, 255, 255, .07);
    --hc-shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --hc-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -16px rgba(0, 0, 0, .6);
    --hc-shadow-lg: 0 20px 48px -18px rgba(0, 0, 0, .7);
}

/* Without JavaScript a "system" preference still follows the device. */
@media (prefers-color-scheme: dark) {
    html[data-theme="system"]:not([data-theme-resolved]) {
        --hc-bg: #0b1220; --hc-surface: #172133; --hc-surface-2: #1c283c; --hc-text: #f1f5f9; --hc-text-2: #cbd5e1;
        --hc-muted: #9aa8bc; --hc-border: #2a3a52; --hc-input-bg: #111a2b; --hc-input-border: #64748b; --hc-link: #7cb4fb;
    }
}

html[data-theme-resolved="dark"]:not([data-hc-protected]):not([data-hc-light-content]) { color-scheme: dark; }
html[data-theme-resolved="light"] { color-scheme: light; }

/* ---------- Theme switcher ---------- */
.hc-theme-menu { position: relative; display: inline-block; }
.hc-theme-trigger {
    list-style: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
    color: inherit; cursor: pointer; border: 1px solid transparent; transition: background-color .15s, border-color .15s;
}
.hc-theme-trigger::-webkit-details-marker { display: none; }
.hc-theme-trigger:hover { background: rgba(127, 140, 160, .14); }
.hc-theme-trigger:focus-visible, .hc-theme-option:focus-visible { outline: 3px solid var(--hc-focus); outline-offset: 2px; }
.hc-theme-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hc-theme-trigger .hc-theme-icon-dark { display: none; }
html[data-theme-resolved="dark"] .hc-theme-trigger .hc-theme-icon-dark { display: block; }
html[data-theme-resolved="dark"] .hc-theme-trigger .hc-theme-icon-light { display: none; }
.hc-theme-panel {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 1100; width: 220px; padding: 8px;
    background: var(--hc-surface-elevated); color: var(--hc-text); border: 1px solid var(--hc-border);
    border-radius: var(--hc-radius); box-shadow: var(--hc-shadow-lg); font: 400 14px/1.4 var(--hc-font); text-align: left;
}
.hc-theme-panel-title { display: block; padding: 6px 10px 8px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--hc-muted); }
.hc-theme-option {
    display: grid; grid-template-columns: 20px 1fr; align-items: center; column-gap: 10px; width: 100%; min-height: 40px;
    padding: 8px 10px; border: 0; border-radius: var(--hc-radius-sm); background: transparent; color: var(--hc-text);
    font: 600 14px/1.3 var(--hc-font); text-align: left; cursor: pointer;
}
.hc-theme-option small { grid-column: 2; font-weight: 500; font-size: 12px; color: var(--hc-muted); }
.hc-theme-option:hover { background: var(--hc-surface-2); }
.hc-theme-option[aria-checked="true"] { background: var(--hc-primary-soft); color: var(--hc-link); }
@media (prefers-reduced-motion: reduce) {
    .hc-theme-trigger { transition: none; }
}

/* Corner switcher on standalone sign-in pages */
.hc-auth-theme { position: fixed; top: 16px; right: 16px; z-index: 1050; }
.hc-auth-theme .hc-theme-trigger { background: var(--hc-surface); color: var(--hc-text); border-color: var(--hc-border); box-shadow: var(--hc-shadow); }
.hc-auth-theme .hc-theme-trigger:hover { background: var(--hc-surface-2); }
