/* Performance Optimization CSS */

/* Preload and lazy loading optimizations */
.lazy-load {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.lazy-load.loaded {
    opacity: 1;
    transform: translateY(0);
}

/* Image optimization */
.optimized-image {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    will-change: transform;
}

/* Proper image sizing for containers (zoom-friendly) */
.product-card img,
.media-content img,
.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    max-width: 100%;
}

/* Loading skeleton animations */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

.dark .skeleton {
    background: linear-gradient(
        90deg,
        #374151 25%,
        #4b5563 50%,
        #374151 75%
    );
    background-size: 200% 100%;
}

@keyframes skeleton-loading {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Product card skeleton */
.product-card-skeleton {
    display: block;
    width: 100%;
    margin-bottom: 1rem;
}

.product-card-skeleton .skeleton-image {
    width: 100%;
    height: 0;
    padding-bottom: 125%; /* 4:5 aspect ratio */
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
}

.product-card-skeleton .skeleton-title {
    height: 1.25rem;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
}

.product-card-skeleton .skeleton-price {
    height: 1rem;
    width: 60%;
    border-radius: 0.25rem;
    margin-bottom: 0.75rem;
}

.product-card-skeleton .skeleton-button {
    height: 2.5rem;
    border-radius: 0.5rem;
}

/* Smooth fade-in animations */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Progressive image loading */
.progressive-image {
    position: relative;
    overflow: hidden;
}

.progressive-image .placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.dark .progressive-image .placeholder {
    background: #374151;
}

.progressive-image .placeholder.hidden {
    opacity: 0;
    pointer-events: none;
}

.progressive-image img {
    position: relative;
    z-index: 2;
    transition: opacity 0.3s ease;
}

/* Critical CSS for above-the-fold content */
.hero-section {
    min-height: 100vh;
    will-change: transform;
}

/* Optimized font loading */
.font-loading {
    font-display: swap;
}

/* Reduce layout shifts */
.fixed-aspect-ratio {
    position: relative;
    width: 100%;
    height: 0;
}

.fixed-aspect-ratio.ratio-4-5 {
    padding-bottom: 125%; /* 4:5 aspect ratio */
}

.fixed-aspect-ratio.ratio-16-9 {
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
}

.fixed-aspect-ratio > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Video loading optimization */
.video-container {
    position: relative;
    background-color: #000;
}

.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #e2e8f0, #f1f5f9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.dark .video-placeholder {
    background: linear-gradient(45deg, #374151, #4b5563);
}

.video-loading {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-loading.loaded {
    opacity: 1;
}

/* Optimized animations */
.optimized-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.optimized-hover:hover {
    transform: translateY(-2px);
}

/* Defer non-critical CSS */
.defer-load {
    display: none;
}

.defer-load.ready {
    display: block;
}

/* Reduce paint and composite layers */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* Mobile-first responsive images */
.responsive-image {
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* Loading states */
.loading-state {
    pointer-events: none;
    opacity: 0.7;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Optimize scroll performance */
.scroll-optimized {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Prefetch and preload hints */
.prefetch-container {
    position: relative;
}

.prefetch-container::before {
    content: '';
    position: absolute;
    top: -100px;
    left: 0;
    width: 1px;
    height: 1px;
    background: transparent;
}

/* Intersection Observer optimization */
.intersection-trigger {
    height: 1px;
    width: 100%;
    position: absolute;
    bottom: 100px;
}

/* Critical path optimization */
.above-fold {
    contain: layout style paint;
}

.below-fold {
    contain: layout style;
}

/* Resource hints */
.resource-hint {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

/* Memory usage optimization */
.memory-optimized {
    contain: strict;
}