/* Performance Optimizations */

/* Image optimization */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Lazy loading for images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Contain paint for better performance */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* GPU acceleration */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Optimize font rendering */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Reduce layout shifts */
img, video, iframe {
    aspect-ratio: attr(width) / attr(height);
}

/* Content visibility for off-screen elements */
.off-screen {
    content-visibility: auto;
    contain-intrinsic-size: 200px;
}

/* Prevent layout shifts */
.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;
    }
}

/* Optimize animations */
@media (prefers-reduced-motion: no-preference) {
    .optimized-animation {
        transform: translateZ(0);
        will-change: transform;
    }
}

/* Critical CSS - Above the fold content */
.above-fold {
    contain: layout style paint;
}
