.gallery-grid,
ul[data-gallery],
ul[data-gallery] > li {
  list-style: none;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
  padding: 0;
  list-style: none;
}

.gallery-grid li {
  overflow: hidden;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid #d7d7d7;
  background: #fff;
  box-shadow: 0 5px 14px rgb(0 0 0 / 10%);
}

.gallery-grid li > span,
.gallery-grid li > a {
  display: block;
}

.gallery-grid li > span > a {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #ecebe8;
}

.gallery-grid img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 220ms ease, filter 220ms ease;
}

.gallery-grid a:hover img,
.gallery-grid a:focus-visible img {
  filter: brightness(1.08);
  transform: scale(1.04);
}

.gallery-grid a:focus-visible {
  outline: 3px solid #c8753c;
  outline-offset: -3px;
}

.gallery-link-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 0.5rem;
  width: 100%;
  max-width: none;
  margin: 1rem 0;
  padding: 0.75rem;
  background: transparent;
}

.gallery-link-grid > a {
  display: block;
  flex: 0 0 80px;
  width: 80px;
  height: 120px;
  overflow: hidden;
  border: 1px solid #d0cfca;
  background: #fff;
}

.gallery-link-grid > a img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0 !important;
  object-fit: cover;
}

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

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: rgb(12 14 13 / 93%);
}

.gallery-lightbox-stage {
  display: grid;
  width: min(90vw, 1100px);
  height: min(82vh, 780px);
  place-items: center;
}

.gallery-lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 12px 40px rgb(0 0 0 / 38%);
}

.gallery-lightbox-button {
  position: absolute;
  z-index: 1;
  display: grid;
  width: 3.4rem;
  height: 3.4rem;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 40%);
  border-radius: 50%;
  background: rgb(0 0 0 / 32%);
  color: #fff;
  cursor: pointer;
  font: 2.4rem/1 Georgia, serif;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.gallery-lightbox-button:hover,
.gallery-lightbox-button:focus-visible {
  border-color: #e0a16f;
  background: #c8753c;
  color: #201813;
  outline: none;
}

.gallery-lightbox-close {
  top: 1rem;
  right: 1rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 3rem;
}

.gallery-lightbox-previous {
  left: 2vw;
  top: 50%;
  transform: translateY(-50%);
}

.gallery-lightbox-next {
  right: 2vw;
  top: 50%;
  transform: translateY(-50%);
}

.gallery-lightbox-caption {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 auto;
  color: #f4f0e9;
  font-size: 0.95rem;
  text-align: center;
}

.gallery-lightbox-caption-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-lightbox-caption-count {
  white-space: nowrap;
}

@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .gallery-lightbox-stage {
    width: 100vw;
    height: 72vh;
  }

  .gallery-lightbox-button {
    width: 2.7rem;
    height: 2.7rem;
  }

  .gallery-lightbox-previous {
    left: 0.5rem;
  }

  .gallery-lightbox-next {
    right: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-grid img,
  .gallery-lightbox-button {
    transition: none;
  }
}
