/* Conteneur principal de la galerie, centré avec largeur maximale */
.gallery-wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 32px 80px;
}

/* En-tête : titre à gauche, compteur de photos à droite.
   Le compteur est mis à jour dynamiquement par JS à chaque changement de filtre. */
.gallery-head {
  padding: 52px 0 36px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}

.gallery-head-left h1 {
  font-family: "Cormorant Garamond", serif;
  font-size: 62px;
  font-weight: 500;
  color: #1d1d1d;
  margin: 0 0 8px;
  line-height: 1;
  letter-spacing: -1px;
}

.gallery-head-left p {
  color: #777;
  font-size: 14px;
  margin: 0;
  line-height: 1.6;
  max-width: 480px;
}

/* Compteur de photos : chiffre en grand (orange) + libellé en petit */
.gallery-count {
  font-family: "Cormorant Garamond", serif;
  font-size: 13px;
  color: #aaa;
  letter-spacing: 1px;
  white-space: nowrap;
  flex-shrink: 0;
  padding-bottom: 6px;
}

.gallery-count strong {
  font-size: 42px;
  font-weight: 400;
  color: var(--orange);
  line-height: 1;
  display: block;
  margin-bottom: 2px;
}

/* Boutons de filtre : inactifs par défaut, orange quand actif.
   Le JS bascule la classe "active" et appelle applyFilter au clic. */
.gallery-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid #ddd;
  color: #666;
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
  border-radius: 2px;
  text-transform: uppercase;
}

.filter-btn:hover {
  border-color: var(--orange);
  color: var(--orange);
}

.filter-btn.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

/* Pastille de comptage dans le bouton de filtre */
.filter-count {
  background: rgba(0,0,0,0.1);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.filter-btn.active .filter-count {
  background: rgba(255,255,255,0.25);
}

/* Sections : chaque groupe (Aubagne, Ollioules…) est séparé par un label et un espace */
.gallery-sections {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.gallery-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Cormorant Garamond", serif;
  font-size: 22px;
  font-weight: 500;
  color: #444;
  margin: 0 0 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ddd;
}

.section-tag {
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  background: var(--orange);
  color: #fff;
  padding: 3px 9px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Grille principale : 3 colonnes, hauteur automatique de 290px par rangée.
   grid-auto-flow:dense remplit les trous laissés par w2/h2 en réordonnant l'affichage. */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 290px;
  grid-auto-flow: row dense;
  gap: 4px;
}

.gi.w2 { grid-column: span 2; }
.gi.h2 { grid-row: span 2; }

/* Élément de la grille : fond sombre par défaut (visible pendant le chargement de l'image).
   cursor:zoom-in indique visuellement que le clic ouvre la lightbox. */
.gi {
  position: relative;
  overflow: hidden;
  cursor: zoom-in;
  background: #1a1a1a;
  margin: 0;
}

/* Les photos de produits ont un fond clair et object-fit:contain pour ne pas les rogner */
.gi[data-cat="produits"] { background: #f5f3ef; }

.gi img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.65s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gi[data-cat="produits"] img {
  object-fit: contain;
  padding: 12px;
}

/* Zoom léger au survol */
.gi:hover img {
  transform: scale(1.07);
}

/* Légende en overlay : masquée par défaut (translateY 100%), glisse en bas au survol.
   Le dégradé noir en bas assure la lisibilité du texte blanc sur l'image. */
.gi-cap {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 28px 16px 14px;
  background: linear-gradient(to top, rgba(10,8,5,0.75) 0%, transparent 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gi:hover .gi-cap {
  transform: translateY(0);
}

/* Ligne orange qui s'étend de gauche à droite sous chaque photo au survol.
   width part de 0 à 100% via transition. */
.gi::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0;
  width: 0; height: 3px;
  background: var(--orange);
  transition: width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gi:hover::after { width: 100%; }

/* Lightbox : panneau plein écran fixé (z-index 1000 pour passer au-dessus de tout).
   Invisible par défaut (opacity:0 + visibility:hidden). La classe "open" le rend visible. */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(8, 7, 5, 0.94);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
}

/* Conteneur de l'image : max 90% de la largeur et 82% de la hauteur de l'écran.
   La transition d'opacité est appliquée ici pour les changements d'image (showImage). */
.lb-img-wrap {
  max-width: min(90vw, 1100px);
  max-height: 82vh;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.lb-img-wrap img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  display: block;
}

/* Bouton de fermeture en haut à droite */
.lb-close {
  position: absolute;
  top: 20px; right: 28px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.18s;
  font-weight: 300;
}

.lb-close:hover { color: #fff; }

/* Boutons de navigation prev/next : cercles semi-transparents positionnés au centre vertical */
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7);
  width: 46px; height: 46px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  padding: 0;
}

.lb-nav:hover {
  background: rgba(232,155,42,0.2);
  border-color: rgba(232,155,42,0.4);
  color: #fff;
}

.lb-prev { left: 24px; }
.lb-next { right: 24px; }

/* Footer de la lightbox : légende et compteur "X / N" centrés en bas */
.lb-footer {
  position: absolute;
  bottom: 24px;
  left: 50%; transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.lb-caption {
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}

.lb-counter {
  color: rgba(255,255,255,0.28);
  font-size: 11px;
  letter-spacing: 2px;
}

/* Tablette : 2 colonnes, hauteur de rangée réduite.
   w2 est supprimé (trop large à 2 colonnes seulement). */
@media (max-width: 980px) {
  .gallery-wrap { padding: 0 20px 60px; }
  .gallery-head { padding: 36px 0 24px; flex-direction: column; align-items: flex-start; }
  .gallery-head-left h1 { font-size: 44px; }
  .gallery-sections { gap: 28px; }
  .gallery-section-head { font-size: 18px; }
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 240px;
  }
  .gi.w2 { grid-column: span 1; }
}

/* Mobile : 1 colonne, h2 désactivé pour uniformiser les hauteurs */
@media (max-width: 540px) {
  .gallery-head-left h1 { font-size: 34px; }
  .gallery-sections { gap: 20px; }
  .gallery-section-head { font-size: 16px; }
  .gallery-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: 260px;
  }
  .gi.h2 { grid-row: span 1; }
  /* Boutons nav rapprochés des bords sur petit écran */
  .lb-prev { left: 10px; }
  .lb-next { right: 10px; }
}

@media (max-width: 480px) {
  .gallery-wrap { padding: 0 12px 40px; }
  .gallery-head { padding: 24px 0 16px; }
  .gallery-head-left h1 { font-size: 28px; }
}
