/* Shared treatment for every storefront gallery, using the selected site's theme. */
#product-photo-grid {
  --text: var(--text-main);
  --muted: var(--text-muted);
  overflow-y: auto;
  --gallery-gutter: clamp(1rem, 3vw, 2.2rem);
  --gallery-photo-max-height: min(32rem, calc(100dvh - 7rem));
  padding-block: var(--gallery-gutter);
  padding-inline: max(var(--gallery-gutter), (100% - var(--site-content-max, 90rem)) / 2);
}

#product-photo-grid .photo-grid-header {
  align-items: center;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

#product-photo-grid .photo-grid-header h2 {
  color: var(--text-main);
  font-size: clamp(1.5rem, 3vw, 2.15rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
}

#product-photo-grid .photo-grid-item {
  border: 0;
  background: transparent;
  box-shadow: none;
}

#product-photo-grid .photo-grid-item img {
  justify-self: start;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: var(--gallery-photo-max-height);
  object-fit: contain;
  border-radius: .45rem;
}

#product-photo-grid-status { color: var(--text-main); }

#product-photo-grid .photo-grid-stage {
  position: relative;
  display: grid;
  justify-self: start;
  min-width: 0;
  max-width: 100%;
}

#product-photo-grid .photo-grid-stage[data-sized],
#product-photo-grid .photo-grid-stage[data-unavailable] {
  width: min(100%, var(--gallery-cover-width, 14rem), calc(var(--gallery-photo-max-height) * var(--gallery-cover-ratio, 1.33)));
  aspect-ratio: var(--gallery-cover-ratio, 1.33);
}

#product-photo-grid .photo-grid-stage[data-sized] img,
#product-photo-grid .photo-grid-stage[data-unavailable] img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-position: right bottom;
}

#product-photo-grid .gallery-slide-controls {
  position: absolute;
  inset-inline-end: min(8px, 4%);
  inset-block-end: 8px;
  max-width: 92%;
  gap: 0;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 36%);
  border-radius: 999px;
  background: rgb(11 30 22 / 48%);
  backdrop-filter: blur(5px);
  color: #fff;
  text-shadow: 0 1px 3px #000;
}

#product-photo-grid .photo-grid-stage:not([data-sized], [data-unavailable]) .gallery-slide-controls {
  visibility: hidden;
}

#product-photo-grid .gallery-slide-controls button {
  min-width: 0;
  width: 44px;
  padding: 0 .2rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  text-shadow: inherit;
  opacity: 1;
}

#product-photo-grid .gallery-slide-controls button:is(:hover, :focus-visible) {
  background: rgb(255 255 255 / 20%);
}

#product-photo-grid .gallery-slide-controls span {
  flex-shrink: 0;
  padding-inline: .15rem;
  white-space: nowrap;
}

#product-gallery-details:not([hidden]) {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  color: var(--text-main);
  font-size: 1rem;
  line-height: 1.55;
}

#product-gallery-details h3 {
  margin: 0;
  font: inherit;
  font-weight: 700;
}

#product-gallery-details p { margin: 0; max-width: 62ch; color: var(--text-main); }
#product-gallery-details ul { margin: .5rem 0 1rem; padding-inline-start: 1.15rem; }
#product-gallery-details li { color: var(--text-main); }

#product-gallery-details .button {
  flex-shrink: 0;
  max-width: 100%;
  min-height: 3rem;
  background: #245b3d;
  color: #fff;
  border: 0;
  border-radius: .5rem;
  padding: .75rem 1.1rem;
  font-size: 1rem;
  font-weight: 700;
}

#product-gallery-details .button:hover { background: #194630; }

#product-photo-grid[data-product-gallery="true"] #product-photo-grid-items {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(.65rem, 1.2vw, 1.1rem);
  margin: 0;
  max-width: none;
}

#product-photo-grid .photo-grid-item p {
  width: 100%;
  margin: 0;
  padding: .55rem .2rem 0;
  color: var(--text-main);
  font-size: .95rem;
  line-height: 1.45;
  text-align: center;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

#product-photo-grid .photo-grid-item .photo-grid-caption {
  padding-inline: 0 .5rem;
  font-size: .875rem;
  text-align: start;
}

@media (min-width: 900px) {
  #product-photo-grid[data-inox="true"][open] {
    display: grid;
    grid-template-columns: clamp(13rem, 18vw, 16rem) minmax(0, 1fr);
    grid-template-areas: "heading heading" "details status" "details photos" "footer footer";
    grid-template-rows: auto auto 1fr auto;
    align-content: start;
    align-items: start;
    column-gap: 1.5rem;
  }
  #product-photo-grid[data-inox="true"] .photo-grid-header { grid-area: heading; }
  #product-photo-grid[data-inox="true"] #product-gallery-details:not([hidden]) {
    grid-area: details;
    display: block;
    margin: 0;
  }
  #product-photo-grid[data-inox="true"] #product-gallery-details ul + .button,
  #product-photo-grid[data-inox="true"] #product-gallery-details div + h3 { margin-top: 1rem; }
  #product-photo-grid[data-inox="true"] #product-photo-grid-status { grid-area: status; }
  #product-photo-grid[data-inox="true"] #product-photo-grid-items {
    grid-area: photos;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  #product-photo-grid[data-inox="true"] .photo-grid-footer { grid-area: footer; }
}

@media (max-width: 899px) {
  #product-photo-grid[data-product-gallery="true"] #product-photo-grid-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  #product-gallery-details:not([hidden]) { flex-direction: column; margin-bottom: 1.25rem; }
}

@media (min-width: 100rem) {
  #product-photo-grid #product-photo-grid-items:has(> :nth-child(5)) {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  }
}
