/* Samantha's House: gallery.
   The default grid keeps the theme's look; `class: gallery--mosaic` on the block turns it into the
   editorial collage used on the Events page (feature tiles + captions that ride over the image). */

.block--gallery .gallery__link { border: 2px solid var(--sh-line); box-shadow: 0 8px 12px rgb(16 79 158 / 0.04); }
.block--gallery figcaption { font-weight: 600; color: var(--sh-blue); }

/* Mosaic ------------------------------------------------------------------- */
/* One row = one tile unit, and every tile spans a whole number of units (1x1, 2x2, 1x2), so the
   collage tiles cleanly at 4, 3 or 2 columns whatever aspect ratio each photo has. `dense` backfills
   the gaps the bigger tiles leave behind. */
.gallery--mosaic .gallery {
  --cols: 4;
  grid-auto-rows: clamp(9rem, 13vw, 13rem);
  grid-auto-flow: dense;
  gap: clamp(0.75rem, 1.4vw, 1.25rem);
}

.gallery--mosaic .gallery__item { position: relative; margin: 0; }
/* Two wide openers anchor the collage; two portraits break up the rhythm between them. */
.gallery--mosaic .gallery__item:nth-child(1),
.gallery--mosaic .gallery__item:nth-child(6) { grid-column: span 2; grid-row: span 2; }
.gallery--mosaic .gallery__item:nth-child(4),
.gallery--mosaic .gallery__item:nth-child(9) { grid-row: span 2; }

.gallery--mosaic .gallery__link {
  height: 100%;
  border-radius: var(--maw-radius-lg);
}
.gallery--mosaic .gallery__item img { height: 100%; width: 100%; object-fit: cover; border-radius: inherit; }

/* Caption sits over the photo on hover / keyboard focus. The same text is the image's alt, so
   nothing is lost when it stays hidden (touch, reduced motion). */
.gallery--mosaic figcaption {
  position: absolute;
  inset: auto 0 0 0;
  margin: 0;
  padding: 2.5rem 1.1rem 1rem;
  border-radius: 0 0 var(--maw-radius-lg) var(--maw-radius-lg);
  background: linear-gradient(to top, rgb(15 39 64 / 0.88), rgb(15 39 64 / 0));
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.35;
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 300ms var(--maw-ease), transform 300ms var(--maw-ease);
  pointer-events: none;
}
.gallery--mosaic .gallery__item:hover figcaption,
.gallery--mosaic .gallery__item:focus-within figcaption { opacity: 1; transform: none; }

@media (max-width: 960px) {
  .gallery--mosaic .gallery { --cols: 3; }
}
@media (max-width: 640px) {
  .gallery--mosaic .gallery { --cols: 2; grid-auto-rows: 8rem; }
  /* Keep the openers full-width so the collage still reads as one composition on a phone. */
  .gallery--mosaic .gallery__item:nth-child(1),
  .gallery--mosaic .gallery__item:nth-child(6) { grid-column: span 2; grid-row: span 2; }
  .gallery--mosaic figcaption { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery--mosaic figcaption { transition: none; transform: none; }
}

/* Lightbox ----------------------------------------------------------------- */
/* Built by user/site/js/site.js from the gallery's own links; without JS those links still work. */
.lightbox {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: clamp(1rem, 4vw, 3rem);
  border: 0;
  background: transparent;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(0.5rem, 2vw, 1.5rem);
}
.lightbox::backdrop { background: rgb(15 39 64 / 0.92); }
.lightbox:not([open]) { display: none; }

.lightbox__figure {
  grid-column: 2;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  min-height: 0;
}
.lightbox__img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 11rem);
  width: auto;
  height: auto;
  border-radius: var(--maw-radius-lg);
  border: 2px solid rgb(255 255 255 / 0.18);
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.45);
  background: rgb(255 255 255 / 0.06);
}
.lightbox.is-loading .lightbox__img { opacity: 0.35; }
.lightbox__img { transition: opacity 200ms var(--maw-ease); }

.lightbox__caption {
  margin: 0;
  max-width: 44rem;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 600;
  color: rgb(255 255 255 / 0.9);
}
.lightbox__count {
  grid-column: 2;
  margin: 0;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgb(255 255 255 / 0.55);
}

.lightbox__close,
.lightbox__nav {
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 2px solid rgb(255 255 255 / 0.25);
  background: rgb(255 255 255 / 0.1);
  color: #fff;
  cursor: pointer;
  transition: background 200ms var(--maw-ease), border-color 200ms var(--maw-ease), transform 200ms var(--maw-ease);
}
.lightbox__close:hover,
.lightbox__nav:hover { background: var(--sh-orange); border-color: var(--sh-orange); }
.lightbox__close:focus-visible,
.lightbox__nav:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.lightbox__nav { width: clamp(2.75rem, 5vw, 3.5rem); aspect-ratio: 1; font-size: 1.125rem; }
.lightbox__nav--prev { grid-column: 1; }
.lightbox__nav--next { grid-column: 3; }
.lightbox__nav:active { transform: scale(0.94); }

.lightbox__close {
  position: absolute;
  top: clamp(0.75rem, 2.5vw, 1.75rem);
  right: clamp(0.75rem, 2.5vw, 1.75rem);
  width: 2.75rem;
  aspect-ratio: 1;
  font-size: 1rem;
}

@media (max-width: 640px) {
  /* Nav buttons move under the photo so the image gets the full width. */
  .lightbox { grid-template-columns: 1fr; justify-items: center; }
  .lightbox__figure, .lightbox__count { grid-column: 1; }
  .lightbox__img { max-height: calc(100dvh - 14rem); }
  .lightbox__nav--prev, .lightbox__nav--next { grid-column: 1; grid-row: 3; }
  .lightbox__nav--prev { justify-self: start; }
  .lightbox__nav--next { justify-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox__img, .lightbox__close, .lightbox__nav { transition: none; }
}
