/* Gallery System Styles - Extracted from main.js for better performance */

/* Désactiver TOUTES les transitions hover sur mobile en global */
@media (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: transparent !important;
  }

  .gallery-item,
  .gallery-item *,
  .gallery-item img,
  .gallery-item-container,
  .gallery-item-container img,
  img {
    transition: none !important;
    transform: none !important;
  }

  .gallery-item:hover img,
  .gallery-item:active img,
  .gallery-item-container:hover img,
  .gallery-item-container:active img {
    transform: none !important;
  }

  /* Conserver le centrage du bouton lecture malgré la remise à zéro globale */
  .video-play-button {
    transform: translate(-50%, -50%) !important;
  }
}

/* Centrage du texte de la section */
.gallery-section h2,
.gallery-section p {
  text-align: center;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* Style du curseur personnalisé pour l'effet bite */
.bite-container {
  position: relative;
}

.bite-container img:not(.gallery-item img) {
  cursor: url("../cursor.svg") 20 20, pointer;
}

.bite-container img:not(.gallery-item img):hover {
  cursor: url("../cursor.svg") 20 20, pointer !important;
}

/* Style des onglets de filtrage */
.gallery-tabs {
  justify-content: flex-start !important;
  margin-top: 32px;
  margin-bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 8px;
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
}

/* Style des onglets comme navigation-link */
.gallery-tab {
  font-family: Quicksand, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  border-radius: 100px;
  display: inline-block;
}

.gallery-tab:not(.active):hover {
  background-color: #094a3c12;
}

.gallery-tab.active {
  font-weight: 700;
}

/* Marge supérieure du conteneur de la galerie */
.gallery-container {
  margin-top: 8px;
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) !important;
  gap: 16px !important;
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
}

/* Border radius des items de la galerie */
.gallery-item {
  border-radius: var(--radius--lg);
  overflow: hidden;
}

/* Ratio des images - garder le ratio original sans forcer 4:5 */
.gallery-item-container {
  position: relative;
  display: inline-block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.gallery-item-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Activer hover uniquement sur desktop */
@media (hover: hover) and (pointer: fine) {
  .gallery-item-container img {
    transition: transform 0.5s ease;
  }

  .gallery-item:hover img {
    transform: scale(1.05);
  }

  /* Webflow cell hover - désactiver sur mobile */
  .cell {
    transition: transform .5s ease-in-out;
  }

  .cell:hover {
    transform: scale(1.05);
  }
}

.gallery-item-video .gallery-item-container img {
  filter: brightness(0.85);
}

/* Activer transitions et hover uniquement sur desktop */
@media (hover: hover) and (pointer: fine) {
  .gallery-item-video .gallery-item-container img {
    transition: transform 0.5s ease, filter 0.3s ease;
  }

  .gallery-item-video:hover .gallery-item-container img {
    filter: brightness(1);
  }
}

.video-play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  z-index: 2;
}

.video-play-button svg {
  display: block;
}

/* Désactiver hover sur mobile pour éviter sticky hover */
@media (hover: hover) and (pointer: fine) {
  .video-play-button:hover svg circle {
    fill: rgba(0, 0, 0, 0.75);
  }
}

.video-play-button:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 4px;
  border-radius: 50%;
}

.lightbox-video {
  display: none;
  background-color: #000;
}

/* Version mobile : utilisation de la structure w-row */
@media (max-width: 768px) {
  #portfolio .w-layout-blockcontainer.main-container.w-container > *:not(.gallery-tabs):not(.gallery-container) {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  #portfolio .w-layout-blockcontainer.main-container.w-container {
    max-width: 100vw !important;
    width: 100vw !important;
    margin-left: -20px !important;
    margin-right: -20px !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    overflow: visible !important;
  }

  #portfolio {
    overflow: visible !important;
    width: 100vw !important;
    position: relative !important;
    left: 50% !important;
    right: 50% !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
  }

  /* Sortir la galerie du flux normal pour éviter les contraintes du main-container */
  .gallery-section {
    position: relative;
    overflow: visible !important;
    width: 100vw !important;
    max-width: 100vw !important;
    box-sizing: border-box;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: -20px !important;
    margin-right: -20px !important;
  }

  /* Filtres sur une ligne scrollable en mobile */
  .gallery-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    padding: 0;
    margin-bottom: 8px;
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
  }

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

  .gallery-tab {
    flex: 0 0 auto;
    margin-right: 8px;
  }

  .gallery-tab:first-child {
    margin-left: 20px;
  }

  .gallery-tab:last-child {
    margin-right: 20px;
  }

  /* Photos sur une ligne scrollable */
  .gallery-container {
    display: flex !important;
    flex-wrap: nowrap !important;
    padding: 0;
    margin-bottom: 16px;
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    gap: 16px;
    overflow-x: auto;
    overflow-y: visible;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
  }

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

  .gallery-item {
    flex: 0 0 auto;
    width: 80vw;
    max-width: 300px;
    min-height: 100vw;
    white-space: normal;
  }

  .gallery-item:first-child {
    margin-left: 20px;
  }

  .gallery-item:last-child {
    margin-right: 20px;
  }

  .gallery-item-container {
    height: 100%;
  }
}

/* Style de la lightbox - override des styles inline de index.html */
.lightbox {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background-color: rgba(0, 0, 0, 0.9) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 1000 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.3s ease !important;
}

.lightbox.active {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.lightbox-content {
  position: relative !important;
  max-width: 90% !important;
  max-height: 90% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-direction: column !important;
  gap: 16px !important;
  padding: 0 !important;
}

.lightbox-img-container {
  position: relative !important;
  width: min(50.625vh, 540px) !important;
  aspect-ratio: 9 / 16 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  border-radius: var(--radius--lg) !important;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5) !important;
  background-color: #000 !important;
}

.lightbox-media {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

.lightbox-img {
  display: block;
}

.lightbox-close {
  position: fixed !important;
  top: 20px !important;
  right: 20px !important;
  color: white !important;
  cursor: pointer !important;
  background: rgba(0, 0, 0, 0.5) !important;
  border: none !important;
  outline: none !important;
  width: 50px !important;
  height: 50px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  z-index: 1005 !important;
  line-height: 1 !important;
  transition: background 0.3s ease !important;
  pointer-events: auto !important;
}

.lightbox-close:hover {
  background: rgba(0, 0, 0, 0.25) !important;
}

.lightbox-close svg {
  width: 24px !important;
  height: 24px !important;
  display: block !important;
}

.lightbox-nav {
  position: fixed !important;
  top: 50% !important;
  left: 0 !important;
  right: 0 !important;
  width: 100vw !important;
  display: flex !important;
  justify-content: space-between !important;
  transform: translateY(-50%) !important;
  pointer-events: none !important;
  z-index: 1002 !important;
}

.lightbox-prev,
.lightbox-next {
  color: white !important;
  cursor: pointer !important;
  background: rgba(0, 0, 0, 0.5) !important;
  border: none !important;
  outline: none !important;
  width: 60px !important;
  height: 60px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  pointer-events: auto !important;
  line-height: 1 !important;
  transition: background 0.3s ease !important;
  z-index: 1005 !important;
}

.lightbox-prev {
  margin-left: 20px !important;
}

.lightbox-next {
  margin-right: 20px !important;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(0, 0, 0, 0.8) !important;
}

.lightbox-prev svg,
.lightbox-next svg {
  width: 32px !important;
  height: 32px !important;
  display: block !important;
}

.lightbox-title {
  color: white;
  font-family: var(--font-family-heading);
  font-size: 1.5rem;
  text-align: center;
  max-width: 80%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  line-height: 1.2;
  min-height: 3.6rem;
}

/* Progress bar container - cachée par défaut (desktop) */
.lightbox-progress-container {
  display: none;
}

.lightbox-tap-left,
.lightbox-tap-right {
  display: none;
}

/* Style du bouton "Voir plus" */
.gallery-load-more {
  grid-column: 1 / -1;
  margin: 32px auto 0;
  padding: 14px 32px;
  background-color: #094a3c;
  color: white;
  font-family: Quicksand, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
  outline: none;
  display: block;
}

.gallery-load-more:hover:not(:disabled) {
  background-color: #0a5a48;
  transform: translateY(-2px);
}

.gallery-load-more:active:not(:disabled) {
  transform: translateY(0);
}

.gallery-load-more:disabled {
  background-color: #888;
  cursor: not-allowed;
  opacity: 0.6;
}

@media (max-width: 768px) {
  /* Désactiver toutes transitions hover sur mobile */
  .cell {
    transition: none !important;
  }

  .cell:hover {
    transform: none !important;
  }

  /* Mobile Stories Mode: Plein écran */
  .lightbox {
    background-color: #000 !important;
  }

  .lightbox-content {
    max-width: 100% !important;
    max-height: 100% !important;
    width: 100vw !important;
    height: 100vh !important;
    gap: 0 !important;
    padding: 0 !important;
    position: relative !important;
    z-index: 1 !important;
  }

  .lightbox-img-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    aspect-ratio: unset !important;
    border-radius: 0 !important;
    max-height: 100vh !important;
    z-index: 1000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none !important;
  }

  .lightbox-media {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center center !important;
    position: relative !important;
    z-index: 1 !important;
    border-radius: 0 !important;
  }

  .lightbox-img {
    border-radius: 0 !important;
  }

  /* Masquer les contrôles vidéo natifs sur mobile (Stories mode) */
  .lightbox-video::-webkit-media-controls {
    display: none !important;
  }

  .lightbox-video::-webkit-media-controls-enclosure {
    display: none !important;
  }

  .lightbox-video::-webkit-media-controls-panel {
    display: none !important;
  }

  .lightbox-video::--webkit-media-controls-play-button {
    display: none !important;
  }

  .lightbox-video::-webkit-media-controls-start-playback-button {
    display: none !important;
  }

  /* Progress bar container (Stories-style) */
  .lightbox-progress-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    display: flex !important;
    gap: 4px !important;
    padding: 24px 16px 64px 16px !important;
    z-index: 1004 !important;
    pointer-events: none !important;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0) 100%) !important;
  }

  .lightbox-progress-bar {
    flex: 1 !important;
    background: rgba(255, 255, 255, 0.4) !important;
    border-radius: 9999px !important;
    overflow: hidden !important;
    position: relative !important;
    height: 3px !important;
  }

  .lightbox-progress-fill {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    height: 100% !important;
    background: white !important;
    width: 0 !important;
    transition: none !important;
    border-radius: 9999px !important;
  }

  .lightbox-progress-fill.completed {
    width: 100% !important;
  }

  /* Titre avec gradient overlay en bas */
  .lightbox-title {
    position: fixed !important;
    bottom: 0px !important;
    left: 0 !important;
    right: 0 !important;
    font-size: 1.4rem !important;
    font-weight: 600 !important;
    color: white !important;
    padding: 32px 16px 32px 16px !important;
    margin: 0 !important;
    max-width: 100% !important;
    display: block !important;
    text-align: center !important;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.3) 100%) !important;
    text-shadow: 0px 4px 30px rgba(0, 0, 0, 0.3) !important;
    line-height: 1.35 !important;
    word-break: break-word !important;
    z-index: 1004 !important;
    pointer-events: none !important;
    overflow: visible !important;
    -webkit-line-clamp: unset !important;
    -webkit-box-orient: unset !important;
    transform: translateY(0) !important;
    opacity: 1 !important;
  }

  @keyframes fadeUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1 !important;
      transform: translateY(0) !important;
    }
  }

  /* Bouton close repositionné */
  .lightbox-close {
    position: fixed !important;
    top: 49px !important;
    right: 16px !important;
    width: 40px !important;
    height: 40px !important;
    background: rgba(0, 0, 0, 0.15) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    z-index: 9999 !important;
    pointer-events: auto !important;
  }

  .lightbox-close svg {
    width: 20px !important;
    height: 20px !important;
  }

  /* Navigation cachée, remplacée par tap zones */
  .lightbox-nav {
    display: none !important;
  }

  .lightbox-prev,
  .lightbox-next {
    display: none !important;
  }

  /* Tap zones invisibles pour navigation */
  .lightbox-tap-left,
  .lightbox-tap-right {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 35% !important;
    z-index: 1003 !important;
    cursor: pointer !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .lightbox-tap-left {
    left: 0 !important;
    /* DEBUG */
    /* background: rgba(255, 0, 0, 0.2) !important; */
  }

  .lightbox-tap-right {
    right: 0 !important;
    /* DEBUG */
    /* background: rgba(0, 0, 255, 0.2) !important; */
  }

  .testimonials-gradient-left,
  .testimonials-gradient-right {
    display: none !important;
  }
}

/* Animation du conteneur galerie (style animtext Webflow) */
@keyframes mobileGalleryAnimText {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* État initial du conteneur avant animation (mobile) */
.gallery-container.gallery-before-animate {
  opacity: 0;
  transform: translateY(20px);
}

/* Mobile: button sous la galerie horizontale */
@media (max-width: 768px) {
  /* Appliquer l'animation uniquement sur mobile */
  .gallery-container.gallery-animate {
    animation: mobileGalleryAnimText 1s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
  }
  .gallery-load-more {
    margin: 20px auto 0;
    grid-column: auto;
    width: calc(100% - 40px);
    max-width: 300px;
    background: none;
    color: var(--color-primary);
    /* Désactiver toutes les animations Webflow sur mobile */
    animation: none !important;
    transition: none !important;
  }

  .gallery-load-more:hover:not(:disabled) {
    background: none;
    transform: none;
  }

}
