/**
 * Топ-Тюнинг: галерея карточки — лента кадров на странице и полоса миниатюр.
 * Стили работают поверх `slider.css` и включаются только при активном модуле
 * (класс `psg-on` на контейнере `.au-rama`).
 */

.psg-host > .product-image {
  display: none;
}

.psg {
  position: relative;
  /* без просвета до полосы миниатюр: владелец видел белую полосу в 8 px
     между кадром и превью (01.11.2026) */
  margin: 0;
}

.psg__viewport {
  position: relative;
  /* ширина явно, а не auto: в блоке описания на проде (`overflow: hidden`
     у `.collapsed`) браузер считал auto-ширину нулевой и лента схлопывалась
     в 0 px по высоте (02.11.2026) */
  width: 100%;
  overflow: hidden;
  background: #0d0f12;
  border-radius: 8px;
  outline: none;
}

.psg__viewport:focus-visible {
  box-shadow: 0 0 0 2px #e2001a;
}

.psg__track {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.psg__track::-webkit-scrollbar {
  display: none;
}

/* кадр держит пропорцию 3:2 — как .au-rama-aspect в легаси-слайдере:
   раньше здесь стояла фиксированная высота 420 px, и фото 3:2 повисало
   маленьким прямоугольником в чёрном поле во всю ширину колонки */
.psg__slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 3 / 2;
  cursor: zoom-in;
}

.psg__img {
  display: block;
  width: 100%;
  height: 100%;
  /* кадр заполняет рамку целиком: ни чёрных полей, ни просветов */
  object-fit: cover;
  -webkit-user-drag: none;
  user-select: none;
}

.psg__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(17, 20, 24, .62);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
  transition: background .15s ease, opacity .15s ease;
}

.psg__nav:hover {
  background: #e2001a;
}

.psg__nav_prev {
  left: 10px;
}

.psg__nav_next {
  right: 10px;
}

.psg__zoom {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(17, 20, 24, .62);
  color: #fff;
  cursor: pointer;
  z-index: 3;
  transition: background .15s ease, opacity .15s ease;
}

.psg__zoom:hover {
  background: #e2001a;
}

.psg__zoom svg {
  display: block;
  margin: 0 auto;
}

.psg__counter {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(17, 20, 24, .62);
  color: #fff;
  font-size: 12px;
  letter-spacing: .02em;
  z-index: 3;
  pointer-events: none;
}

/* на карточке товара сайт прячет весь легаси-блок (item.css:320) —
   показываем его обратно, нам из него нужна только полоса миниатюр */
.product_page_card .au-rama.big-photo.psg-on,
.product_page_card .psg-on .au-rama-thumbs {
  visibility: visible !important;
}

/* полоса миниатюр: нативная прокрутка вместо float-ленты легаси-слайдера
   display:block обязателен — сайтовый slider.css прячет полосу до класса
   .full-screen, которым управлял старый gallery.js (мы его не грузим) */
.psg-on .au-rama-thumbs {
  display: block !important;
  width: 100%;
  height: 88px !important;
  overflow: visible;
}

.psg-on .au-rama-thumbs__wrapper {
  /* сайт ставит position:absolute!important и width:9999em для float-ленты */
  position: static !important;
  width: 100% !important;
  overflow: visible;
  height: auto;
  /* легаси-скрипт двигает ленту через transform: translateX(-104px) */
  transform: none !important;
}

.psg-on .au-rama-thumbs__inner {
  position: static;
  display: flex;
  flex-wrap: nowrap;
  justify-content: safe center;
  width: 100% !important;
  max-width: 100% !important;
  height: 88px;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  list-style: none;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.psg-on .au-rama-thumbs__inner > li {
  float: none;
  flex: 0 0 auto;
  width: 152px;
  height: 88px;
}

.psg-on .au-rama-thumbs__link {
  display: block;
  width: 152px;
  height: 88px;
  overflow: hidden;
}

.psg-on .au-rama-thumbs__img {
  width: 152px;
  height: 88px;
  object-fit: cover;
}

.psg-on .au-rama-thumbs__nav,
.psg-on .au-rama-thumbs__rama {
  display: none !important;
}

.psg-on .au-rama-big {
  /* !important нужен: video_sources.js оставляет инлайновый display:block
     после закрытия плеера (ревью Кодекса, блокер 1). В видео-режиме правило
     ниже специфичнее и тоже с !important — оно и выигрывает. */
  display: none !important;
}

/* режим видео: лента кадров уступает место большому блоку с плеером.
   На карточке .psg — сосед .au-rama (вставлен в .product-img-box), поэтому
   класс psg-video ставится и на контейнер сцены: ловим оба случая. */
.psg-on.psg-video .psg,
.psg-video .psg {
  display: none !important;
}

.psg-on.psg-video .au-rama-big {
  display: block !important;
  visibility: visible !important;
}

/* страховка без JS: как только внутри большого блока появился плеер,
   показываем блок и прячем ленту — не зависим от того, успел ли модуль
   переключить режим (iframe YouTube приходит асинхронно) */
.psg-on .au-rama-big:has(iframe, video, .tt-video--overlay) {
  display: block !important;
  visibility: visible !important;
}

.psg-host:has(.au-rama-big iframe) > .psg,
.psg-host:has(.au-rama-big video) > .psg,
.psg-host:has(.tt-video--overlay) > .psg {
  display: none !important;
}

.psg-on.psg-video .au-rama-thumbs__link.psg-thumb-active {
  outline-color: #6b7280;
}

.psg-on .au-rama-thumbs__link.psg-thumb-active {
  outline: 3px solid #e2001a;
  outline-offset: -3px;
}

.psg-on .au-rama-thumbs__link {
  cursor: pointer;
}

/* подпись кадра в полноэкранном просмотре */
.psg-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 14px;
  background: rgba(0, 0, 0, .82);
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  z-index: 20;
  pointer-events: none;
}

@media (max-width: 750px) {
  .psg__img {
    max-height: 100%;
  }

  .psg__nav {
    width: 40px;
    height: 40px;
    font-size: 22px;
  }

  .psg__nav_prev {
    left: 6px;
  }

  .psg__nav_next {
    right: 6px;
  }

  .psg__zoom {
    right: 6px;
    top: 6px;
    width: 34px;
    height: 34px;
  }

  .psg__counter {
    left: 6px;
    top: 6px;
    font-size: 11px;
  }

  .psg-caption {
    font-size: 13px;
    padding: 8px 12px;
  }
}

/* ── полоса миниатюр внутри полноэкранного просмотрщика ─────────────────── */
.psg-thumbs {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 12px 12px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  background: linear-gradient(to top, rgba(0, 0, 0, .88), rgba(0, 0, 0, .55) 60%, rgba(0, 0, 0, 0));
}
.psg-thumbs::-webkit-scrollbar { display: none; }
.psg-thumbs__item {
  flex: 0 0 auto;
  width: 152px;
  height: 88px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  background: #1b1f24;
  overflow: hidden;
  cursor: pointer;
  opacity: .55;
  transition: opacity .15s, border-color .15s;
}
.psg-thumbs__item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.psg-thumbs__item:hover { opacity: .85; }
.psg-thumbs__item.is-active { opacity: 1; border-color: #e2001a; }
.psg-thumbs__item:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* подпись в просмотрщике — над полосой */
.pswp .psg-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 114px;
  z-index: 25;
  padding: 10px 16px;
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  background: rgba(0, 0, 0, .82);
}

@media (max-width: 750px) {
  .psg-thumbs { padding: 8px 8px 10px; gap: 5px; }
  .psg-thumbs__item { width: 96px; height: 56px; }
  .pswp .psg-caption { bottom: 74px; font-size: 13px; padding: 8px 12px; }
}

/* планшеты 768–1023: item.css держит левую колонку 500px с overflow:hidden,
   наша галерея выше — снимаем ограничение только у инициализированной галереи */
@media (min-width: 768px) and (max-width: 1023px) {
  .product_page_card .left.psg-host {
    height: auto !important;
    overflow: visible !important;
  }
}

/* Кнопка «поделиться» и подсказка в полноэкранном просмотре.
   Кнопка живёт в верхней полосе PhotoSwipe (appendTo: 'bar'), поэтому это
   не круг на абсолютной позиции, а слот 50×60 в общем ряду с «лупой» и
   крестиком: иконка с тёмной подложкой внутри, позицию задаёт сама полоса. */
.psg-share {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 60px;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.psg-share svg {
  box-sizing: content-box;
  /* 20 px иконка + 7 px подложки = 34 px круг: чуть крупнее штатных
     иконок PhotoSwipe (32 px), но того же порядка — не спорит с «лупой». */
  padding: 7px;
  border-radius: 50%;
  background: rgba(17, 20, 24, 0.62);
  transition: background-color 0.2s ease;
}

.pswp--ui-visible .psg-share {
  opacity: 1;
}

.psg-share:hover svg,
.psg-share:focus-visible svg {
  background: #e2001a;
}

.psg-share:focus-visible {
  outline: none;
}

.psg-toast {
  position: absolute;
  left: 50%;
  bottom: 132px;
  transform: translateX(-50%);
  z-index: 30;
  max-width: min(90vw, 520px);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(17, 20, 24, 0.92);
  color: #fff;
  font: 500 14px/1.35 inherit;
  text-align: center;
  pointer-events: none;
  word-break: break-all;
}

@media (max-width: 750px) {
  /* Размер кнопки «поделиться» не переопределяем: она в общей полосе
     PhotoSwipe, и полоса сама держит высоту 60 px и ширину кнопок 50 px. */

  .psg-toast {
    bottom: 88px;
    font-size: 13px;
  }
}

/* ------------------------------------------------------------------ */
/* Главная галерея карточки товара: одно фото ровным квадратом        */
/* ------------------------------------------------------------------ */

.psg--card {
  margin: 0;
}

.psg--card .psg__viewport,
.psg--card .psg__slide {
  aspect-ratio: 1 / 1;
}

.psg--card .psg__nav,
.psg--card .psg__counter {
  display: none;
}

/* полоса миниатюр снаружи: превью — только в полноэкранном просмотре */
.psg-host--card .au-rama-thumbs,
.psg--card ~ .au-rama .au-rama-thumbs {
  display: none !important;
}

/* ------------------------------------------------------------------ */
/* Главная картинка карточки услуги: всегда прямоугольная 3:2         */
/* ------------------------------------------------------------------ */

/* карточка услуги: кадр прямоугольный, стрелок и счётчика снаружи нет */
.psg--service .psg__viewport,
.psg--service .psg__slide {
  aspect-ratio: 3 / 2;
}

.psg-thumbs__item--video {
  position: relative;
}

.psg-thumbs__item--video::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  margin: -9px 0 0 -6px;
  border-style: solid;
  border-width: 9px 0 9px 15px;
  border-color: transparent transparent transparent #fff;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6));
  pointer-events: none;
}

.psg-card-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.product-view.service .au-rama-thumbs {
  display: none;
}

/* ------------------------------------------------------------------ */
/* Иконки управления — по наведению (решение владельца, 03.11.2026)    */
/* ------------------------------------------------------------------ */

/*
 * На десктопе стрелки, лупа и «поделиться» закрывают кусок кадра, поэтому по
 * умолчанию они прозрачные и проявляются при наведении на галерею или на
 * полноэкранный просмотр. `pointer-events: none` у скрытых иконок — чтобы
 * нельзя было нажать невидимую кнопку; фокус с клавиатуры их возвращает
 * через :focus-within / :focus-visible.
 *
 * Всё это только для устройств с мышью: на телефоне и планшете наведения нет,
 * и там иконки остаются видимыми всегда — иначе галерею нечем листать.
 *
 * Блок стоит последним в файле: у `.pswp--ui-visible .psg-share` такая же
 * специфичность, и наше правило должно перекрывать её.
 *
 * «Поделиться» в полноэкранном просмотре: сам просмотр занимает весь экран,
 * поэтому его :hover истинен всегда и кнопку им не скрыть. Класс
 * `.psg-share-reveal` вешает photoswipe-gallery.js, когда курсор попадает в
 * верхнюю полосу — туда же, где кнопка закрытия.
 */
@media (hover: hover) and (pointer: fine) {
  .psg__nav,
  .psg__zoom,
  .pswp--ui-visible .psg-share {
    opacity: 0;
    pointer-events: none;
  }

  .psg:hover .psg__nav,
  .psg:hover .psg__zoom,
  .psg:focus-within .psg__nav,
  .psg:focus-within .psg__zoom,
  .psg-share-reveal .psg-share,
  .psg-share:focus-visible {
    opacity: 1;
    pointer-events: auto;
  }
}

/* 20.11.2026: автор снимка на кадре (data-author миниатюры), как подпись старого слайдера */
.psg__slide--credit {
  position: relative;
}
.psg__author {
  position: absolute;
  right: 8px;
  bottom: 6px;
  max-width: 70%;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(17, 20, 24, .55);
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
/* 20.11.2026: при ≤ N фото старый слайдер превращал полосу миниатюр в точки-«пули»
   (au-rama-bullit) – под галереей новости оставался один кружок. Счётчик и стрелки есть у psg. */
.news-detail .psg-on.au-rama-bullit .au-rama-thumbs {
  display: none !important;
}
