/*!
 * Modern Font Loading
 * Optimized for performance and accessibility
 */

/* ===== GOOGLE FONTS IMPORT ===== */
/* Using font-display: swap for better performance */

/* Inter - Primary font for body text and UI */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* Crimson Pro - Secondary font for headings and quotes */
@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:wght@400;500;600;700&display=swap');

/* ===== FONT FACE DECLARATIONS ===== */
/* Fallback font declarations with proper font-display */

@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial'), local('Helvetica'), local('sans-serif');
  font-display: swap;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'Crimson Pro Fallback';
  src: local('Georgia'), local('Times New Roman'), local('serif');
  font-display: swap;
  ascent-override: 84%;
  descent-override: 22%;
  line-gap-override: 0%;
}

/* ===== FONT LOADING OPTIMIZATION ===== */

/* Preload critical fonts */
/* Add these link tags to HTML head:
<link rel="preload" href="https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuLyfAZ9hiA.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://fonts.gstatic.com/s/crimsonpro/v23/q5uYsoa5M_tv7IihmnkabC5XiXCAlXGks1WZzm2LZTc.woff2" as="font" type="font/woff2" crossorigin>
*/

/* ===== FONT STACK DEFINITIONS ===== */

/* Update CSS custom properties with proper fallbacks */
:root {
  --font-primary: 'Inter', 'Inter Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-secondary: 'Crimson Pro', 'Crimson Pro Fallback', Georgia, 'Times New Roman', serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

/* ===== FONT LOADING STATES ===== */

/* Show fallback fonts while web fonts load */
.fonts-loading body {
  font-family: var(--font-primary);
}

.fonts-loading h1,
.fonts-loading h2,
.fonts-loading h3,
.fonts-loading h4,
.fonts-loading h5,
.fonts-loading h6 {
  font-family: var(--font-secondary);
}

/* Smooth transition when fonts load */
.fonts-loaded * {
  transition: font-family 0.1s ease-out;
}

/* ===== FONT FEATURE SETTINGS ===== */

/* Enable OpenType features for better typography */
body {
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures contextual;
}

/* Optimize number rendering */
.numeric {
  font-feature-settings: 'tnum' 1;
  font-variant-numeric: tabular-nums;
}

/* Small caps for abbreviations */
.small-caps {
  font-feature-settings: 'smcp' 1;
  font-variant-caps: small-caps;
}

/* ===== RESPONSIVE TYPOGRAPHY ===== */

/* Fluid typography for better responsive design */
html {
  font-size: clamp(14px, 2.5vw, 16px);
}

/* Responsive heading sizes */
h1 {
  font-size: clamp(2rem, 5vw, 3rem);
}

h2 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
}

h3 {
  font-size: clamp(1.5rem, 3vw, 1.875rem);
}

h4 {
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */

/* Respect user's font size preferences */
@media (prefers-reduced-motion: reduce) {
  .fonts-loaded * {
    transition: none;
  }
}

/* High contrast mode adjustments */
@media (prefers-contrast: high) {
  body {
    font-weight: var(--font-medium);
  }
  
  h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-bold);
  }
}

/* ===== PRINT STYLES ===== */

@media print {
  body {
    font-family: var(--font-secondary);
    font-size: 12pt;
    line-height: 1.4;
  }
  
  h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-secondary);
    page-break-after: avoid;
  }
}