/* Performance and Loading Optimizations */

/* Critical above-the-fold styles */
.header {
    contain: layout style;
    will-change: transform;
}

.hero-section {
    contain: layout;
}

/* Optimize images for performance */
img {
    will-change: transform;
    transition: transform 0.2s ease;
}

img:hover {
    transform: scale(1.02);
}

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

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Lazy loading placeholder */
[data-lazy] {
    background: linear-gradient(90deg, #f0f0f0 25%, transparent 37%, #f0f0f0 63%);
    background-size: 400% 100%;
    animation: loading 1.4s ease infinite;
}

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

/* Critical rendering optimizations */
.critical-render {
    content-visibility: auto;
    contain-intrinsic-size: 200px;
}

/* Reduce layout shifts */
.aspect-ratio-16-9 {
    aspect-ratio: 16 / 9;
    width: 100%;
    height: auto;
}

.aspect-ratio-1-1 {
    aspect-ratio: 1 / 1;
    width: 100%;
    height: auto;
}

/* Optimize animations for 60fps */
@media (prefers-reduced-motion: no-preference) {
    .smooth-transition {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Memory optimization for mobile */
@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }
    
    /* Reduce complexity on mobile */
    .complex-animation {
        animation: none;
    }
    
    /* Optimize images for mobile */
    img {
        image-rendering: optimizeQuality;
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Print optimizations */
@media print {
    .no-print {
        display: none !important;
    }
    
    .print-break {
        page-break-after: always;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}