/**
 * Lazy Loading Styles
 * Progressive image loading with smooth transitions
 */

/* Base styles for lazy-loaded images */
img[data-src],
img.lazy {
  opacity: 0;
  transition: opacity 0.3s ease-in-out, filter 0.3s ease-in-out;
  filter: blur(5px);
}

/* Loading state */
img.lazy-loading {
  opacity: 0.5;
  filter: blur(3px);
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* Loaded state */
img.lazy-loaded {
  opacity: 1;
  filter: blur(0);
}

/* Error state */
img.lazy-error {
  opacity: 0.3;
  filter: grayscale(100%);
  position: relative;
}

img.lazy-error::after {
  content: '⚠';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2em;
  color: #999;
}

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

/* Responsive image container */
.image-container {
  position: relative;
  overflow: hidden;
  background-color: #f5f5f5;
}

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

.aspect-ratio-4-3 {
  padding-bottom: 75%;
}

.aspect-ratio-1-1 {
  padding-bottom: 100%;
}

.aspect-ratio-3-2 {
  padding-bottom: 66.67%;
}

/* Absolute positioned images within containers */
.image-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

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

/* Gallery specific lazy loading */
.gallery-grid img[data-src] {
  min-height: 200px;
  background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

/* Blur-up technique for hero images */
.hero-image-container {
  position: relative;
  overflow: hidden;
}

.hero-image-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  filter: blur(20px);
  transform: scale(1.1);
  opacity: 1;
  transition: opacity 0.3s ease-out;
}

.hero-image-main {
  position: relative;
  z-index: 1;
}

.hero-image-main.lazy-loaded ~ .hero-image-placeholder {
  opacity: 0;
}

/* Progressive enhancement for native lazy loading */
@supports (loading: lazy) {
  img[loading="lazy"] {
    opacity: 1;
    filter: none;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  img[data-src],
  img.lazy,
  img.lazy-loading,
  img.lazy-loaded {
    transition: none;
    animation: none;
  }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .image-container {
    background-color: #1a1a1a;
  }
  
  img.lazy-loading {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
  }
  
  .gallery-grid img[data-src] {
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
  }
}