/*
 * Мобильная версия (аудит 13.10.2026): поиск в шапке, закреплённая полоска, размеры полей и кнопок,
 * заголовки и текст, меню, карточка товара, каталог в два ряда, свёрнутые сортировка и форма заявки,
 * компактный баннер cookie. Десктоп не затрагивается: всё внутри max-width.
 */

.header__search-toggle,
.mobile-bar,
.filter-toggle,
.last-form__toggle {
    display: none;
}

.mobile-search[hidden] {
    display: none !important;
}

/* ---------- Шапка, поиск, закреплённая полоска (до 1024 px) ---------- */
@media (max-width: 1024px) {
    .header__search-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--color-dark);
    }

    .mobile-search {
        position: relative;
        padding: 10px 0 14px;
    }

    .mobile-search__form {
        display: flex;
        gap: 8px;
    }

    .mobile-search__input {
        flex: 1 1 auto;
        min-width: 0;
        height: 48px;
        padding: 0 14px;
        border: 1px solid var(--color-dark-gray);
        background-color: var(--color-white);
        color: var(--color-dark);
        font-family: var(--font-family);
        font-size: 16px;
        outline: 0;
        -webkit-appearance: none;
        border-radius: 0;
    }

    .mobile-search__input:focus {
        border-color: var(--color-purple);
    }

    .mobile-search__btn {
        flex: 0 0 auto;
        height: 48px;
        min-height: 48px;
        padding: 0 18px;
    }

    .header__search-toggle svg {
        width: 24px;
        height: 24px;
    }

    /* Подсказки поиска на телефоне: фото и название — строкой, цена и кнопки — под ними. */
    .search-suggest__item-content {
        grid-template-columns: 56px 1fr;
        gap: 8px 12px;
    }

    .search-suggest__item-img {
        width: 56px;
        height: 56px;
    }

    .search-suggest__item-actions {
        grid-column: 1 / -1;
        justify-self: stretch;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    /* Подсказки поиска — под строкой на всю ширину. */
    .mobile-search .search-suggest {
        top: 100%;
        right: 0;
        left: 0;
        width: auto;
        max-height: 60vh;
    }

    .mobile-bar {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 90;
        padding: 0 var(--container-offset);
        background-color: var(--color-bg);
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
        transform: translateY(-110%);
        transition: transform 0.2s ease;
    }

    .mobile-bar.is-visible {
        transform: translateY(0);
    }

    .mobile-bar__row {
        display: flex;
        align-items: center;
        gap: 4px;
        height: 56px;
    }

    .mobile-bar__logo {
        display: flex;
        align-items: center;
        margin-right: auto;
        min-height: 44px;
    }

    .mobile-bar__logo img {
        width: 111px;
        height: auto;
    }

    .mobile-bar__btn {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        border: 0;
        background: none;
        color: var(--color-dark);
        cursor: pointer;
    }

    .mobile-bar__cart {
        background-color: var(--color-dark);
        color: var(--color-white);
    }

    .mobile-bar__cart .notification {
        position: absolute;
        top: -4px;
        right: -4px;
    }

    .mobile-bar .mobile-search {
        padding-top: 0;
    }

    /* Меню телефона: разделы каталога под «Каталогом». */
    .menu__sections {
        display: flex;
        flex-direction: column;
        margin: 4px 0 10px 16px;
    }

    .menu__section-link {
        display: flex;
        align-items: center;
        min-height: 40px;
        color: var(--color-dark-gray);
        font-size: 1rem;
        text-decoration: none;
    }
}

/* Кнопки шапки помещаются в ряд вместе с лупой. */
@media (max-width: 576px) {
    .header__btn,
    .open-menu {
        width: 48px;
        height: 48px;
    }
}

@media (max-width: 375px) {
    .header__btn,
    .open-menu {
        width: 44px;
        height: 44px;
    }
}

/* ---------- Поля ввода и кнопки (до 1024 px) ---------- */
@media (max-width: 1024px) {
    /* iPhone увеличивает страницу при вводе в поле мельче 16 px. */
    input[type="text"],
    input[type="search"],
    input[type="tel"],
    input[type="email"],
    input[type="number"],
    input[type="password"],
    input:not([type]),
    select,
    textarea {
        font-size: 16px !important;
    }

    .header__city,
    .product__delivery-btn,
    .section__link {
        min-height: 44px;
    }

    .product__delivery-btn {
        padding: 0 4px;
    }

    .home-links__link {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    .product-input__btn {
        min-width: 32px;
        min-height: 32px;
    }

    /* Полоска покупки: окошко количества не уезжает за левый край. */
    .product__sticky-bar-actions {
        justify-content: stretch;
    }

    .product__sticky-bar-btn {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
    }
}

/* ---------- Заголовки, текст, строка разделов (до 767 px) ---------- */
@media (max-width: 767px) {
    .page-header,
    .page-header > * {
        overflow: visible;
        text-overflow: clip;
    }

    .page-header__title.title-2,
    h1.title-2 {
        font-size: 1.75rem;
        line-height: 1.2;
        overflow-wrap: break-word;
        -webkit-hyphens: auto;
        hyphens: auto;
    }

    .hero-catalog__title,
    .hero-catalog__big .hero-catalog__title {
        font-size: 2rem !important;
        overflow-wrap: break-word;
        -webkit-hyphens: auto;
        hyphens: auto;
        text-overflow: clip;
    }

    .section__title.title-2,
    .last-form__title.title-2 {
        font-size: 1.75rem;
    }

    /* Текст страниц: свободнее строки, не мельче 15 px. */
    .article-text__description,
    .article-text__description p,
    .article-text__description li,
    .article-card__content,
    .product__characteristic-description,
    .product__characteristic-info,
    .description-text,
    .payment__text,
    .payment__item p,
    .delivery__text,
    .contacts__text,
    .repair__text,
    .returns p,
    .doc-text p,
    .doc-text li {
        line-height: 1.5;
    }

    .main .text,
    .main p.text,
    .payment p,
    .contacts p,
    .contacts__info,
    .product__characteristic-description {
        font-size: 0.9375rem;
        line-height: 1.5;
    }

    /* Разделы каталога — одной строкой с прокруткой пальцем, кнопки по 44 px. */
    .catalog-nav__list {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 20px;
        padding-bottom: 2px;
    }

    .catalog-nav__list::-webkit-scrollbar {
        display: none;
    }

    .catalog-nav__item {
        flex: 0 0 auto;
        margin: 0 !important;
    }

    .catalog-nav__link {
        display: flex;
        align-items: center;
        min-height: 44px;
        white-space: nowrap;
    }

    /* Карточка товара: без «Каталог товаров» и строки разделов — сразу фото, название, цена. */
    .product-page > .page-header,
    .product-page > .catalog-nav > .catalog-nav__list {
        display: none;
    }

    /* Сортировка каталога — одной кнопкой. */
    .filter-toggle {
        display: flex;
        width: 100%;
        min-height: 48px;
        margin-bottom: 16px;
    }

    .filter-toggle + .filter {
        display: none;
    }

    .filter-toggle + .filter.is-open {
        display: flex;
    }
}

/* ---------- Товары по два в ряд (до 576 px) ---------- */
@media (max-width: 576px) {
    .products-list:not(.swiper-wrapper),
    .products-list.grid3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px 10px;
    }

    .products-list:not(.swiper-wrapper) .product-card__img,
    .products-list.grid3 .product-card__img {
        height: auto;
        aspect-ratio: 1 / 1;
    }

    .products-list:not(.swiper-wrapper) .product-card__img img,
    .products-list.grid3 .product-card__img img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .products-list:not(.swiper-wrapper) .product-card__title,
    .products-list.grid3 .product-card__title {
        font-size: 0.8125rem;
        line-height: 1.3;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .products-list:not(.swiper-wrapper) .product-card__code,
    .products-list.grid3 .product-card__code,
    .products-list:not(.swiper-wrapper) .product-card__buy-info,
    .products-list.grid3 .product-card__buy-info {
        font-size: 0.75rem;
    }

    .products-list:not(.swiper-wrapper) .product-card__footer,
    .products-list.grid3 .product-card__footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .products-list:not(.swiper-wrapper) .product-card__btn,
    .products-list.grid3 .product-card__btn {
        min-height: 44px;
        height: auto;
        padding: 8px 6px;
        font-size: 0.8125rem;
        white-space: normal;
    }
}

/* ---------- Форма «Не нашли нужную запчасть?» и баннер cookie (до 767 px) ---------- */
@media (max-width: 767px) {
    .last-form__toggle {
        display: flex;
        width: 100%;
        min-height: 48px;
        margin-top: 20px;
    }

    .last-form:not(.is-open) .last-form__form {
        display: none;
    }

    .last-form.is-open .last-form__toggle {
        display: none;
    }

    .cookie-info__container {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .cookie-info__text {
        font-size: 0.8125rem !important;
        line-height: 1.4;
        margin: 0 !important;
    }

    .cookie-info__btns,
    .cookie-info__container > div:last-child {
        display: flex;
        flex-direction: row;
        gap: 8px;
    }

    .cookie-info__btn {
        flex: 1 1 0;
        min-height: 44px;
        height: 44px;
        margin: 0 !important;
        width: auto !important;
    }
}

/* ---------- Отступы сверху, фото товара, кнопка меню (до 767 px) ---------- */
@media (max-width: 767px) {
    .main {
        padding-top: 16px;
    }

    .breadcrumb {
        margin-top: 0;
    }

    .product-page > .catalog-nav {
        padding-top: 0;
    }

    /* Фото товара ниже — цена и «В корзину» ближе к началу страницы. */
    .product-page .product-slider:not(.full-screen) .product-preview {
        height: 280px;
    }

    .open-menu {
        background: none;
    }

    .open-menu svg rect {
        fill: transparent;
    }

    .cookie-info {
        padding: 0;
    }

    .cookie-info__text {
        font-size: 0.75rem !important;
        line-height: 1.35 !important;
    }
}

/* ---------- Главная на телефоне: короче до товаров (до 576 px) ---------- */
@media (max-width: 576px) {
    /* Лента декоративных фото — только преимущества магазина. */
    .hero__slider .swiper {
        display: none;
    }

    .hero__footer {
        margin-bottom: 20px;
    }

    /* Плитки разделов ниже: заголовок и ссылка без больших полей. */
    .hero-catalog__big {
        min-height: 170px;
        height: 170px;
    }

    .hero-catalog__big .hero-catalog__title,
    .hero-catalog__title {
        font-size: 1.5rem !important;
        padding: 20px 16px;
    }

    .hero-catalog__heading {
        font-size: 1.25rem !important;
        padding: 18px 16px 8px;
    }

    .hero-catalog__description {
        padding: 0 16px;
    }

    .hero-catalog__dark,
    .hero-catalog__white,
    .hero-catalog__group:focus .hero-catalog__white,
    .hero-catalog__group:hover .hero-catalog__white {
        min-height: 110px;
        padding-bottom: 44px;
    }

    .hero-catalog__group {
        gap: 12px;
        margin-bottom: 12px;
    }

    .hero-catalog__line {
        gap: 12px;
        margin-bottom: 12px;
    }

    .hero-catalog__link {
        --tile-link-gap: 12px;
    }

    /* Статей на главной — три, остальные в разделе «Статьи». */
    .articles .articles__item:nth-child(n+4) {
        display: none;
    }

    .home-links__more {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        margin-top: 12px;
        padding: 0;
        border: 0;
        background: none;
        color: var(--color-purple);
        font-family: var(--font-family);
        font-size: 0.9375rem;
        cursor: pointer;
    }
}

/* ---------- Карточка товара: короче до кнопки «В корзину» (до 576 px) ---------- */
@media (max-width: 576px) {
    /* Ряд миниатюр не нужен: основное фото листается пальцем и стрелками. */
    .product-page .product-slider:not(.full-screen) .product-slider__thumbs {
        display: none;
    }

    .product-page .product__slider {
        margin-bottom: 0;
    }

    .product-page .product {
        gap: 16px;
    }

    .product-page .product__info {
        margin-top: 0;
        padding-top: 0;
    }

    .product-page .product__name {
        margin-bottom: 20px;
    }
}
