/* Lightbox gallery (snippets/lightbox-gallery.php): justified rows in page order.
   Each tile grows by its aspect ratio (--w/--h), so a row fills the width uncropped. */
.lightbox-gallery {
  --gallery-row: 7.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.1875rem;
  margin: var(--space-xl) 0;
}

/* Soaks up the last row's free space, so its tiles keep the row height. */
.lightbox-gallery::after {
  content: "";
  flex-grow: 1000000;
}

.lightbox-gallery-item {
  flex-grow: calc(var(--w) / var(--h));
  flex-basis: calc(var(--w) / var(--h) * var(--gallery-row));
  display: block;
  overflow: hidden;
  background: #eeeff1;
}

.lightbox-gallery-item img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.3s ease-out;
}

.lightbox-gallery-item:hover img,
.lightbox-gallery-item:focus-visible img {
  transform: scale(1.04);
}

.lightbox-gallery-item:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: -3px;
}

@media screen and (min-width: 40em) {
  .lightbox-gallery {
    --gallery-row: 11.25rem;
  }
}

/* Videos below the photos, at their own aspect ratio. */
.gallery-videos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: var(--space);
  margin: var(--space-xl) 0;
}

.gallery-videos video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  background: #000;
}

/* Page title above the photo, as the previous lightbox showed it. */
.pswp__hsg-caption {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 15rem);
  z-index: 10;
  padding: var(--space-xl) 0;
  color: var(--pswp-icon-color);
  text-shadow: 1px 1px 3px var(--pswp-icon-color-secondary);
  font-size: 0.875rem;
  line-height: 1.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .lightbox-gallery-item img {
    transition: none;
  }
}

/* main.css centres every <section> in a 1200px column; PhotoSwipe's scroll wrapper is one. */
.pswp__scroll-wrap {
  max-width: none;
  margin: 0;
}

.pswp__scroll-wrap::after {
  content: none;
}
