/* rvd174.ru — карточка товара (все виды: РВД, промрукава, фитинги, адаптеры, муфты, БРС, спираль, станки).
   Подключается только в шаблоне «Товар». Переменные — из main.css. */
@layer components {
  /* сетка карточки: слева галерея и описание, справа заголовок, цена и характеристики;
     на телефоне — заголовок, галерея, цена, характеристики, описание */
  .product {
    display: grid; grid-template-columns: minmax(0, 45fr) minmax(0, 55fr); column-gap: 40px;
    grid-template-areas: "media head" "media info" "about info"; grid-template-rows: auto auto 1fr;
    margin-top: 40px;
  }
  .product__head { grid-area: head; }
  .product__media { grid-area: media; }
  .product__info { grid-area: info; }
  .product__about { grid-area: about; }

  .product__title { font-size: clamp(30px, 3.9vw, 56px); font-weight: 600; line-height: 1.12; }
  .product__subtitle { display: block; margin-top: 12px; font-size: clamp(20px, 1.8vw, 26px); line-height: 1.25; }

  .product__h2 { margin-bottom: 18px; font-size: 16px; font-weight: 500; text-transform: uppercase; }
  .product__h2--big { margin-bottom: 14px; font-size: clamp(22px, 1.8vw, 26px); font-weight: 500; text-transform: none; }
  .product__section, .product__buy, .rating { padding-block: 28px; border-top: 1px solid #ccc; }

  /* галерея (вид — как stgGallery старого сайта): квадратная сцена с тонкой обводкой, лента слайдов с прокруткой-«защёлкой»,
     круглые стрелки, счётчик внизу слева, миниатюры с тонкой обводкой (активная — красная рамка), видео на тёмном фоне */
  .gallery { margin-bottom: 30px; }
  .gallery__stage { position: relative; aspect-ratio: 1; border: 1px solid var(--c-frame); border-radius: 16px; background: var(--c-white); overflow: hidden; }
  .gallery__track { display: flex; height: 100%; overflow: auto hidden; scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none; overscroll-behavior-x: contain; }
  .gallery__track::-webkit-scrollbar { display: none; }
  .gallery__track:focus-visible { outline: 2px solid var(--c-red); outline-offset: -2px; }
  /* слайд — flex с точной высотой: в нём height в % считается от слайда (в grid-ячейке не считался, и содержимое вылезало) */
  .gallery__slide { position: relative; flex: 0 0 100%; height: 100%; padding: 14px; display: flex; align-items: center; justify-content: center; overflow: hidden; scroll-snap-align: center; scroll-snap-stop: always; }
  .gallery__slide > :not(.gallery__expand) { width: 100%; height: 100%; min-height: 0; }
  .gallery__zoom { display: block; cursor: zoom-in; }
  .gallery__zoom picture, .gallery__play picture { display: contents; }
  .gallery__img { display: block; width: 100%; height: 100%; object-fit: contain; }
  /* видео: во всю сцену на чёрном, как плеер */
  .gallery__slide--video { padding: 0; background: #000; }
  .gallery__video { display: block; object-fit: contain; background: #000; }
  .gallery__play { position: relative; display: grid; place-items: center; border: 0; padding: 0; background: radial-gradient(circle at 50% 40%, #2b2b2f, #111); }
  .gallery__play .gallery__img { position: absolute; inset: 0; opacity: .92; }
  .gallery__play-icon { position: relative; width: 72px; height: 72px; border-radius: 50%; background: rgb(183 21 19 / .94); box-shadow: 0 6px 24px rgb(0 0 0 / .35); transition: scale var(--t); }
  .gallery__play-icon::after, .gallery__thumb--video::after { content: ""; position: absolute; left: 50%; top: 50%; translate: -36% -50%; border-style: solid; border-color: transparent; border-left-color: var(--c-white); border-width: 13px 0 13px 21px; }
  .gallery__play:hover .gallery__play-icon { scale: 1.08; }
  .gallery__expand {
    position: absolute; right: 10px; top: 10px; z-index: 3; display: grid; place-items: center; width: 38px; height: 38px;
    border: 0; border-radius: 10px; background: rgb(0 0 0 / .55); color: var(--c-white); transition: background-color var(--t);
  }
  .gallery__expand:hover { background: rgb(0 0 0 / .75); }
  .gallery__expand .icon { width: 20px; height: 20px; }
  .gallery__nav {
    position: absolute; top: 50%; translate: 0 -50%; z-index: 2; display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
    border: 0; border-radius: 50%; background: rgb(255 255 255 / .92); color: #1d1d1f; box-shadow: 0 2px 12px rgb(0 0 0 / .2);
    transition: background-color var(--t), scale var(--t);
  }
  .gallery__nav:hover { background: var(--c-white); scale: 1.07; }
  .gallery__nav .icon { width: 24px; height: 24px; }
  .gallery__nav--prev { left: 10px; } .gallery__nav--prev .icon { rotate: 90deg; }
  .gallery__nav--next { right: 10px; } .gallery__nav--next .icon { rotate: -90deg; }
  .gallery__counter { position: absolute; left: 12px; bottom: 12px; z-index: 2; padding: 4px 11px; border-radius: 20px; background: rgb(0 0 0 / .55); color: var(--c-white); font-size: 13px; line-height: 1.4; pointer-events: none; }
  /* лента миниатюр: листается только вбок (overflow-y задан явно, иначе при overflow-x:auto браузер ставит auto и по вертикали),
     полосы прокрутки нет — вместо неё края плавно гаснут, если в ту сторону есть ещё миниатюры (классы ставит product.js);
     мышью ленту можно тянуть */
  .gallery__thumbs {
    position: relative; display: flex; gap: 8px; margin-top: 10px; padding: 3px 2px; overflow: auto hidden;
    scroll-behavior: smooth; scrollbar-width: none; overscroll-behavior-x: contain;
  }
  .gallery__thumbs::-webkit-scrollbar { display: none; }
  .gallery__thumbs.has-left { mask-image: linear-gradient(90deg, transparent, #000 36px); }
  .gallery__thumbs.has-right { mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent); }
  .gallery__thumbs.has-left.has-right { mask-image: linear-gradient(90deg, transparent, #000 36px, #000 calc(100% - 36px), transparent); }
  .gallery__thumbs.is-dragging { cursor: grabbing; scroll-behavior: auto; }
  .gallery__thumbs li { flex: none; }
  /* блочная кнопка с точной высотой: картинка 100%×100% вписывается в рамку */
  .gallery__thumb {
    position: relative; display: block; width: 86px; height: 66px; padding: 4px; border: 2px solid transparent; border-radius: 10px;
    background: var(--c-white); box-shadow: 0 0 0 1px var(--c-frame); opacity: .75; overflow: hidden; transition: opacity var(--t), border-color var(--t);
  }
  .gallery__thumb:hover, .gallery__thumb[aria-current="true"] { opacity: 1; }
  .gallery__thumb[aria-current="true"] { border-color: var(--c-red); }
  .gallery__thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
  .gallery__thumb--video { background: #161618; }
  .gallery__thumb--video img { position: absolute; inset: 0; object-fit: cover; opacity: .85; }
  .gallery__thumb--video::before { content: ""; position: absolute; z-index: 1; left: 50%; top: 50%; translate: -50% -50%; width: 30px; height: 30px; border-radius: 50%; background: rgb(183 21 19 / .94); }
  .gallery__thumb--video::after { z-index: 1; border-width: 6px 0 6px 10px; }  /* поверх картинки (она позиционирована и иначе перекрывает значок) */
  /* одно фото — без сцены, в своих пропорциях, со скруглёнными углами (как на старом сайте) */
  .gallery--single .gallery__img { height: auto; border-radius: 14px; }
  .gallery--empty { aspect-ratio: 1; display: grid; place-items: center; border: 1px dashed var(--c-line); border-radius: 16px; color: var(--c-muted); }

  /* наличие */
  .stock { margin-top: 26px; }
  .stock__row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 22px; }
  .stock__text { font-size: 18px; }
  .stock__text small { display: block; margin-top: 4px; font-size: 14px; color: var(--c-muted); }
  .stock__badge { flex: none; padding: 8px 14px; border-radius: var(--radius-s); background: #fbe3e3; color: var(--c-red); font-size: 14px; font-weight: 500; text-transform: uppercase; }

  /* цена и кнопки */
  .price { margin-bottom: 30px; font-size: 18px; }
  .price--ask { text-align: left; font-size: clamp(12px, 1.8vw, 18px); font-weight: 500; }
  .price__label { font-size: 13px; font-weight: 500; text-transform: uppercase; color: #6b6b6b; }
  .price__value { margin-left: 10px; font-size: clamp(30px, 3vw, 42px); font-weight: 700; color: var(--c-red); white-space: nowrap; }
  .price__old { margin-left: 10px; font-size: 20px; color: var(--c-muted); }
  .product__buttons { display: flex; flex-wrap: wrap; gap: 30px; }
  .btn--dark, .btn--grey { min-height: 46px; padding: 11px 24px; border-radius: var(--radius-m); font-size: 15px; font-weight: 500; text-transform: uppercase; }
  .btn--dark { background: var(--c-black); }
  .btn--dark:hover { background: #333; }
  .btn--grey { background: #ccc; color: var(--c-text); }
  .btn--grey:hover { background: #bbb; color: var(--c-text); }
  .product__warranty { margin-top: 18px; font-size: 14px; }
  .product__warranty a { color: var(--c-red); }

  /* рейтинг */
  .rating { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 16px; }
  .rating__stars { position: relative; font-size: 22px; line-height: 1; color: #e0e0e0; letter-spacing: 2px; }
  .rating__stars::before { content: "★★★★★"; position: absolute; inset: 0 auto 0 0; width: var(--rating, 0%); overflow: hidden; color: #ffc107; }
  .rating__value { font-size: 19px; font-weight: 700; }
  .rating__count { color: var(--c-muted); }

  /* характеристики и комплектность: сетка в 3 колонки, у станков — список */
  .specs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 16px; }
  .specs__row dt { margin-bottom: 4px; font-size: 12px; font-weight: 600; line-height: 1.35; text-transform: uppercase; color: #6b6b6b; }
  .specs__row dd { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
  .specs--list { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .specs--list .specs__row dt { font-size: 14px; font-weight: 400; text-transform: none; }
  .specs.is-collapsed { max-height: 200px; overflow: hidden; mask-image: linear-gradient(#000 70%, transparent); }
  .specs__more { display: block; margin: 12px 0 0 auto; padding: 0; border: 0; background: none; color: var(--c-red); font-size: 14px; text-transform: uppercase; }
  .specs__more:hover { text-decoration: underline; }

  .product__delivery p { font-size: 15px; }
  .product__brand { margin-top: 16px; max-width: 100%; }

  /* описание и особенности (левая колонка) */
  .product__summary { margin-bottom: 36px; }
  .prose { font-size: 15px; line-height: 1.45; }
  .prose > * + * { margin-top: .8em; }
  .prose ul, .prose ol { padding-left: 1.3em; }
  .prose h2 { font-size: 20px; }
  .prose h3 { font-size: 17px; }
  .prose img { height: auto; }
  .prose table { border-collapse: collapse; width: 100%; }
  .prose td, .prose th { padding: 6px 8px; border: 1px solid var(--c-line); }

  .features__heading { margin-bottom: 24px; font-size: clamp(22px, 1.8vw, 26px); font-weight: 500; }
  .features__list { display: grid; gap: 26px; }
  .features__item { display: grid; grid-template-columns: 60px minmax(0, 1fr); column-gap: 24px; row-gap: 6px; align-items: center; }
  .features__item > picture { grid-row: 1 / 3; display: block; width: 60px; height: 60px; }
  .features__icon { width: 60px; height: 60px; object-fit: contain; }   /* серый круг уже нарисован в самой картинке 60×60 */
  .features__title { font-size: 16px; font-weight: 500; text-transform: uppercase; }
  .features__text { font-size: 14px; }

  /* преимущества (станки) */
  .benefits { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 30px; margin-top: 50px; }
  .benefits__item { position: relative; min-height: 280px; padding: 20px 16px; border-radius: 30px 30px 30px 80px; background: #141414; color: var(--c-white); overflow: hidden; }
  .benefits__title { display: block; text-align: right; font-size: 17px; font-weight: 600; line-height: 1.2; text-transform: uppercase; }
  .benefits__icon { position: absolute; left: 16px; bottom: 16px; width: 140px; height: 140px; border-radius: 50%; background: #f2f2f2; padding: 20px; }
  .benefits__item::after { content: ""; position: absolute; right: 18px; bottom: 18px; width: 48px; height: 48px;
    background: radial-gradient(circle at 75% 25%, var(--c-red) 7px, transparent 8px), radial-gradient(circle at 25% 75%, var(--c-red) 7px, transparent 8px), radial-gradient(circle at 75% 75%, var(--c-red) 7px, transparent 8px); }

  /* вкладки «Свойства / Особенности / Описание» */
  .tabs { margin-top: 50px; }
  .tabs:not(:has(.tabs__panel)) { display: none; }
  .tabs__list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
  .tabs__tab { padding: 10px 22px; border: 1px solid var(--c-line); border-radius: var(--radius-s); background: var(--c-white); font-size: 16px; }
  .tabs__tab[aria-selected="true"] { border-color: var(--c-red); background: var(--c-red); color: var(--c-white); }
  .tabs__panel + .tabs__panel { margin-top: 40px; }
  .tabs__title { margin-bottom: 16px; }
  .tabs.is-ready .tabs__panel + .tabs__panel { margin-top: 0; }
  .tabs.is-ready .tabs__title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

  /* увеличенное фото: окно <dialog> со стрелками и листанием пальцем */
  /* окно на весь экран, затемнение почти чёрное; фото/видео по центру; клик мимо них закрывает окно */
  .zoom { width: 100%; height: 100%; max-width: none; max-height: none; background: transparent; overflow: hidden; }
  .zoom::backdrop { background: rgb(10 10 12 / .93); }
  .zoom__body {
    position: absolute; inset: 0; margin: auto; width: min(96vw, 1400px); height: min(86vh, 900px);
    display: flex; align-items: center; justify-content: center; pointer-events: none;
  }
  .zoom__body > * { max-width: 100%; max-height: 100%; pointer-events: auto; }
  .zoom__img { object-fit: contain; border-radius: 6px; background: var(--c-white); touch-action: pan-y pinch-zoom; }
  .zoom__video { border-radius: 8px; background: #000; }
  .zoom__close, .zoom__nav {
    position: absolute; z-index: 2; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%;
    background: rgb(255 255 255 / .14); color: var(--c-white); transition: background-color var(--t);
  }
  .zoom__close:hover, .zoom__nav:hover { background: rgb(255 255 255 / .3); }
  .zoom__close { top: 16px; right: 16px; width: 46px; height: 46px; }
  .zoom__nav { top: 50%; translate: 0 -50%; width: 52px; height: 52px; }
  .zoom__nav .icon, .zoom__close .icon { width: 26px; height: 26px; }
  .zoom__nav--prev { left: 16px; } .zoom__nav--prev .icon { rotate: 90deg; }
  .zoom__nav--next { right: 16px; } .zoom__nav--next .icon { rotate: -90deg; }
  .zoom__cap { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; color: #cfcfd4; font-size: 14px; pointer-events: none; }

  @media (max-width: 1199px) {
    .specs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .benefits { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (max-width: 959px) {
    .product { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "media" "info" "about"; grid-template-rows: none; margin-top: 16px; }
    .product__head { margin-bottom: 20px; }
    .gallery { margin-bottom: 10px; }
    .product__about { margin-top: 20px; }
    .product__buttons { gap: 12px; }
    .product__buttons .btn { flex: 1 1 200px; }
  }
  @media (max-width: 760px) {   /* галерея на телефоне — размеры как у старого сайта */
    .gallery__stage { border-radius: 12px; }
    .gallery__nav { width: 38px; height: 38px; }
    .gallery__thumb { width: 72px; height: 56px; }
    .gallery__play-icon { width: 62px; height: 62px; }
    .zoom__body { width: 100vw; height: 80vh; }
    .zoom__nav { width: 42px; height: 42px; }
    .zoom__nav--prev { left: 6px; } .zoom__nav--next { right: 6px; }
  }
  @media (prefers-reduced-motion: reduce) {
    .gallery__track, .gallery__thumbs { scroll-behavior: auto; }
  }
  @media (max-width: 639px) {
    .specs { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .benefits { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .benefits__item { min-height: 200px; }
    .benefits__icon { width: 110px; height: 110px; }
  }
}
