/* ═══════════════════════════════════════════════════════════════
   LynBro Design System v2.0
   Tokens, typography, colors, glassmorphism, utilities
   ═══════════════════════════════════════════════════════════════ */

/* ─── Fonts ─────────────────────────────────────────────────── */
:root {
  --font-body: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

/* ─── Spacing scale ─────────────────────────────────────────── */
:root {
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.5rem;    /* 24px */
  --space-6: 2rem;      /* 32px */
  --space-7: 3rem;      /* 48px */
  --space-8: 4rem;      /* 64px */
  --space-9: 5rem;      /* 80px */
  --space-10: 6rem;     /* 96px */
  --space-11: 8rem;     /* 128px */
  --space-12: 12rem;    /* 192px */
}

/* ─── Layout ────────────────────────────────────────────────── */
:root {
  --max-width: 1240px;
  --max-width-narrow: 780px;
  --max-width-wide: 1440px;
  --header-height: 72px;
}

/* ─── Border radius ─────────────────────────────────────────── */
:root {
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;
}

/* ─── Transitions ───────────────────────────────────────────── */
:root {
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 150ms var(--ease-smooth);
  --transition-mid: 300ms var(--ease-out);
  --transition-slow: 600ms var(--ease-out);
  --transition-extra: 1200ms var(--ease-out);
}

/* ─── Z-index scale ─────────────────────────────────────────── */
:root {
  --z-bg: -1;
  --z-base: 1;
  --z-dropdown: 20;
  --z-sticky: 40;
  --z-header: 60;
  --z-overlay: 70;
  --z-modal: 80;
  --z-cookie: 85;
  --z-chat: 90;
  --z-top: 96;
  --z-max: 9999;
}

/* ─── Light theme (default) ─────────────────────────────────── */
:root,
:root[data-theme='light'] {
  --bg-main: #f0f4ff;
  --bg-subtle: #e8eeff;
  --surface-main: rgba(255, 255, 255, 0.80);
  --surface-elevated: rgba(232, 239, 255, 0.80);
  --surface-glass: rgba(255, 255, 255, 0.55);
  --border-soft: rgba(201, 213, 255, 0.65);
  --border-strong: rgba(150, 175, 235, 0.55);

  --text-primary: #0b1437;
  --text-secondary: #2a3a6b;
  --text-muted: #445d96;
  --text-inverse: #f0f4ff;

  --accent: #ffd600;
  --accent-soft: rgba(255, 214, 0, 0.15);
  --primary: #1a56ff;
  --primary-soft: rgba(26, 86, 255, 0.12);
  --cyan: #00d4ff;
  --cyan-soft: rgba(0, 212, 255, 0.12);

  --gradient-primary: linear-gradient(135deg, #1a56ff, #00d4ff);
  --gradient-accent: linear-gradient(135deg, #ffd600, #ffaa00);
  --gradient-mesh: radial-gradient(circle at 20% 20%, rgba(26, 86, 255, 0.08) 0%, transparent 50%),
                    radial-gradient(circle at 80% 30%, rgba(0, 212, 255, 0.06) 0%, transparent 50%),
                    radial-gradient(circle at 50% 80%, rgba(255, 214, 0, 0.05) 0%, transparent 50%);

  --shadow-soft: 0 4px 24px rgba(10, 25, 61, 0.08);
  --shadow-md: 0 8px 32px rgba(10, 25, 61, 0.12);
  --shadow-lg: 0 16px 48px rgba(10, 25, 61, 0.16);
  --shadow-glow-blue: 0 0 40px rgba(26, 86, 255, 0.15);
  --shadow-glow-cyan: 0 0 40px rgba(0, 212, 255, 0.12);
  --shadow-glow-accent: 0 0 40px rgba(255, 214, 0, 0.12);

  --glass-bg: rgba(255, 255, 255, 0.60);
  --glass-border: rgba(201, 213, 255, 0.40);
  --glass-blur: 20px;
  --glass-saturate: 1.8;

  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;

  --code-bg: rgba(15, 23, 42, 0.06);
  --noise-opacity: 0.025;
}

/* ─── Dark theme ────────────────────────────────────────────── */
:root[data-theme='dark'] {
  --bg-main: #060c1f;
  --bg-subtle: #0a1232;
  --surface-main: rgba(13, 27, 62, 0.80);
  --surface-elevated: rgba(17, 33, 84, 0.80);
  --surface-glass: rgba(13, 27, 62, 0.55);
  --border-soft: rgba(36, 64, 126, 0.55);
  --border-strong: rgba(50, 85, 160, 0.55);

  --text-primary: #e8f0ff;
  --text-secondary: #b8c9ee;
  --text-muted: #7b9acc;
  --text-inverse: #0b1437;

  --accent: #ffd600;
  --accent-soft: rgba(255, 214, 0, 0.12);
  --primary: #3b7aff;
  --primary-soft: rgba(59, 122, 255, 0.15);
  --cyan: #00d4ff;
  --cyan-soft: rgba(0, 212, 255, 0.10);

  --gradient-primary: linear-gradient(135deg, #2563eb, #06b6d4);
  --gradient-accent: linear-gradient(135deg, #ffd600, #ffaa00);
  --gradient-mesh: radial-gradient(circle at 15% 15%, rgba(26, 86, 255, 0.12) 0%, transparent 50%),
                    radial-gradient(circle at 85% 25%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
                    radial-gradient(circle at 50% 90%, rgba(255, 214, 0, 0.06) 0%, transparent 50%);

  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
  --shadow-glow-blue: 0 0 60px rgba(26, 86, 255, 0.20);
  --shadow-glow-cyan: 0 0 60px rgba(0, 212, 255, 0.15);
  --shadow-glow-accent: 0 0 60px rgba(255, 214, 0, 0.15);

  --glass-bg: rgba(13, 27, 62, 0.60);
  --glass-border: rgba(36, 64, 126, 0.35);
  --glass-blur: 24px;
  --glass-saturate: 1.6;

  --success: #34d399;
  --warning: #fbbf24;
  --error: #f87171;
  --info: #60a5fa;

  --code-bg: rgba(255, 255, 255, 0.06);
  --noise-opacity: 0.03;
}

/* ─── Global reset ──────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-main);
  background-image: var(--gradient-mesh);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ─── Typography ────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

h1 { font-size: clamp(2.2rem, 5vw, 4.5rem); }
h2 { font-size: clamp(1.6rem, 3.5vw, 3rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.75rem); }
h4 { font-size: clamp(1rem, 1.5vw, 1.35rem); }

p {
  color: var(--text-secondary);
  max-width: 75ch;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

strong, b {
  font-weight: 700;
}

img, video, svg {
  display: block;
  max-width: 100%;
}

/* ─── Layout utilities ──────────────────────────────────────── */
.container {
  width: min(var(--max-width), calc(100% - 2rem));
  margin-inline: auto;
}

.container-narrow {
  width: min(var(--max-width-narrow), calc(100% - 2rem));
  margin-inline: auto;
}

.container-wide {
  width: min(var(--max-width-wide), calc(100% - 2rem));
  margin-inline: auto;
}

/* ─── Glassmorphism ─────────────────────────────────────────── */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,.05);
  transition: transform var(--transition-mid), box-shadow var(--transition-mid), border-color var(--transition-fast);
}

.glass-card:hover {
  transform: translateY(-4px);
  border-color: rgba(26, 86, 255, 0.5);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(26, 86, 255, 0.2), 0 0 30px rgba(26, 86, 255, 0.1);
}

/* ─── Gradient border effect ────────────────────────────────── */
.gradient-border {
  position: relative;
  background: var(--surface-main);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.gradient-border::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: var(--gradient-primary);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ─── Neon glow text ────────────────────────────────────────── */
.neon-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glow-text {
  text-shadow: 0 0 20px rgba(26, 86, 255, 0.4), 0 0 40px rgba(0, 212, 255, 0.2);
}

/* ─── Buttons ───────────────────────────────────────────────── */
.primary-btn,
.ghost-btn,
.icon-btn {
  border: 0;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-mid);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.primary-btn {
  background: var(--gradient-primary);
  color: #fff;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  box-shadow: 0 4px 16px rgba(26, 86, 255, 0.3);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(26, 86, 255, 0.4);
}

.primary-btn-lg {
  padding: 1rem 2rem;
  font-size: 1.05rem;
}

.ghost-btn {
  background: var(--surface-elevated);
  color: var(--text-primary);
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  border: 1px solid var(--border-soft);
}

.ghost-btn:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  background: var(--surface-main);
}

.icon-btn {
  width: 40px;
  height: 40px;
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-soft);
}

.icon-btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

/* ─── Accent highlight ──────────────────────────────────────── */
.accent { color: var(--accent); }
.text-primary-color { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* ─── Section spacing ───────────────────────────────────────── */
.section {
  position: relative;
  padding: clamp(4rem, 8vw, 7rem) 0;
}

.section > .container {
  position: relative;
  z-index: var(--z-base);
}

.section-header {
  margin-bottom: clamp(2rem, 4vw, 3.5rem);
}

.section-header h2 {
  margin-bottom: 0.75rem;
}

.section-header p {
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: var(--text-muted);
}

/* ─── Tags / Pills ──────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid transparent;
}

.tag-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.price-pill {
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.8rem;
}

/* ─── Skip link ─────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: var(--z-max);
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #0b1226;
  border-radius: var(--radius-sm);
}

/* ─── Three.js canvas ───────────────────────────────────────── */
.three-bg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: var(--z-bg);
  pointer-events: none;
  opacity: 0.4;
  transition: opacity 1s ease;
}

/* ─── Visibility ────────────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ─── Selection ─────────────────────────────────────────────── */
::selection {
  background: rgba(26, 86, 255, 0.25);
  color: var(--text-primary);
}

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-soft); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

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

/* ─── Safe area for notched devices ─────────────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}
