/* Harmonisation des styles pour les galeries */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  padding: 24px 0;
  max-width: 1400px;
  margin: 0 auto;
}

.gallery-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  aspect-ratio: 16/9;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.gallery-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 60%, rgba(0,0,0,.4));
  opacity: 0;
  transition: opacity .4s ease;
  z-index: 1;
}

.gallery-item:hover::before {
  opacity: 1;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease, transform 0.3s ease;
  background: linear-gradient(45deg, rgba(255,255,255,.03), rgba(255,255,255,.06));
  transform: scale(1.01); /* Évite les bords blancs */
  filter: brightness(1);
  will-change: transform, opacity, filter;
  backface-visibility: hidden;
}

.gallery-item:hover img {
  transform: scale(1.06);
  filter: brightness(1.1);
}

.gallery-item img[loading],
.gallery-item img:not([loaded]) {
  opacity: 0.5;
  filter: blur(8px);
}

.gallery-item img[loaded] {
  opacity: 1;
  filter: none;
  transform: scale(1.01);
}

.gallery-item figcaption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 16px;
  font-size: 15px;
  line-height: 1.4;
  color: #fff;
  text-shadow: 0 1px 8px rgba(0,0,0,.3);
  background: linear-gradient(transparent, rgba(0,0,0,.6));
  transform: translateY(100%);
  transition: transform .4s cubic-bezier(.22,1,.36,1);
  z-index: 2;
}

.gallery-item:hover figcaption {
  transform: translateY(0);
}

/* Mode carrousel plein écran */
.fullscreen-carousel {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.4s;
}

.fullscreen-carousel.is-active {
  opacity: 1;
  visibility: visible;
}

.carousel-slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  opacity: 0;
  transform: scale(.96) translateY(20px);
  transition: all .6s cubic-bezier(.22,1,.36,1);
  pointer-events: none;
}

.carousel-slide.is-active {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.carousel-slide img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  opacity: 0;
  transform: scale(.98);
  transition: all .6s cubic-bezier(.22,1,.36,1);
}

.carousel-slide.is-active img {
  opacity: 1;
  transform: scale(1);
}

/* Navigation du carrousel plein écran */
.fullscreen-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  z-index: 2;
}

.fullscreen-btn {
  pointer-events: auto;
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(4px);
  border: none;
  color: #fff;
  font-size: 32px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color .3s, transform .3s, opacity .3s;
  opacity: .6;
}

.fullscreen-btn:hover {
  background: rgba(255,255,255,.2);
  opacity: 1;
  transform: scale(1.1);
}

.fullscreen-close {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  z-index: 1001;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  opacity: 0.7;
}

.fullscreen-close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: rotate(90deg) scale(1.1);
  opacity: 1;
}

.fullscreen-close:active {
  transform: rotate(90deg) scale(0.95);
}

/* Légendes en mode plein écran */
.carousel-slide figcaption {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.8);
  color: #fff;
  padding: 12px 24px;
  border-radius: 100px;
  font-size: 16px;
  opacity: 0;
  transition: all .4s ease;
  backdrop-filter: blur(10px);
  text-align: center;
  max-width: 80%;
}

.carousel-slide.is-active figcaption {
  opacity: .8;
  transform: translateX(-50%) translateY(0);
}


/* Support tactile */
@media (hover: none) {
  .gallery-item figcaption {
    transform: translateY(0);
    font-size: 12px;
    padding: 8px;
  }
  
  .fullscreen-btn {
    opacity: 0.8;
    background: rgba(255,255,255,.15);
  }
}