/* ========================================
   OPTIMISATIONS IMAGES - Performance & UX
   ======================================== */

/* === Optimisations générales === */
img {
  max-width: 100%;
  height: auto;
  display: block;
  
  /* Optimisations de rendu */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: optimize-contrast;
  
  /* Transition fluide pour le lazy loading */
  transition: opacity 0.3s ease-in-out;
}

/* Images en cours de chargement */
img[loading="lazy"] {
  opacity: 0;
}

/* Images chargées */
img[loading="lazy"].loaded,
img[loading="eager"] {
  opacity: 1;
}

/* === Picture element optimisé === */
picture {
  display: block;
  width: 100%;
}

picture img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* === Optimisations spécifiques === */

/* Images de galerie */
.gallery-image {
  width: 100%;
  height: 300px;
  object-fit: cover;
  border-radius: 8px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-image:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* Images de preview sur l'accueil */
.gallery-preview-image {
  width: 100%;
  height: 250px;
  object-fit: cover;
  border-radius: 6px;
}

/* Image portrait */
.portrait-image {
  width: 100%;
  max-width: 400px;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* === Optimisations responsive === */
@media (max-width: 768px) {
  .gallery-image {
    height: 200px;
  }
  
  .gallery-preview-image {
    height: 180px;
  }
  
  .portrait-image {
    max-width: 300px;
  }
}

/* === Optimisations pour écrans haute densité === */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  picture img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* === Skeleton loader pour les images === */
.image-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 8px;
}

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

/* === Support des formats modernes === */
/* WebP sera géré via JavaScript pour le background de hero */

/* === Optimisations de performance === */
.galerie-grid {
  /* Utilise GPU pour l'animation */
  transform: translateZ(0);
  will-change: scroll-position;
}

.galerie-item {
  /* Évite les reflows */
  contain: layout style paint;
}

/* === Mode sombre (économie d'énergie) === */
@media (prefers-color-scheme: dark) {
  img {
    filter: brightness(0.9);
  }
}

/* === Réduction des animations (accessibilité) === */
@media (prefers-reduced-motion: reduce) {
  img {
    transition: none;
  }
  
  .gallery-image:hover {
    transform: none;
  }
  
  .image-skeleton {
    animation: none;
  }
}