/* ==========================================================================
   HATSTACK // CORE DESIGN & THEME TOKENS
   Single source of truth for :root defaults and [data-theme] token sets.
   ========================================================================== */

:root {
  /* Surface & Text Tokens (Default Warm Hatstack) */
  --surface-canvas: #000000;
  --canvas-gradient: none;
  --surface-panel: rgba(12, 8, 5, 0.96);
  --surface-card: #080605;
  --text-primary: #FFF7ED;
  --text-muted: #A8A29E;

  /* Accent Tokens (Themeable) */
  --accent-rgb: 222, 89, 19;
  --accent: #DE5913;
  --accent-hover: #F16F24;
  --accent-bright: #FB923C;
  --accent-soft: #FED7AA;
  --accent-deep: #BA490C;
  --accent-2: #FB923C;
  --on-accent: #1A0A02;

  /* Selection Tokens (Themeable) */
  --select-rgb: 222, 89, 19;
  --select: var(--accent);
  --on-select: var(--on-accent);

  /* Body Figure Hue & Saturation Filter */
  --figure-hue-rotate: 0deg;
  --figure-saturate: 1;

  /* Brand Logo Tokens (Themeable) */
  --logo-filter: none;
  --logo-filter-hover: drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.55));

  /* Neutral Sidebar Tokens */
  --sidebar-bg: #0e0e10;
  --sidebar-card: #17171a;
  --sidebar-card-hover: #1e1e22;
  --sidebar-border: #2a2a2e;
  --sidebar-text: #e8e8ea;
  --sidebar-text-muted: #8b8b92;

  /* Universal Z-Index Hierarchy */
  --z-sticky: 100;
  --z-topbar: 500;
  --z-backdrop: 1000;
  --z-drawer: 1100;
  --z-modal-backdrop: 1200;
  --z-modal: 1300;

  /* TopBar Theming Tokens */
  --topbar-bg: rgba(14, 14, 18, 0.95);
  --topbar-border: var(--panel-border);
  --clock-pill-bg: var(--bg-core);
  --clock-pill-border: var(--panel-border);

  /* Backward-Compatible Core Tokens */
  --bg-core: #08080A;
  --bg-elevated: #0E0E12;
  --bg: #08080A;
  --panel: #131317;
  --panel-hover: #1A1A22;
  --panel-active: #20202A;
  --panel-border: rgba(255, 255, 255, 0.07);
  --panel-border-hover: rgba(var(--accent-rgb), 0.35);
  --accent-dim: var(--accent-deep);
  --accent-subtle: rgba(var(--accent-rgb), 0.12);
  --accent-glow: rgba(var(--accent-rgb), 0.22);
  --text-main: #EDEDED;
  --text-dim: #54545E;

  /* Neutral Overlays (Consolidated 4 Black, 3 White levels) */
  --overlay-black-heavy: rgba(0, 0, 0, 0.90);
  --overlay-black-medium: rgba(0, 0, 0, 0.75);
  --overlay-black-soft: rgba(0, 0, 0, 0.45);
  --overlay-black-subtle: rgba(0, 0, 0, 0.20);
  --overlay-white-strong: rgba(255, 255, 255, 0.35);
  --overlay-white-medium: rgba(255, 255, 255, 0.18);
  --overlay-white-subtle: rgba(255, 255, 255, 0.08);

  /* Semantic Status & Lockout Tokens (Fixed / Non-Themed) */
  --status-danger: #EF4444;
  --status-danger-bright: #F87171;
  --status-danger-deep: #DC2626;
  --status-danger-soft: #FCA5A5;
  --status-danger-subtle: rgba(239, 68, 68, 0.15);
  --status-danger-border: rgba(239, 68, 68, 0.40);
  --error: var(--status-danger);
  --error-subtle: var(--status-danger-subtle);

  /* Semantic Telemetry & Biometrics Tokens (Fixed / Non-Themed) */
  --data-sky: #38BDF8;
  --data-sky-subtle: rgba(56, 189, 248, 0.15);
  --data-sky-glow: rgba(56, 189, 248, 0.30);
  --data-indigo: #6366F1;
  --data-indigo-bright: #818CF8;
  --data-indigo-soft: #A5B4FC;
  --data-indigo-subtle: rgba(99, 102, 241, 0.20);
  --data-purple: #C084FC;
  --data-slate-border: #334155;
  --data-slate-text: #94A3B8;
  --data-slate-muted: #64748B;
  --data-slate-dark: #1E293B;
  --user-teal: #00E5FF;
  --success: #10B981;
  --success-subtle: rgba(16, 185, 129, 0.12);

  /* Typography Framework Tokens */
  --font-display: 'Cascadia Code', monospace;
  --font-body: 'Cascadia Code', monospace;
  --font-header: var(--font-display);
  --font-title: var(--font-display);
  --font-mono: var(--font-body);
  --font-sans: var(--font-body);
  --font-main: var(--font-body);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  /* Shape & Decorative Tokens (Neutral Defaults) */
  --shape-card: none;
  --shape-button: none;
  --shape-modal: none;
  --corner-marks: none;
  --frame-style: none;

  /* Safe-Area Insets for Wrapped / Notched Viewports */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

body {
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
}

.top-bar,
.gcal-top-bar {
  padding-top: var(--safe-top);
}

.nav-drawer {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* Orange Theme Override (Default Hatstack) */
html[data-theme='orange'],
[data-theme='orange'] {
  --accent-rgb: 222, 89, 19;
  --accent: #DE5913;
  --accent-hover: #F16F24;
  --accent-bright: #FB923C;
  --accent-soft: #FED7AA;
  --accent-deep: #BA490C;
  --accent-2: #FB923C;
  --on-accent: #1A0A02;

  --select-rgb: 222, 89, 19;
  --select: var(--accent);
  --on-select: var(--on-accent);

  --surface-canvas: #000000;
  --canvas-gradient: none;
  --surface-panel: rgba(12, 8, 5, 0.96);
  --surface-card: #080605;
  --text-primary: #FFF7ED;
  --text-muted: #A8A29E;

  --sidebar-bg: #0e0e10;
  --sidebar-card: #17171a;
  --sidebar-card-hover: #1e1e22;
  --sidebar-border: #2a2a2e;
  --sidebar-text: #e8e8ea;
  --sidebar-text-muted: #8b8b92;

  --figure-hue-rotate: 0deg;
  --figure-saturate: 1;

  --font-display: 'Cascadia Code', monospace;
  --font-body: 'Cascadia Code', monospace;

  --logo-filter: none;
  --logo-filter-hover: drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.55));

  --gcal-surface: #08080A;
  --gcal-surface-subtle: #0E0E12;
  --gcal-surface-card: #131317;
  --gcal-surface-popover: #17171E;
  --gcal-accent: #DE5913;
  --gcal-now-line: #FF3B30;
}

/* HATSTACK '86 (HatStark copy with Hatstack orange colors) */
html[data-theme='hs86'],
[data-theme='hs86'] {
  --accent-rgb: 222, 89, 19;
  --accent: #DE5913;
  --accent-hover: #F16F24;
  --accent-bright: #DE5913;
  --accent-soft: rgba(var(--accent-rgb), 0.25);
  --accent-deep: #BA490C;
  --accent-2: #BA490C;
  --on-accent: #1A0802;

  --select-rgb: 222, 89, 19;
  --select: var(--accent);
  --on-select: #1A0802;

  --surface-canvas: #080605;
  --canvas-gradient: radial-gradient(ellipse at 50% 0%, #1A0D07 0%, #080605 70%);
  --surface-panel: #0E0907;
  --surface-card: #150E0A;
  --text-primary: #EDE5DF;
  --text-muted: #9E887E;

  --sidebar-bg: #0B0705;
  --sidebar-card: #120C08;
  --sidebar-card-hover: #1A110B;
  --sidebar-border: #4D2612;
  --sidebar-text: #EDE5DF;
  --sidebar-text-muted: #9E887E;

  --topbar-bg: rgba(14, 9, 7, 0.95);
  --topbar-border: var(--sidebar-border);
  --clock-pill-bg: var(--surface-card);
  --clock-pill-border: var(--sidebar-border);

  --figure-hue-rotate: 0deg;
  --figure-saturate: 1;

  --font-display: 'Orbitron', sans-serif;
  --shape-card: none;
  --shape-button: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
  --shape-modal: none;
  --font-body: 'Rajdhani', sans-serif;

  --logo-filter: none;
  --logo-filter-hover: drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.7));

  --gcal-surface: #080605;
  --gcal-surface-subtle: #0E0907;
  --gcal-surface-card: #150E0A;
  --gcal-surface-popover: #1A110B;
  --gcal-border: #4D2612;
  --gcal-border-subtle: #2C160B;
  --gcal-accent: #DE5913;
  --gcal-now-line: #FF4500;
  --gcal-radius: 0px;
}

/* Emerald Theme Override (Jos Workspace) */
html[data-theme='emerald'],
[data-theme='emerald'] {
  --accent-rgb: 16, 185, 129;
  --accent: #10B981;
  --accent-hover: #34D399;
  --accent-bright: #6EE7B7;
  --accent-soft: #A7F3D0;
  --accent-deep: #065F46;
  --accent-2: #34D399;
  --on-accent: #02140D;

  --select-rgb: 16, 185, 129;
  --select: var(--accent);
  --on-select: var(--on-accent);

  --surface-canvas: #020704;
  --canvas-gradient: none;
  --surface-panel: rgba(4, 12, 8, 0.96);
  --surface-card: #040D07;
  --text-primary: #ECFDF5;
  --text-muted: #A7F3D0;

  --sidebar-bg: #0e0e10;
  --sidebar-card: #17171a;
  --sidebar-card-hover: #1e1e22;
  --sidebar-border: #2a2a2e;
  --sidebar-text: #e8e8ea;
  --sidebar-text-muted: #8b8b92;

  --figure-hue-rotate: 140deg;
  --figure-saturate: 1;

  --font-display: 'Cascadia Code', monospace;
  --font-body: 'Cascadia Code', monospace;

  --logo-filter: hue-rotate(85deg) saturate(1.25);
  --logo-filter-hover: hue-rotate(85deg) saturate(1.35) drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.7));

  --gcal-surface: #020704;
  --gcal-surface-subtle: #040D07;
  --gcal-surface-card: #08170D;
  --gcal-surface-popover: #0C2113;
  --gcal-border: rgba(16, 185, 129, 0.2);
  --gcal-border-subtle: rgba(16, 185, 129, 0.08);
  --gcal-accent: #10B981;
  --gcal-now-line: #34D399;
}

/* JARVIS BLUE (Iron Man HUD: cold cyan lines on deep navy) */
html[data-theme='jarvis'],
[data-theme='jarvis'] {
  --accent-rgb: 0, 190, 255;
  --accent: #00BEFF;
  --accent-hover: #4FD6FF;
  --accent-bright: #8CE8FF;
  --accent-soft: #BFF1FF;
  --accent-deep: #0B5F83;
  --accent-2: #5B8CFF;
  --on-accent: #02131C;

  --select-rgb: 0, 190, 255;
  --select: #00BEFF;
  --on-select: #02131C;

  --surface-canvas: #02060D;
  --canvas-gradient: radial-gradient(ellipse at 50% 0%, #06182B 0%, #02060D 70%);
  --surface-panel: #07121F;
  --surface-card: #0B1A2B;
  --text-primary: #E4F6FF;
  --text-muted: #7FA8BF;

  --sidebar-bg: #050D18;
  --sidebar-card: #0A1828;
  --sidebar-card-hover: #0F2238;
  --sidebar-border: #11425C;
  --sidebar-text: #E4F6FF;
  --sidebar-text-muted: #7FA8BF;

  --topbar-bg: rgba(7, 18, 31, 0.95);
  --topbar-border: var(--sidebar-border);
  --clock-pill-bg: var(--surface-card);
  --clock-pill-border: var(--sidebar-border);

  --figure-hue-rotate: 175deg;
  --figure-saturate: 1;

  --font-display: 'Orbitron', sans-serif;
  --shape-card: none;
  --shape-button: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
  --shape-modal: none;
  --font-body: 'Rajdhani', sans-serif;

  --logo-filter: hue-rotate(170deg) saturate(1.4);
  --logo-filter-hover: hue-rotate(170deg) saturate(1.5) drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.7));

  --gcal-surface: #02060D;
  --gcal-surface-subtle: #07121F;
  --gcal-surface-card: #0B1A2B;
  --gcal-surface-popover: #0F2238;
  --gcal-border: #11425C;
  --gcal-border-subtle: rgba(0, 190, 255, 0.1);
  --gcal-accent: #00BEFF;
  --gcal-now-line: #00E5FF;
}

/* CYBERPUNK (Cyberpunk 2077 menu: crimson to near-black gradient, red text, cyan select) */
html[data-theme='cyberpunk'],
[data-theme='cyberpunk'] {
  --accent-rgb: 255, 61, 79;
  --accent: #FF3D4F;
  --accent-hover: #FF6B78;
  --accent-bright: #FF8E98;
  --accent-soft: #FFC4C9;
  --accent-deep: #7A1621;
  --accent-2: #2EE6F6;
  --on-accent: #1A0408;

  --select-rgb: 46, 230, 246;
  --select: #2EE6F6;
  --on-select: #031A1F;

  --surface-canvas: #0B0912;
  --canvas-gradient: linear-gradient(180deg, #3A0D18 0%, #1C0A18 35%, #0B0912 100%);
  --surface-panel: #150B14;
  --surface-card: #1E0E1A;
  --text-primary: #FFE1E3;
  --text-muted: #B07880;

  --sidebar-bg: #12080F;
  --sidebar-card: #1A0C14;
  --sidebar-card-hover: #26101C;
  --sidebar-border: #4A1822;
  --sidebar-text: #FF6A75;
  --sidebar-text-muted: #A8525B;

  --topbar-bg: rgba(21, 11, 20, 0.95);
  --topbar-border: var(--sidebar-border);
  --clock-pill-bg: var(--surface-card);
  --clock-pill-border: var(--sidebar-border);

  --figure-hue-rotate: 332deg;
  --figure-saturate: 1;

  --font-display: 'Play', sans-serif;
  --shape-card: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
  --shape-button: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
  --shape-modal: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
  --font-body: 'Play', sans-serif;

  --logo-filter: hue-rotate(330deg) saturate(1.3);
  --logo-filter-hover: hue-rotate(330deg) saturate(1.4) drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.7));

  --gcal-surface: #0B0912;
  --gcal-surface-subtle: #150B14;
  --gcal-surface-card: #1E0E1A;
  --gcal-surface-popover: #2A1224;
  --gcal-border: #4A1822;
  --gcal-border-subtle: rgba(255, 61, 79, 0.12);
  --gcal-accent: #FF3D4F;
  --gcal-now-line: #2EE6F6;
}

/* METAL GEAR (MGS codec screen: pale mint lines on dark green, red call block) */
html[data-theme='mgs'],
[data-theme='mgs'] {
  --accent-rgb: 134, 211, 170;
  --accent: #86D3AA;
  --accent-hover: #A5E4C1;
  --accent-bright: #C2F0D6;
  --accent-soft: #D6F6E5;
  --accent-deep: #3F6F57;
  --accent-2: #C8202A;
  --on-accent: #07140D;

  --select-rgb: 200, 32, 42;
  --select: #C8202A;
  --on-select: #2A0507;

  --surface-canvas: #0C1712;
  --canvas-gradient: none;
  --surface-panel: #12221A;
  --surface-card: #17291F;
  --text-primary: #CFEBDB;
  --text-muted: #7DA791;

  --sidebar-bg: #0E1A14;
  --sidebar-card: #132319;
  --sidebar-card-hover: #1A3024;
  --sidebar-border: #4F8A6D;
  --sidebar-text: #CFEBDB;
  --sidebar-text-muted: #7DA791;

  --topbar-bg: rgba(18, 34, 26, 0.95);
  --topbar-border: var(--sidebar-border);
  --clock-pill-bg: var(--surface-card);
  --clock-pill-border: var(--sidebar-border);

  --figure-hue-rotate: 122deg;
  --figure-saturate: 0.6;

  --font-display: 'Silkscreen', monospace;
  --shape-card: none;
  --shape-button: none;
  --shape-modal: none;
  --frame-style: double;
  --font-body: 'Share Tech Mono', monospace;

  --logo-filter: hue-rotate(115deg) saturate(1.1);
  --logo-filter-hover: hue-rotate(115deg) saturate(1.2) drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.7));

  --gcal-surface: #0C1712;
  --gcal-surface-subtle: #12221A;
  --gcal-surface-card: #17291F;
  --gcal-surface-popover: #1E3528;
  --gcal-border: #4F8A6D;
  --gcal-border-subtle: rgba(134, 211, 170, 0.12);
  --gcal-accent: #86D3AA;
  --gcal-now-line: #C8202A;
}
