.photo-gallery {
  max-width: 90rem;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 5rem) clamp(1rem, 3vw, 2rem);
}

.photo-gallery__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: clamp(0.5rem, 1.4vw, 1rem);
}

.photo-gallery__item {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  background: #181818;
  border: 0;
  cursor: pointer;
}

.photo-gallery__item::after {
  position: absolute;
  inset: 0;
  content: "";
  background: rgb(0 0 0 / 0%);
  transition: background-color 160ms ease;
}

.photo-gallery__item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.75rem;
  transition: transform 220ms ease;
}

.photo-gallery__item:hover::after,
.photo-gallery__item:focus-visible::after {
  background: rgb(0 0 0 / 22%);
}

.photo-gallery__item:hover img,
.photo-gallery__item:focus-visible img {
  transform: scale(1.05);
}

.photo-gallery__item:focus-visible,
.photo-lightbox button:focus-visible {
  outline: 0.1875rem solid #fff;
  outline-offset: 0.1875rem;
}

.photo-lightbox {
  position: fixed;
  z-index: 10000;
  inset: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(0.5rem, 2vw, 2rem);
  padding: clamp(1rem, 4vw, 4rem);
  background: rgb(0 0 0 / 92%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 240ms ease, visibility 0s linear 240ms;
}

.photo-lightbox[hidden] {
  display: none;
}

.photo-lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.photo-lightbox__content {
  display: grid;
  width: min(100%, 90rem);
  height: calc(100vh - 8rem);
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  justify-items: center;
  transform: scale(0.97);
  transition: transform 240ms ease;
}

.photo-lightbox.is-open .photo-lightbox__content {
  transform: scale(1);
}

.photo-lightbox__swiper {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.photo-lightbox__swiper .swiper-wrapper {
  display: flex;
  width: 100%;
  height: 100%;
}

.photo-lightbox__swiper .swiper-slide {
  display: flex;
  flex: 0 0 100%;
  width: 100%;
  height: 100% !important;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  border-radius: 0;
  overflow: visible;
}

.photo-lightbox__swiper .swiper-slide .photo-lightbox__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0.75rem;
}

.photo-lightbox__counter {
  margin-top: 0.75rem;
  color: #fff;
  font-family: var(--font-family-semibold, sans-serif);
  font-size: 0.875rem;
}

.photo-lightbox button {
  color: #fff;
  background: rgb(255 255 255 / 12%);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.photo-lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  font-size: 2.25rem;
  line-height: 1;
}

.photo-lightbox__navigation {
  display: grid;
  width: 3rem;
  height: 3rem;
  place-items: center;
  font-size: 1.5rem;
}

.photo-lightbox button:hover {
  background: rgb(255 255 255 / 26%);
}

body.photo-lightbox-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .photo-gallery__item::after,
  .photo-gallery__item img,
  .photo-lightbox,
  .photo-lightbox__content,
  .photo-lightbox__image {
    transition: none;
  }
}

@media (max-width: 40rem) {
  .photo-gallery__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-lightbox {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 1rem;
  }

  .photo-lightbox__content {
    grid-row: 1;
    height: calc(100vh - 7rem);
  }

  .photo-lightbox__swiper {
    height: 100%;
  }

  .photo-lightbox__navigation {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
  }

  .photo-lightbox__navigation--previous {
    left: 0.75rem;
  }

  .photo-lightbox__navigation--next {
    right: 0.75rem;
  }
}