/**
 * Speed Optimization CSS
 * Improves Core Web Vitals and page loading performance
 */

/* Lazy Loading Styles */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

img[data-src].loaded {
    opacity: 1;
}

/* Critical CSS - Above the fold content */
.hero-section {
    contain: layout style paint;
}

/* Image Optimization */
img {
    max-width: 100%;
    height: auto;
    loading: lazy;
}

/* Font Loading Optimization */
@font-face {
    font-family: 'Vazirmatn';
    font-display: swap;
    src: url('https://fonts.gstatic.com/s/vazirmatn/v33s7r6md3Valvmjb1fPhtVSDM26YlPce70v66YlPce70vJJI.woff2') format('woff2');
}

/* Preload critical resources */
.preload-critical {
    font-display: swap;
}

/* Reduce layout shifts */
.carousel-item {
    min-height: 400px;
}

/* Optimize animations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Critical rendering path optimization */
.above-fold {
    will-change: transform;
}

/* Image compression hints */
img[loading="lazy"] {
    content-visibility: auto;
}

/* Optimize carousel performance */
.carousel-item {
    contain: layout style paint;
    transform: translateZ(0);
}

/* Reduce paint complexity */
.shadow-lg {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Optimize text rendering */
body {
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Critical CSS for navigation */
.nav-optimized {
    contain: layout style;
    will-change: auto;
}

/* Optimize button interactions */
.btn-optimized {
    touch-action: manipulation;
    will-change: transform;
}

/* Reduce repaints */
.static-content {
    contain: layout style paint;
}

/* Optimize scrolling */
.scroll-optimized {
    contain: layout style paint;
    transform: translateZ(0);
}

/* Image placeholder */
.img-placeholder {
    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;
    }
}

/* Optimize form elements */
input, textarea, select {
    contain: layout style;
}

/* Reduce layout thrashing */
.fixed-element {
    contain: layout style paint;
    will-change: transform;
}

/* Optimize carousel transitions */
.carousel-transition {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}
