/* ========================================
   HEADER
======================================== */

.site-header {
    position: fixed;

    top: 0;
    left: 0;

    width: 100%;
    height: 82px;

    display: flex;
    align-items: center;

    background:
        var(--header-background);

    border-bottom:
        1px solid
        var(--border);

    backdrop-filter:
        blur(18px);

    -webkit-backdrop-filter:
        blur(18px);

    z-index: 1000;

    transition:
        background 0.35s ease,
        border-color 0.35s ease;
}


.header-container {
    width:
        min(1180px, calc(100% - 48px));

    height: 100%;

    margin: 0 auto;

    display: flex;
    align-items: center;
}


/* ========================================
   BRAND
======================================== */

.brand {
    display: flex;
    align-items: center;

    gap: 10px;

    color:
        var(--text-primary);

    text-decoration: none;

    flex-shrink: 0;
}


.brand-logo {
    width: 70px;
    height: 70px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;
}


.brand-logo img {
    width: 100%;
    height: 100%;

    object-fit: contain;
}


.brand-name {
    font-size: 20px;
    font-weight: 650;

    letter-spacing: -0.3px;
}


/* ========================================
   NAVIGATION
======================================== */

.main-nav {
    display: flex;
    align-items: center;

    gap: 28px;

    margin-left: auto;
    margin-right: 30px;
}


.main-nav a {
    position: relative;

    color:
        var(--text-secondary);

    font-size: 14px;
    font-weight: 500;

    text-decoration: none;

    transition:
        color 0.2s ease,
        transform 0.2s ease;
}


.main-nav a:hover {
    color:
        var(--text-primary);
}


.main-nav a::after {
    content: "";

    position: absolute;

    left: 50%;
    bottom: -9px;

    width: 0;
    height: 2px;

    background:
        var(--text-primary);

    border-radius: 50px;

    transform:
        translateX(-50%);

    transition:
        width 0.2s ease;
}


.main-nav a:hover::after {
    width: 100%;
}


/* ========================================
   DISABLED DOCUMENTATION
======================================== */

.main-nav .nav-disabled {
    position: relative;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    color:
        var(--text-muted);

    background: transparent;

    border: 0;

    font-family: inherit;
    font-size: 14px;
    font-weight: 500;

    opacity: 0.52;

    cursor: not-allowed;

    user-select: none;

    -webkit-tap-highlight-color:
        transparent;
}


/* ========================================
   DOCUMENTATION TOOLTIP
======================================== */

.nav-disabled-tooltip {
    position: absolute;

    left: 50%;
    top: calc(100% + 16px);

    width: max-content;
    max-width: 260px;

    padding:
        10px
        13px;

    color:
        var(--text-primary);

    background:
        var(--surface-strong);

    border:
        1px solid
        var(--border);

    border-radius: 10px;

    box-shadow:
        var(--shadow);

    font-size: 12px;
    font-weight: 500;
    line-height: 1.45;

    text-align: center;

    opacity: 0;
    visibility: hidden;

    pointer-events: none;

    transform:
        translate(-50%, -5px);

    transition:
        opacity 0.12s ease,
        transform 0.12s ease,
        visibility 0.12s ease;

    z-index: 2000;
}


.nav-disabled-tooltip::before {
    content: "";

    position: absolute;

    left: 50%;
    bottom: 100%;

    width: 8px;
    height: 8px;

    background:
        var(--surface-strong);

    border-left:
        1px solid
        var(--border);

    border-top:
        1px solid
        var(--border);

    transform:
        translateX(-50%)
        translateY(4px)
        rotate(45deg);
}


@media (hover: hover) and (pointer: fine) {

    .main-nav
    .nav-disabled:hover
    .nav-disabled-tooltip,

    .main-nav
    .nav-disabled:focus-visible
    .nav-disabled-tooltip {

        opacity: 1;
        visibility: visible;

        transform:
            translate(-50%, 0);
    }
}


.main-nav
.nav-disabled.tooltip-open
.nav-disabled-tooltip {

    opacity: 1;
    visibility: visible;

    transform:
        translate(-50%, 0);
}


/* ========================================
   HEADER ACTIONS
======================================== */

.header-actions {
    display: flex;
    align-items: center;

    gap: 12px;

    flex-shrink: 0;
}


/* ========================================
   DOWNLOAD BUTTON
======================================== */

.header-download-button {
    min-height: 44px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding:
        0
        18px;

    background:
        var(--button-primary-background);

    color:
        var(--button-primary-text);

    border-radius: 10px;

    font-size: 14px;
    font-weight: 650;

    text-decoration: none;

    transition:
        transform 0.2s ease,
        background 0.2s ease,
        color 0.2s ease,
        opacity 0.2s ease;
}


.header-download-button:hover {
    transform:
        translateY(-2px);

    background:
        var(--button-primary-hover);
}


/* ========================================
   MOBILE MENU BUTTON
======================================== */

.mobile-menu-button {
    width: 44px;
    height: 44px;

    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;

    gap: 5px;

    padding: 0;

    background:
        var(--surface);

    border:
        1px solid
        var(--border);

    border-radius: 10px;

    cursor: pointer;
}


.mobile-menu-button span {
    width: 18px;
    height: 2px;

    display: block;

    background:
        var(--text-primary);

    border-radius: 10px;

    transition:
        transform 0.25s ease,
        opacity 0.25s ease;
}


.mobile-menu-button.open span:nth-child(1) {
    transform:
        translateY(7px)
        rotate(45deg);
}


.mobile-menu-button.open span:nth-child(2) {
    opacity: 0;
}


.mobile-menu-button.open span:nth-child(3) {
    transform:
        translateY(-7px)
        rotate(-45deg);
}


/* ========================================
   BACKDROP
======================================== */

.mobile-menu-backdrop {
    position: fixed;

    inset: 0;

    background:
        rgba(0, 0, 0, 0.45);

    opacity: 0;
    visibility: hidden;

    transition:
        opacity 0.25s ease,
        visibility 0.25s ease;

    z-index: 900;
}


.mobile-menu-backdrop.open {
    opacity: 1;
    visibility: visible;
}


/* ========================================
   HEADER NOTICE
======================================== */

.header-notice {
    position: fixed;

    top: 98px;
    right: 24px;

    width:
        min(360px, calc(100% - 48px));

    display: flex;
    align-items: center;

    gap: 12px;

    padding:
        14px
        16px;

    color:
        var(--text-primary);

    background:
        var(--surface-strong);

    border:
        1px solid
        var(--border);

    border-radius: 14px;

    box-shadow:
        var(--shadow);

    opacity: 0;
    visibility: hidden;

    transform:
        translateY(-8px);

    transition:
        opacity 0.2s ease,
        visibility 0.2s ease,
        transform 0.2s ease;

    z-index: 3000;
}


.header-notice.show {
    opacity: 1;
    visibility: visible;

    transform:
        translateY(0);
}


.header-notice-icon {
    width: 32px;
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    color:
        var(--accent);

    background:
        color-mix(
            in srgb,
            var(--accent) 10%,
            transparent
        );

    border-radius: 9px;

    font-size: 17px;
    font-weight: 800;
}


.header-notice div:last-child {
    display: flex;
    flex-direction: column;

    gap: 3px;
}


.header-notice strong {
    font-size: 13px;
}


.header-notice span {
    color:
        var(--text-secondary);

    font-size: 12px;
    line-height: 1.4;
}


/* ========================================
   LIGHT THEME
======================================== */

html[data-theme="light"]
.nav-disabled-tooltip,

html[data-theme="light"]
.header-notice {

    background: #ffffff;
}


html[data-theme="light"]
.nav-disabled-tooltip::before {

    background: #ffffff;
}


/* ========================================
   MOBILE
======================================== */

@media (max-width: 850px) {

    .site-header {
        height: 74px;
    }


    .header-container {
        width:
            calc(100% - 28px);
    }


    .brand-logo {
        width: 52px;
        height: 52px;
    }


    .brand-name {
        display: none;
    }


    .mobile-menu-button {
        display: flex;
    }


    /*
     * Mobile navigation
     */

    .main-nav {
        position: fixed;

        top: 74px;
        left: 14px;
        right: 14px;

        display: flex;
        flex-direction: column;
        align-items: stretch;

        gap: 6px;

        margin: 0;

        padding: 14px;

        background:
            var(--surface-strong);

        border:
            1px solid
            var(--border);

        border-radius: 16px;

        box-shadow:
            var(--shadow);

        opacity: 0;
        visibility: hidden;

        transform:
            translateY(-10px);

        transition:
            opacity 0.25s ease,
            visibility 0.25s ease,
            transform 0.25s ease;

        z-index: 1200;
    }


    .main-nav.open {
        opacity: 1;
        visibility: visible;

        transform:
            translateY(8px);
    }


    /*
     * Dark theme mobile menu:
     * make the panel substantially more opaque so page content
     * does not show through the navigation labels.
     */

    html[data-theme="dark"] .main-nav {
        background:
            rgba(13, 18, 18, 0.97);

        border-color:
            rgba(255, 255, 255, 0.10);

        box-shadow:
            0 24px 60px
            rgba(0, 0, 0, 0.52);

        backdrop-filter:
            blur(24px);

        -webkit-backdrop-filter:
            blur(24px);
    }


    html[data-theme="dark"] .main-nav a {
        color:
            rgba(255, 255, 255, 0.92);
    }


    html[data-theme="dark"] .main-nav a:hover,
    html[data-theme="dark"] .main-nav a:focus-visible {
        background:
            rgba(255, 255, 255, 0.06);
    }


    .main-nav a,
    .main-nav .nav-disabled {
        width: 100%;
        min-height: 48px;

        display: flex;
        align-items: center;

        padding:
            0
            16px;

        border-radius: 10px;

        font-size: 15px;

        text-align: left;
    }


    .main-nav a {
        color:
            var(--text-primary);
    }


    .main-nav a:hover {
        background:
            var(--surface-hover);
    }


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


    .main-nav .nav-disabled {
        justify-content: flex-start;

        background:
            var(--surface);

        border:
            1px solid
            var(--border);

        opacity: 0.55;
    }


    /*
     * На мобильном tooltip внутри меню
     * не используем — показываем notice.
     */

    .nav-disabled-tooltip {
        display: none;
    }


    /*
     * Download visually disabled
     */

    .header-download-button {
        min-height: 44px;

        padding:
            0
            15px;

        color:
            var(--text-muted);

        background:
            var(--surface);

        border:
            1px solid
            var(--border);

        opacity: 0.62;

        cursor: not-allowed;
    }


    .header-download-button:hover {
        transform: none;

        background:
            var(--surface);
    }


    .header-notice {
        top: 88px;

        left: 14px;
        right: 14px;

        width: auto;
    }

}


/* ========================================
   SMALL MOBILE
======================================== */

@media (max-width: 420px) {

    .header-container {
        width:
            calc(100% - 20px);
    }


    .brand-logo {
        width: 48px;
        height: 48px;
    }


    .header-actions {
        gap: 8px;
    }


    .header-download-button {
        padding:
            0
            12px;

        font-size: 13px;
    }

}