/* ==========================================
   ДЕСКТОП
   ========================================== */
.site-header {
    width: 100%;
    background-color: #021834;
    transition: background-color 0.4s ease-in-out, opacity 0.4s ease-in-out;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.site-header .header-content {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.header-content .header-content-inner {
    display: grid;
    grid-template-columns: 220px 1fr auto;
    grid-template-areas:
        "logo top search"
        "logo middle search";
    gap: 2rem;
    align-items: start;
}

.header-content-inner .header-content-logo {
    grid-area: logo;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.header-content-logo a {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 220px;
    width: 220px;
}

.header-content-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: all 0.4s ease-in-out;
}

.header-content-inner .header-content-top {
    grid-area: top;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: auto;
    padding-bottom: 1rem;
    border-bottom: 1px solid #ffffff;
    transition: 0.25s ease;
    width: 100%;
}

.header-content-inner .header-content-middle {
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out, opacity 0.3s ease-in-out, margin 0.4s ease-in-out;
    grid-area: middle;
    align-items: left;
    justify-content: left;
}

.header-content-middle h1 {
    font-size: clamp(2rem, 5vw, 2.5rem);
    line-height: 1.3;
    letter-spacing: -0.01em;
    font-weight: 600;
    text-align: left;
    margin: 0;
}

/* Навигация (десктоп) */
.header-content-top .main-nav {
    flex-grow: 1;
    max-width: 100%;
}

.main-nav ul {
    display: flex;
    justify-content: space-between;
    align-items: center;
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    gap: 4rem;
}

.main-nav ul li {
    white-space: nowrap;
}

/* Поиск (десктоп) */
.search-container {
    grid-area: search;
    display: flex;
    align-items: center;
    height: 50px;
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 2px 6px;
    transition: border-color 0.4s ease, background-color 0.4s ease, padding 0.4s ease;
    align-self: center;
}

.search-container:focus-within,
.search-container:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
}

.search-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    width: 36px;
    border-radius: 50%;
    padding: 0;
    flex-shrink: 0;
    transition: background-color 0.2s ease;
    order: 1;
}

.search-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.search-btn img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.search-input {
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 0.95rem;
    width: 0;
    opacity: 0;
    padding: 0;
    pointer-events: none;
    order: 2;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.search-container:focus-within .search-input,
.search-container:hover .search-input {
    width: 180px;
    opacity: 1;
    padding: 0 10px;
    pointer-events: auto;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Бургер (скрыт на десктопе) */
.burger-btn {
    display: none;
}

/* ==========================================
   КОМПАКТНЫЙ РЕЖИМ (десктоп)
   ========================================== */
.site-header.header-scrolled .header-content-inner {
    grid-template-areas: "logo top search";
    grid-template-columns: 220px 1fr auto;
    align-items: center;
    align-content: center;
    gap: 0rem;
}

.site-header.header-scrolled .header-content-top {
    border-bottom-color: transparent;
    padding-bottom: 0;
    height: 100px;
}

.site-header.header-scrolled .header-content-top .main-nav a {
    padding: 0.75rem 1.25rem;
}

.site-header.header-scrolled .search-container {
    height: 40px;
}

.site-header.header-scrolled .search-btn {
    height: 32px;
    width: 32px;
}

.site-header.header-scrolled .search-btn img {
    width: 16px;
    height: 16px;
}

/* ==========================================
   МОБИЛЬНАЯ ВЕРСИЯ: max-width 768px
   ========================================== */
@media (max-width: 768px) {

    /* --- Верхняя панель: бургер | лого (центр) | поиск --- */
    .header-content .header-content-inner {
        grid-template-columns: 1fr auto 1fr;
        grid-template-areas:
            "burger logo search"
            "middle middle middle";
        gap: 0;
        align-items: center;
        padding: 1.25rem 1.5rem;
    }

    .burger-btn {
        display: flex;
        grid-area: burger;
        justify-self: start;
        background: none;
        border: none;
        cursor: pointer;
        padding: 16px;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 9px;
        z-index: 210;
    }

    .burger-btn span {
        display: block;
        width: 32px;
        height: 3.5px;
        background-color: #ffffff;
        border-radius: 3px;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .burger-btn.active span:nth-child(1) {
        transform: translateY(12.5px) rotate(45deg);
    }

    .burger-btn.active span:nth-child(2) {
        opacity: 0;
    }

    .burger-btn.active span:nth-child(3) {
        transform: translateY(-12.5px) rotate(-45deg);
    }

    .header-content-inner .header-content-logo {
        grid-area: logo;
        justify-self: center;
        position: relative;
        z-index: 210;
    }

    .header-content-logo a {
        height: 90px;
        width: 90px;
    }

    /* Поиск — в верхней панели справа */
    .search-container {
        grid-area: search;
        justify-self: end;
        height: 56px;
    }

    .search-btn {
        height: 52px;
        width: 52px;
    }

    .search-btn img {
        width: 26px;
        height: 26px;
    }

    .search-input {
        width: 0;
        opacity: 0;
    }

    .search-container:focus-within .search-input,
    .search-container:hover .search-input {
        width: 140px;
    }

    /* H1 — показываем на мобильном */
    .header-content-inner .header-content-middle {
        grid-area: middle;
        display: block;
        text-align: center;
        padding: 1.25rem 0 0;
    }

    .header-content-middle h1 {
        font-size: clamp(1.2rem, 4.5vw, 1.6rem);
        line-height: 1.4;
    }

    /* --- Выпадающее меню (на весь экран) --- */
    .header-content-inner .header-content-top {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        background-color: rgba(0, 0, 0, 0.88);
        backdrop-filter: blur(8px);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 80px 2rem 2rem;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        border-bottom: none;
        height: auto;
        z-index: 200;
        overflow-y: auto;
    }

    .header-content-top.open {
        transform: translateX(0);
    }

    /* --- Навигация в меню --- */
    .header-content-top .main-nav {
        max-width: 320px;
        width: 100%;
        flex-grow: 0;
    }

    .main-nav ul {
        flex-direction: column;
        gap: 0;
        align-items: stretch;
    }

    .main-nav ul li {
        white-space: normal;
    }

    .main-nav a {
        display: block;
        text-align: left;
        padding: 1rem 1.5rem 1rem 1.5rem;
        font-size: 1.2rem;
        border-radius: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        background: transparent;
        margin: 0;
        flex: none;
    }

    .main-nav a::after {
        display: none;
    }

    /* Белая вертикальная линия слева от навигации */
    .main-nav {
        border-left: 2px solid rgba(255, 255, 255, 0.6);
    }

    /* --- Компактный режим отключаем на мобильном --- */
    .site-header.header-scrolled .header-content-logo a {
        height: 90px;
        width: 90px;
    }

    .site-header.header-scrolled .header-content-top {
        height: auto;
        padding-bottom: 0;
    }

    .site-header.header-scrolled .header-content-middle h1 {
        font-size: clamp(1.2rem, 4.5vw, 1.6rem);
    }
}
