/*
 * Champion — плавная адаптация шапки
 * Исправляет промежуточные ширины, на которых полное название учреждения
 * пересекалось с главным меню.
 */

/* Базовая защита от переполнения */
.site-header,
.site-header .header-inner,
.site-header .brand,
.site-header .main-nav,
.site-header .header-actions {
    min-width: 0;
}

.site-header .header-inner,
.site-header .brand,
.site-header .brand__script,
.site-header .brand__divider,
.site-header .brand__coat,
.site-header .brand__text,
.site-header .main-nav,
.site-header .main-nav > a,
.site-header .main-nav .nav-dropdown__trigger,
.site-header .header-actions,
.site-header .search-button,
.site-header .login-button,
.site-header .menu-toggle {
    transition:
        width .22s ease,
        height .22s ease,
        min-height .22s ease,
        max-width .22s ease,
        gap .22s ease,
        padding .22s ease,
        font-size .22s ease,
        opacity .18s ease;
}

.site-header .brand__text {
    white-space: normal !important;
    overflow-wrap: normal;
    word-break: normal;
}

/* Компактный десктоп: шапка постепенно сжимается, но меню остаётся горизонтальным */
@media (max-width: 1360px) and (min-width: 1181px) {
    .site-header .container {
        width: min(1280px, calc(100% - 32px)) !important;
    }

    .site-header .header-inner {
        min-height: 88px !important;
        grid-template-columns: minmax(350px, 405px) minmax(0, 1fr) auto !important;
        column-gap: 10px !important;
    }

    .site-header .brand {
        gap: 9px !important;
    }

    .site-header .brand__script {
        width: 122px !important;
        height: 58px !important;
        flex: 0 0 122px;
    }

    .site-header .brand__divider {
        height: 50px !important;
    }

    .site-header .brand__coat {
        width: 42px !important;
        height: 56px !important;
    }

    .site-header .brand__text {
        max-width: 205px !important;
        font-size: 11px !important;
        line-height: 1.22 !important;
        font-weight: 400 !important;
    }

    .site-header .main-nav {
        justify-content: flex-end !important;
        gap: clamp(6px, .62vw, 10px) !important;
    }

    .site-header .main-nav > a,
    .site-header .main-nav .nav-dropdown__trigger {
        min-height: 88px !important;
        padding-inline: 0 !important;
        font-size: clamp(12px, .95vw, 14px) !important;
    }

    .site-header .nav-dropdown {
        min-height: 88px !important;
    }

    .site-header .header-actions {
        gap: 6px !important;
    }

    .site-header .search-button {
        width: 42px !important;
        min-width: 42px !important;
        min-height: 42px !important;
        padding: 0 !important;
    }

    .site-header .login-button {
        min-height: 42px !important;
        padding: 0 12px !important;
        font-size: 12px !important;
        white-space: nowrap;
    }
}

/*
 * Планшет и небольшие ноутбуки.
 * Переключаемся на бургер раньше штатных 1040 px, поскольку при масштабе
 * браузера 90% экран шириной около 1030 px превращается примерно в 1140 CSS-px.
 */
@media (max-width: 1180px) {
    .site-header {
        overflow: visible !important;
    }

    .site-header .container {
        width: min(100% - 28px, 1120px) !important;
    }

    .site-header .header-inner {
        position: relative;
        min-height: 86px !important;
        grid-template-columns: minmax(0, 1fr) auto auto !important;
        align-items: center !important;
        gap: 10px !important;
    }

    .site-header .brand {
        width: fit-content;
        max-width: 100%;
        gap: 9px !important;
        overflow: hidden;
    }

    .site-header .brand__script {
        width: 120px !important;
        height: 56px !important;
        flex: 0 0 120px;
    }

    .site-header .brand__divider {
        height: 48px !important;
        flex: 0 0 1px;
    }

    .site-header .brand__coat {
        width: 40px !important;
        height: 54px !important;
        flex: 0 0 40px;
    }

    .site-header .brand__text {
        display: -webkit-box;
        max-width: 220px !important;
        font-size: 10.5px !important;
        line-height: 1.2 !important;
        font-weight: 400 !important;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 4;
        overflow: hidden;
    }

    .site-header .menu-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        grid-column: 2;
        width: 44px;
        height: 44px;
        min-width: 44px;
        padding: 0;
        border-radius: 10px;
    }

    .site-header .header-actions {
        grid-column: 3;
        display: flex !important;
        gap: 6px !important;
    }

    .site-header .search-button {
        width: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 0 !important;
    }

    .site-header .eye-button {
        display: none !important;
    }

    .site-header .login-button {
        min-height: 44px !important;
        padding: 0 13px !important;
        font-size: 12px !important;
        white-space: nowrap;
    }

    .site-header .main-nav {
        position: absolute !important;
        z-index: 1000;
        left: 14px !important;
        right: 14px !important;
        top: calc(100% + 8px) !important;
        display: none !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 0 !important;
        max-height: min(72vh, 620px);
        overflow-x: hidden !important;
        overflow-y: auto !important;
        border: 1px solid #e3e6eb;
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 18px 44px rgba(18, 27, 38, .16);
    }

    .site-header .main-nav.is-open {
        display: flex !important;
    }

    .site-header .main-nav > a,
    .site-header .main-nav .nav-dropdown__trigger {
        width: 100% !important;
        min-height: 50px !important;
        justify-content: flex-start !important;
        padding: 0 18px !important;
        border-bottom: 1px solid #eceef2;
        font-size: 14px !important;
        text-align: left !important;
        white-space: normal !important;
    }

    .site-header .main-nav > a::after,
    .site-header .main-nav .nav-dropdown__trigger::after {
        display: none !important;
    }

    .site-header .nav-dropdown {
        width: 100% !important;
        min-height: 50px !important;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: stretch;
        border-bottom: 1px solid #eceef2;
    }

    .site-header .nav-dropdown__trigger {
        border-bottom: 0 !important;
    }

    .site-header .nav-dropdown__toggle {
        width: 50px;
        min-height: 50px;
        border-left: 1px solid #eceef2;
    }

    .site-header .nav-dropdown__menu {
        grid-column: 1 / -1;
        position: static !important;
        width: 100% !important;
        box-shadow: none !important;
    }
}

/* Телефон: сохраняем компактность без резкого скачка размеров */
@media (max-width: 760px) {
    .site-header .container {
        width: calc(100% - 24px) !important;
    }

    .site-header .header-inner {
        min-height: 76px !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
        gap: 8px !important;
    }

    .site-header .brand {
        gap: 7px !important;
    }

    .site-header .brand__script {
        width: 94px !important;
        height: 48px !important;
        flex-basis: 94px;
    }

    .site-header .brand__divider {
        display: none !important;
    }

    .site-header .brand__coat {
        width: 31px !important;
        height: 42px !important;
        flex-basis: 31px;
    }

    .site-header .brand__text {
        max-width: 132px !important;
        font-size: 8.5px !important;
        line-height: 1.18 !important;
    }

    .site-header .menu-toggle {
        grid-column: 2;
    }

    .site-header .header-actions {
        display: none !important;
    }

    .site-header .main-nav {
        left: 12px !important;
        right: 12px !important;
    }
}

@media (max-width: 430px) {
    .site-header .brand__text {
        display: none !important;
    }

    .site-header .brand__coat {
        width: 34px !important;
        height: 44px !important;
    }
}

/* Для пользователей, отключивших анимацию */
@media (prefers-reduced-motion: reduce) {
    .site-header *,
    .site-header *::before,
    .site-header *::after {
        transition: none !important;
    }
}
