/**
 * Мобильный фикс популярных + новости после них.
 * Подключать ПОСЛЕДНИМ. Десктоп ≥1280 не трогаем.
 */

@media screen and (max-width: 1279px) {
  /* Контейнер растёт по контенту */
  html body .white-background-container {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    margin-top: 0 !important;
    display: block !important;
  }

  html body .popular-products-grid {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    max-width: 100% !important;
    width: 100% !important;
    padding: 10px 15px 24px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    display: block !important;
  }

  html body .popular-products-grid #popularProductsRow.popular-products-row,
  html body #popularProductsRow.popular-products-row {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    grid-template-columns: none !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 24px !important;
    overflow: visible !important;
    position: static !important;
  }

  /* Карточка = высота по содержимому (убиваем height:450px из style.css) */
  html body .popular-products-grid #popularProductsRow .popular-product-item,
  html body #popularProductsRow .popular-product-item.square,
  html body #popularProductsRow .popular-product-item.first-square,
  html body #popularProductsRow .popular-product-item {
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
    float: none !important;
    clear: both !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    z-index: auto !important;
  }

  /* Квадратное фото в потоке */
  html body .popular-products-grid #popularProductsRow .product-image-container,
  html body #popularProductsRow .popular-product-item .product-image-container {
    width: 100% !important;
    max-width: 100% !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 0 0 100% !important;
    aspect-ratio: unset !important;
    margin: 0 0 12px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    position: relative !important;
    display: block !important;
    flex: 0 0 auto !important;
  }

  html body #popularProductsRow .product-image-link {
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
  }

  html body .popular-products-grid #popularProductsRow .popular-product-img,
  html body #popularProductsRow .popular-product-item .popular-product-img {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: auto !important;
    height: auto !important;
    max-width: 80% !important;
    max-height: 80% !important;
    margin: 0 !important;
    object-fit: contain !important;
  }

  html body #popularProductsRow .popular-product-item:hover .popular-product-img {
    transform: translate(-50%, -50%) !important;
  }

  html body #popularProductsRow .product-text-content {
    display: block !important;
    flex: 0 0 auto !important;
    position: static !important;
    left: 0 !important;
    top: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 8px 8px !important;
    margin: 0 !important;
  }

  html body #popularProductsRow .popular-product-name,
  html body #popularProductsRow .popular-product-feature {
    position: static !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    display: block !important;
    -webkit-line-clamp: unset !important;
    white-space: normal !important;
  }

  html body #popularProductsRow .popular-product-name {
    font-size: 16px !important;
    line-height: 1.3 !important;
    margin: 0 0 8px !important;
  }

  html body #popularProductsRow .popular-product-feature {
    font-size: 13px !important;
    line-height: 1.35 !important;
    margin: 3px 0 !important;
    padding: 0 !important;
  }

  /* «Показать больше» — строго под описанием, только мобилка */
  html body .popular-products-grid .learn-more-container,
  html body .white-background-container .popular-products-grid .learn-more-container {
    display: flex !important;
    justify-content: center !important;
    position: static !important;
    float: none !important;
    clear: both !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 48px 0 16px !important;
    padding: 36px 0 28px !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    z-index: 2 !important;
    transform: none !important;
    background: #fff !important;
  }

  html body .popular-products-grid .learn-more,
  html body .white-background-container .popular-products-grid .learn-more {
    position: static !important;
    display: inline-flex !important;
    margin: 0 !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
  }

  /* Последняя карточка — запас снизу под кнопку */
  html body #popularProductsRow .popular-product-item:last-child {
    margin-bottom: 12px !important;
    padding-bottom: 24px !important;
  }

  html body #popularProductsRow .popular-product-item:last-child .product-text-content {
    padding-bottom: 20px !important;
  }

  /* Ряд товаров не фиксируем по высоте — кнопка идёт после него в потоке */
  html body #popularProductsRow.popular-products-row {
    margin-bottom: 0 !important;
    padding-bottom: 16px !important;
  }

  /* Новости НЕ наезжают на популярные (убиваем margin-top: -100px) */
  html body .news-section {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 24px !important;
    position: relative !important;
    z-index: 1 !important;
    clear: both !important;
    height: auto !important;
    overflow: visible !important;
  }

  html body .news-container,
  html body .news-pages-container,
  html body .news-grid {
    height: auto !important;
    overflow: visible !important;
    position: relative !important;
  }
}
