:root {
  /*
   * Основные размеры блока.
   *
   * Менять чаще всего нужно только эти три переменные:
   * --om-gallery-desktop-width  - максимальная ширина галереи на десктопе;
   * --om-gallery-desktop-height - высота видимой области на десктопе;
   * --om-gallery-mobile-height  - высота видимой области на телефоне.
   */
  --om-gallery-desktop-width: 750px;
  --om-gallery-desktop-height: 1000px;
  --om-gallery-mobile-height: min(126vw, 680px);

  /*
   * Цвета галереи.
   * --om-gallery-gold используется для спиннера загрузки.
   */
  --om-gallery-bg: #050505;
  --om-gallery-gold: #c6a35b;
}

/* Обертка всей галереи в карточке товара. */
.om-product-gallery {
  width: min(100%, var(--om-gallery-desktop-width));
  margin: 0 auto;
  color: #fff;
}

/*
 * Видимая область слайдера.
 * touch-action: pan-y оставляет вертикальный скролл страницы на мобильном,
 * но позволяет нашему JS обрабатывать горизонтальный свайп галереи.
 */
.om-product-gallery__viewport {
  position: relative;
  height: var(--om-gallery-desktop-height);
  overflow: hidden;
  background: var(--om-gallery-bg);
  outline: none;
  cursor: zoom-in;
  touch-action: pan-y;
}

/* Лента слайдов. JS двигает ее через transform: translate3d(...). */
.om-product-gallery__track {
  display: flex;
  height: 100%;
  will-change: transform;
}

/* Класс добавляется только на момент анимированного перехода между фото. */
.om-product-gallery__track.is-animated {
  transition: transform 320ms cubic-bezier(.22, .61, .36, 1);
}

/* Один слайд всегда занимает 100% ширины viewport. */
.om-product-gallery__slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
}

.om-product-gallery__picture,
.om-product-gallery__image {
  display: block;
  width: 100%;
  height: 100%;
}

.om-product-gallery__image {
  /*
   * contain показывает изделие целиком.
   * Если нужно заполнение блока с возможной обрезкой, поменяйте на cover.
   */
  object-fit: cover;
  opacity: 0;
  transition: opacity 220ms ease;
  user-select: none;
  -webkit-user-drag: none;
}

.om-product-gallery__image.is-loaded {
  opacity: 1;
}

/* Десктопные стрелки основной галереи. На мобильном они скрываются ниже. */
.om-product-gallery__arrow {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 42px;
  height: 62px;
  border: 0;
  border-radius: 0;
  color: #fff;
  background: rgba(0, 0, 0, .34);
  transform: translateY(-50%);
  cursor: pointer;
}

.om-product-gallery__arrow:hover {
  background: rgba(0, 0, 0, .54);
}

.om-product-gallery__arrow:disabled {
  opacity: .28;
  cursor: default;
}

.om-product-gallery__arrow.is-hidden {
  display: none;
}

.om-product-gallery__arrow--prev {
  left: 12px;
}

.om-product-gallery__arrow--next {
  right: 12px;
}

.om-product-gallery__arrow span {
  display: block;
  font-size: 42px;
  line-height: 1;
}

/* Загрузчик для маленького превью в карточке. */
.om-product-gallery__loader {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.om-product-gallery__loader.is-visible {
  opacity: 1;
}

/* Общий спиннер используется и в карточке, и в большом просмотре. */
.om-gallery-spinner {
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255, 255, 255, .22);
  border-top-color: var(--om-gallery-gold);
  border-radius: 50%;
  animation: om-gallery-spin 720ms linear infinite;
}

/* Нижняя подсказка "Нажмите для увеличения" в основной галерее. */
.om-product-gallery__open-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 3;
  padding: 8px 13px;
  font-size: 12px;
  line-height: 1;
  letter-spacing: .04em;
  color: rgba(255, 255, 255, .82);
  background: rgba(0, 0, 0, .42);
  transform: translateX(-50%);
  pointer-events: none;
}

/*
 * Кнопки zoom в большом просмотре.
 * Они регистрируются из gallery.js через локальный PhotoSwipe API.
 */
.pswp__custom-zoom {
  width: 44px !important;
  height: 44px !important;
  color: #fff !important;
}

.pswp__custom-zoom svg {
  width: 24px;
  height: 24px;
}

/* Загрузчик внутри большого просмотра. */
.pswp__om-loader {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: #fff;
  font-size: 13px;
  background: rgba(0, 0, 0, .54);
  opacity: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: opacity 160ms ease;
}

.pswp__om-loader.is-visible {
  opacity: 1;
}

/* Нижняя подсказка внутри большого просмотра. */
.pswp__om-hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 20;
  padding: 8px 12px;
  color: rgba(255, 255, 255, .78);
  font-size: 12px;
  background: rgba(0, 0, 0, .42);
  transform: translateX(-50%);
  pointer-events: none;
}

.om-pswp-hide-counter .pswp__counter {
  display: none;
}

@keyframes om-gallery-spin {
  to {
    transform: rotate(360deg);
  }
}

/*
 * Мобильный режим.
 * Breakpoint должен совпадать с mobile_breakpoint в result_modifier.php.
 */
@media (max-width: 767px) {
  .om-product-gallery {
    width: 100%;
  }

  .om-product-gallery__viewport {
    height: var(--om-gallery-mobile-height);
  }

  .om-product-gallery__arrow {
    display: grid;
    place-items: center;
    width: 34px;
    height: 52px;
    background: rgba(0, 0, 0, .28);
  }

  .om-product-gallery__arrow--prev {
    left: 6px;
  }

  .om-product-gallery__arrow--next {
    right: 6px;
  }

  .om-product-gallery__arrow span {
    font-size: 34px;
  }

  .om-product-gallery__open-hint {
    bottom: 14px;
    font-size: 11px;
  }
}
