/* Cumulative Layout Shift (CLS) Fixes for Regal Website */

/* 1. Font Loading Optimization - Prevent layout shifts from font loading */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300 600;
    font-display: swap;
    /* Critical for preventing layout shifts */
    src: url('https://fonts.gstatic.com/s/inter/v13/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2') format('woff2');
    size-adjust: 100%;
}

@font-face {
    font-family: 'Playfair Display';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    /* Critical for preventing layout shifts */
    src: url('https://fonts.gstatic.com/s/playfairdisplay/v39/nuFiD-vYSZviVYUb_rj3ij__anPXJzDwcbmjWBN2PKdFvUDQZNLo_U2r.woff2') format('woff2');
    size-adjust: 100%;
}

/* 2. Main Content Container Stability */
.main-content {
    contain: layout style;
    min-height: 100vh;
    /* Prevent main content layout shifts */
    will-change: auto;
}

/* 3. Hero Section Layout Stability */
.hero-section {
    contain: layout;
    min-height: 80vh;
    /* Reserve space for content */
}

.hero-section h1 {
    /* Reserve space for hero title to prevent font loading shifts */
    min-height: 120px;
    contain: layout;
    font-size-adjust: 0.5;
}

.hero-section .lead {
    /* Reserve space for hero subtitle */
    min-height: 50px;
    contain: layout;
}

/* 4. Button Container Stability - Fix 0.045 CLS score */
.d-flex.flex-wrap.justify-content-center.gap-3 {
    /* Prevent layout shifts in button container */
    min-height: 60px;
    contain: layout;
    align-items: center;
}

.hero-section .btn {
    /* Reserve consistent space for buttons */
    min-height: 50px;
    min-width: 160px;
    contain: layout;
    /* Prevent button text shifts during font loading */
    font-size-adjust: 0.5;
}

/* Mobile responsive button container */
@media (max-width: 768px) {
    .d-flex.flex-wrap.justify-content-center.gap-3 {
        min-height: 120px;
        /* Account for stacked buttons */
        flex-direction: column;
        gap: 0.7rem;
    }

    .hero-section .btn {
        min-width: 140px;
    }
}

/* 5. Typography Layout Stability */
h1,
h2,
h3,
h4,
h5,
h6 {
    /* Prevent heading layout shifts during font loading */
    font-size-adjust: 0.5;
    contain: layout;
}

h1.display-2 {
    /* Specific fix for main hero heading */
    min-height: 120px;
    line-height: 1.2;
}

h1.display-2.fw-bold.mb-3.text-white {
    /* Hero title specific spacing reservation */
    min-height: 100px;
}

/* 6. Product Cards Layout Stability */
.product-card {
    contain: layout;
    min-height: 350px;
    /* Reserve consistent height */
}

.product-image-container {
    /* Fixed aspect ratio prevents image loading shifts */
    aspect-ratio: 1/1;
    contain: layout;
}

/* 7. Navigation Icon Stability */
.nav-icon,
button.nav-icon {
    /* Prevent icon layout shifts */
    min-width: 40px;
    min-height: 40px;
    contain: layout;
}

/* 8. Flexbox Container Optimizations */
.row.g-4 {
    contain: layout;
}

.col-lg-3,
.col-md-6 {
    contain: layout;
}

/* 9. Image Loading Stability */
img {
    /* Prevent image loading layout shifts */
    max-width: 100%;
    height: auto;
}

.card-img-top {
    aspect-ratio: 1/1;
    object-fit: cover;
    contain: layout;
}

/* 10. Testimonials Section Stability */
.testimonial-card {
    min-height: 300px;
    contain: layout;
}

/* 11. Mobile Horizontal Scroll Stability */
.featured-products-mobile,
.testimonials-mobile {
    contain: layout;
    min-height: 200px;
}

/* 12. Inspiration Section Stability */
.inspiration-row {
    contain: layout;
}

.inspiration-img {
    aspect-ratio: 1/1;
    contain: layout;
}

/* 13. Critical Above-the-Fold Optimizations */
.hero-section .container {
    contain: layout;
}

.hero-section .position-relative {
    contain: layout;
}

/* 14. Font Fallback Improvements */
body {
    font-size-adjust: 0.5;
}

/* 15. Prevent Reflow During Font Swaps */
.fw-bold,
.font-weight-bold {
    font-size-adjust: 0.5;
}

/* 16. Button Specific Optimizations */
.btn {
    contain: layout;
    min-height: 38px;
}

.btn-lg {
    min-height: 50px;
    min-width: 120px;
}

.btn-sm {
    min-height: 32px;
}

/* 17. Container Stability */
.container {
    contain: layout;
}

/* 18. Section Spacing Stability */
section {
    contain: layout;
}

/* 19. Jacket Banner Specific Fixes */
.jacket-banner-section h1 {
    min-height: 80px;
    contain: layout;
}

.jacket-banner-section .lead {
    min-height: 60px;
    contain: layout;
}

/* 20. Mobile Specific Optimizations */
@media (max-width: 767px) {
    .hero-section h1 {
        min-height: 60px;
    }

    .hero-section .lead {
        min-height: 40px;
    }

    .d-flex.flex-wrap.justify-content-center.gap-3 {
        min-height: 100px;
    }
}

/* 21. Performance Optimizations */
.will-change-auto {
    will-change: auto;
}

/* Reset will-change after animations complete */
.hero-section,
.main-content,
.product-card {
    animation-fill-mode: both;
}

/* 22. Prevent Bootstrap Grid Shifts */
.row {
    contain: layout;
}

[class*="col-"] {
    contain: layout;
}

/* 23. Specific Element Containment */
.card {
    contain: layout;
}

.card-body {
    contain: layout;
}

/* 24. Icon Stability */
.fas,
.far,
.fab {
    /* Prevent icon font loading shifts */
    font-size-adjust: 0.5;
    min-width: 1em;
    min-height: 1em;
    contain: layout;
}

/* 25. Final CLS Prevention Rules */
* {
    /* Global containment where safe */
    box-sizing: border-box;
}

/* Specific elements that commonly cause CLS */
.position-relative,
.position-absolute {
    contain: layout;
}

/* Ensure smooth font loading transitions */
@supports (font-display: swap) {
    * {
        font-display: swap;
    }
}


