/* ==========================================================================
   Поиск по каталогу: кнопка и панель в шапке, выпадающий список, страница /search/
   ========================================================================== */

.header {
    position: relative;
}

/* Кнопка поиска + «Написать нам» — одним блоком */
.header__tools {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 24px;
}
.header .header__tools .social {
    position: static;
    margin: 0;
}

.hsearch-toggle {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 1px solid #c1c1c1;
    border-radius: 50%;
    color: #fff;
    transition: background-color .2s, border-color .2s;
}
.hsearch-toggle:hover,
.hsearch-toggle:focus-visible {
    background-color: #ea6032;
    border-color: #ea6032;
    color: #fff;
}
.hsearch-toggle__icon,
.hsearch__icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

/* Панель поиска поверх шапки */
.hsearch {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 0 24px;
    background: #22282d;
}
.hsearch[hidden] {
    display: none;
}
.hsearch__form {
    position: relative;
    flex: 1 1 auto;
    max-width: 960px;
}
.hsearch__field {
    display: flex;
    align-items: center;
    height: 56px;
    background: #fff;
}
.hsearch__icon {
    flex-shrink: 0;
    margin-left: 20px;
    color: #9a9a9a;
}
.hsearch.is-loading .hsearch__icon {
    color: #ea6032;
    animation: hsearch-pulse .8s ease-in-out infinite alternate;
}
@keyframes hsearch-pulse {
    from { opacity: 1; }
    to { opacity: .3; }
}
.hsearch__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    max-width: none;
    padding: 0 16px 0 12px;
    border: 0;
    background: transparent;
    color: #333;
    font-family: inherit;
    font-size: 17px;
    font-weight: 500;
    -webkit-appearance: none;
    appearance: none;
}
.hsearch__input::placeholder {
    color: #9a9a9a;
    font-weight: 300;
}
.hsearch__input::-webkit-search-decoration,
.hsearch__input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}
.hsearch__submit {
    flex-shrink: 0;
    height: 100%;
    padding: 0 32px;
    background: #ea6032;
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .78px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color .3s;
}
.hsearch__submit:hover {
    background: #dd4817;
}
.hsearch__close {
    position: relative;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: transparent;
    cursor: pointer;
}
.hsearch__close::before,
.hsearch__close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 26px;
    height: 2px;
    margin: -1px 0 0 -13px;
    background: #fff;
    transform: rotate(45deg);
    transition: background-color .2s;
}
.hsearch__close::after {
    transform: rotate(-45deg);
}
.hsearch__close:hover::before,
.hsearch__close:hover::after {
    background: #ea6032;
}

/* Выпадающий список */
.hsearch__results {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 31;
    max-height: min(70vh, 640px);
    overflow-y: auto;
    overscroll-behavior: contain;
    /* при выборе стрелками товар не прячется под закреплённой строкой «Показать все результаты» */
    scroll-padding-bottom: 54px;
    background: #fff;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
    color: #333;
    text-align: left;
}
.hsearch__results[hidden] {
    display: none;
}
.hsearch__list {
    padding: 6px 0;
}
.hsearch__item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    color: #333;
    transition: background-color .15s;
}
.hsearch__item:hover,
.hsearch__item.is-active {
    background: #fdefea;
}
.hsearch__thumb {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    max-width: none;
    object-fit: contain;
    background: #f5f5f5;
}
.hsearch__text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.hsearch__name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    transition: color .15s;
}
.hsearch__item:hover .hsearch__name,
.hsearch__item.is-active .hsearch__name,
.hsearch__name mark {
    color: #ea6032;
}
.hsearch__name mark {
    background: none;
}
.hsearch__section {
    overflow: hidden;
    color: #8a8a8a;
    font-size: 13px;
    font-weight: 300;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* закреплена внизу списка: видна, даже если товары не поместились и список прокручивается */
.hsearch__all {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #eee;
    background: #fff;
    color: #ea6032;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    transition: background-color .15s;
}
.hsearch__all:hover,
.hsearch__all.is-active {
    background: #fdefea;
    color: #ea6032;
}
.hsearch__count {
    color: #8a8a8a;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
}
.hsearch__note {
    padding: 14px 20px 4px;
    color: #8a8a8a;
    font-size: 13px;
    line-height: 1.4;
}
.hsearch__empty {
    padding: 20px;
    font-size: 15px;
    line-height: 1.5;
}
.hsearch__hint {
    display: block;
    margin-top: 6px;
    color: #8a8a8a;
    font-size: 13px;
}

/* Страница /search/ */
.search-page__form {
    display: flex;
    margin: 30px 0 0;
}
.search-page__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 60px;
    max-width: none;
    padding: 0 20px;
    border: 1px solid #e3e3e3;
    border-right: 0;
    background: #fff;
    color: #333;
    font-family: inherit;
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
}
.search-page__input:focus {
    border-color: #ea6032;
}
.search-page__submit,
.search-page__order {
    height: 60px;
    padding: 0 36px;
    font-family: inherit;
    font-size: 15px;
    cursor: pointer;
}
.search-page__summary {
    margin: 20px 0 0;
    color: #333;
    font-size: 16px;
    line-height: 1.5;
}
.search-page__message {
    margin: 20px 0 60px;
    font-size: 16px;
    line-height: 1.6;
}
.search-page__message p + p {
    margin-top: 8px;
}
.search-page__message a {
    text-decoration: underline;
}
.search-page__order {
    margin-top: 24px;
}
.search-page .bottom_nav {
    padding-bottom: 30px;
}

@media (min-width: 639px) {
    .search-page__form,
    .search-page__summary,
    .search-page__message {
        margin-right: 45px;
        margin-left: 45px;
    }
}

/* Планшеты и телефоны: шапка в две строки, блок с кнопками — справа во второй строке */
@media (max-width: 1189px) {
    .header__tools {
        position: absolute;
        top: 148px;
        right: 16px;
        margin: 0;
    }
}

@media (max-width: 638px) {
    .header__tools {
        top: 122px;
        right: 12px;
        gap: 8px;
    }
    .hsearch-toggle {
        width: 44px;
        height: 44px;
    }
    .hsearch {
        gap: 4px;
        padding: 0 8px 0 12px;
    }
    .hsearch__field {
        height: 48px;
    }
    .hsearch__icon {
        margin-left: 14px;
    }
    .hsearch__input {
        padding: 0 8px;
        font-size: 16px;
    }
    .hsearch__submit {
        padding: 0 14px;
        font-size: 13px;
        letter-spacing: .5px;
    }
    .hsearch__close {
        width: 40px;
    }
    /* список — на всю ширину экрана: выходит за поле на отступ слева и на кнопку закрытия справа (40 + 4 + 8) */
    .hsearch__results {
        right: -52px;
        left: -12px;
        max-height: calc(100vh - 150px);
        max-height: calc(100dvh - 150px);
    }
    .hsearch__item {
        gap: 12px;
        padding: 10px 12px;
    }
    .hsearch__thumb {
        width: 48px;
        height: 48px;
    }
    .hsearch__name {
        font-size: 14px;
    }
    .hsearch__all,
    .hsearch__note,
    .hsearch__empty {
        padding-right: 12px;
        padding-left: 12px;
    }
    /* плавающая кнопка звонка из подвала перекрывает низ списка — прячем, пока открыт поиск */
    .hsearch-open .call-widget {
        display: none;
    }

    .search-page__form {
        margin-top: 20px;
    }
    .search-page__input,
    .search-page__submit {
        height: 52px;
    }
    .search-page__submit {
        padding: 0 20px;
    }
}

@media (max-width: 370px) {
    .header__tools {
        top: 106px;
        gap: 6px;
    }
    .hsearch-toggle {
        width: 40px;
        height: 40px;
    }
    .header .header__tools .social {
        gap: 8px;
        padding: 6px 6px 6px 10px;
    }
}

@media (max-width: 350px) {
    /* на самых узких экранах «Написать нам» — только иконкой, чтобы поместилась кнопка поиска */
    .header__tools .social__title {
        display: none;
    }
    .header .header__tools .social {
        padding: 6px;
    }
}
