/**
 * Enhanced CSS for improved image loading and responsive design
 * Better user experience with lazy loading and optimized images
 */

/* Profile photo enhancements */
.profile-photo {
    transition: opacity 0.3s ease-in-out, transform 0.3s ease;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.profile-photo:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* Loading states */
.profile-photo[data-src] {
    opacity: 0.3;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

.profile-photo.loaded {
    opacity: 1;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Picture element enhancements */
picture {
    display: block;
    overflow: hidden;
    border-radius: inherit;
}

picture img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    transition: inherit;
}

/* Responsive image containers */
.image-container {
    position: relative;
    display: inline-block;
    overflow: hidden;
}

.image-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.image-container:hover::before {
    opacity: 1;
    animation: shine 0.6s ease-out;
}

@keyframes shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Error fallback */
.profile-photo.error {
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    min-height: 120px;
}

/* WebP support detection */
.no-webp picture source[type="image/webp"] {
    display: none;
}

/* Lazy loading intersection observer support */
.lazy {
    opacity: 0;
    transition: opacity 0.3s;
}

.lazy.loaded {
    opacity: 1;
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .profile-photo {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .profile-photo {
        box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
    }
    
    .profile-photo:hover {
        box-shadow: 0 6px 20px rgba(255, 255, 255, 0.2);
    }
    
    .profile-photo.error {
        background-color: #212529;
        border-color: #495057;
        color: #adb5bd;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .profile-photo {
        transition: none;
    }
    
    .profile-photo:hover {
        transform: none;
    }
    
    .loading {
        animation: none;
    }
    
    .image-container::before {
        animation: none;
    }
}

/* Focus accessibility */
.profile-photo:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .profile-photo {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .profile-photo:hover {
        transform: none;
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .profile-photo {
        max-width: 120px;
        max-height: 120px;
    }
}

@media (max-width: 480px) {
    .profile-photo {
        max-width: 100px;
        max-height: 100px;
    }
}

/* Performance optimizations */
.profile-photo {
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Container query support (future-proofing) */
@container (max-width: 300px) {
    .profile-photo {
        max-width: 80px;
        max-height: 80px;
    }
}
