/* Styles pour la galerie de réalisations */
.page-service #gallery.section {
  /* Réduit l'espace juste sous la hero sur la page réalisations */
  padding-top: clamp(0rem, 1vw, 2rem);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 2.5rem; /* Espace augmenté */
  padding-top: 2rem;
}

.chantier-card {
  background-color: #fff;
  border-radius: 12px; /* Plus arrondi */
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  opacity: 0; /* Pour animation d'apparition */
  transform: translateY(20px);
  animation: card-fade-in 0.5s ease forwards;
}

@keyframes card-fade-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Animation en cascade pour les cartes */
.chantier-card.is-visible {
  animation-delay: var(--card-delay, 0s);
}

.chantier-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.chantier-images {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
}

.chantier-slider-wrapper {
  display: flex;
  transition: transform 0.4s ease-in-out;
  height: 100%;
}

.chantier-images img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

/* Mobile/Tablet: enable horizontal scroll with snap */
@media (max-width: 991px) {
  .chantier-slider-wrapper {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 0; /* no gaps between slides for snap */
    overscroll-behavior-x: contain; /* reduce ballistic overscroll */
  }
  .chantier-slider-wrapper::-webkit-scrollbar {
    display: none;
  }
  .chantier-images img {
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always; /* ensure it stops at each slide even on fast swipes */
  }
  .slider-nav {
    display: none; /* hide arrows on touch scroll */
  }
}

.chantier-info {
  padding: 1.5rem;
  background-color: #fff;
  flex-grow: 1; /* Permet au texte de pousser le footer vers le bas */
}

.chantier-info h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.chantier-info p {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.chantier-meta {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--dark);
}

.chantier-badge {
  display: inline-block;
  background-color: var(--primary-light);
  color: var(--primary);
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chantier-images img {
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.chantier-images img:hover {
  opacity: 0.8;
}

/* -- Nouveaux styles pour les filtres -- */
.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 2.5rem;
}

.filter-btn {
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  background-color: #f3f4f6;
  color: var(--text);
  border: 2px solid transparent;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.filter-btn:hover {
  background-color: #e5e7eb;
  color: var(--brand);
}

/* Active state: très visible */
.filter-btn.is-active {
  background: linear-gradient(45deg, var(--brand), var(--brand-light));
  color: #fff;
  border-color: #000; /* contour noir demandé */
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

/* Focus accessible + cohérent */
.filter-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #000, 0 0 0 5px rgba(0, 0, 0, 0.25);
}

/* -- Styles pour le slider dans la carte -- */

.slider-nav {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  padding: 0 0.5rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 10; /* Assure que la navigation est au-dessus des images */
  pointer-events: none; /* Ne capte pas les clics sauf sur les boutons */
}

.chantier-card:hover .slider-nav {
  opacity: 1;
}

.slider-btn {
  background-color: rgba(0, 0, 0, 0.4);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  pointer-events: auto; /* Boutons cliquables */
}

.slider-btn:hover {
  background-color: rgba(0, 0, 0, 0.7);
}

.slider-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.slider-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.3s ease;
}

.slider-dot.is-active {
  background-color: white;
  transform: scale(1.2);
}

/* Masquer les cartes pour le filtrage */
.chantier-card.is-hidden {
  display: none;
}

.gallery-cta {
  text-align: center;
  margin-top: 4rem;
  padding: 2rem;
  background-color: var(--bg-alt);
  border-radius: 8px;
}

.gallery-cta p {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  font-weight: 600;
}

/* Lightbox Styles */
.lightbox {
  display: none;
  position: fixed;
  z-index: 3000; /* Above header (1200) and sticky bars */
  padding-top: 60px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.lightbox.is-visible {
  display: block;
  opacity: 1;
}

.lightbox-content {
  margin: auto;
  display: block;
  width: auto;
  height: auto;
  max-width: 90%;
  max-height: 80vh;
  animation-name: lightbox-zoom;
  animation-duration: 0.4s;
}

@keyframes lightbox-zoom {
  from {
    transform: scale(0.8);
  }
  to {
    transform: scale(1);
  }
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
  cursor: pointer;
  user-select: none;
}

.lightbox-close {
  top: 15px;
  right: 35px;
  font-size: 50px;
}

.lightbox-prev {
  left: 2rem;
  transform: translateY(-50%);
}

.lightbox-next {
  right: 2rem;
  transform: translateY(-50%);
}

.lightbox-close:hover,
.lightbox-close:focus,
.lightbox-prev:hover,
.lightbox-prev:focus,
.lightbox-next:hover,
.lightbox-next:focus {
  color: #bbb;
  text-decoration: none;
}

#lightbox-caption {
  margin: auto;
  display: block;
  width: 80%;
  max-width: 700px;
  text-align: center;
  color: #ccc;
  padding: 10px 0;
  height: 150px;
}

@media screen and (max-width: 768px) {
  .lightbox-prev,
  .lightbox-next {
    font-size: 30px;
    padding: 10px;
  }
}
