/* ============================================================
   YancoTab v2.0 — Design Tokens
   Derived from YancoHub's Cinematic Cosmic Glassmorphism
   ============================================================ */

:root {
  /* ── Backgrounds ── */
  --bg:          #060b14;
  --bg-card:     rgba(8, 18, 32, 0.85);
  --bg-glass:    rgba(0, 229, 193, 0.04);
  --bg-panel:    rgba(8, 15, 28, 0.95);
  --bg-surface:  #0c1628;
  --bg-elevated: #111e36;

  /* ── Accent (Teal) — overridden per color theme ── */
  --accent:        #00e5c1;
  --accent-rgb:    0, 229, 193;
  --accent-contrast: #0a0f1a; /* dark text on bright accent */
  --accent-dim:    rgba(0, 229, 193, 0.25);
  --accent-glow:   rgba(0, 229, 193, 0.35);
  --accent-bright: #33ffdd;
  --accent-bg:     rgba(0, 229, 193, 0.08);
  --accent-subtle: rgba(0, 229, 193, 0.04);

  /* ── UI Text (for labels, dots, nav, placeholders) ── */
  --ui-text-rgb: 200, 220, 240;

  /* ── Text Hierarchy ── */
  --text-bright: #c8d6e5;
  --text:        #8a9bb0;
  --text-dim:    #3d4f63;

  /* ── Semantic Colors ── */
  --danger:    #ff4757;
  --success:   #2ed573;
  --warning:   #ffa502;
  --gold:      #ffc800;
  --gold-dim:  rgba(255, 200, 0, 0.1);
  --info:      #0a84ff;

  /* ── Border ── */
  --border:       rgba(255, 255, 255, 0.06);
  --border-accent: rgba(0, 229, 193, 0.15);
  --border-light: rgba(255, 255, 255, 0.1);

  /* ── Radius ── */
  --radius-xs:  4px;
  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --radius-pill: 999px;

  /* ── Shadows & Glows ── */
  --glow-sm:   0 0 15px rgba(0, 229, 193, 0.2), 0 0 30px rgba(0, 229, 193, 0.08);
  --glow-md:   0 0 30px rgba(0, 229, 193, 0.18), 0 8px 32px rgba(0, 0, 0, 0.4);
  --glow-lg:   0 0 60px rgba(0, 229, 193, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  /* ── Transitions ── */
  --ease-out:   cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast:   0.15s var(--ease-out);
  --transition-normal: 0.3s var(--ease-out);
  --transition-slow:   0.5s var(--ease-out);
  --transition-spring: 0.55s var(--ease-spring);

  /* ── Typography ── */
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-xs:    11px;
  --font-sm:    13px;
  --font-base:  14px;
  --font-md:    16px;
  --font-lg:    18px;
  --font-xl:    24px;
  --font-xxl:   28px;

  /* ── Z-Index Scale ── */
  --z-wallpaper:   0;
  --z-particles:   1;
  --z-grid:        10;
  --z-dock:        100;
  --z-statusbar:   200;
  --z-window:      300;
  --z-overlay:     400;
  --z-modal:       500;
  --z-context:     600;
  --z-search:      700;
  --z-toast:       800;
  --z-boot:        900;
  --z-fatal:       1000;

  /* ── Spacing ── */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  12px;
  --space-lg:  16px;
  --space-xl:  24px;
  --space-xxl: 32px;

  /* ── Glass ── */
  --glass-blur:    blur(20px);
  --glass-blur-sm: blur(12px);
  --glass-blur-lg: blur(32px);
  --glass-blur-dock: blur(32px) saturate(1.6);

  /* ── Inner Glow (premium 0.5px white stroke) ── */
  --inner-glow: inset 0 0.5px 0 rgba(255, 255, 255, 0.25);

  /* ── YancoVerse Luminous Design Language ── */
  --yv-edge-glow:
    radial-gradient(ellipse at 50% 0%, rgba(var(--accent-rgb), 0.12), transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(var(--accent-rgb), 0.08), transparent 50%),
    radial-gradient(ellipse at 0% 50%, rgba(var(--accent-rgb), 0.05), transparent 40%),
    radial-gradient(ellipse at 100% 50%, rgba(var(--accent-rgb), 0.05), transparent 40%);
  --yv-glass: linear-gradient(165deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 30%, transparent 50%);
  --yv-platform: radial-gradient(ellipse, rgba(var(--accent-rgb), 0.18), transparent 70%);
  --yv-platform-hover: radial-gradient(ellipse, rgba(var(--accent-rgb), 0.32), transparent 70%);

  /* ── Hex Icon ── */
  --hex-clip: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  --hex-size: 62px;
  --hex-gap:  10px;

  /* ── Nav Bar ── */
  --nav-height: 64px;

  /* ── Cosmic Atelier (premium layer) ── */
  /* Aurora drift — three stops blended behind boards/cards */
  --aurora-1: rgba(0, 229, 193, 0.22);   /* teal */
  --aurora-2: rgba(107,  92, 255, 0.18); /* violet */
  --aurora-3: rgba( 10,  15,  40, 0.00); /* fade */
  --aurora-bg:
    radial-gradient(1200px 700px at 15% 20%, var(--aurora-1), transparent 60%),
    radial-gradient( 900px 600px at 85% 80%, var(--aurora-2), transparent 60%),
    radial-gradient( 600px 400px at 50% 50%, rgba(0, 229, 193, 0.05), transparent 70%);

  /* Constellation particles */
  --particle-dim:    rgba(var(--accent-rgb), 0.35);
  --particle-bright: rgba(var(--accent-rgb), 0.95);

  /* Depth system — 5 tiers of layered elevation */
  --depth-1: 0 1px 2px rgba(0, 0, 0, 0.25), inset 0 0.5px 0 rgba(255, 255, 255, 0.06);
  --depth-2: 0 2px 6px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.04), inset 0 0.5px 0 rgba(255, 255, 255, 0.08);
  --depth-3: 0 6px 18px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(var(--accent-rgb), 0.08), inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
  --depth-4: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(var(--accent-rgb), 0.12), inset 0 0.5px 0 rgba(255, 255, 255, 0.16), 0 0 40px rgba(var(--accent-rgb), 0.15);
  --depth-5: 0 24px 80px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(var(--accent-rgb), 0.20), inset 0 0.5px 0 rgba(255, 255, 255, 0.22), 0 0 80px rgba(var(--accent-rgb), 0.25);

  /* Spring recipes (tuned for different weight classes) */
  --spring-soft:  cubic-bezier(0.22, 1.20, 0.36, 1.00); /* UI panels, tooltips */
  --spring-snap:  cubic-bezier(0.34, 1.56, 0.64, 1.00); /* buttons, card flips */
  --spring-heavy: cubic-bezier(0.18, 1.10, 0.32, 1.00); /* tiles, weighted moves */

  /* Specular highlight — simulates a virtual light at top-left */
  --specular: linear-gradient(135deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.04) 35%, transparent 60%);

  /* ── Liquid Glass Recipe (premium polish pass) ──
     Composable layers — combine via background: var(--lg-tint), var(--lg-sheen);
     Every "polished" surface uses the same vocabulary. */
  --lg-tint-deep:    rgba(8, 20, 36, 0.55);   /* hex icon body */
  --lg-tint-card:    rgba(8, 18, 32, 0.55);   /* widget card body */
  --lg-tint-pill:    rgba(6, 14, 24, 0.50);   /* search, toast, dock */
  --lg-tint-modal:   rgba(10, 18, 32, 0.78);  /* modal cards */

  /* Top-light gradient — "wet glass" sheen */
  --lg-sheen:        linear-gradient(180deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.02) 22%, rgba(8, 18, 32, 0.32) 60%, rgba(2, 8, 16, 0.48) 100%);
  --lg-sheen-soft:   linear-gradient(165deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0.04) 30%, transparent 55%);
  --lg-spotlight:    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(var(--accent-rgb), 0.14), transparent 60%);

  /* Edge — top inner highlight + bottom inner shadow */
  --lg-edge:         inset 0 1.5px 0 rgba(255,255,255,0.30), inset 0 -1.5px 0 rgba(0,0,0,0.42);
  --lg-edge-soft:    inset 0 1px 0 rgba(255,255,255,0.18), inset 0 -1px 0 rgba(0,0,0,0.18);
  --lg-ring-accent:  inset 0 0 0 1px rgba(var(--accent-rgb), 0.22);
  --lg-ring-glow:    inset 0 0 24px rgba(var(--accent-rgb), 0.10);

  /* Cast halo — the under-glow under a floating surface */
  --lg-cast:         radial-gradient(ellipse, rgba(var(--accent-rgb), 0.45), rgba(var(--accent-rgb), 0.10) 45%, transparent 75%);
  --lg-cast-deep:    radial-gradient(ellipse, rgba(var(--accent-rgb), 0.60), rgba(var(--accent-rgb), 0.15) 45%, transparent 75%);

  /* Backdrop blur with saturation */
  --lg-blur:         blur(8px) saturate(1.4);
  --lg-blur-card:    blur(20px) saturate(1.3);
  --lg-blur-modal:   blur(32px) saturate(1.5);

  /* Specular sweep — animated translateX gradient */
  --lg-sweep:        linear-gradient(115deg, transparent 30%, rgba(255,255,255,0) 42%, rgba(255,255,255,0.45) 50%, rgba(255,255,255,0) 58%, transparent 70%);

  /* ── Motion Vocabulary (canonical names) ── */
  --motion-snappy:    120ms cubic-bezier(0.4, 0, 0.2, 1);
  --motion-cinematic: 380ms cubic-bezier(0.16, 0.84, 0.32, 1);
  --motion-spring:    550ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ── Legacy Aliases (v1.0 compat) ── */
  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-surface-1: rgba(255, 255, 255, 0.1);
  --glass-surface-2: rgba(20, 30, 40, 0.55);
  --glass-surface-3: rgba(10, 15, 25, 0.75);
  --glow-blue: #3ec8ff;
  --glow-teal: var(--accent);
  --glow-purple: #6b5cff;
  --text-primary: var(--text-bright);
  --text-muted: var(--text);
  --surface-text: var(--text-bright);
  --surface-muted: var(--text);
  --border-medium: var(--border);

  /* ── iOS Safe Areas ── */
  --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);

  /* ── Viewport fix (set by JS for iOS) ── */
  --vh: 1vh;
}

/* ============================================================
   Light Theme Overrides
   ============================================================ */

body.theme-light {
  /* ── Backgrounds ── */
  --bg:          #f5f5f7;
  --bg-card:     rgba(255, 255, 255, 0.85);
  --bg-glass:    rgba(0, 122, 255, 0.04);
  --bg-panel:    rgba(245, 245, 247, 0.95);
  --bg-surface:  #ffffff;
  --bg-elevated: #f0f0f2;

  /* ── Accent (Blue for light mode contrast — passes WCAG AA) ── */
  --accent:          #007AFF;
  --accent-rgb:      0, 122, 255;
  --accent-contrast: #ffffff;
  --accent-dim:      rgba(0, 122, 255, 0.15);
  --accent-glow:     rgba(0, 122, 255, 0.25);
  --accent-bright:   #0A84FF;
  --accent-bg:       rgba(0, 122, 255, 0.06);
  --accent-subtle:   rgba(0, 122, 255, 0.03);

  /* ── UI Text (dark text for light backgrounds) ── */
  --ui-text-rgb: 60, 60, 67;

  /* ── Text Hierarchy ── */
  --text-bright: #1d1d1f;
  --text:        #6e6e73;
  --text-dim:    #aeaeb2;

  /* ── Semantic Colors ── */
  --danger:  #ff3b30;
  --success: #34c759;
  --warning: #ff9500;
  --gold:    #e6a800;
  --gold-dim: rgba(230, 168, 0, 0.1);
  --info:    #007AFF;

  /* ── Borders ── */
  --border:       rgba(0, 0, 0, 0.08);
  --border-accent: rgba(0, 122, 255, 0.15);
  --border-light: rgba(0, 0, 0, 0.05);

  /* ── Shadows (lighter, less dramatic) ── */
  --glow-sm:   0 0 15px rgba(0, 122, 255, 0.08);
  --glow-md:   0 2px 12px rgba(0, 0, 0, 0.08);
  --glow-lg:   0 4px 24px rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);

  /* ── Glass ── */
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(0, 0, 0, 0.06);
  --glass-surface-1: rgba(255, 255, 255, 0.6);
  --glass-surface-2: rgba(240, 240, 242, 0.8);
  --glass-surface-3: rgba(245, 245, 247, 0.9);

  /* ── YancoVerse (light) ── */
  --yv-edge-glow:
    radial-gradient(ellipse at 50% 0%, rgba(var(--accent-rgb), 0.06), transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(var(--accent-rgb), 0.04), transparent 50%),
    radial-gradient(ellipse at 0% 50%, rgba(var(--accent-rgb), 0.03), transparent 40%),
    radial-gradient(ellipse at 100% 50%, rgba(var(--accent-rgb), 0.03), transparent 40%);
  --yv-glass: linear-gradient(165deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 30%, transparent 50%);
  --yv-platform: radial-gradient(ellipse, rgba(0, 0, 0, 0.06), transparent 70%);
  --yv-platform-hover: radial-gradient(ellipse, rgba(0, 0, 0, 0.1), transparent 70%);
  --inner-glow: inset 0 0.5px 0 rgba(255, 255, 255, 0.5);

  /* ── Aurora (muted in light mode — over light backgrounds) ── */
  --aurora-1: rgba(0, 122, 255, 0.10);
  --aurora-2: rgba(107,  92, 255, 0.06);
  --aurora-3: rgba(255, 255, 255, 0.00);
  --aurora-bg:
    radial-gradient(1200px 700px at 15% 20%, var(--aurora-1), transparent 60%),
    radial-gradient( 900px 600px at 85% 80%, var(--aurora-2), transparent 60%),
    radial-gradient( 600px 400px at 50% 50%, rgba(0, 122, 255, 0.03), transparent 70%);

  /* ── Particles (unused in light, but defined to avoid dark-mode bleed) ── */
  --particle-dim:    rgba(var(--accent-rgb), 0.20);
  --particle-bright: rgba(var(--accent-rgb), 0.60);

  /* ── Depth system (5 tiers, lighter shadows for light background) ── */
  --depth-1: 0 1px 2px rgba(0, 0, 0, 0.06), inset 0 0.5px 0 rgba(255, 255, 255, 0.50);
  --depth-2: 0 2px 6px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04), inset 0 0.5px 0 rgba(255, 255, 255, 0.60);
  --depth-3: 0 6px 18px rgba(0, 0, 0, 0.10), 0 0 0 1px rgba(var(--accent-rgb), 0.10), inset 0 0.5px 0 rgba(255, 255, 255, 0.70);
  --depth-4: 0 12px 40px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(var(--accent-rgb), 0.14), inset 0 0.5px 0 rgba(255, 255, 255, 0.80), 0 0 40px rgba(var(--accent-rgb), 0.10);
  --depth-5: 0 24px 80px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(var(--accent-rgb), 0.20), inset 0 0.5px 0 rgba(255, 255, 255, 0.90), 0 0 80px rgba(var(--accent-rgb), 0.18);

  /* ── Specular (lighter virtual highlight on light surfaces) ── */
  --specular: linear-gradient(135deg, rgba(255, 255, 255, 0.70) 0%, rgba(255, 255, 255, 0.20) 35%, transparent 60%);

  /* ── Liquid Glass — light mode (inverted highlight, warm cast) ── */
  --lg-tint-deep:    rgba(255, 255, 255, 0.62);
  --lg-tint-card:    rgba(255, 255, 255, 0.65);
  --lg-tint-pill:    rgba(255, 255, 255, 0.58);
  --lg-tint-modal:   rgba(255, 255, 255, 0.92);

  --lg-sheen:        linear-gradient(180deg, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0.15) 22%, rgba(0, 0, 0, 0.02) 60%, rgba(0, 0, 0, 0.04) 100%);
  --lg-sheen-soft:   linear-gradient(165deg, rgba(255,255,255,0.50) 0%, rgba(255,255,255,0.15) 30%, transparent 55%);
  --lg-spotlight:    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(var(--accent-rgb), 0.08), transparent 60%);

  --lg-edge:         inset 0 1.5px 0 rgba(255,255,255,0.85), inset 0 -1.5px 0 rgba(0,0,0,0.08);
  --lg-edge-soft:    inset 0 1px 0 rgba(255,255,255,0.60), inset 0 -1px 0 rgba(0,0,0,0.05);
  --lg-ring-accent:  inset 0 0 0 1px rgba(var(--accent-rgb), 0.20);
  --lg-ring-glow:    inset 0 0 24px rgba(var(--accent-rgb), 0.05);

  --lg-cast:         radial-gradient(ellipse, rgba(var(--accent-rgb), 0.18), rgba(var(--accent-rgb), 0.05) 45%, transparent 75%);
  --lg-cast-deep:    radial-gradient(ellipse, rgba(var(--accent-rgb), 0.28), rgba(var(--accent-rgb), 0.08) 45%, transparent 75%);

  --lg-sweep:        linear-gradient(115deg, transparent 30%, rgba(255,255,255,0) 42%, rgba(255,255,255,0.55) 50%, rgba(255,255,255,0) 58%, transparent 70%);

  /* ── Legacy aliases ── */
  --glow-blue: #007AFF;
  --glow-teal: var(--accent);
  --glow-purple: #5856d6;
  --text-primary: var(--text-bright);
  --text-muted: var(--text);
  --surface-text: var(--text-bright);
  --surface-muted: var(--text);
  --border-medium: var(--border);
}

/* Light mode scrollbar */
body.theme-light {
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}
body.theme-light ::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.15); }
body.theme-light ::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.25); }

/* Light mode focus */
body.theme-light *:focus-visible {
  outline-color: rgba(0, 122, 255, 0.5);
}

/* ── Scrollbar Styling ── */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--accent-rgb), 0.15) transparent;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(var(--accent-rgb), 0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(var(--accent-rgb), 0.3); }

/* ── Focus Accessibility ── */
*:focus-visible {
  outline: 2px solid rgba(var(--accent-rgb), 0.5);
  outline-offset: 2px;
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
