/* ═══════════════════════════════════════════════════════════════
   base.css — Digital Quora Design Tokens & Reset
   ═══════════════════════════════════════════════════════════════ */

/* ── Fonts ──────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ── Design Tokens ──────────────────────────────────────────── */
:root {
  /* Typography */
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-display: 'Space Grotesk', 'Plus Jakarta Sans', system-ui, sans-serif;

  /* Fluid Type Scale */
  --text-xs:   clamp(0.7rem, 0.65rem + 0.25vw, 0.75rem);
  --text-sm:   clamp(0.8rem, 0.75rem + 0.25vw, 0.875rem);
  --text-base: clamp(0.938rem, 0.875rem + 0.3vw, 1rem);
  --text-lg:   clamp(1.065rem, 0.98rem + 0.4vw, 1.125rem);
  --text-xl:   clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
  --text-2xl:  clamp(1.5rem, 1.25rem + 1.25vw, 2rem);
  --text-3xl:  clamp(1.875rem, 1.5rem + 1.875vw, 2.5rem);
  --text-4xl:  clamp(2.25rem, 1.75rem + 2.5vw, 3.25rem);
  --text-5xl:  clamp(2.75rem, 2rem + 3.75vw, 4rem);

  /* Spacing (4px system) */
  --sp-0: 0;
  --sp-1: 0.25rem;   /* 4px */
  --sp-2: 0.5rem;    /* 8px */
  --sp-3: 0.75rem;   /* 12px */
  --sp-4: 1rem;      /* 16px */
  --sp-5: 1.25rem;   /* 20px */
  --sp-6: 1.5rem;    /* 24px */
  --sp-8: 2rem;      /* 32px */
  --sp-10: 2.5rem;   /* 40px */
  --sp-12: 3rem;     /* 48px */
  --sp-16: 4rem;     /* 64px */
  --sp-20: 5rem;     /* 80px */
  --sp-24: 6rem;     /* 96px */
  --sp-32: 8rem;     /* 128px */

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --max-w: 1200px;
  --max-w-narrow: 720px;
  --max-w-wide: 1400px;

  /* ── Light Mode (Default) ─────────────────────────────────── */
  --color-primary: #f59e0b;
  --color-primary-dark: #d97706;
  --color-primary-light: #fbbf24;
  --color-primary-pale: rgba(245, 158, 11, 0.1);
  --color-secondary: #0f172a;
  --color-accent: #10b981;
  --color-accent-pale: rgba(16, 185, 129, 0.1);
  --color-danger: #ef4444;
  --color-danger-pale: rgba(239, 68, 68, 0.08);

  --color-bg: #fffbeb;
  --color-surface: #ffffff;
  --color-surface-2: #fef3c7;
  --color-surface-3: #f5f0e1;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-faint: #94a3b8;
  --color-border: rgba(15, 23, 42, 0.1);
  --color-border-strong: rgba(15, 23, 42, 0.2);

  --color-nav-bg: rgba(255, 251, 235, 0.85);
  --color-card-bg: #ffffff;
  --color-input-bg: #ffffff;

  color-scheme: light;
}

/* ── Dark Mode ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-surface-2: #334155;
  --color-surface-3: #475569;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-text-faint: #64748b;
  --color-border: rgba(241, 245, 249, 0.1);
  --color-border-strong: rgba(241, 245, 249, 0.2);
  --color-primary-pale: rgba(245, 158, 11, 0.15);
  --color-accent-pale: rgba(16, 185, 129, 0.15);
  --color-danger-pale: rgba(239, 68, 68, 0.12);

  --color-nav-bg: rgba(15, 23, 42, 0.9);
  --color-card-bg: #1e293b;
  --color-input-bg: #1e293b;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.15);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.25), 0 2px 4px -2px rgba(0,0,0,0.15);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3), 0 4px 6px -4px rgba(0,0,0,0.15);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.35), 0 8px 10px -6px rgba(0,0,0,0.2);

  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  overflow-x: hidden;
  min-height: 100vh;
  transition: background var(--transition-slow), color var(--transition-slow);
}

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

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

button {
  cursor: pointer;
  font: inherit;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font: inherit;
  color: inherit;
  background: var(--color-input-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  transition: border-color var(--transition-interactive),
              box-shadow var(--transition-interactive);
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-pale);
}

ul, ol { list-style: none; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  line-height: 1.2;
  font-weight: 700;
  color: var(--color-text);
}

::selection {
  background: var(--color-primary);
  color: var(--color-secondary);
}

/* ── Skip to content ────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-4);
  background: var(--color-primary);
  color: var(--color-secondary);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-md);
  z-index: 9999;
  font-weight: 600;
}
.skip-link:focus {
  top: var(--sp-4);
}

/* ── Scroll Animation Foundation ────────────────────────────── */
.reveal {
  opacity: 1;
}

@supports (animation-timeline: scroll()) {
  .reveal {
    opacity: 0;
    animation: revealFade linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 100%;
  }
  .reveal-clip {
    clip-path: inset(100% 0 0 0);
    animation: revealClip linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 100%;
  }
}

@keyframes revealFade {
  to { opacity: 1; }
}
@keyframes revealClip {
  to { clip-path: inset(0 0 0 0); }
}

/* JS fallback for browsers without scroll-timeline */
.reveal.is-visible {
  opacity: 1 !important;
  clip-path: inset(0 0 0 0) !important;
  transition: opacity 0.6s var(--ease-out), clip-path 0.6s var(--ease-out);
}

/* ── Reduced Motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  .reveal, .reveal-clip {
    opacity: 1 !important;
    clip-path: none !important;
  }
}

/* ── Utility ────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--sp-5);
}

.container-wide {
  max-width: var(--max-w-wide);
}

.container-narrow {
  max-width: var(--max-w-narrow);
}

.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;
}
