/* =========================================================
   Product gallery
   ========================================================= */

.product-gallery {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 1rem;
  align-items: start;
}

.product-gallery--single {
  grid-template-columns: 1fr;
}

/* The rail is as tall as the main image (the stage drives the grid row); the
   thumbnails scroll inside it, with up/down buttons when they do not all fit. */
.product-gallery__rail {
  position: relative;
  align-self: stretch;
  min-height: 0;
  width: 48px;
}

.product-gallery__thumbs {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: 2px 0;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.product-gallery__thumbs::-webkit-scrollbar {
  display: none;
}

.product-gallery__rail.has-overflow .product-gallery__thumbs {
  top: 32px;
  bottom: 32px;
}

.product-gallery__nav {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border-color, var(--gray-light));
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  transition: border-color .2s ease, opacity .2s ease;
}

.product-gallery__nav[hidden] {
  display: none;
}

.product-gallery__nav--up {
  top: 0;
}

.product-gallery__nav--down {
  bottom: 0;
}

.product-gallery__nav:hover:not(:disabled) {
  border-color: var(--primary, var(--text));
}

.product-gallery__nav:disabled {
  opacity: .35;
  cursor: default;
}

.product-gallery__thumb {
  display: block;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  padding: 0;
  margin:0 auto;
  border: 1px solid var(--border-color, var(--gray-light));
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}

.product-gallery__thumb:hover {
  transform: translateY(-1px);
  border-color: var(--primary, var(--text));
}

.product-gallery__thumb.is-active {
  border-color: var(--primary, var(--text));
  box-shadow: 0 0 0 2px var(--overlay-08);
}

.product-gallery__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-gallery__stage {
  min-width: 0;
}

.product-gallery__zoom {
  display: block;
  width: 100%;
  border: 1px solid var(--border-color, var(--gray-light));
  border-radius: 16px;
  background: var(--surface);
  overflow: hidden;
  cursor: zoom-in;
}

.product-gallery__img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: var(--surface);
}

.product-gallery__placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border-color, var(--gray-light));
  border-radius: 16px;
  background: linear-gradient(180deg, var(--surface-hover), var(--surface-disabled));
}

@media (max-width: 767px) {
  .product-gallery {
    grid-template-columns: 1fr;
  }

  .product-gallery__rail {
    order: 2;
    width: auto;
  }

  .product-gallery__thumbs,
  .product-gallery__rail.has-overflow .product-gallery__thumbs {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: .25rem;
  }

  .product-gallery__nav {
    display: none;
  }

  .product-gallery__thumb {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
  }

  .product-gallery__stage {
    order: 1;
  }
}