/* ============================================ 
   PERFORMANCE & CLS OPTIMIZATION CSS 
   ============================================ */

/* 1. PREVENT SCROLLBAR LAYOUT SHIFT */
html {
    scrollbar-gutter: stable;
    overflow-y: scroll;
}

body {
    overflow-y: scroll;
}

/* Override Bootstrap modal to prevent layout shift */
body.modal-open {
    padding-right: 0 !important;
}

/* 2. FONT LOADING OPTIMIZATION */
@font-face {
    font-family: 'Roboto';
    src: url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap');
    font-display: swap;
}

@font-face {
    font-family: 'Poppins';
    src: url('https://fonts.googleapis.com/css2?family=Poppins:wght@600;700&display=swap');
    font-display: swap;
}

/* 3. IMAGE OPTIMIZATION - NO LAYOUT SHIFT */
img {
    display: block;
    max-width: 100%;
    height: auto;
    aspect-ratio: auto;
}

/* Prevent img CLS by ensuring aspect-ratio is maintained */
img[width][height] {
    aspect-ratio: attr(width) / attr(height);
}

/* Banner/Hero image optimization */
.blog-featured-image,
.hero-image,
.banner-image {
    max-width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16 / 9;
}

/* 4. DYNAMIC SECTION SIZING - PREVENT CLS */
.video-section,
.testimonial-section,
.service-section,
.gallery-section {
    min-height: 300px;
}

.blog-section,
.content-section {
    min-height: 200px;
}

.hero-section,
.blog-hero {
    min-height: 400px;
}

/* 5. MODAL & DRAWER OPTIMIZATION */
.modal {
    overflow-y: auto;
}

.modal-backdrop {
    opacity: 0.5;
}

/* 6. LOADING STATES - SKELETON SCREENS */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* 7. PARAGRAPH & TEXT - ENSURE STABLE HEIGHT */
p {
    line-height: 1.6;
    margin-bottom: 1rem;
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

/* 8. CONTAINER SIZING */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* 9. ROW & COLUMN STABILIZATION */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

[class*="col-"] {
    padding-right: 15px;
    padding-left: 15px;
}

/* 10. BUTTON & INTERACTIVE ELEMENT STABILITY */
button, .btn {
    min-height: 44px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

button:active,
.btn:active {
    transform: none;
    box-shadow: none;
}

/* 11. FORM ELEMENTS */
input, textarea, select {
    min-height: 44px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* 12. NAVIGATION STABILITY */
.navbar {
    min-height: 70px;
}

.nav-item {
    display: flex;
    align-items: center;
    min-height: 50px;
}

/* 13. CARD LAYOUT STABILITY */
.card {
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* 14. LAZY LOADING - CRITICAL IMAGES ONLY */
img[loading="lazy"] {
    /* Images will load when visible */
}

/* NO lazy loading for LCP candidates (hero/banner) */
.hero-image,
.blog-hero img,
.banner-image {
    loading: auto;
}

/* 15. WEB FONTS - OPTIMIZE LOADING */
body {
    font-family: 'Poppins', 'Roboto', Arial, sans-serif;
    font-display: swap;
}

/* 16. CRITICAL RENDERING PATH */
/* Inline critical CSS above fold */
.above-fold {
    display: block;
}

/* Defer below-fold content rendering */
.below-fold {
    contain: layout style paint;
}

/* 17. ANIMATION OPTIMIZATION */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 18. RESPONSIVE IMAGE CONTAINERS */
.img-container {
    position: relative;
    width: 100%;
    padding-bottom: 66.67%; /* 3:2 aspect ratio */
    overflow: hidden;
}

.img-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.img-container-16-9 {
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
}

.img-container-4-3 {
    padding-bottom: 75%; /* 4:3 aspect ratio */
}

/* 19. PREVENT TEXT EXPANSION */
.text-content {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* 20. CRITICAL RESOURCE PRELOADING */
/* (add preload links in HTML head) */
