/**
 * Multi-CDN Font Loading Strategy
 * 
 * This file provides fallback font loading for users in regions where
 * Google Fonts may be blocked or slow (China, Russia, etc.)
 * 
 * CDN Priority:
 * 1. cdnjs.cloudflare.com (blocked in some Russia regions, but works in many)
 * 2. jsdelivr.net (China/Russia friendly)
 * 3. bootcdn.cn (China-specific)
 * 4. Google Fonts (fallback for rest of world)
 */

/* Inter Variable Font from jsDelivr (works in China & most of Russia) */
@import url('https://cdn.jsdelivr.net/npm/@fontsource/inter@5.0.16/index.css');

/* Fallback for specific weights if variable font fails */
@font-face {
  font-family: 'Inter Fallback';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/npm/@fontsource/inter@5.0.16/files/inter-latin-300-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter Fallback';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/npm/@fontsource/inter@5.0.16/files/inter-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter Fallback';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/npm/@fontsource/inter@5.0.16/files/inter-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter Fallback';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/npm/@fontsource/inter@5.0.16/files/inter-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter Fallback';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/npm/@fontsource/inter@5.0.16/files/inter-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============================================
   FLUID TYPOGRAPHY SYSTEM - Improved Readability
   ============================================ */

/* 1) Color tokens for better readability */
:root {
  /* High-contrast text colors */
  --text-primary: #0f172a;      /* slate-900 - main text */
  --text-secondary: #475569;    /* slate-600 - secondary text */
  --text-muted: #64748b;        /* slate-500 - muted text */
  --accent: #10b981;            /* emerald-500 - matches brand */
  
  /* 2) Fluid type scale - automatically scales between mobile and desktop */
  /* Small text (legal, captions) */
  --step--1: clamp(0.8125rem, 0.79rem + 0.11vw, 0.875rem);
  
  /* Base body text */
  --step-0: clamp(1rem, 0.96rem + 0.18vw, 1.125rem);
  
  /* Lead paragraph / small headings */
  --step-1: clamp(1.125rem, 1.06rem + 0.33vw, 1.375rem);
  
  /* Section subheadings (h4) */
  --step-2: clamp(1.375rem, 1.24rem + 0.68vw, 1.875rem);
  
  /* Major section headings (h3) */
  --step-3: clamp(1.75rem, 1.5rem + 1.25vw, 2.625rem);
  
  /* Page section headings (h2) */
  --step-4: clamp(2.125rem, 1.79rem + 1.68vw, 3.25rem);
  
  /* Hero/main headings (h1) */
  --step-5: clamp(2.625rem, 2.16rem + 2.32vw, 4.25rem);
}

/* 3) Apply Inter font globally with system fallbacks */
body {
  font-family: 'Inter', 'Inter Fallback', system-ui, -apple-system, BlinkMacSystemFont, 
    'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 
    'Helvetica Neue', sans-serif;
  color: var(--text-primary);
  font-size: var(--step-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* 4) Heading hierarchy - consistent, readable, bold */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
  margin: 0;
}

h1 { 
  font-size: var(--step-5); 
  font-weight: 800;
  line-height: 1.1;
}

h2 { 
  font-size: var(--step-4); 
  font-weight: 700;
  line-height: 1.15;
}

h3 { 
  font-size: var(--step-3); 
  font-weight: 700;
}

h4 { 
  font-size: var(--step-2); 
  font-weight: 600;
}

h5 { 
  font-size: var(--step-1); 
  font-weight: 600;
}

h6 { 
  font-size: var(--step-0); 
  font-weight: 600;
}

/* 5) Paragraph styles */
p {
  margin: 0 0 1.25em;
  line-height: 1.65;
}

/* Lead paragraph for emphasis */
.lead {
  font-size: var(--step-1);
  line-height: 1.55;
  color: var(--text-primary);
  font-weight: 400;
}

/* Small text (legal, captions) */
.small, small {
  font-size: var(--step--1);
  color: var(--text-secondary);
  line-height: 1.5;
}

/* 6) Section styling utilities */
.section-eyebrow {
  display: inline-block;
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.section-title {
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.section-subtitle {
  font-size: var(--step-1);
  color: var(--text-secondary);
  line-height: 1.55;
  font-weight: 400;
}

/* 7) Card/Feature block typography */
.card-title {
  font-size: var(--step-2);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.card-text {
  font-size: var(--step-0);
  color: var(--text-secondary);
  line-height: 1.6;
}

/* 8) Lists */
ul, ol {
  padding-left: 1.5em;
  margin: 0 0 1.25em;
  line-height: 1.65;
}

li {
  margin-bottom: 0.5em;
}

/* 9) Links */
a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: all 0.2s ease;
}

a:hover {
  text-decoration-thickness: 2px;
  color: #059669; /* darker emerald on hover */
}

/* 10) Improve text contrast in dark mode */
.dark body {
  color: #f1f5f9; /* slate-100 */
}

.dark h1, .dark h2, .dark h3, .dark h4, .dark h5, .dark h6 {
  color: #ffffff;
}

.dark p, .dark .card-text {
  color: #cbd5e1; /* slate-300 */
}

.dark .small, .dark small, .dark .section-subtitle {
  color: #94a3b8; /* slate-400 */
}

/* 11) Better spacing for sections */
section {
  margin-block: 3rem;
}

/* 12) Optimal reading width */
.prose, .container {
  max-width: min(100% - 2rem, 75ch);
  margin-inline: auto;
}

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

/* 14) Improve base font size on small screens for readability */
@media (max-width: 420px) {
  :root {
    font-size: 106.25%; /* 17px base instead of 16px */
  }
}

/* 15) Print styles for better document printing */
@media print {
  body {
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
  }
  
  h1 { font-size: 24pt; }
  h2 { font-size: 20pt; }
  h3 { font-size: 16pt; }
  h4 { font-size: 14pt; }
}
