/* ═══════════════════════════════════════════════════════════════
   KIYAMOV-SITE-V2 — Lightbox v2 (ADR-014)
   Полноэкранный просмотрщик фотографий в эстетике Quiet Luxury.
   - Без внешних зависимостей и тяжелых библиотек
   - Строгая темная подложка без блюра (zero GPU jank)
   - Музейный режим (скрытие контролов при бездействии через 3.5 с)
   - Уважение prefers-reduced-motion и доступность (focus trap, ARIA)
   ═══════════════════════════════════════════════════════════════ */

/* Курсор приближения на кликабельных кадрах галереи */
.case-shot,
.sv-shot,
.sv-lcp__frame,
[data-lightbox] {
  cursor: zoom-in;
}

/* Фиксированный контейнер лайтбокса */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #08080a;
  outline: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition:
    opacity 320ms cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0s linear 320ms;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 320ms cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0s;
}

/* Верхняя панель: счётчик слева, кнопка закрытия справа */
.lightbox__header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1.25rem, 4vw, 3.5rem);
  box-sizing: border-box;
  z-index: 20;
  pointer-events: none;
  transition: opacity 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox__counter {
  font-family: var(--font-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.7);
  pointer-events: auto;
}

.lightbox__close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  outline: none;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
  border-radius: 0;
  transition: color 200ms ease, opacity 200ms ease;
}

.lightbox__close:focus {
  outline: none;
}

.lightbox__close:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

/* Кнопки навигации (стрелки влево / вправо) */
.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  z-index: 20;
  padding: 0;
  border-radius: 0;
  transition:
    color 200ms ease,
    opacity 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox__nav:hover,
.lightbox__nav:focus-visible {
  color: #ffffff;
}

.lightbox__nav:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.lightbox__nav--prev {
  left: clamp(0.75rem, 2.5vw, 2.5rem);
}

.lightbox__nav--next {
  right: clamp(0.75rem, 2.5vw, 2.5rem);
}

@media (max-width: 768px) {
  .lightbox__nav {
    display: none; /* На мобильных экранах — навигация свайпами */
  }
}

/* Центральная сцена просмотра */
.lightbox__stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.25rem, 4vw, 4rem);
  box-sizing: border-box;
  cursor: default;
}

.lightbox__slide {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__img {
  display: block;
  max-width: calc(100vw - clamp(2.5rem, 9vw, 9rem));
  max-height: calc(100vh - clamp(4.5rem, 11vh, 8.5rem));
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  will-change: transform, opacity;
  transition:
    transform 250ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 768px) {
  .lightbox__header {
    height: 56px;
    padding: 0 1.25rem;
  }

  .lightbox__stage {
    padding: 4rem 1rem 2rem;
  }

  .lightbox__img {
    max-width: calc(100vw - 2rem);
    max-height: calc(100dvh - 6rem);
  }
}

/* Музейный режим: скрытие элементов управления при неактивности */
.lightbox.is-idle .lightbox__header,
.lightbox.is-idle .lightbox__nav {
  opacity: 0;
  pointer-events: none;
  transition: opacity 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Состояния перехода между кадрами (direction-aware) */
.lightbox__img.is-anim-out-prev {
  opacity: 0;
  transform: translateX(20px);
}

.lightbox__img.is-anim-out-next {
  opacity: 0;
  transform: translateX(-20px);
}

.lightbox__img.is-anim-in-prev {
  opacity: 0;
  transform: translateX(-20px);
}

.lightbox__img.is-anim-in-next {
  opacity: 0;
  transform: translateX(20px);
}

/* Уважение prefers-reduced-motion: никаких сдвигов, только мягкий фейд */
@media (prefers-reduced-motion: reduce) {
  .lightbox,
  .lightbox.is-open,
  .lightbox__header,
  .lightbox__nav,
  .lightbox__img {
    transition-duration: 120ms !important;
    transition-timing-function: ease !important;
  }

  .lightbox__img.is-anim-out-prev,
  .lightbox__img.is-anim-out-next,
  .lightbox__img.is-anim-in-prev,
  .lightbox__img.is-anim-in-next {
    transform: none !important;
    opacity: 0 !important;
  }
}
