/* ============================================================================
   TYPOGRAPHIC SCALE SYSTEM
   Consistent font sizing across all breakpoints
   ============================================================================ */

:root {
  /* ── FONT SIZES (MOBILE FIRST - Base) ── */
  --font-xs: 12px;
  --font-sm: 13px;
  --font-base: 14px;
  --font-lg: 16px;
  --font-xl: 18px;
  --font-2xl: 20px;
  --font-3xl: 24px;
  --font-4xl: 28px;
  --font-5xl: 32px;
  --font-6xl: 40px;
  
  /* ── LINE HEIGHTS ── */
  --line-tight: 1.2;
  --line-snug: 1.25;
  --line-normal: 1.5;
  --line-relaxed: 1.6;
  --line-loose: 1.75;
  
  /* ── LETTER SPACING ── */
  --tracking-tighter: -0.05em;
  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.05em;
  --tracking-wider: 0.1em;
  
  /* ── FONT WEIGHTS ── */
  --weight-light: 300;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-extrabold: 800;
}

/* ============================================================================
   MOBILE (≤480px) - Extra Small Phones
   ============================================================================ */
@media (max-width: 480px) {
  :root {
    --font-xs: 11px;
    --font-sm: 12px;
    --font-base: 13px;
    --font-lg: 14px;
    --font-xl: 16px;
    --font-2xl: 18px;
    --font-3xl: 22px;
    --font-4xl: 26px;
    --font-5xl: 30px;
    --font-6xl: 36px;
  }
  
  /* Optimize line heights for mobile readability */
  body {
    font-size: var(--font-base);
    line-height: var(--line-relaxed);
    letter-spacing: var(--tracking-normal);
  }
  
  /* Headings with proper hierarchy */
  h1, .h1 {
    font-size: var(--font-4xl);
    line-height: var(--line-tight);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-tight);
    margin: 16px 0 8px 0;
  }
  
  h2, .h2 {
    font-size: var(--font-3xl);
    line-height: var(--line-snug);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-tight);
    margin: 14px 0 6px 0;
  }
  
  h3, .h3 {
    font-size: var(--font-2xl);
    line-height: var(--line-snug);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-normal);
    margin: 12px 0 4px 0;
  }
  
  h4, .h4 {
    font-size: var(--font-xl);
    line-height: var(--line-normal);
    font-weight: var(--weight-semibold);
    margin: 10px 0 4px 0;
  }
  
  h5, .h5 {
    font-size: var(--font-lg);
    line-height: var(--line-normal);
    font-weight: var(--weight-semibold);
    margin: 8px 0 2px 0;
  }
  
  h6, .h6 {
    font-size: var(--font-base);
    line-height: var(--line-normal);
    font-weight: var(--weight-semibold);
    margin: 6px 0 2px 0;
  }
  
  /* Paragraph spacing */
  p {
    margin: 8px 0;
    line-height: var(--line-relaxed);
  }
  
  /* Small text */
  small, .small {
    font-size: var(--font-sm);
    line-height: var(--line-normal);
  }
  
  /* Links */
  a {
    font-size: inherit;
    font-weight: var(--weight-medium);
  }
  
  /* Form elements */
  input, textarea, select {
    font-size: var(--font-base);
    line-height: var(--line-normal);
  }
  
  /* Labels */
  label {
    font-size: var(--font-sm);
    font-weight: var(--weight-medium);
  }
  
  /* Navigation */
  nav {
    font-size: var(--font-base);
  }
  
  nav a, .nav-link {
    font-size: var(--font-base);
    font-weight: var(--weight-medium);
  }
  
  /* Buttons */
  button, .btn, [role="button"] {
    font-size: var(--font-base);
    line-height: var(--line-normal);
    font-weight: var(--weight-medium);
  }
  
  /* Cards and containers */
  .card, .card-title {
    font-size: var(--font-base);
  }
  
  .card-subtitle {
    font-size: var(--font-sm);
  }
  
  /* Utility classes */
  .text-xs { font-size: var(--font-xs); }
  .text-sm { font-size: var(--font-sm); }
  .text-base { font-size: var(--font-base); }
  .text-lg { font-size: var(--font-lg); }
  .text-xl { font-size: var(--font-xl); }
  .text-2xl { font-size: var(--font-2xl); }
  .text-3xl { font-size: var(--font-3xl); }
  .text-4xl { font-size: var(--font-4xl); }
}

/* ============================================================================
   MOBILE+ (481-768px) - Standard Mobile & Small Tablets
   ============================================================================ */
@media (min-width: 481px) and (max-width: 768px) {
  :root {
    --font-xs: 12px;
    --font-sm: 13px;
    --font-base: 14px;
    --font-lg: 15px;
    --font-xl: 18px;
    --font-2xl: 20px;
    --font-3xl: 24px;
    --font-4xl: 28px;
    --font-5xl: 32px;
    --font-6xl: 40px;
  }
  
  body {
    font-size: var(--font-base);
    line-height: var(--line-relaxed);
  }
  
  h1, .h1 {
    font-size: var(--font-4xl);
    line-height: var(--line-snug);
    font-weight: var(--weight-bold);
    margin: 16px 0 8px 0;
  }
  
  h2, .h2 {
    font-size: var(--font-3xl);
    line-height: var(--line-snug);
    font-weight: var(--weight-semibold);
    margin: 14px 0 8px 0;
  }
  
  h3, .h3 {
    font-size: var(--font-2xl);
    line-height: var(--line-snug);
    font-weight: var(--weight-semibold);
    margin: 12px 0 6px 0;
  }
  
  h4, .h4 {
    font-size: var(--font-xl);
    line-height: var(--line-normal);
    font-weight: var(--weight-semibold);
    margin: 10px 0 4px 0;
  }
  
  p {
    margin: 10px 0;
    line-height: var(--line-relaxed);
  }
  
  small, .small {
    font-size: var(--font-sm);
  }
}

/* ============================================================================
   TABLET (769-1024px) - Large Tablets
   ============================================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --font-xs: 12px;
    --font-sm: 13px;
    --font-base: 15px;
    --font-lg: 16px;
    --font-xl: 18px;
    --font-2xl: 22px;
    --font-3xl: 26px;
    --font-4xl: 32px;
    --font-5xl: 36px;
    --font-6xl: 44px;
  }
  
  body {
    font-size: var(--font-base);
    line-height: var(--line-relaxed);
  }
  
  h1, .h1 {
    font-size: var(--font-4xl);
    line-height: var(--line-snug);
    font-weight: var(--weight-bold);
    margin: 20px 0 10px 0;
  }
  
  h2, .h2 {
    font-size: var(--font-3xl);
    line-height: var(--line-snug);
    font-weight: var(--weight-semibold);
    margin: 16px 0 8px 0;
  }
  
  h3, .h3 {
    font-size: var(--font-2xl);
    line-height: var(--line-snug);
    font-weight: var(--weight-semibold);
    margin: 14px 0 7px 0;
  }
  
  p {
    margin: 12px 0;
    line-height: var(--line-relaxed);
  }
}

/* ============================================================================
   DESKTOP (≥1025px) - Full Desktop Experience
   ============================================================================ */
@media (min-width: 1025px) {
  :root {
    --font-xs: 12px;
    --font-sm: 14px;
    --font-base: 16px;
    --font-lg: 18px;
    --font-xl: 20px;
    --font-2xl: 24px;
    --font-3xl: 30px;
    --font-4xl: 36px;
    --font-5xl: 42px;
    --font-6xl: 48px;
  }
  
  body {
    font-size: var(--font-base);
    line-height: var(--line-relaxed);
  }
  
  h1, .h1 {
    font-size: var(--font-4xl);
    line-height: var(--line-snug);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-tight);
    margin: 24px 0 12px 0;
  }
  
  h2, .h2 {
    font-size: var(--font-3xl);
    line-height: var(--line-snug);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-tight);
    margin: 20px 0 10px 0;
  }
  
  h3, .h3 {
    font-size: var(--font-2xl);
    line-height: var(--line-snug);
    font-weight: var(--weight-semibold);
    margin: 16px 0 8px 0;
  }
  
  h4, .h4 {
    font-size: var(--font-xl);
    line-height: var(--line-normal);
    font-weight: var(--weight-semibold);
    margin: 12px 0 6px 0;
  }
  
  p {
    margin: 14px 0;
    line-height: var(--line-relaxed);
  }
  
  small, .small {
    font-size: var(--font-sm);
  }
  
  /* Desktop-specific optimizations */
  input, textarea, select {
    font-size: var(--font-base);
  }
}

/* ============================================================================
   UTILITY FONT SIZE CLASSES (All Breakpoints)
   ============================================================================ */

.text-xs { font-size: var(--font-xs); }
.text-sm { font-size: var(--font-sm); }
.text-base { font-size: var(--font-base); }
.text-lg { font-size: var(--font-lg); }
.text-xl { font-size: var(--font-xl); }
.text-2xl { font-size: var(--font-2xl); }
.text-3xl { font-size: var(--font-3xl); }
.text-4xl { font-size: var(--font-4xl); }
.text-5xl { font-size: var(--font-5xl); }
.text-6xl { font-size: var(--font-6xl); }

/* Line height utilities */
.leading-tight { line-height: var(--line-tight); }
.leading-snug { line-height: var(--line-snug); }
.leading-normal { line-height: var(--line-normal); }
.leading-relaxed { line-height: var(--line-relaxed); }
.leading-loose { line-height: var(--line-loose); }

/* Font weight utilities */
.font-light { font-weight: var(--weight-light); }
.font-normal { font-weight: var(--weight-normal); }
.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold { font-weight: var(--weight-bold); }
.font-extrabold { font-weight: var(--weight-extrabold); }

/* Letter spacing utilities */
.tracking-tighter { letter-spacing: var(--tracking-tighter); }
.tracking-tight { letter-spacing: var(--tracking-tight); }
.tracking-normal { letter-spacing: var(--tracking-normal); }
.tracking-wide { letter-spacing: var(--tracking-wide); }
.tracking-wider { letter-spacing: var(--tracking-wider); }

/* ============================================================================
   RESPONSIVE TEXT ALIGNMENT
   ============================================================================ */

@media (max-width: 768px) {
  .text-left-mobile { text-align: left; }
  .text-center-mobile { text-align: center; }
  .text-right-mobile { text-align: right; }
}

@media (min-width: 1025px) {
  .text-left-desktop { text-align: left; }
  .text-center-desktop { text-align: center; }
  .text-right-desktop { text-align: right; }
}

/* ============================================================================
   TRUNCATION & TEXT OVERFLOW
   ============================================================================ */

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================================
   TYPOGRAPHY RESETS & CONSISTENCY
   ============================================================================ */

/* Ensure form inputs inherit typography */
input, textarea, select, button, .btn {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

/* Code blocks */
code, pre {
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.85em;
  line-height: 1.5;
}

/* Links don't break typography */
a {
  color: inherit;
  text-decoration: inherit;
}

/* Lists */
ul, ol {
  margin: 12px 0;
  padding-left: 20px;
  line-height: var(--line-relaxed);
}

li {
  margin: 4px 0;
}

/* ============================================================================
   DARK MODE TYPOGRAPHY (if applicable)
   ============================================================================ */

.dark-mode {
  /* Typography remains consistent across color modes */
  /* Only colors change, not font sizes or weights */
}

/* ============================================================================
   PRINT TYPOGRAPHY
   ============================================================================ */

@media print {
  body {
    font-size: 12pt;
    line-height: 1.5;
  }
  
  h1 { font-size: 24pt; }
  h2 { font-size: 18pt; }
  h3 { font-size: 16pt; }
  
  a {
    text-decoration: underline;
  }
}
