/**
 * Wooble Scalable Typography System
 * 
 * Uses CSS custom properties and fluid typography for:
 * - Consistent scaling across viewports
 * - Accessibility (rem units respect user font-size preference)
 * - Easy theming and maintenance
 * 
 * Base: 16px (1rem) - aligns with DESIGN_SYSTEM.md
 */

:root {
  /* Base scale - 16px default, respects user preference */
  --font-size-base: 1rem;
  
  /* Typography scale (rem-based for scalability) */
  --font-size-xs: 0.75rem;    /* 12px - Caption, labels, metadata */
  --font-size-sm: 0.875rem;   /* 14px - Small, secondary content */
  --font-size-base: 1rem;     /* 16px - Body, main content */
  --font-size-lg: 1.125rem;   /* 18px - Lead text, large body */
  --font-size-xl: 1.25rem;    /* 20px - H4, card titles */
  --font-size-2xl: 1.5rem;   /* 24px - H3, subsection headers */
  --font-size-3xl: 2rem;      /* 32px - H2, section headers */
  --font-size-4xl: 2.5rem;   /* 40px - H1, hero (min) */
  --font-size-5xl: 3rem;      /* 48px - Display */
  --font-size-6xl: 3.75rem;   /* 60px - Hero max */
  
  /* Fluid typography - scales with viewport (clamp(min, preferred, max)) */
  --font-fluid-h1: clamp(2.5rem, 5vw + 1.5rem, 3.75rem);
  --font-fluid-h2: clamp(2rem, 4vw + 1rem, 3rem);
  --font-fluid-h3: clamp(1.5rem, 3vw + 0.75rem, 2rem);
  --font-fluid-h4: clamp(1.25rem, 2vw + 0.5rem, 1.5rem);
  --font-fluid-body: clamp(0.9375rem, 0.5vw + 0.875rem, 1rem);
  --font-fluid-lead: clamp(1rem, 1vw + 0.5rem, 1.25rem);
  
  /* Line heights */
  --leading-none: 1;
  --leading-tight: 1.2;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.6;
  --leading-loose: 1.8;
  
  /* Letter spacing */
  --tracking-tighter: -0.02em;
  --tracking-tight: -0.015em;
  --tracking-normal: -0.01em;
  --tracking-wide: 0.01em;
  --tracking-wider: 0.05em;
  
  /* Font weights (Manrope scale) */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
}

/* Root html - base for rem scaling */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Respect user's reduced motion / font size preferences */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Optional: Scale base for larger viewports (subtle) */
@media (min-width: 1200px) {
  html {
    font-size: 17px;
  }
}

@media (min-width: 1600px) {
  html {
    font-size: 18px;
  }
}

/* Typography utility classes (use .wooble- prefix to avoid Tailwind conflicts) */
.wooble-text-caption {
  font-size: var(--font-size-xs);
  line-height: var(--leading-normal);
  font-weight: var(--font-weight-normal);
}

.wooble-text-small {
  font-size: var(--font-size-sm);
  line-height: var(--leading-normal);
  font-weight: var(--font-weight-normal);
}

.wooble-text-body {
  font-size: var(--font-size-base);
  line-height: var(--leading-relaxed);
  font-weight: var(--font-weight-normal);
}

.wooble-text-lead {
  font-size: var(--font-fluid-lead);
  line-height: var(--leading-relaxed);
  font-weight: var(--font-weight-normal);
}

/* Fluid headings - use for scalable hero/section text */
.wooble-text-fluid-h1,
h1.wooble-text-fluid {
  font-size: var(--font-fluid-h1);
  line-height: var(--leading-tight);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--tracking-tighter);
}

.wooble-text-fluid-h2,
h2.wooble-text-fluid {
  font-size: var(--font-fluid-h2);
  line-height: var(--leading-snug);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--tracking-tight);
}

.wooble-text-fluid-h3,
h3.wooble-text-fluid {
  font-size: var(--font-fluid-h3);
  line-height: var(--leading-snug);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--tracking-normal);
}

.wooble-text-fluid-h4,
h4.wooble-text-fluid {
  font-size: var(--font-fluid-h4);
  line-height: var(--leading-snug);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--tracking-normal);
}

/* Fixed headings - for consistent sizing */
.wooble-text-h1 { font-size: var(--font-size-4xl); line-height: var(--leading-tight); font-weight: var(--font-weight-bold); }
.wooble-text-h2 { font-size: var(--font-size-3xl); line-height: var(--leading-snug); font-weight: var(--font-weight-semibold); }
.wooble-text-h3 { font-size: var(--font-size-2xl); line-height: var(--leading-snug); font-weight: var(--font-weight-semibold); }
.wooble-text-h4 { font-size: var(--font-size-xl); line-height: var(--leading-snug); font-weight: var(--font-weight-medium); }
