/* =============================================
   ПОИСК В ШАПКЕ
   Кнопка-лупа в шапке и в нижней панели мобилки, выпадающая панель под шапкой.
   Поле и кнопка — как в блоке подписки (subscribe_main.css),
   появление — как у попапа языка (cubic-bezier(0.34, 1.56, 0.64, 1)),
   карточки подсказок — шрифты/цвета карточек товаров.
   ============================================= */

/* ===== Кнопка-лупа в шапке ===== */
.search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: #000;
    flex-shrink: 0;
}

.search-toggle svg {
    display: block;
}

.search-toggle:hover,
.is-search-open .search-toggle {
    color: #005C67; /* как .like-icon:hover */
}

/* «Пульс» при открытии — как у сердечка избранного (pulse2 из header.css) */
.search-toggle.is-burst svg,
.mobile-bottom-bar__search.is-burst svg {
    transform-origin: center;
    animation: pulse2 .42s ease-out;
}

/* Лупа в строке меню — только на планшете */
.nav > .search-toggle--nav {
    display: none;
    flex: 0 0 auto;
    width: auto;
}

/* ===== 541–1024: строка с логотипом и иконками и так заполнена до предела —
   лупа уходит в конец строки меню (меню на этих ширинах идёт второй строкой во всю ширину) ===== */
@media (min-width: 541px) and (max-width: 1024px) {
    .actions-icons > .search-toggle {
        display: none;
    }

    .nav > .search-toggle--nav {
        display: flex;
        margin-left: clamp(24px, 4vw, 48px);
    }
}

/* ===== Десктоп (>1024): лупа добавила в строку иконок ~45 px, и на части ширин (1451–1560, 1081–1165)
   обрезался последний пункт меню («Анонсы»). Теперь при нехватке места первым сжимается пустое место
   справа от флага (раньше это были ширина блока языка 76/60/50/44 px при самом флаге 44 px + отступ справа),
   а меню и логотип — только когда это место кончилось. Когда места хватает, всё стоит как раньше. ===== */
@media (min-width: 1025px) {
    .header-inner > .nav,
    .header-inner > .header-left-outer {
        flex-shrink: 0.001;
    }

    .header-inner > .header-actions {
        flex-shrink: 1;
        min-width: 0;
    }

    .header-actions > .language-box {
        flex-shrink: 1;
        width: 108px;      /* = прежние 76 px + отступ 32 px */
        min-width: 44px;   /* сам флаг с отступами кнопки */
        margin-right: 0;
    }
}

@media (min-width: 1025px) and (max-width: 1350px) {
    .header-actions > .language-box {
        width: 76px;       /* 60 + 16 */
    }
}

@media (min-width: 1025px) and (max-width: 1150px) {
    .header-actions > .language-box {
        width: 62px;       /* 50 + 12 */
    }
}

@media (min-width: 1025px) and (max-width: 1080px) {
    .header-actions > .language-box {
        width: 52px;       /* 44 + 8 */
    }
}

/* ===== Кнопка-лупа в нижней панели (мобилка) ===== */
.mobile-bottom-bar__search {
    color: rgba(255, 255, 255, 0.60);
    padding: 0;
}

.mobile-bottom-bar__search svg {
    width: 29.4px;
    height: 29.4px;
    display: block;
}

.is-search-open .mobile-bottom-bar__search {
    color: #F6881B;
}

/* ===== Панель ===== */
.site-search {
    /* fixed, а не absolute: у .header-wrapper есть transform, внутри него fixed ломается.
       Верх панели = низ шапки, считается в js/search.js при открытии */
    position: fixed;
    top: var(--site-search-top, 111px);
    left: 0;
    right: 0;
    z-index: 950;
    max-height: calc(100vh - var(--site-search-top, 111px));
    overflow-y: auto;
    overscroll-behavior: contain;
    /* Полоса прокрутки — как фейковый скроллбар попапа каталога: бирюзовый бегунок на белом */
    scrollbar-width: thin;
    scrollbar-color: #005C67 #fff;
    background: #fff;
    border-top: 1px solid rgba(0, 92, 103, 0.12);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.08);

    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                visibility 0s linear 0.3s;
}

.is-search-open .site-search {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                visibility 0s linear 0s;
}

.site-search__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 40px 24px;
    box-sizing: border-box;
}

.site-search::-webkit-scrollbar {
    width: 9px;
}

.site-search::-webkit-scrollbar-track {
    background: #fff;
}

.site-search::-webkit-scrollbar-thumb {
    background: #005C67;
    border-radius: 14px;
}

/* Пока панель открыта, страница под ней не прокручивается (как у меню каталога) */
/* Только html: если запретить прокрутку и у body, он становится контейнером прокрутки
   и липкая шапка уезжает со страницы */
html.site-search-lock {
    overflow: hidden;
}

/* Подложка под панелью — как у попапа каталога: светлая вуаль с размытием */
.site-search-overlay {
    position: fixed;
    inset: 0;
    /* начинается под шапкой — шапку не размываем ни на одной ширине */
    top: var(--site-search-top, 0px);
    z-index: 800;
    background: rgba(255, 255, 255, 0.17);
    backdrop-filter: blur(31.55px);
    -webkit-backdrop-filter: blur(31.55px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.is-search-open .site-search-overlay {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}

/* ===== Форма ===== */
.site-search__form {
    display: flex;
    align-items: center;
    gap: 16px;
}

.site-search__field {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid #000;
    border-radius: 4px;
    transition: border-color 0.2s ease;
    cursor: text;
}

.site-search__field:hover,
.site-search__field:focus-within {
    border-color: #005C67;
}

.site-search__field-icon {
    display: flex;
    padding-left: 17px;
    color: #222322;
    flex-shrink: 0;
}

.site-search__field:focus-within .site-search__field-icon {
    color: #005C67;
}

.site-search__input {
    flex: 1 1 auto;
    min-width: 0;
    background: none;
    border: none;
    outline: none;
    padding: 17px 12px;
    color: #222322;
    font-family: "tt-commons-pro", sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1;
    -webkit-appearance: none;
    appearance: none;
}

.site-search__input::placeholder {
    color: rgba(34, 35, 34, 0.8);
    opacity: 0.5;
}

.site-search__input:focus::placeholder {
    opacity: 0.3;
}

.site-search__input::-webkit-search-cancel-button,
.site-search__input::-webkit-search-decoration {
    -webkit-appearance: none;
    display: none;
}

.site-search__clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-right: 6px;
    padding: 0;
    border: none;
    background: none;
    color: #222322;
    opacity: 0.5;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.site-search__clear[hidden] {
    display: none;
}

/* Крестики — как у попапа каталога и мини-карточки: увеличение при наведении */
.site-search__clear:hover {
    transform: scale(1.43);
}

.site-search__clear:active {
    transform: scale(0.95);
}

/* Кнопка «Найти» — как кнопка подписки */
.site-search__submit {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 175px;
    padding: 20px 24px;
    border: 1px solid #005C67;
    border-radius: 4px;
    background: #005C67;
    color: #fff;
    font-family: "tt-commons-pro", sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 12.6px;
    letter-spacing: 1.12px;
    text-transform: uppercase;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Как у основных кнопок сайта: наведение — контур, нажатие — оранжевая */
.site-search__submit:hover {
    background: none;
    border-color: #005C67;
    color: #005C67;
}

.site-search__submit:active {
    background: #F6881B;
    border-color: #F6881B;
    color: #fff;
}

.site-search__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: none;
    color: #222322;
    opacity: 0.75;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.site-search__close:hover {
    transform: scale(1.43);
}

.site-search__close:active {
    transform: scale(0.95);
}

/* ===== Результаты ===== */
.site-search__results:empty {
    display: none;
}

.site-search__results {
    margin-top: 12px;
    transition: opacity 0.2s ease;
}

.site-search.is-loading .site-search__results {
    opacity: 0.5;
}

.site-search__list {
    display: flex;
    flex-direction: column;
}

.site-search__item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s ease;
}

.site-search__item + .site-search__item {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Наведение — как у пунктов попапа каталога: оранжевый текст + подчёркивание */
.site-search__item:focus-visible {
    outline: none;
}

.site-search__cover {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    overflow: hidden;
    background: #F2F2EE;
    flex-shrink: 0;
}

.site-search__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.site-search__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1 1 auto;
}

.site-search__tag {
    align-self: flex-start;
    padding: 2px 8px;
    border: 1px solid #F6881B;
    border-radius: 4px;
    color: #664E1F;
    font-family: "tt-commons-pro", sans-serif;
    font-size: 12px;
    line-height: 1.3;
}

.site-search__name {
    color: #000;
    font-family: "PT Astra Serif", serif;
    font-size: 18px;
    font-style: italic;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-search__name {
    transition: color 0.2s ease;
}

.site-search__item:hover .site-search__name,
.site-search__item.is-active .site-search__name,
.site-search__item:focus-visible .site-search__name {
    color: #F6881B;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.site-search__format {
    color: #111;
    font-family: "tt-commons-pro", sans-serif;
    font-size: 14px;
    line-height: 1.2;
}

.site-search__price {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
    font-family: "tt-commons-pro", sans-serif;
    letter-spacing: 1.12px;
}

.site-search__price-current {
    color: #222322;
    font-size: 18px;
    font-weight: 500;
}

.site-search__price-old {
    color: #C3C7C3;
    font-size: 14px;
    font-weight: 500;
    text-decoration: line-through;
}

/* «Все результаты» */
.site-search__group + .site-search__group {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Анонсы, страницы, вопросы — текстом */
.site-search__other {
    list-style: none;
    margin: 0;
    padding: 0;
}

.site-search__other-link {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 6px 16px;
    color: #222322;
    text-decoration: none;
    font-family: "tt-commons-pro", sans-serif;
    font-size: 16px;
    line-height: 1.35;
    transition: color 0.2s ease;
}

.site-search__other-type {
    flex-shrink: 0;
    min-width: 88px;
    color: #8A8A8A;
    font-size: 12px;
    letter-spacing: 1.12px;
    text-transform: uppercase;
}

.site-search__other-title b {
    font-weight: 600;
}

.site-search__other-link:hover,
.site-search__other-link.is-active,
.site-search__other-link:focus-visible {
    color: #F6881B;
    outline: none;
}

.site-search__other-link:hover .site-search__other-title,
.site-search__other-link.is-active .site-search__other-title,
.site-search__other-link:focus-visible .site-search__other-title {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.site-search__all {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 12px 16px 0;
    color: #005C67;
    font-family: "tt-commons-pro", sans-serif;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1.12px;
    text-transform: uppercase;
    text-decoration: none;
}

.site-search__all::after {
    content: "";
    width: 24px;
    height: 24px;
    background: url("/local/templates/my/images/icons/guidance_right-arrow.svg") center / contain no-repeat;
    transition: transform 0.2s ease;
}

.site-search__all {
    transition: color 0.2s ease;
}

.site-search__all:hover {
    color: #F6881B;
}

.site-search__all:hover .site-search__all-text {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.site-search__all:hover::after {
    transform: translateX(4px);
}

.site-search__count {
    color: #8A8A8A;
    font-weight: 400;
}

.site-search__empty,
.site-search__note {
    padding: 0 16px;
    color: #222322;
    font-family: "tt-commons-pro", sans-serif;
    font-size: 16px;
    line-height: 1.4;
}

.site-search__note {
    margin-bottom: 8px;
    color: #5F5F5F;
    font-size: 14px;
}

.site-search__link {
    color: #005C67;
    text-underline-offset: 2px;
}

/* ===== 1024px ===== */
@media (max-width: 1024px) {
    .site-search__inner {
        padding: 20px 24px 28px;
    }

    .site-search__submit {
        min-width: 0;
    }
}

/* ===== 768px ===== */
@media (max-width: 768px) {
    .site-search__submit {
        display: none; /* Enter / «Найти» на клавиатуре */
    }

    .site-search__name {
        font-size: 18px;
    }

    .site-search__price-current {
        font-size: 18px;
    }
}

/* ===== 540px — мобилка: панель между шапкой (логотип и бургер остаются видны)
   и нижней панелью с иконками ===== */
@media (max-width: 540px) {
    .site-search {
        bottom: 80px; /* высота нижней панели: 24 + 32 + 24 */
        max-height: none;
        -webkit-overflow-scrolling: touch;
    }

    .site-search-overlay {
        bottom: 80px;
    }

    .site-search__inner {
        padding: 16px 16px 24px;
    }

    .site-search__form {
        gap: 8px;
    }

    .site-search__input {
        padding: 14px 10px;
    }

    .site-search__field-icon {
        padding-left: 14px;
    }

    .site-search__item {
        gap: 12px;
        padding: 10px 4px;
    }

    .site-search__cover {
        width: 56px;
        height: 56px;
    }

    .site-search__name {
        font-size: 17px;
        white-space: normal;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }

    .site-search__price-current {
        font-size: 16px;
    }

    .site-search__all {
        margin: 16px 4px 0;
    }

    .site-search__other-link {
        padding-left: 4px;
        padding-right: 4px;
    }

    .site-search__other-link {
        flex-direction: column;
        gap: 2px;
    }

    .site-search__empty,
    .site-search__note {
        padding: 0 4px;
    }

}
