/* IKD_PRODUCT_CARD_LAYOUT_V4
 *
 * Жёсткое правило:
 * исходное изображение НИКОГДА не режем.
 *
 * В отличие от прошлой версии:
 * - img больше не растягивается width:100% + height:100%;
 * - размер img = auto/auto;
 * - ограничение только max-width/max-height;
 * - сбрасываем старые absolute/transform/scale правила;
 * - убираем внутренний padding фотозоны, чтобы квадрат 1200x1200
 *   использовал всю доступную площадь.
 */

.product-grid,
.popular-grid,
.promo-grid {
  align-items: stretch !important;
}

.product-grid > .product-card,
.popular-grid > .product-card,
.promo-grid > .product-card {
  height: 100% !important;
}

/* Реальная квадратная фотозона карточки. */
.product-card > .product-photo {
  box-sizing: border-box !important;
  position: relative !important;

  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  aspect-ratio: 1 / 1 !important;

  padding: 0 !important;
  margin: 0 !important;

  display: flex !important;
  align-items: center !important;
  justify-content: center !important;

  overflow: hidden !important;
  background: #f7f3ee !important;
}

/*
 * Сам файл сохраняет собственные пропорции.
 * Это более жёсткий вариант contain: физически невозможно
 * увеличить изображение за пределы квадрата.
 */
.product-card > .product-photo > img {
  box-sizing: border-box !important;

  position: static !important;
  inset: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;

  display: block !important;

  width: auto !important;
  height: auto !important;

  min-width: 0 !important;
  min-height: 0 !important;

  max-width: 100% !important;
  max-height: 100% !important;

  aspect-ratio: auto !important;

  object-fit: contain !important;
  object-position: center center !important;

  margin: auto !important;
  padding: 0 !important;

  transform: none !important;
  translate: none !important;
  rotate: none !important;
  scale: 1 !important;

  clip-path: none !important;
  zoom: 1 !important;
}

/* Не разрешаем старым hover-эффектам снова увеличивать фото. */
.product-card > .product-photo:hover > img,
.product-card:hover > .product-photo > img {
  transform: none !important;
  scale: 1 !important;
}

/* Контент всех карточек остаётся выровненным. */
.product-card > .product-body {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;
}

.product-card .product-title {
  min-height: 47px !important;
}

.product-card .price-block {
  margin-top: auto !important;
}

/*
 * "Разделы каталога":
 * не одна длинная полоса, а нормальная адаптивная сетка.
 */
.category-strip {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)) !important;
  gap: 14px !important;

  overflow: visible !important;
  padding-bottom: 0 !important;

  align-items: stretch !important;
}

.category-tile {
  box-sizing: border-box !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 100% !important;

  display: flex !important;
  align-items: center !important;
  gap: 14px !important;
}

/* Фото раздела также без scale/cover/обрезания. */
.category-tile > img {
  box-sizing: border-box !important;

  position: static !important;
  inset: auto !important;

  width: 92px !important;
  height: 92px !important;
  min-width: 92px !important;
  min-height: 92px !important;
  max-width: 92px !important;
  max-height: 92px !important;
  flex: 0 0 92px !important;

  aspect-ratio: 1 / 1 !important;

  padding: 6px !important;
  margin: 0 !important;

  object-fit: contain !important;
  object-position: center center !important;

  transform: none !important;
  translate: none !important;
  rotate: none !important;
  scale: 1 !important;

  background: #f7f3ee !important;
}

/* Подробная карточка: тот же принцип. */
.detail-gallery-main img,
.detail-photo img {
  object-fit: contain !important;
  object-position: center center !important;
  transform: none !important;
  scale: 1 !important;
}

/* Планшет. */
@media (max-width: 980px) {
  .category-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* Телефон. */
@media (max-width: 560px) {
  .category-strip {
    grid-template-columns: 1fr !important;
  }

  .category-tile > img {
    width: 78px !important;
    height: 78px !important;
    min-width: 78px !important;
    min-height: 78px !important;
    max-width: 78px !important;
    max-height: 78px !important;
    flex-basis: 78px !important;
  }
}
