/* Homepage photo gallery + lightbox.
   Linked automatically by scripts/gallery-core.mjs on pages that carry the gallery.
   Photos come from the Merchynt image widget; see that file for why it isn't an iframe. */

.gallery {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(10px, 1.4vw, 18px);
}

.gallery__link {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-soft-2);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .25s var(--ease), transform .25s var(--ease);
}
.gallery__link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .45s var(--ease);
}
.gallery__link:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.gallery__link:hover img { transform: scale(1.04); }
.gallery__link:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

.gallery__zoom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  color: var(--navy);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.gallery__zoom svg { width: 16px; height: 16px; }
.gallery__link:hover .gallery__zoom,
.gallery__link:focus-visible .gallery__zoom { opacity: 1; transform: none; }

/* Every photo stays in the HTML so it's indexed; the extras are only hidden.
   They're lazy-loaded, so hidden ones cost nothing until "See all" is pressed. */
.gallery--clamped .gallery__item:nth-child(n + 9) { display: none; }
.gallery__more { margin-top: clamp(24px, 3vw, 34px); }
.gallery:not(.gallery--clamped) + .gallery__more { display: none; }

@media (max-width: 820px) {
  .gallery { grid-template-columns: repeat(3, 1fr); }
  .gallery--clamped .gallery__item:nth-child(n + 7) { display: none; }
}
@media (max-width: 520px) {
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .gallery__zoom { opacity: 1; transform: none; width: 30px; height: 30px; right: 8px; bottom: 8px; }
}

/* ---------------------------------------------------------------- lightbox */

.gl-modal {
  border: 0;
  padding: 0;
  margin: auto; /* the site reset zeroes dialog's UA margin */
  width: min(1100px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  background: transparent;
  overflow: visible;
  color: #fff;
}
.gl-modal::backdrop {
  background: rgba(6, 23, 41, .88);
  backdrop-filter: blur(4px);
}
.gl-modal[open] { animation: gl-in .22s var(--ease); }
.gl-modal[open]::backdrop { animation: gl-fade .22s var(--ease); }
@keyframes gl-in { from { opacity: 0; transform: scale(.98); } }
@keyframes gl-fade { from { opacity: 0; } }

.gl-modal__figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.gl-modal__img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 140px);
  width: auto;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  background: var(--navy-2);
}
.gl-modal__caption {
  display: flex;
  gap: 14px;
  align-items: baseline;
  justify-content: center;
  text-align: center;
  font-size: .98rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, .92);
  padding-inline: 56px;
}
.gl-modal__count {
  flex: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: .08em;
  color: var(--gold);
}

.gl-modal__btn {
  position: fixed;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .95);
  color: var(--navy);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.gl-modal__btn svg { width: 22px; height: 22px; }
.gl-modal__btn:hover { background: #fff; transform: scale(1.06); }
.gl-modal__btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.gl-modal__close { top: 16px; right: 16px; }
.gl-modal__prev { left: 16px; top: 50%; margin-top: -23px; }
.gl-modal__next { right: 16px; top: 50%; margin-top: -23px; }

@media (max-width: 620px) {
  .gl-modal__prev, .gl-modal__next { top: auto; bottom: 16px; margin-top: 0; }
  .gl-modal__img { max-height: calc(100vh - 190px); }
  .gl-modal__caption { padding-inline: 8px; flex-direction: column; align-items: center; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery__link, .gallery__link img, .gallery__zoom, .gl-modal__btn { transition: none; }
  .gallery__link:hover, .gallery__link:hover img { transform: none; }
  .gl-modal[open], .gl-modal[open]::backdrop { animation: none; }
}
