/**
 * Performance Optimizations CSS
 * Improves rendering performance and reduces layout shifts
 */

/* Optimize font rendering */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Prevent layout shifts with images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Lazy loaded images fade in */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

img[loading="lazy"].loaded,
img[loading="lazy"][decoding="async"] {
    opacity: 1;
}

/* Optimize animations for performance */
.product-card,
.category-card,
.product-grid-item {
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Reduce repaints */
.product-card:hover,
.category-card:hover {
    transform: translate3d(0, 0, 0);
}

/* Content visibility for off-screen content */
.lazy-fade {
    content-visibility: auto;
    contain-intrinsic-size: 200px;
}

/* Optimize scroll performance */
html {
    scroll-behavior: smooth;
}

/* GPU acceleration for smooth animations */
.product-card img,
.category-card img {
    transform: translateZ(0);
}

/* Reduce layout thrashing */
.products-grid-homepage,
.product-grid-item {
    contain: layout style paint;
}

/* Optimize font loading */
@font-face {
    font-family: 'Inter';
    font-display: swap;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Optimize carousel performance */
.swiper-container,
.swiper-wrapper {
    contain: layout style paint;
    transform: translateZ(0);
}

/* Memory optimization - hide off-screen elements */
.hero-slide:not(.active) {
    visibility: hidden;
    pointer-events: none;
}

/* Optimize button interactions */
button,
.btn-primary,
.btn-secondary {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Prevent text selection during interactions */
button:active,
a:active {
    -webkit-user-select: none;
    user-select: none;
}
