/**
 * Font Loading Optimization CSS
 * Prevents FOIT (Flash of Invisible Text) and layout shifts
 * Provides smooth font loading experience
 */

/* Default font stack for loading state */
html.fonts-loading,
html.fonts-loading body,
html.fonts-loading * {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

/* Specific overrides for title elements during loading */
html.fonts-loading .hero-title,
html.fonts-loading h1,
html.fonts-loading h2,
html.fonts-loading .title {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif !important;
    font-weight: 700 !important; /* Approximate custom font weight */
    visibility: visible !important;
}

/* Smooth transition when fonts load */
.hero-title,
h1, h2, h3, h4, h5, h6,
.title,
body {
    transition: font-family 0.15s ease-in-out;
}

/* Font display swap behavior */
@supports (font-display: swap) {
    @font-face {
        font-family: 'Exo';
        font-display: swap;
    }
    
    @font-face {
        font-family: 'Fredoka One';
        font-display: swap;
    }
    
    @font-face {
        font-family: 'Inter';
        font-display: swap;
    }
    
    @font-face {
        font-family: 'Orbitron';
        font-display: swap;
    }
}

/* Accessibility: Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .hero-title,
    h1, h2, h3, h4, h5, h6,
    .title,
    body {
        transition: none;
    }
}

/* Loading state indicators (optional visual feedback) */
html.fonts-loading::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #FFD700, transparent);
    animation: fontLoadProgress 2s ease-in-out infinite;
    z-index: 9999;
    opacity: 0.3;
}

html.fonts-loaded::before {
    display: none;
}

@keyframes fontLoadProgress {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100vw); }
}

/* Performance optimization: Prevent flash during font swap */
html.fonts-loading .hero-title,
html.fonts-loading [class*="title"],
html.fonts-loading h1,
html.fonts-loading h2 {
    text-rendering: optimizeSpeed;
}

html.fonts-loaded .hero-title,
html.fonts-loaded [class*="title"], 
html.fonts-loaded h1,
html.fonts-loaded h2 {
    text-rendering: optimizeLegibility;
}