/* Galerie fiche produit — vignettes latérales (desktop) / bandeau (mobile) */
.product-gallery {
  width: 100%;
  --gallery-thumb-size: 4.35rem;
  --gallery-thumb-gap: 0.45rem;
  --gallery-thumb-visible: 4;
  --gallery-thumb-scroll-gutter: 0.55rem;
  --gallery-thumbs-max-height: calc(
    (var(--gallery-thumb-size) * var(--gallery-thumb-visible)) +
    (var(--gallery-thumb-gap) * (var(--gallery-thumb-visible) - 1))
  );
}

.product-gallery__layout {
  display: block;
  width: 100%;
}

.product-gallery--multi .product-gallery__layout {
  display: grid;
  grid-template-columns: calc(var(--gallery-thumb-size) + var(--gallery-thumb-scroll-gutter)) minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
}

.product-gallery__figure {
  margin: 0;
  min-width: 0;
}

.product-gallery__main-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: min(52vh, 28rem);
  padding: 0.35rem;
  background: #fff;
  border: 1px solid var(--b, #e5e7eb);
  border-radius: var(--r);
  box-sizing: border-box;
}

.product-gallery__main-wrap picture {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.product-gallery__main {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  transition: opacity 0.2s ease;
}

.product-gallery__main-wrap.is-swapping .product-gallery__main {
  opacity: 0.72;
}

/* Priorité sur .product-hero__img (main.css) quand les deux classes coexistent */
.product-gallery .product-gallery__main.product-hero__img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.product-gallery__zoom-btn {
  position: absolute;
  right: var(--space-sm);
  bottom: var(--space-sm);
  width: 2.75rem;
  height: 2.75rem;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--b);
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.92);
  color: var(--p);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ease);
}

.product-gallery__zoom-btn:hover {
  background: #fff;
}

.product-gallery__thumbs-nav {
  min-width: 0;
  width: calc(var(--gallery-thumb-size) + var(--gallery-thumb-scroll-gutter));
  max-height: var(--gallery-thumbs-max-height);
  align-self: start;
}

.product-gallery__thumbs {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: var(--gallery-thumb-gap);
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-height: var(--gallery-thumbs-max-height);
  overflow-x: hidden;
  overflow-y: auto;
  direction: rtl;
  scrollbar-width: thin;
  scrollbar-color: rgba(8, 145, 178, 0.45) transparent;
}

.product-gallery__thumbs::-webkit-scrollbar {
  width: 5px;
}

.product-gallery__thumbs::-webkit-scrollbar-track {
  background: transparent;
}

.product-gallery__thumbs::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(8, 145, 178, 0.45);
}

.product-gallery__thumb-item {
  flex: 0 0 auto;
  direction: ltr;
  width: var(--gallery-thumb-size);
  margin-inline-start: auto;
}

.product-gallery__thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--gallery-thumb-size);
  height: var(--gallery-thumb-size);
  padding: 3px;
  border: 2px solid var(--b, #e5e7eb);
  border-radius: var(--r-sm);
  background: #fff;
  cursor: pointer;
  line-height: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.product-gallery__thumb.is-active {
  border-color: var(--a, #0891B2);
  box-shadow: 0 0 0 1px rgba(8, 145, 178, 0.2);
}

.product-gallery__thumb:hover {
  border-color: color-mix(in srgb, var(--a, #0891B2) 65%, var(--b, #e5e7eb));
}

.product-gallery__thumb:focus-visible {
  outline: 2px solid var(--a, #0891B2);
  outline-offset: 2px;
}

.product-gallery__thumb--variant {
  position: relative;
  flex-direction: column;
  gap: 2px;
  height: auto;
  min-height: var(--gallery-thumb-size);
  max-width: var(--gallery-thumb-size);
  text-decoration: none;
  color: inherit;
}

.product-gallery__thumb--variant:hover {
  border-color: var(--p);
}

.product-gallery__thumb-variant-label {
  display: block;
  font-size: 0.62rem;
  line-height: 1.15;
  text-align: center;
  color: var(--muted, #6b7280);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px 2px;
}

.product-gallery__thumb-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 3.75rem;
  max-height: 3.75rem;
  object-fit: contain;
  object-position: center;
  border-radius: calc(var(--r-sm) - 3px);
}

.product-gallery__thumb--config.is-active {
  border-color: var(--a, #0891B2);
  box-shadow:
    0 0 0 1px rgba(8, 145, 178, 0.2),
    inset 0 0 0 1px rgba(8, 145, 178, 0.08);
}

.product-gallery__thumb--config .product-gallery__thumb-img {
  max-width: 100%;
  max-height: 100%;
}

.product-gallery__dialog {
  border: none;
  padding: 0;
  max-width: min(96vw, 1100px);
  max-height: 92vh;
  background: transparent;
}

.product-gallery__dialog::backdrop {
  background: rgba(17, 24, 39, 0.72);
}

.product-gallery__dialog-img {
  display: block;
  max-width: 100%;
  max-height: 88vh;
  margin: 0 auto;
  border-radius: var(--r);
  background: #fff;
}

.product-gallery__dialog-close {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 2;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: var(--p);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

/* Accessoires : vignettes sous l’image (pleine largeur principale) */
.product-gallery--multi.product-gallery--thumbs-below .product-gallery__layout {
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.product-gallery--thumbs-below .product-gallery__main-wrap {
  max-height: min(56vh, 32rem);
}

.product-gallery--thumbs-below .product-gallery__thumbs-nav {
  width: 100%;
  max-height: none;
  align-self: stretch;
}

.product-gallery--thumbs-below .product-gallery__thumbs {
  flex-direction: row;
  direction: ltr;
  flex-wrap: nowrap;
  max-height: none;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.15rem;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(8, 145, 178, 0.45) transparent;
}

.product-gallery--thumbs-below .product-gallery__thumbs::-webkit-scrollbar {
  width: auto;
  height: 5px;
}

.product-gallery--thumbs-below .product-gallery__thumb-item {
  margin-inline-start: 0;
  scroll-snap-align: start;
}

@media (max-width: 767px) {
  .product-gallery--multi .product-gallery__layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 0.55rem;
  }

  .product-gallery__figure {
    order: 1;
  }

  .product-gallery__thumbs-nav {
    order: 2;
    width: 100%;
    max-height: none;
  }

  .product-gallery__thumbs {
    flex-direction: row;
    direction: ltr;
    flex-wrap: nowrap;
    max-height: none;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.15rem;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .product-gallery__thumb-item {
    scroll-snap-align: start;
    margin-inline-start: 0;
    width: var(--gallery-thumb-size);
  }
}

@media (prefers-reduced-motion: reduce) {
  .product-gallery__main {
    transition: none;
  }
}
