/**
 * Sierra at Tahoe - Font Loading Optimization
 * Preload critical fonts and manage font fallbacks
 */

/* Critical font preloading - Add to HTML head */
/*
<link rel="preload" href="assets/fonts/GT-Standard-L-Standard-Regular.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="assets/fonts/GT-Standard-L-Standard-Heavy.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="assets/fonts/GT-Standard-M-Standard-Regular.woff2" as="font" type="font/woff2" crossorigin>
*/

/* Font display optimization for non-critical fonts */
@font-face {
    font-family: 'GT Standard Trial';
    src: url('../fonts/GT-Standard-L-Standard-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0020-007E, U+00A0-00FF;
}

@font-face {
    font-family: 'GT Standard Trial';
    src: url('../fonts/GT-Standard-L-Standard-Heavy.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0020-007E, U+00A0-00FF;
}

@font-face {
    font-family: 'GT Standard Trial';
    src: url('../fonts/GT-Standard-M-Standard-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0020-007E, U+00A0-00FF;
}

/* Font loading states */
.fonts-loading {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}

.fonts-loaded {
    font-family: 'GT Standard Trial', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}

/* Progressive font enhancement */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}

.gt-standard-loaded body,
.gt-standard-loaded h1,
.gt-standard-loaded h2,
.gt-standard-loaded h3,
.gt-standard-loaded h4,
.gt-standard-loaded h5,
.gt-standard-loaded h6 {
    font-family: 'GT Standard Trial', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}

/* Reduce layout shift during font load */
@font-face {
    font-family: 'GT Standard Fallback';
    src: local(-apple-system), local(BlinkMacSystemFont), local('Segoe UI');
    font-weight: 400;
    font-style: normal;
    ascent-override: 92%;
    descent-override: 23%;
    line-gap-override: 0%;
    size-adjust: 100%;
}

/* Font loading error fallback */
.font-load-error {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif !important;
}

/* Optimized font stacks for different contexts */
.heading-font {
    font-family: 'GT Standard Trial', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 700;
    font-feature-settings: "kern" 1, "liga" 1;
}

.body-font {
    font-family: 'GT Standard Trial', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
    font-feature-settings: "kern" 1;
}

.ui-font {
    font-family: 'GT Standard Trial', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
}

/* Performance: Reduce repaints during font swapping */
* {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Hide text until fonts are ready to prevent FOIT */
@media (max-width: 768px) {
    .critical-text {
        visibility: hidden;
    }

    .fonts-loaded .critical-text {
        visibility: visible;
    }
}