/**
 * Frontend styles for iWorx Speedy and More plugin
 */

/* Performance optimizations for better Core Web Vitals */
.iworx-optimized-images {
    transition: opacity 0.3s ease;
}

.iworx-optimized-images[loading="lazy"] {
    opacity: 0;
}

.iworx-optimized-images[loading="lazy"].loaded {
    opacity: 1;
}

/* Minimize layout shift (CLS) */
.iworx-sam-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

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

/* Critical CSS for above-the-fold content */
.iworx-sam-critical {
    /* This would contain critical CSS for faster rendering */
    display: block;
    visibility: visible;
}

/* Preload and prefetch optimizations */
.iworx-sam-preload {
    opacity: 1;
    visibility: visible;
}

/* Optimize font loading */
@font-face {
    font-family: 'OptimizedFont';
    src: url('font.woff2') format('woff2');
    font-display: swap; /* Improves font loading performance */
}

/* Container queries for responsive images */
@container (min-width: 768px) {
    .iworx-responsive-image {
        max-width: 100%;
        height: auto;
    }
}

/* Reduce motion for users who prefer it */
@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;
    }
}

/* Performance-focused utility classes */
.iworx-sam-lazy-load {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.iworx-sam-lazy-load.loaded {
    opacity: 1;
}

.iworx-sam-fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

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

/* Optimize scroll performance */
.iworx-sam-smooth-scroll {
    scroll-behavior: smooth;
}

/* GPU acceleration for better performance */
.iworx-sam-gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* Intersection Observer loading states */
.iworx-sam-observer-loading {
    background: #f5f5f5;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iworx-sam-observer-loading::before {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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