.gallery-page {
  --gallery-thumb-ratio: 3 / 2;
  padding: 1.75rem 1rem 3.5rem;
  background: #fff;
}

.gallery-page--compact {
  padding: 0.5rem 0 1rem;
}

.gallery-page--square {
  --gallery-thumb-ratio: 1 / 1;
}

.gallery-page__intro {
  margin: 0 auto 1rem;
  text-align: center;
}

.gallery-page__intro h1 {
  margin: 0 0 0.75rem;
  color: #111;
  font-family: 'Roboto', sans-serif;
  font-size: 3rem;
  font-weight: 300;
  letter-spacing: 0.06em;
}

.lightbox-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
}

.lightbox-gallery__card {
  appearance: none;
  width: 100%;
  padding: 0;
  border: 1px solid #5c83ff;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease;
}

.lightbox-gallery__card:hover,
.lightbox-gallery__card:focus-visible {
  transform: translateY(-2px);
  border-color: #2d5cff;
  outline: none;
}

.lightbox-gallery__thumb {
  display: block;
  width: 100%;
  aspect-ratio: var(--gallery-thumb-ratio);
  object-fit: cover;
  background: #f3f3f3;
}

.gallery-lightbox[hidden] {
  display: none !important;
}

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

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.gallery-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 17, 17, 0.86);
  backdrop-filter: blur(8px);
}

.gallery-lightbox__dialog {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  padding: 1rem 1rem 1.15rem;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.35);
}

.gallery-lightbox__figure {
  margin: 0;
}

.gallery-lightbox__caption {
  margin: 0;
  padding: 0 3.5rem 0.95rem;
  color: #222;
  font-family: 'Roboto', sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.2;
  text-align: center;
}

.gallery-lightbox__image-wrap {
  border-radius: 0;
  overflow: hidden;
  background: #fff;
}

.gallery-lightbox__image {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 11rem);
  object-fit: contain;
  background: #fff;
}

.gallery-lightbox__close,
.gallery-lightbox__nav {
  appearance: none;
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: color 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.gallery-lightbox__close:hover,
.gallery-lightbox__close:focus-visible,
.gallery-lightbox__nav:hover,
.gallery-lightbox__nav:focus-visible {
  transform: scale(1.04);
  outline: none;
}

.gallery-lightbox__close {
  top: 0.55rem;
  right: 0.55rem;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border-radius: 999px;
  background: rgba(56, 56, 56, 0.72);
  font-size: 2rem;
  line-height: 1;
}

.gallery-lightbox__close:hover,
.gallery-lightbox__close:focus-visible {
  background: rgba(56, 56, 56, 0.88);
}

.gallery-lightbox__nav {
  top: 50%;
  width: 3.5rem;
  height: 5rem;
  margin-top: -2.5rem;
  color: rgba(95, 95, 95, 0.9);
  font-size: 5.2rem;
  font-weight: 300;
  line-height: 0.8;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.55);
  opacity: 0.9;
}

.gallery-lightbox__nav--prev {
  left: 0.55rem;
}

.gallery-lightbox__nav--next {
  right: 0.55rem;
}

.gallery-lightbox__nav:hover,
.gallery-lightbox__nav:focus-visible {
  color: rgba(55, 55, 55, 0.96);
  opacity: 1;
}

@media (max-width: 900px) {
  .lightbox-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .gallery-lightbox__dialog {
    padding: 0.9rem 0.9rem 1rem;
  }

  .gallery-lightbox__nav {
    top: 50%;
    bottom: auto;
    margin-top: -2rem;
    width: 3rem;
    height: 4rem;
    font-size: 4.3rem;
  }

  .gallery-lightbox__nav--prev {
    left: 0.65rem;
  }

  .gallery-lightbox__nav--next {
    right: 0.65rem;
  }
}

@media (max-width: 640px) {
  .gallery-page {
    padding-top: 1rem;
  }

  .gallery-page__intro h1 {
    font-size: 2.35rem;
  }

  .lightbox-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .gallery-lightbox__caption {
    padding-right: 2.6rem;
    padding-left: 2.6rem;
    font-size: 0.95rem;
  }

  .gallery-lightbox__image {
    max-height: calc(100vh - 9.5rem);
  }
}
