.gallery {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 2;
  column-gap: var(--s-3);
}

.gallery__item {
  margin: 0 0 var(--s-3);
  break-inside: avoid;
}

.gallery__link {
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--cream);
}

.gallery__link img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 400ms ease;
}

.gallery__link:hover img { transform: scale(1.04); }
.gallery__link:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }

@media (min-width: 700px) {
  .gallery { columns: 3; column-gap: var(--s-4); }
  .gallery__item { margin-bottom: var(--s-4); }
}

@media (min-width: 1100px) {
  .gallery { columns: 4; }
}

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(14, 11, 28, .94);
  color: #fff;
}

.lightbox::backdrop { background: rgba(14, 11, 28, .94); }
.lightbox[open] { display: grid; place-items: center; overflow: hidden; }

.lightbox__figure {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  width: 100%;
  gap: var(--s-3);
  margin: 0;
  padding: 64px var(--s-4) var(--s-4);
}

.lightbox__img {
  --ar: 0.75;
  --img-max-h: calc(100dvh - 140px);
  display: block;
  width: min(calc(100vw - 2 * var(--s-4)), calc(var(--img-max-h) * var(--ar)));
  height: auto;
  aspect-ratio: var(--ar);
  border-radius: var(--radius);
  object-fit: contain;
}

.lightbox__caption {
  max-width: min(60ch, 100%);
  font-size: .9rem;
  text-align: center;
  color: var(--on-dark-muted);
}

.lightbox__count { white-space: nowrap; color: #fff; font-weight: 700; }

.lightbox__btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 180ms ease;
}

.lightbox__btn:hover { background: rgba(255, 255, 255, .22); }
.lightbox__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lightbox__btn--close { top: var(--s-3); right: var(--s-3); }
.lightbox__btn--prev, .lightbox__btn--next { top: 50%; transform: translateY(-50%); }
.lightbox__btn--prev { left: var(--s-3); }
.lightbox__btn--next { right: var(--s-3); }

@media (max-width: 699px) {
  .lightbox__btn--prev, .lightbox__btn--next { top: auto; bottom: var(--s-3); transform: none; }
  .lightbox__figure { padding-bottom: 76px; }
  .lightbox__img { --img-max-h: calc(100dvh - 200px); }
}

html.lightbox-open { overflow: hidden; }
