/**
 * Lazy Loading CSS Styles
 * Progressive loading for sections and images
 */

/* Lazy Section Loading */
.lazy-section {
  opacity: 0;
  transform: translateY(20px);
  transition: none;
}

.lazy-section.section-loaded {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.lazy-section.section-preloading {
  opacity: 0.3;
}

/* Progressive Image Loading */
img.lazy-img {
  opacity: 0;
  background: #f0f0f0;
  min-height: 200px;
  position: relative;
}

/* Desktop only - shimmer effect */
@media (min-width: 769px) {
  img.lazy-img::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 2s infinite;
  }
  
  @keyframes shimmer {
    0% { transform: translateX(0); }
    100% { transform: translateX(300%); }
  }
}

img.lazy-loaded {
  opacity: 1;
  transition: opacity 0.4s ease-in;
  background: none;
}

img.lazy-loaded::before {
  display: none;
}

/* Loading spinner for sections */
.lazy-section {
  position: relative;
  min-height: 200px;
}

.lazy-section::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--accent-color, #165b33);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  opacity: 0.3;
  z-index: 1;
}

.lazy-section.section-loaded::before {
  opacity: 0;
  animation: none;
  display: none;
}

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

/* Optimize critical content - ensure above-fold loads immediately */
#hero,
#header {
  opacity: 1 !important;
  transform: none !important;
  min-height: auto !important;
}

#hero::before,
#header::before {
  display: none !important;
}

/* Portfolio items fade in */
.portfolio-item {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.section-loaded .portfolio-item {
  opacity: 1;
  transform: scale(1);
}

/* Stagger animation for portfolio items */
.section-loaded .portfolio-item:nth-child(1) { transition-delay: 0.05s; }
.section-loaded .portfolio-item:nth-child(2) { transition-delay: 0.1s; }
.section-loaded .portfolio-item:nth-child(3) { transition-delay: 0.15s; }
.section-loaded .portfolio-item:nth-child(4) { transition-delay: 0.2s; }
.section-loaded .portfolio-item:nth-child(5) { transition-delay: 0.25s; }
.section-loaded .portfolio-item:nth-child(6) { transition-delay: 0.3s; }

/* Service boxes lazy load */
.service-box {
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.section-loaded .service-box {
  opacity: 1;
  transform: translateY(0);
}

/* Video lazy loading */
video[data-lazy-video] {
  background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
  min-height: 300px;
}

/* Performance optimization - prevent animations on low-end devices */
@media (prefers-reduced-motion: reduce) {
  .lazy-section,
  .lazy-img,
  .portfolio-item,
  .service-box {
    transition: none !important;
    animation: none !important;
  }
  
  .lazy-section::before {
    display: none !important;
  }
}

/* Mobile optimization - Disable heavy animations for performance */
@media (max-width: 768px) {
  .lazy-section {
    transform: translateY(10px);
  }
  
  img.lazy-img {
    min-height: 150px;
    animation: none !important; /* Disable shimmer on mobile */
    background: #f0f0f0; /* Simple gray background */
  }
  
  /* Faster transitions on mobile */
  .lazy-section.section-loaded {
    transition: opacity 0.3s ease-out;
  }
  
  img.lazy-loaded {
    transition: opacity 0.2s ease-in;
  }
  
  /* Remove loading spinner on mobile for better performance */
  .lazy-section::before {
    display: none !important;
  }
  
  /* Disable portfolio stagger on mobile */
  .portfolio-item {
    transition: opacity 0.2s ease !important;
  }
}

/* Performance optimization - reduce motion on request */
@media (prefers-reduced-motion: reduce) {
  .lazy-section,
  .portfolio-item,
  .service-box,
  img.lazy-loaded {
    transition: none !important;
    animation: none !important;
  }
  
  .lazy-section::before {
    display: none !important;
  }
}
