/* ================================================================
   galerie.css — Les Lames de la Rose
   Styles spécifiques à la page Galerie.

   TABLE DES MATIÈRES
   ------------------------------------------------------------------
   1.  Barre d'outils (filtres + compteur)
   2.  Grille principale de la galerie
   3.  Items de la grille (formats normal / large / tall)
   4.  Overlay au survol (titre + bouton commande)
   5.  Message "aucun résultat"
   6.  Lightbox (visionneuse plein écran)
   7.  Bandeau CTA "Configurer ma pièce"
   8.  Animations (entrée filtrée, transition items)
   9.  Media queries (≤ 900px)
================================================================ */


/* Cadrage dédié à la photographie verticale de la bannière Galerie. */
.gallery-page-banner .page-banner-bg {
  background-position: center 70%;
}

/* ----------------------------------------------------------------
   1. BARRE D'OUTILS
   Ligne horizontale avec les filtres à gauche et le compteur
   d'items à droite. Collée en haut de page après le scroll.
---------------------------------------------------------------- */

/* Conteneur de la toolbar */
.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.8rem 4rem;
  border-bottom: 1px solid var(--border);
  /* Colle la toolbar au sommet pendant le scroll, sous la nav fixe */
  position: sticky;
  top: 70px;                 /* Hauteur de la nav */
  z-index: 50;
  background: rgba(10, 9, 8, 0.96);
  backdrop-filter: blur(12px);
}

/* Zone des boutons de filtre */
.gallery-filters {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  /* Annule les styles de pages.css qui les centraient */
  justify-content: flex-start;
  margin-bottom: 0;
}

/* Bouton de filtre individuel */
.filter-btn {
  font-family: 'Cinzel', serif;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--white-dim);
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.55rem 1.2rem;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, background 0.25s;
  white-space: nowrap;
}

.filter-btn:hover {
  color: var(--white);
  border-color: rgba(201, 168, 76, 0.4);
}

/* Filtre actif : couleur dorée + fond légèrement doré */
.filter-btn.active {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(201, 168, 76, 0.07);
}

/* Compteur "X Créations" à droite, de la même taille que le menu */
.gallery-count {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  font-style: italic;
  color: var(--white-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Chiffre en doré */
.gallery-count span {
  color: var(--gold);
  font-weight: 300;
}


/* ----------------------------------------------------------------
   2. GRILLE PRINCIPALE
   CSS Grid 4 colonnes. Les items "large" et "tall" s'étendent
   sur plusieurs colonnes/lignes pour créer un layout éditorial.
---------------------------------------------------------------- */

/* Conteneur de la grille */
.gallery-main {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;                  /* Joints très fins entre les photos */
  /* Pas de padding : la grille va bord à bord */
}


/* ----------------------------------------------------------------
   3. ITEMS DE LA GRILLE
---------------------------------------------------------------- */

/* Item de base */
.gallery-grid-item {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  /* Transition pour le filtre (opacité + scale) */
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* ── Formats spéciaux ── */

/* Large : occupe 2 colonnes */
.gallery-grid-item.large {
  grid-column: span 2;
}

/* Tall : occupe 2 lignes */
.gallery-grid-item.tall {
  grid-row: span 2;
}

/* ── Ratio-box : force le ratio d'aspect de chaque photo ── */

/* Conteneur du ratio (empêche la photo de s'écraser) */
.gallery-grid-item .ratio-box {
  position: relative;
  width: 100%;
  /* Ratio 4:3 par défaut */
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

/* Item tall : ratio portrait 3:4 sur toute la hauteur */
.gallery-grid-item.tall .ratio-box {
  aspect-ratio: unset;       /* Annule l'aspect-ratio pour laisser height: 100% */
  height: 100%;
}

/* Item large : ratio cinémascope 16:7 */
.gallery-grid-item.large .ratio-box {
  aspect-ratio: 16 / 7;
}

/* ── Photo ── */
.gallery-grid-item .gallery-creation-image {
  position: absolute;        /* Remplit entièrement le ratio-box */
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Filtre sombre + légère teinte sépia par défaut */
  filter: brightness(0.55) sepia(0.2);
  transition: filter 0.6s ease, transform 0.8s ease;
  display: block;
}

/* Survol : éclaircit et supprime le sépia, léger zoom */
.gallery-grid-item:hover .gallery-creation-image {
  filter: brightness(0.82) sepia(0);
  transform: scale(1.05);
}

.gallery-creation-image.reel-change {
  animation: reelImageChange 0.42s ease both;
}

@keyframes reelImageChange {
  0%   { opacity: 0.45; transform: scale(1.035) translateX(8px); }
  100% { opacity: 1; transform: scale(1); }
}

/* Indicateur de pellicule, inspiré des publications multi-photos. */
.gallery-carousel-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 4;
  min-width: 48px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(240, 235, 227, 0.18);
  border-radius: 15px;
  background: rgba(8, 7, 6, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.gallery-carousel-frames {
  position: relative;
  width: 13px;
  height: 13px;
}

.gallery-carousel-frames i {
  position: absolute;
  width: 9px;
  height: 9px;
  border: 1px solid var(--white);
}

.gallery-carousel-frames i:first-child {
  top: 0;
  left: 0;
}

.gallery-carousel-frames i:last-child {
  right: 0;
  bottom: 0;
  opacity: 0.7;
}

.gallery-carousel-badge strong {
  color: var(--white);
  font-family: 'Cinzel', serif;
  font-size: 0.58rem;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.gallery-carousel-arrow {
  position: absolute;
  top: 50%;
  z-index: 5;
  width: 34px;
  height: 34px;
  padding: 0 0 3px;
  border: 1px solid rgba(240, 235, 227, 0.35);
  border-radius: 50%;
  background: rgba(8, 7, 6, 0.72);
  color: var(--white);
  font-family: Arial, sans-serif;
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.gallery-carousel-arrow--previous { left: 0.8rem; }
.gallery-carousel-arrow--next { right: 0.8rem; }

.gallery-grid-item:hover .gallery-carousel-arrow,
.gallery-carousel-arrow:focus-visible {
  opacity: 1;
}

.gallery-carousel-arrow:hover,
.gallery-carousel-arrow:focus-visible {
  border-color: var(--gold);
  background: rgba(8, 7, 6, 0.9);
}

.gallery-reel {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 5.2rem;
  z-index: 6;
  display: flex;
  flex-direction: row;
  gap: 6px;
  padding: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid rgba(240, 235, 227, 0.14);
  background: rgba(8, 7, 6, 0.56);
  backdrop-filter: blur(7px);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  scrollbar-width: none;
}

.gallery-reel::-webkit-scrollbar {
  display: none;
}

.gallery-grid-item:hover .gallery-reel,
.gallery-reel:focus-within {
  opacity: 1;
  transform: translateY(0);
}

.gallery-reel-thumbnail {
  position: relative;
  width: 46px;
  height: 36px;
  flex: 0 0 36px;
  padding: 0;
  overflow: hidden;
  border: 1px solid transparent;
  background: var(--black);
  cursor: pointer;
  opacity: 0.62;
  transition: opacity 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.gallery-reel-thumbnail img {
  position: static;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: none;
  transform: none;
}

.gallery-reel-thumbnail:hover,
.gallery-reel-thumbnail:focus-visible,
.gallery-reel-thumbnail.active {
  border-color: var(--gold);
  opacity: 1;
  transform: translateY(3px);
}

.gallery-reel-status {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  background: rgba(8, 7, 6, 0.68);
  backdrop-filter: blur(5px);
}

.gallery-reel-counter {
  color: var(--white);
  font-family: 'Cinzel', serif;
  font-size: 0.52rem;
  letter-spacing: 0.11em;
  white-space: nowrap;
}

.gallery-reel-progress {
  display: block;
  width: 38px;
  height: 1px;
  overflow: hidden;
  background: rgba(240, 235, 227, 0.3);
}

.gallery-reel-progress-value {
  display: block;
  height: 100%;
  background: var(--gold);
  transition: width 0.3s ease;
}

/* Item masqué par le filtre : retiré du flux pour que la grille se réorganise. */
.gallery-grid-item.hidden {
  display: none;
}


/* ----------------------------------------------------------------
   4. OVERLAY AU SURVOL
   Fond semi-transparent du bas, avec titre + sous-titre +
   bouton "Commander →" qui apparaissent.
---------------------------------------------------------------- */

/* Overlay couvrant toute la photo */
.gallery-grid-item .item-overlay {
  position: absolute;
  inset: 0;
  /* Dégradé du bas vers le haut : opaque en bas, transparent en haut */
  background: linear-gradient(
    to top,
    rgba(10, 9, 8, 0) 0%,
    rgba(10, 9, 8, 0) 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 1.6rem;
  transition: background 0.4s ease;
}

/* Au survol : dégradé visible */
.gallery-grid-item:hover .item-overlay {
  background: linear-gradient(
    to top,
    rgba(10, 9, 8, 0.85) 0%,
    rgba(10, 9, 8, 0.1)  60%,
    rgba(10, 9, 8, 0)    100%
  );
}

/* Bloc texte (titre + sous-titre) dans l'overlay */
.item-overlay-text {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.35s ease 0.05s, transform 0.35s ease 0.05s;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.gallery-grid-item:hover .item-overlay-text {
  opacity: 1;
  transform: translateY(0);
}

/* Titre de la photo */
.item-overlay-text span {
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--white);
  display: block;
  margin-bottom: 0.25rem;
}

/* Sous-titre (matériau, finition…) */
.item-overlay-text small {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 0.82rem;
  color: var(--gold);
  display: block;
}

/* Bouton "Commander →" dans l'overlay */
.item-overlay-btn {
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--black);
  background: var(--gold);
  padding: 0.5rem 1rem;
  text-decoration: none;
  display: inline-block;
  margin-top: 0.8rem;
  /* Décalé et invisible par défaut, apparaît après le texte */
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease 0.1s, transform 0.35s ease 0.1s,
              background 0.2s;
  flex-shrink: 0;
}

.gallery-grid-item:hover .item-overlay-btn {
  opacity: 1;
  transform: translateY(0);
}

.item-overlay-btn:hover {
  background: var(--gold-light);
}


/* ----------------------------------------------------------------
   5. MESSAGE "AUCUN RÉSULTAT"
   Affiché par le JS quand un filtre ne trouve aucune photo.
---------------------------------------------------------------- */
.gallery-empty {
  text-align: center;
  padding: 6rem 4rem;
  border-top: 1px solid var(--border);
}

.gallery-empty svg {
  display: block;
  margin: 0 auto 1.5rem;
}

.gallery-empty p {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.1rem;
  color: rgba(240, 235, 227, 0.35);
}


/* ----------------------------------------------------------------
   6. LIGHTBOX — VISIONNEUSE PLEIN ÉCRAN
   S'ouvre au clic sur une photo. Navigation précédent / suivant
   par boutons, flèches clavier ou swipe (géré en JS).
---------------------------------------------------------------- */

/* Fond sombre de la lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(5, 4, 4, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Invisible par défaut */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  backdrop-filter: blur(8px);
}

/* Lightbox ouverte (classe ajoutée par le JS) */
.lightbox-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Bouton fermeture × (coin supérieur droit) */
.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: transparent;
  border: 1px solid rgba(240, 235, 227, 0.2);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  z-index: 10;
}

.lightbox-close:hover {
  border-color: var(--gold);
  background: rgba(201, 168, 76, 0.1);
}

/* Boutons navigation (précédent / suivant) */
.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 1px solid rgba(240, 235, 227, 0.15);
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  z-index: 10;
}

.lightbox-prev { left: 1.5rem; }
.lightbox-next { right: 1.5rem; }

.lightbox-prev:hover,
.lightbox-next:hover {
  border-color: var(--gold);
  background: rgba(201, 168, 76, 0.1);
}

/* Conteneur de l'image centrale */
.lightbox-img-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  max-height: 90vh;
}

/* Image affichée dans la lightbox */
.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  display: block;
  /* Animation d'entrée : fondu + léger zoom */
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Image chargée et visible */
.lightbox-img.loaded {
  opacity: 1;
  transform: scale(1);
}

/* Légende sous l'image (titre + sous-titre) */
.lightbox-caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin-top: 1.2rem;
  text-align: center;
}

.lightbox-title {
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--white);
}

.lightbox-sub {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 0.88rem;
  color: var(--gold);
}

/* Compteur "3 / 12" en bas de l'écran */
.lightbox-counter {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  color: rgba(240, 235, 227, 0.35);
}


/* ----------------------------------------------------------------
   7. BANDEAU CTA
   Section avec fond et appel à l'action vers la page commandes.
---------------------------------------------------------------- */
.gallery-cta {
  border-top: 1px solid var(--border);
  background: var(--dark-card);
  padding: 5rem 4rem;
  text-align: center;
}

.gallery-cta-inner {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.gallery-cta h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 300;
  line-height: 1.3;
  color: var(--white);
}

/* Bouton .btn-gold réutilisé depuis style.css */


/* ----------------------------------------------------------------
   8. ANIMATIONS
---------------------------------------------------------------- */

/* Classe ajoutée dynamiquement par le JS sur les items filtrés.
   Crée une légère animation d'entrée quand une catégorie est affichée. */
.gallery-grid-item.filter-enter {
  animation: filterIn 0.4s ease forwards;
}

@keyframes filterIn {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}


/* ----------------------------------------------------------------
   9. MEDIA QUERIES (≤ 900px)
---------------------------------------------------------------- */
@media (max-width: 900px) {

  /* Sur écran vertical, conserve les étincelles, la lame et les mains visibles. */
  .gallery-page-banner .page-banner-bg {
    background-position: center 65%;
  }

  /* Toolbar en colonne sur mobile */
  .gallery-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.2rem 1.5rem;
    top: 65px;
  }

  /* Compteur aligné à droite sur mobile */
  .gallery-count {
    align-self: flex-end;
  }

  /* Grille : 2 colonnes au lieu de 4 */
  .gallery-main {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Sur mobile, tous les items ont le même format (plus de large/tall) */
  .gallery-grid-item.large,
  .gallery-grid-item.tall {
    grid-column: span 1;
    grid-row: span 1;
  }

  .gallery-grid-item .ratio-box,
  .gallery-grid-item.tall .ratio-box,
  .gallery-grid-item.large .ratio-box {
    aspect-ratio: 4 / 3;
    height: auto;
  }

  /* Sur mobile, toujours montrer l'overlay (pas de hover) */
  .gallery-grid-item .item-overlay {
    background: linear-gradient(
      to top,
      rgba(10, 9, 8, 0.7) 0%,
      transparent 60%
    );
  }

  .item-overlay-text {
    opacity: 1;
    transform: translateY(0);
  }

  /* Masque le bouton "Commander" sur mobile (pas assez de place) */
  .item-overlay-btn {
    display: none;
  }

  .gallery-carousel-arrow {
    opacity: 0.88;
  }

  .gallery-reel {
    opacity: 1;
    transform: translateY(0);
  }

  /* CTA */
  .gallery-cta {
    padding: 3rem 1.5rem;
  }

  /* Boutons nav lightbox plus petits */
  .lightbox-prev,
  .lightbox-next {
    width: 38px;
    height: 38px;
  }

  .lightbox-prev { left: 0.5rem; }
  .lightbox-next { right: 0.5rem; }
}

@media (max-width: 480px) {
  /* 1 colonne sur très petits écrans */
  .gallery-main {
    grid-template-columns: 1fr;
  }
}
