/* Catalog — сетка карточек товаров
   Figma: 360 card (6645:14872) / Product card 1440 (6628:12422)
   Mobile first; desktop layout с 768
*/

.bz-catalog-products {
  background-color: var(--bz-bg-prim, #f7f6f1);
  /* Figma: фильтры → товары = 40px (360 и 1440); боковые 20 / 30 */
  padding: 40px 20px 0;
  margin: 0;
  box-sizing: border-box;
  overflow: visible !important;
}

/* Не даём Bootstrap .px-* / .p-* сбить горизонтальные отступы макета */
.bz-catalog-products.px-0,
.bz-catalog-products.p-0 {
  padding-left: 20px !important;
  padding-right: 20px !important;
  padding-top: 40px !important;
}

.bz-catalog-products__empty {
  margin: 0;
  padding: 24px 0;
  color: var(--bz-b-100, #2d2c2c);
  font-family: Inter, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: -0.02em;
}

.bz-catalog-products__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 15px;
  row-gap: 25px;
  margin: 0;
  padding: 0;
}

/* Bitrix ajax-строки не должны ломать CSS-grid */
.bz-catalog-products__grid [data-entity="items-row"] {
  display: contents;
}

.bz-catalog-products__grid [data-entity="items-row"] > [class*="col"],
.bz-catalog-products__grid [data-entity="items-row"] > [class*="col"].p-1 {
  width: auto;
  max-width: none;
  flex: none;
  /* Bootstrap .p-1 использует !important — иначе карточка уже макета */
  padding: 0 !important;
  margin: 0;
}

.bz-catalog-products .product-item-container {
  height: 100%;
}

/* ——— Card ——— */
.bz-pcard {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.bz-pcard__media {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 153 / 137;
  overflow: hidden;
  text-decoration: none;
  background-color: #edeae7;
}

.bz-pcard__img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  padding: 0;
  border: 0;
  border-radius: 0;
  transition: opacity 0.25s ease;
}

.bz-pcard__img--hover {
  opacity: 0;
}

.bz-pcard__media:hover .bz-pcard__img--hover {
  opacity: 1;
}

/* :focus-visible отдельно — Safari < 15.4 не знает его и выбросил бы правило с :hover целиком */
.bz-pcard__media:focus-visible .bz-pcard__img--hover {
  opacity: 1;
}

.bz-pcard__media:hover .bz-pcard__img--main.has-hover {
  opacity: 0;
}

.bz-pcard__media:focus-visible .bz-pcard__img--main.has-hover {
  opacity: 0;
}

.bz-pcard__actions {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bz-pcard__fav,
.bz-pcard__compare {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 40px;
  background-color: #fff;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: none;
}

.bz-pcard__fav:hover,
.bz-pcard__compare:hover {
  background-color: #fff;
}

.bz-pcard__fav:focus-visible,
.bz-pcard__compare:focus-visible {
  background-color: #fff;
}

.bz-pcard__fav img,
.bz-pcard__compare img {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.bz-pcard__body {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  gap: 15px;
  margin: 15px 0 0;
  padding: 0;
  background: transparent;
}

.bz-pcard__meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
}

.bz-pcard__title {
  margin: 0;
  color: var(--bz-b-100, #2d2c2c);
  font-family: Inter, sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: -0.02em;
}

.bz-pcard__title a {
  color: inherit;
  text-decoration: none;
}

.bz-pcard__title a:hover {
  color: var(--bz-prim, #f27e00);
  text-decoration: none;
}

.bz-pcard__title a:focus-visible {
  color: var(--bz-prim, #f27e00);
  text-decoration: none;
}

.bz-pcard__stock {
  margin: 0;
  color: rgba(45, 44, 44, 0.6);
  font-family: Inter, sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: -0.02em;
  /* Figma: «в наличии» lowercase */
  text-transform: lowercase;
}

.bz-pcard__price {
  margin: 0;
  color: var(--bz-b-100, #2d2c2c);
  font-family: Inter, sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.02em;
}

.bz-pcard__price .sale {
  display: inline-block;
  margin-left: 8px;
  color: rgba(45, 44, 44, 0.45);
  font-weight: 400;
  text-decoration: line-through;
}

.bz-pcard__order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  padding: 10px 20px;
  margin: 0;
  border: 0;
  border-radius: 40px;
  background-color: var(--bz-prim, #f27e00);
  color: #fff;
  -webkit-text-fill-color: #fff;
  font-family: Inter, sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
  text-decoration: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  opacity: 1;
  transform: none;
  animation: none;
}

.bz-pcard__order:hover {
  background-color: var(--bz-prim-hov, #ff9521);
  color: #fff;
  -webkit-text-fill-color: #fff;
}

.bz-pcard__order:focus-visible {
  background-color: var(--bz-prim-hov, #ff9521);
  color: #fff;
  -webkit-text-fill-color: #fff;
}

/* Сбрасываем старую hover-анимацию кнопки */
.bz-pcard.bz-product-card .bz-btn-buy,
.bz-pcard.bz-product-card:hover .bz-btn-buy {
  opacity: 1;
  transform: none;
  animation: none;
}

/* ——— Desktop с 768 ——— */
@media (min-width: 768px) {
  .bz-catalog-products {
    padding: 40px 30px 0;
  }

  .bz-catalog-products.px-0,
  .bz-catalog-products.p-0 {
    padding-left: 30px !important;
    padding-right: 30px !important;
    padding-top: 40px !important;
  }

  .bz-catalog-products__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 15px;
    row-gap: 50px;
  }

  .bz-pcard__media {
    aspect-ratio: 450 / 286;
  }

  .bz-pcard__actions {
    top: 20px;
    right: 20px;
  }

  .bz-catalog-products .bz-pcard__body {
    gap: 20px;
    margin-top: 25px;
    justify-content: flex-start;
  }

  .bz-catalog-products .bz-pcard__stock {
    color: #7e7d7b;
  }

  /* В макете 1440 кнопка скрыта (opacity 0); показываем по hover как в текущем UX */
  .bz-catalog-products .bz-pcard.bz-product-card .bz-pcard__order.bz-btn-buy {
    width: auto;
    min-width: 160px;
    align-self: flex-start;
    opacity: 0 !important;
    transform: rotate(-8.63deg);
    transform-origin: center right;
    transition: opacity 0.25s ease, transform 0.25s ease, background-color 0.2s ease;
    animation: none !important;
  }

  .bz-catalog-products .bz-pcard.bz-product-card:hover .bz-pcard__order.bz-btn-buy,
  .bz-catalog-products .bz-pcard.bz-product-card:focus-within .bz-pcard__order.bz-btn-buy {
    opacity: 1 !important;
    transform: rotate(0);
    animation: none !important;
  }
}

/* ——— «Показать ещё» ———
   Figma: 360 btn 6645:14868 + divider 6645:14869
         1440 btn 6628:12418 + divider 6628:12419
*/
.bz-catalog-more {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 49px 0 0;
  padding: 0 0 60px;
  box-sizing: border-box;
  text-align: center;
}

.bz-catalog-more__divider {
  display: block;
  width: 100%;
  height: 0;
  margin: 0 0 20px;
  padding: 0;
  border: 0;
  border-top: 1px solid #cecece;
}

.bz-catalog-more__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--bz-b-100, #2d2c2c);
  font-family: Inter, sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.bz-catalog-more__btn:hover {
  color: var(--bz-prim, #f27e00);
}

.bz-catalog-more__btn:focus-visible {
  color: var(--bz-prim, #f27e00);
}

.bz-catalog-more__btn:disabled {
  opacity: 0.55;
  cursor: default;
  color: var(--bz-b-100, #2d2c2c);
}

@media (min-width: 768px) {
  .bz-catalog-more {
    margin-top: 60px;
    padding-bottom: 100px;
  }

  .bz-catalog-more__divider {
    margin-bottom: 25px;
  }
}

/* Safari < 15: нет aspect-ratio — держим пропорции через padding-хак */
@supports not (aspect-ratio: 1 / 1) {
  .bz-pcard__media::before {
    content: '';
    display: block;
    padding-top: 89.5425%; /* 137 / 153 */
  }

  @media (min-width: 768px) {
    .bz-pcard__media::before {
      padding-top: 63.5556%; /* 286 / 450 */
    }
  }
}
