/* Approved product-gallery layout. The PHP switch owns both this enqueue
   and the modifier. Turning it off restores the original SSR frame/handlers. */
.vs-gallery.vs-gallery--collage {
  --vs-collage-gap: 8px;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr);
  align-items: start !important;
  gap: var(--vs-collage-gap) !important;
  width: 100%;
  max-width: 660px;
  margin-inline: auto;
}

/* The tall collage scrolls with the page, unlike the original sticky rail. */
.single-product main .wp-block-columns.alignwide > .wp-block-column:first-child:has(> .wp-block-woocommerce-product-image-gallery .vs-gallery--collage) {
  position: static;
  align-self: flex-start;
}

/* Read a tall buy panel in the page's normal flow before its bottom holds
   beside the remaining photos. Short panels hold below the sticky header.
   The columns row bounds the sticky travel; no nested scroller is needed. */
@media (min-width: 782px) {
  .single-product main .wp-block-columns.alignwide > .wp-block-column.vs-collage-buy--follow {
    position: sticky;
    align-self: flex-start;
    top: min(calc(var(--wp-admin--admin-bar--height, 0px) + 88px), calc(100vh - var(--vs-collage-buy-height) - 16px));
    top: min(calc(var(--wp-admin--admin-bar--height, 0px) + 88px), calc(100dvh - var(--vs-collage-buy-height) - 16px));
  }
}

/* The collage owns its full column and needs no rail placeholder. */
.vs-gallery--collage[data-vs-rail]::before { display: none !important; }

.vs-gallery--collage .vs-gallery__main {
  width: 100% !important;
  min-width: 0;
  max-height: none !important;
  margin: 0 !important;
  aspect-ratio: 4 / 5;
  box-shadow: none;
}

.vs-gallery--collage .vs-gallery__ghost { display: none; }
.vs-gallery--collage .vs-gallery__main-img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  object-fit: contain;
}

.vs-gallery--collage .vs-gallery__thumbs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: none;
  gap: var(--vs-collage-gap);
  width: 100% !important;
  max-height: none;
  order: 0;
  margin: 0 !important;
  overflow: visible;
  align-self: start;
}

.vs-gallery--collage .vs-gallery__thumb {
  width: 100% !important;
  min-width: 0;
  height: auto;
  aspect-ratio: 4 / 5;
  border: none;
  opacity: 1;
  transition: none;
  cursor: zoom-in;
}
.vs-gallery--collage .vs-gallery__thumb[data-i="0"] { display: none; }
.vs-gallery--collage .vs-gallery__thumb img { object-fit: contain; }

.vs-gallery--collage .vs-gallery__main:focus-visible,
.vs-gallery--collage .vs-gallery__thumb:focus-visible {
  outline: 2px solid var(--vs-scent-accent, #171311);
  outline-offset: 3px;
}
.vs-gallery--collage .vs-gallery__hint {
  grid-column: 1 / -1;
  margin: 0;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  line-height: 1.5;
  color: var(--vs-muted, #5D5148);
  text-align: center;
}

@media (max-width: 781px) {
  .vs-gallery.vs-gallery--collage { --vs-collage-gap: 6px; }
}
