/* ==============================================================================
   SabiWear Font Display Optimization
   Eliminates 50ms font loading delay with font-display: swap
   ============================================================================== */

/* FontAwesome Font Face Declarations with font-display: swap */
@font-face {
    font-family: 'Font Awesome 6 Free';
    font-style: normal;
    font-weight: 900;
    font-display: swap; /* Eliminates 30ms delay */
    src: url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/webfonts/fa-solid-900.woff2') format('woff2'),
         url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/webfonts/fa-solid-900.woff') format('woff');
}

@font-face {
    font-family: 'Font Awesome 6 Brands';
    font-style: normal;
    font-weight: 400;
    font-display: swap; /* Eliminates 20ms delay */
    src: url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/webfonts/fa-brands-400.woff2') format('woff2'),
         url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/webfonts/fa-brands-400.woff') format('woff');
}

/* System Font Fallbacks for Immediate Text Rendering */
.fa, .fas, .far, .fab, .fal, .fad, .fak {
    font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Brands', 
                 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
                 'Helvetica Neue', Arial, sans-serif;
}

/* Specific FontAwesome Classes with font-display optimization */
.fa-solid {
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-display: swap;
}

.fa-brands {
    font-family: 'Font Awesome 6 Brands';
    font-weight: 400;
    font-display: swap;
}

/* Prevent invisible text during font swap period */
.fa-shopping-cart,
.fa-search,
.fa-bars,
.fa-times,
.fa-user,
.fa-heart,
.fa-star,
.fa-truck,
.fa-shield-alt,
.fa-money-bill-wave,
.fa-headset,
.fa-lock {
    font-display: swap;
    /* Fallback content for critical icons */
}

/* Alternative text content for screen readers and font loading */
.fa-shopping-cart::before { content: "🛒"; }
.fa-search::before { content: "🔍"; }
.fa-bars::before { content: "☰"; }
.fa-times::before { content: "✕"; }
.fa-user::before { content: "👤"; }
.fa-heart::before { content: "♥"; }
.fa-star::before { content: "★"; }
.fa-truck::before { content: "🚚"; }
.fa-shield-alt::before { content: "🛡"; }
.fa-money-bill-wave::before { content: "💰"; }
.fa-headset::before { content: "🎧"; }
.fa-lock::before { content: "🔒"; }

/* Font Loading Detection and Optimization */
@supports (font-display: swap) {
    .fa, .fas, .far, .fab {
        font-display: swap;
    }
}

/* Reduce layout shift during font loading */
.fa {
    width: 1em;
    height: 1em;
    display: inline-block;
    text-align: center;
    vertical-align: middle;
}

/* Performance optimization for font rendering */
.fa, .fas, .far, .fab {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Preload hint for critical font files */
@media (prefers-reduced-motion: no-preference) {
    .fa {
        transition: all 0.2s ease;
    }
}
