.auto-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(0.75rem, 1.2vw, 1rem);
}

.auto-gallery__item {
  display: block;
  position: relative;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: #151515;
  color: inherit;
  cursor: zoom-in;
  text-align: left;
}

.auto-gallery__item img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 260ms ease, opacity 260ms ease;
  -webkit-user-drag: none;
  user-select: none;
}

.auto-gallery__item:hover img,
.auto-gallery__item:focus-visible img {
  transform: scale(1.01);
}

.auto-gallery__item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.12));
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.auto-gallery__item:hover::after,
.auto-gallery__item:focus-visible::after {
  opacity: 1;
}

.auto-gallery__item:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 0.2rem;
}

.auto-gallery__placeholder,
.auto-gallery__empty {
  padding: 1rem 0;
  color: var(--color-text-soft);
  font-size: 0.95rem;
  line-height: 1.6;
}

.gallery-lightbox {
  --lightbox-side-space: 16px;
  --lightbox-top-space: 64px;
  --lightbox-bottom-space: 20px;
  --lightbox-fit-width: calc(100vw - 32px);
  --lightbox-fit-height: calc(100dvh - 84px);
  position: fixed;
  inset: 0;
  z-index: 140;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--lightbox-top-space) var(--lightbox-side-space) var(--lightbox-bottom-space);
  background: rgba(0, 0, 0, 0.86);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  overflow: hidden;
  touch-action: none;
}

.gallery-lightbox.is-open {
  display: flex;
}

.gallery-lightbox__inner {
  position: relative;
  width: var(--lightbox-fit-width);
  height: var(--lightbox-fit-height);
  display: grid;
  place-items: center;
}

.gallery-lightbox__frame {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--lightbox-fit-width);
  height: var(--lightbox-fit-height);
  overflow: hidden;
}

.gallery-lightbox__image {
  display: block;
  width: auto;
  height: auto;
  max-width: var(--lightbox-fit-width);
  max-height: var(--lightbox-fit-height);
  object-fit: contain;
  filter: drop-shadow(0 24px 46px rgba(0, 0, 0, 0.34));
  -webkit-user-drag: none;
  user-select: none;
}

.gallery-lightbox__button,
.gallery-lightbox__close {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  min-height: 2.2rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  text-shadow: 0 0.08rem 0.9rem rgba(0, 0, 0, 0.72);
  transition: opacity 180ms ease, transform 180ms ease;
}

.gallery-lightbox__button {
  font-size: clamp(2.1rem, 4vw, 3.6rem);
  line-height: 1;
}

.gallery-lightbox__close {
  top: calc(var(--lightbox-top-space) * -0.78);
  right: 0;
  font-size: clamp(2rem, 3.2vw, 3rem);
  line-height: 1;
}

.gallery-lightbox__button:hover,
.gallery-lightbox__close:hover {
  opacity: 0.72;
}

.gallery-lightbox__button:focus-visible,
.gallery-lightbox__close:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 0.24rem;
}

.gallery-lightbox__button:disabled {
  opacity: 0.24;
  cursor: default;
}

.gallery-lightbox__button--prev {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.gallery-lightbox__button--next {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.gallery-lightbox__button--prev:hover {
  transform: translateY(-50%) translateX(-0.12rem);
}

.gallery-lightbox__button--next:hover {
  transform: translateY(-50%) translateX(0.12rem);
}

.gallery-lightbox__counter {
  position: absolute;
  left: 0;
  top: calc(var(--lightbox-top-space) * -0.56);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 0.08rem 0.9rem rgba(0, 0, 0, 0.72);
}

body.lightbox-open {
  overflow: hidden;
}

@media (min-width: 48rem) {
  .auto-gallery {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-flow: dense;
  }

  .auto-gallery__item {
    grid-column: span 4;
  }

  .auto-gallery__item.is-landscape {
    grid-column: span 8;
  }

  .auto-gallery__item.is-portrait {
    grid-column: span 4;
  }

  .auto-gallery__item.is-square {
    grid-column: span 4;
  }
}

@media (max-width: 40rem) {
  .gallery-lightbox {
    --lightbox-side-space: 12px;
    --lightbox-top-space: 58px;
    --lightbox-bottom-space: 14px;
  }

  .gallery-lightbox__button {
    font-size: 2.25rem;
  }

  .gallery-lightbox__close {
    top: calc(var(--lightbox-top-space) * -0.82);
    right: 0;
    font-size: 2.2rem;
  }

  .gallery-lightbox__button--prev {
    left: 0;
  }

  .gallery-lightbox__button--next {
    right: 0;
  }

  .gallery-lightbox__counter {
    top: calc(var(--lightbox-top-space) * -0.56);
    font-size: 0.66rem;
    letter-spacing: 0.12em;
  }
}