/* src/css/typography.css - Unified Typography System */

/* ===== TYPOGRAPHY SYSTEM ===== */

/* Font Loading Optimization - Using Google Fonts with fallbacks */

/* Typography Scale - Mobile First Approach */
:root {
    /* Font Families */
    --font-primary: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-secondary: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-title: 'Stix Two Text', Georgia, 'Times New Roman', serif;
    
    /* Font Weights */
    --font-weight-light: 300;
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    /* Font Sizes - Mobile First (Base 16px) */
    --font-size-xs: 0.75rem;    /* 12px */
    --font-size-sm: 0.875rem;   /* 14px */
    --font-size-base: 1rem;     /* 16px */
    --font-size-lg: 1.125rem;   /* 18px */
    --font-size-xl: 1.25rem;    /* 20px */
    --font-size-2xl: 1.5rem;    /* 24px */
    --font-size-3xl: 1.875rem;  /* 30px */
    --font-size-4xl: 2.25rem;   /* 36px */
    --font-size-5xl: 3rem;      /* 48px */
    --font-size-6xl: 3.75rem;   /* 60px */
    
    /* Line Heights */
    --line-height-tight: 1.25;
    --line-height-snug: 1.375;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.625;
    --line-height-loose: 2;
    
    /* Letter Spacing */
    --letter-spacing-tighter: -0.05em;
    --letter-spacing-tight: -0.025em;
    --letter-spacing-normal: 0;
    --letter-spacing-wide: 0.025em;
    --letter-spacing-wider: 0.05em;
    --letter-spacing-widest: 0.1em;
}

/* ===== BASE TYPOGRAPHY STYLES ===== */

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: var(--font-secondary);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-height-relaxed);
    letter-spacing: var(--letter-spacing-normal);
    color: var(--color-text-primary);
    background-color: var(--color-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: color 0.3s ease, background-color 0.3s ease;
}

/* ===== HEADING STYLES ===== */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-primary);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tight);
    color: var(--color-text-primary);
    margin: 0 0 0.75em 0;
    text-wrap: balance;
}

/* Heading Sizes - Mobile First with Fluid Typography */
h1 {
    font-size: clamp(var(--font-size-3xl), 5vw, var(--font-size-5xl));
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tighter);
}

h2 {
    font-size: clamp(var(--font-size-2xl), 4vw, var(--font-size-4xl));
    font-weight: var(--font-weight-semibold);
    color: var(--color-accent-primary);
    text-align: center;
    margin-bottom: 3rem;
}

h3 {
    font-size: clamp(var(--font-size-xl), 3vw, var(--font-size-2xl));
    font-weight: var(--font-weight-semibold);
    color: var(--color-accent-primary);
}

h4 {
    font-size: clamp(var(--font-size-lg), 2.5vw, var(--font-size-xl));
    font-weight: var(--font-weight-medium);
    color: var(--color-accent-secondary);
}

h5 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-primary);
}

h6 {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
}

/* ===== BODY TEXT STYLES ===== */

p {
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    margin: 0 0 1.25em 0;
    color: var(--color-text-primary);
}

/* Lead paragraph */
.lead {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-height-relaxed);
    color: var(--color-text-secondary);
}

/* Small text */
small, .small {
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
    color: var(--color-text-secondary);
}

/* ===== LINK STYLES ===== */

a {
    color: var(--color-accent-secondary);
    text-decoration: none;
    transition: color 0.3s ease, text-decoration 0.3s ease;
    cursor: pointer;
}

a:hover,
a:focus {
    color: var(--color-accent-primary);
    text-decoration: underline;
    outline: none;
}

a:focus-visible {
    outline: 2px solid var(--color-accent-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ===== LIST STYLES ===== */

ul, ol {
    margin: 0 0 1.25em 0;
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.5em;
    line-height: var(--line-height-relaxed);
}

/* Custom list styles */
.list-unstyled {
    list-style: none;
    padding-left: 0;
}

.list-inline {
    list-style: none;
    padding-left: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

/* ===== UTILITY CLASSES ===== */

/* Font Families */
.font-primary { font-family: var(--font-primary); }
.font-secondary { font-family: var(--font-secondary); }
.font-title { font-family: var(--font-title); }

/* Font Weights */
.font-light { font-weight: var(--font-weight-light); }
.font-regular { font-weight: var(--font-weight-regular); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

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

/* Text Colors */
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-accent { color: var(--color-accent-primary); }
.text-accent-secondary { color: var(--color-accent-secondary); }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

/* Text Transform */
.uppercase { text-transform: uppercase; }
.lowercase { text-transform: lowercase; }
.capitalize { text-transform: capitalize; }

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

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

/* ===== RESPONSIVE TYPOGRAPHY ===== */

/* Tablet Adjustments */
@media (min-width: 768px) {
    :root {
        --font-size-base: 1.125rem;  /* 18px on tablet+ */
    }
    
    h2 {
        margin-bottom: 4rem;
    }
    
    p {
        margin-bottom: 1.5em;
    }
}

/* Desktop Adjustments */
@media (min-width: 1024px) {
    h1 {
        line-height: var(--line-height-snug);
    }
    
    .lead {
        font-size: var(--font-size-xl);
    }
}

/* Large Desktop Adjustments */
@media (min-width: 1440px) {
    html {
        font-size: 18px; /* Increase base font size for large screens */
    }
}

/* ===== DARK MODE TYPOGRAPHY ===== */

body.dark-mode {
    /* Enhanced text contrast for dark mode */
    --color-text-primary: var(--dm-text-primary);
    --color-text-secondary: var(--dm-text-secondary);
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3 {
    color: var(--dm-text-primary);
    text-shadow: 0 0 20px rgba(var(--dm-glow-color-rgb-values), 0.3);
}

body.dark-mode h2 {
    color: var(--dm-glow-color);
}

body.dark-mode h3 {
    color: var(--dm-accent-primary);
}

body.dark-mode h4 {
    color: var(--dm-accent-secondary);
}

/* ===== ACCESSIBILITY ===== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        font-weight: var(--font-weight-medium);
    }
    
    h1, h2, h3, h4, h5, h6 {
        font-weight: var(--font-weight-bold);
    }
    
    body.dark-mode {
        --dm-text-primary: #ffffff;
        --dm-text-secondary: #e0e0e0;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* Print styles */
@media print {
    body {
        font-family: Georgia, 'Times New Roman', serif;
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
        background: #fff;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: #000;
        page-break-after: avoid;
    }
    
    p {
        orphans: 3;
        widows: 3;
    }
}