/**
 * Image Optimization Styles
 * Handles loading states, lazy loading effects, and responsive images
 */

/* Lazy loading states */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

img.loading {
    opacity: 0;
    background: linear-gradient(90deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

img.loaded {
    opacity: 1;
}

/* Loading shimmer animation */
@keyframes loading-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Responsive image containers */
.img-container {
    position: relative;
    overflow: hidden;
    background-color: #1a1a1a;
}

.img-container::before {
    content: '';
    display: block;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
}

.img-container.aspect-1-1::before {
    padding-bottom: 100%; /* 1:1 aspect ratio */
}

.img-container.aspect-4-3::before {
    padding-bottom: 75%; /* 4:3 aspect ratio */
}

.img-container.aspect-3-2::before {
    padding-bottom: 66.67%; /* 3:2 aspect ratio */
}

.img-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Technology logo optimization */
.tech-logo {
    max-width: 100%;
    height: auto;
    filter: brightness(1.1) contrast(1.05);
    transition: filter 0.3s ease;
}

.tech-logo:hover {
    filter: brightness(1.2) contrast(1.1);
}

/* Banner image optimization */
.banner-img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 255, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.banner-img:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 255, 0, 0.2);
}

/* Matrix theme image effects */
.matrix-img {
    border: 1px solid #00ff00;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
    filter: hue-rotate(120deg) saturate(1.2);
}

/* Placeholder styles */
.img-placeholder {
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    min-height: 200px;
    border: 1px dashed #00ff00;
}

.img-placeholder::before {
    content: '⚡ Carregando...';
}

/* Error state */
.img-error {
    background: #2a1a1a;
    color: #ff6b6b;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    border: 1px dashed #ff6b6b;
}

.img-error::before {
    content: '⚠ Imagem não disponível';
}

/* Progressive enhancement for modern formats */
.supports-webp .webp-fallback {
    display: none;
}

.supports-avif .avif-fallback {
    display: none;
}

/* Responsive images */
img {
    max-width: 100%;
    height: auto;
}

/* Picture element styling */
picture {
    display: block;
    width: 100%;
}

picture img {
    width: 100%;
    height: auto;
}

/* Critical images (above the fold) */
.critical-img {
    opacity: 1 !important;
    transition: none !important;
}

/* Fade-in animation for loaded images */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.img-fade-in {
    animation: fadeIn 0.6s ease-out;
}

/* Blur-up effect for progressive loading */
.img-blur-up {
    filter: blur(5px);
    transition: filter 0.3s ease;
}

.img-blur-up.loaded {
    filter: blur(0);
}

/* High DPI display optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .tech-logo,
    .banner-img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print styles */
@media print {
    img {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
    }
    
    .img-container::before {
        display: none;
    }
    
    .img-container img {
        position: static;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    img,
    .img-container,
    .banner-img,
    .tech-logo {
        transition: none !important;
        animation: none !important;
    }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .img-placeholder {
        background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    }
    
    .img-error {
        background: #1a0a0a;
    }
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    .img-container {
        margin-bottom: 1rem;
    }
    
    .tech-logo {
        max-height: 60px;
    }
    
    .banner-img {
        border-radius: 4px;
    }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .tech-logo {
        max-height: 80px;
    }
}

/* Desktop optimizations */
@media (min-width: 1025px) {
    .tech-logo {
        max-height: 100px;
    }
    
    .img-container:hover img {
        transform: scale(1.02);
        transition: transform 0.3s ease;
    }
}