/*
 * components/lightbox.css — повноекранний перегляд фото
 */

body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  top: calc(-1 * var(--scroll-y, 0px));
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 50);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
  padding: var(--sp-4);
  padding-top: max(var(--sp-4), var(--safe-top));
  padding-bottom: max(var(--sp-4), var(--safe-bottom));
}

.lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox__overlay {
  position: fixed;
  inset: 0;
  background-color: rgb(0 0 0 / 0.92);
  cursor: zoom-out;
}

.lightbox__content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: calc(100vw - 120px);
  max-height: calc(100dvh - var(--sp-8) - var(--safe-top) - var(--safe-bottom) - 56px);
}

.lightbox__img {
  display: block;
  max-width: calc(100vw - 120px);
  max-height: calc(100dvh - var(--sp-8) - var(--safe-top) - var(--safe-bottom) - 56px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--r-sm);
  transform: scale(0.94);
  opacity: 0;
  transition: transform var(--t-base), opacity var(--t-fast);
  user-select: none;
  -webkit-user-drag: none;
  touch-action: pinch-zoom;
}

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

.lightbox__img.is-loaded {
  opacity: 1;
}

.lightbox__close,
.lightbox__prev,
.lightbox__next {
  position: fixed;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  color: rgb(255 255 255 / 0.85);
  background-color: rgb(0 0 0 / 0.45);
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color var(--t-fast), background-color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

.lightbox__close:hover,
.lightbox__prev:hover,
.lightbox__next:hover {
  color: var(--c-text-inverse);
  background-color: rgb(0 0 0 / 0.75);
}

.lightbox__close:focus-visible,
.lightbox__prev:focus-visible,
.lightbox__next:focus-visible {
  outline: 2px solid var(--c-accent-light);
  outline-offset: 2px;
}

.lightbox__close {
  top: max(var(--sp-4), var(--safe-top));
  right: max(var(--sp-4), var(--safe-right));
}

.lightbox__prev,
.lightbox__next {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__prev {
  left: max(var(--sp-3), var(--safe-left));
}

.lightbox__next {
  right: max(var(--sp-3), var(--safe-right));
}

.lightbox__counter {
  position: fixed;
  bottom: max(var(--sp-5), var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: rgb(255 255 255 / 0.7);
  background-color: rgb(0 0 0 / 0.45);
  padding: var(--sp-1) var(--sp-4);
  border-radius: var(--r-pill);
  white-space: nowrap;
  pointer-events: none;
}

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

  .lightbox__img {
    opacity: 1;
    transform: none;
  }
}
