/* ===========================================================================
   style.css — блок «Отзывы» на странице товара (шаблон reviews компонента
   bitrix:news.list), Битрикс подключает его сам. Перенесён из шаблона main
   компонента catalog.element. Figma: блок на 68:1378, карточка 102:2738.
   =========================================================================== */

@layer blocks {

  /* === Отзывы ===---------------------------------------------------------- */
  /* Тёмная полоса с линзами по краям — общий блок .lens-band (blocks.css),
     здесь только поля полосы */

  .product-reviews {
    padding-block: calc(3vw + clamp(40px, 5.2vw, 100px)) clamp(80px, 13.9vw, 267px);
  }

  .product-reviews__inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .product-reviews__lead {
    max-width: 915px;
    margin: 10px 0 0;
    color: var(--color-text-muted);
  }

  .product-reviews__stage {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
    margin-top: 40px;
  }

  .product-reviews__arrow {
    position: relative;
    z-index: 1;
    flex: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    background: var(--icon) no-repeat center / 40px 40px;
    cursor: pointer;
  }

  .product-reviews__arrow:hover { background-image: var(--icon-hover); }

  /* У края стопки (Swiper без зацикливания) стрелка гаснет */
  .product-reviews__arrow.swiper-button-disabled {
    opacity: 0.3;
    cursor: default;
  }

  .product-reviews__arrow.swiper-button-disabled:hover { background-image: var(--icon); }

  .product-reviews__arrow--prev { --icon: url(images/arrow-left.svg);  --icon-hover: url(images/arrow-left-hover.svg); }
  .product-reviews__arrow--next { --icon: url(images/arrow-right.svg); --icon-hover: url(images/arrow-right-hover.svg); }

  /* Слайдер — Swiper (script.js). С 768px стопка как в макете: текущий
     отзыв сверху, за ним вправо веером три уменьшенных листа, повёрнутых
     на 5°/10°/15° — положение каждого листа задаёт script.js, у слайдера
     класс .is-stack. На мобильном —
     обычная лента: карточки рядом, листаются свайпом. Классы свои
     (wrapperClass / slideClass), CSS Swiper не подключаем — он без слоя и
     перебил бы наши правила; нужное ему — здесь */
  /* isolation: z-index карточек Swiper остаются внутри слайдера, а стрелки
     и полоски (z-index выше) не накрываются повёрнутой стопкой */
  .product-reviews__slider {
    position: relative;
    z-index: 0;
    isolation: isolate;
    width: min(100%, 526px);
  }

  .product-reviews__list {
    position: relative;
    display: flex;
    margin: 0;
    padding: 0;
    list-style: none;
    transition-property: transform;
    box-sizing: content-box;
  }

  .product-reviews__slide {
    position: relative;
    flex-shrink: 0;
    width: 100%;
    height: auto;
    transform-origin: center center;
    backface-visibility: hidden;
    transition-property: transform, opacity;
  }

  /* До запуска Swiper (и без JS) — только первый отзыв */
  .product-reviews__slider:not(.swiper-initialized) .product-reviews__slide + .product-reviews__slide { display: none; }

  .product-reviews__slider.swiper-initialized { cursor: grab; }

  /* Лента на мобильном: соседние карточки за краем слайдера не видны */
  .product-reviews__slider.swiper-initialized:not(.is-stack) { overflow: hidden; }

  /* Стопка: карточки под верхней — пустые полупрозрачные листы, как в
     макете: ближний 50%, дальние 30% (data-depth ставит script.js) */
  .product-reviews__slider.is-stack .product-reviews__slide:not([data-depth="0"]) .review-card {
    background: rgba(56, 74, 96, 0.3);
  }

  .product-reviews__slider.is-stack .product-reviews__slide[data-depth="1"] .review-card {
    background: rgba(56, 74, 96, 0.5);
  }

  .product-reviews__slider.is-stack .product-reviews__slide:not([data-depth="0"]) .review-card > * {
    opacity: 0;
  }

  .review-card,
  .review-card > * { transition: background-color 0.3s ease, opacity 0.3s ease; }

  .review-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    height: 100%;
    min-height: 400px;
    padding: 70px 31px 60px;
    box-sizing: border-box;
    border-radius: var(--radius-quote);
    background: var(--color-gray-800);
    user-select: none;
  }

  /* Звёзды по 24px через 12px — пять слоёв одной картинки; видно столько,
     сколько в оценке: ширина по --rating (template.php) */
  .review-card__stars {
    --star: url(images/review-star.svg);
    flex: none;
    width: calc(var(--rating, 5) * 36px - 12px);
    height: 24px;
    background:
      var(--star) 0 0 / 24px 24px no-repeat,
      var(--star) 36px 0 / 24px 24px no-repeat,
      var(--star) 72px 0 / 24px 24px no-repeat,
      var(--star) 108px 0 / 24px 24px no-repeat,
      var(--star) 144px 0 / 24px 24px no-repeat;
  }

  .review-card__text {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: var(--fs-text-m);
    line-height: 1.25;
  }

  /* Дата публикации — внизу карточки */
  .review-card__date {
    margin-top: auto;
    color: var(--color-gray-500);
    font-size: var(--fs-text-s);
    line-height: 1.25;
  }

  /* Отзыв может быть HTML с абзацами */
  .review-card__text p { margin: 0; }
  .review-card__text p + p { margin-top: 0.5em; }

  .product-reviews__dots {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 10px;
    width: min(100%, 258px);
    margin-top: 40px;
  }

  /* Полоски — пагинация Swiper (bulletClass / bulletActiveClass) */
  .product-reviews__dot {
    flex: 1;
    height: 6px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: var(--color-gray-800);
    cursor: pointer;
    transition: background-color var(--transition);
  }

  .product-reviews__dot.is-active { background: var(--color-white); }

  @media (width < 768px) {
    .product-reviews__arrow { display: none; }
    .review-card { min-height: 0; padding: 40px 20px; }
  }

  @media (width >= 768px) {
    /* повёрнутые листы стопки не должны наезжать на текст над слайдером */
    .product-reviews__stage { gap: 155px; margin-top: 90px; }
    .product-reviews__slider { flex: 0 1 526px; }
  }
}
