/**
 * impeccable.style foundation — buggazi.com
 * Shared design tokens for ALL pages (landing, login, dashboard, roadmap, sales, invite, legal, docs)
 * Dark mode default, light mode via body.landing-light
 *
 * 7 domains: Typography, Color, Spatial, Motion, Interaction, Responsive, Voice
 * Bans: bounce/elastic, layout animations, glassmorphism, gradient-text, em-dashes,
 *       Inter/Playfair/Space Grotesk/DM Sans (reflex-reject fonts), pure #000/#fff
 */

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

/* ── Design Tokens (Dark Mode Default) ────────────────────────────── */
:root {
  /* Typography — Geist Sans + JetBrains Mono for code */
  --font-body: 'Geist Sans', 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', monospace;

  /* Type Scale: 1.333x Perfect Fourth (clamp for fluid sizing) */
  --text-xs: 0.6875rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: clamp(1.125rem, 1.5vw + 0.5rem, 1.333rem);
  --text-xl: clamp(1.333rem, 2vw + 0.5rem, 1.777rem);
  --text-2xl: clamp(1.777rem, 3vw + 0.5rem, 2.369rem);
  --text-3xl: clamp(2rem, 3.5vw + 0.5rem, 3.157rem);
  --text-4xl: clamp(2.25rem, 5vw + 0.5rem, 4.209rem);

  /* Colors — tinted neutrals (chroma toward orange brand hue, never pure black/white) */
  --primary: #c2410c;
  --primary-dark: #9a3412;
  --primary-light: #f97316;
  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-subtle: rgba(249, 115, 22, 0.12);

  --dark: #0c0a08;
  --dark-light: #161410;
  --dark-medium: #24201a;
  --gray-900: #131110;
  --gray-800: #1e1c1a;
  --gray-700: #2d2a26;
  --gray-600: #4a4640;
  --gray-500: #6b6660;
  --gray-400: #9c9690;
  --gray-300: #d1cdc8;
  --gray-200: #e5e2dd;
  --gray-100: #f3f1ee;
  --gray-50: #f9f8f6;
  --white: #faf9f7;

  --success: #22c55e;
  --error: #ef4444;
  --info: #3b82f6;
  --warning: #eab308;

  /* Semantic aliases (used by pages that define their own var names) */
  --bg-primary: var(--dark);
  --bg-secondary: var(--gray-900);
  --bg-tertiary: var(--gray-800);
  --text-primary: var(--white);
  --text-secondary: var(--gray-400);
  --text-muted: var(--gray-500);
  --border: var(--gray-700);
  --border-subtle: var(--gray-800);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #c2410c 0%, #ea580c 100%);
  --gradient-dark: linear-gradient(180deg, #0c0a08 0%, #161410 100%);

  /* Borders & Radius */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);

  /* Motion — ease-out-quart, never bounce/elastic */
  --ease-default: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-enter: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-leave: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-toggle: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-micro: 150ms;
  --duration-state: 250ms;
  --duration-layout: 400ms;
  --duration-entrance: 600ms;

  /* Spatial: 4pt grid */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --space-24: 96px;
}

/* ── Light Mode ───────────────────────────────────────────────────── */
body.landing-light {
  --dark: #faf9f7;
  --dark-light: #f0eee9;
  --dark-medium: #e0ddd6;
  --gray-900: #f5f3f0;
  --gray-800: #eae7e2;
  --gray-700: #d8d4cd;
  --gray-600: #8a8580;
  --gray-500: #6a6560;
  --gray-400: #4a4540;
  --gray-300: #3a3530;
  --gray-200: #2a2520;
  --gray-100: #1a1510;
  --white: #0c0a08;
  --gradient-dark: linear-gradient(180deg, #faf9f7 0%, #f0eee9 100%);

  --bg-primary: #faf9f7;
  --bg-secondary: #f5f3f0;
  --bg-tertiary: #eae7e2;
  --text-primary: #0c0a08;
  --text-secondary: #4a4540;
  --text-muted: #6a6560;
  --border: #d8d4cd;
  --border-subtle: #eae7e2;

  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

/* Light mode: preserve button text on colored backgrounds */
body.landing-light .btn-primary,
body.landing-light .btn-gradient,
body.landing-light [class*="badge-accent"] {
  color: #faf9f7 !important;
}

/* ── Base Typography ──────────────────────────────────────────────── */
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-body);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

/* Body text measure: max 65ch */
p, li, blockquote { max-width: 65ch; }

/* Dark bg compensation (applied globally since dark mode is default) */
body:not(.landing-light) {
  letter-spacing: 0.01em;
}

body:not(.landing-light) p,
body:not(.landing-light) li,
body:not(.landing-light) span {
  line-height: 1.6;
}

/* ── Focus: :focus-visible ────────────────────────────────────────── */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Touch Targets: min 44px ──────────────────────────────────────── */
a, button, [role="button"] { min-height: 44px; }

/* Button active state */
button:active, [role="button"]:active {
  transform: scale(0.97);
  transition-duration: var(--duration-micro);
}

button:disabled, button[aria-busy="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Entrance Animations ──────────────────────────────────────────── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Stagger support: use style="--i: 0" on elements */
.imp-stagger {
  opacity: 0;
  animation: fadeSlideUp var(--duration-entrance) var(--ease-enter) forwards;
  animation-delay: calc(var(--i, 0) * 50ms);
}

/* ── Mode Toggle Button ───────────────────────────────────────────── */
.mode-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: color var(--duration-state) var(--ease-default),
              border-color var(--duration-state) var(--ease-default);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mode-toggle:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (pointer: coarse) {
  a, button, [role="button"] { min-height: 48px; }
}

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