.gallery figure {
  cursor: zoom-in;
}

.gallery figure img,
.gallery figure img:focus,
.gallery figure img:focus-visible {
  border: 0;
  outline: none;
  box-shadow: none;
}

.gallery img.is-lightbox-origin {
  opacity: 0 !important;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 64px);
  visibility: hidden;
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  backdrop-filter: blur(0);
  transition: visibility 0s linear 520ms, background 520ms ease, opacity 520ms ease, backdrop-filter 520ms ease;
}

.lightbox.is-open {
  visibility: visible;
  background: rgba(0, 0, 0, 0.9);
  opacity: 1;
  backdrop-filter: blur(8px);
  transition-delay: 0s;
}

.lightbox.is-resetting {
  transition: none !important;
}

.lightbox__stage {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  cursor: zoom-out;
}

.lightbox__image {
  position: relative;
  z-index: 2;
  display: block;
  max-width: min(78vw, 1280px);
  max-height: 78vh;
  object-fit: contain;
  opacity: 0;
  transform: none;
  transform-origin: center;
  filter: blur(0);
  box-shadow: none;
  transition: opacity 360ms ease;
  cursor: default;
}

.lightbox__dismiss {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 1;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-out;
}

.lightbox__dismiss-left { left: 0; }
.lightbox__dismiss-right { right: 0; }

.lightbox.is-open .lightbox__image {
  opacity: 1;
  transform: scale(1) translateY(0);
  filter: blur(0);
}

.lightbox__image.is-positioning {
  opacity: 0;
}

.lightbox__close,
.lightbox__nav {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(10, 10, 10, 0.62);
  color: #f4f1eb;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 220ms ease, border-color 220ms ease, transform 220ms ease, opacity 240ms ease;
}

.lightbox__close:hover,
.lightbox__nav:hover {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(35, 35, 35, 0.86);
}

.lightbox__close {
  top: 0;
  right: 0;
  width: 46px;
  height: 46px;
  font-size: 1.35rem;
}

.lightbox__nav {
  top: 50%;
  width: 52px;
  height: 70px;
  transform: translateY(-50%);
  font-size: 1.45rem;
  border: 0;
  background: transparent;
  opacity: 0;
}

.lightbox__stage:hover .lightbox__nav,
.lightbox__nav:focus-visible {
  opacity: 0.68;
}

.lightbox__nav:hover {
  transform: translateY(-50%) scale(1.04);
  background: rgba(20, 20, 20, 0.46);
  opacity: 1;
}

.lightbox__prev { left: 0; }
.lightbox__next { right: 0; }

.lightbox__count {
  position: absolute;
  bottom: 0;
  left: 50%;
  margin: 0;
  transform: translateX(-50%);
  color: rgba(244, 241, 235, 0.58);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  z-index: 3;
}

.lightbox.is-closing .lightbox__close,
.lightbox.is-closing .lightbox__nav,
.lightbox.is-closing .lightbox__count {
  pointer-events: none;
  opacity: 0;
}

body.has-lightbox {
  overflow: hidden;
}

@media (max-width: 700px) {
  .lightbox { padding: 58px 12px 52px; }
  .lightbox__image { max-width: 92%; max-height: 72vh; }
  .lightbox__close { top: -46px; }
  .lightbox__nav { top: auto; bottom: -42px; width: 48px; height: 40px; transform: none; }
  .lightbox__nav:hover { transform: scale(1.04); }
  .lightbox__prev { left: 0; }
  .lightbox__next { right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox,
  .lightbox__image { transition: none; }
}
