/* ==========================================================================
   Единая шапка сайта (все страницы)
   Логотип · Помощь ▾ · Правила · Магазин ▾ · Корзина · Telegram · Discord
   ========================================================================== */

.hdr {
    --hdr-green: #62d36c;
    --hdr-line: rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 14px 0 0;
    font-family: Manrope, "Segoe UI", system-ui, sans-serif;
    color: #f4f5f7;
}

.hdr *,
.hdr *::before,
.hdr *::after {
    box-sizing: border-box;
}

.hdr a {
    color: inherit;
    text-decoration: none;
}

.hdr a:hover {
    text-decoration: none;
}

.hdr ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.hdr-inner {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
    min-height: 62px;
    padding: 0 12px 0 26px;
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    border: 1px solid var(--hdr-line);
    border-radius: 999px;
    background: rgba(24, 26, 35, 0.78);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
}

/* Firefox пересчитывает размытие под шапкой каждый кадр (под ней движутся светлячки) — это даёт рывки.
   Заменяем его более плотной подложкой: выглядит почти так же. */
@supports (-moz-appearance: none) {
    .hdr-inner {
        background: rgba(24, 26, 35, 0.94);
        backdrop-filter: none;
    }
}

.hdr-logo {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.hdr-logo img {
    display: block;
    height: 20px;
    width: auto;
}

/* Меню: прижато вправо, соцсети — в самом конце строки */
.hdr-menu {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hdr-nav {
    margin-left: auto;
}

.hdr-list {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hdr-item {
    position: relative;
}

.hdr-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14.5px;
    line-height: 1;
    transition: background 0.18s ease, color 0.18s ease;
}

.hdr-link:hover,
.hdr-item:hover > .hdr-link,
.hdr-item:focus-within > .hdr-link {
    background: rgba(255, 255, 255, 0.08);
}

.hdr-item.is-active > .hdr-link {
    background: rgba(98, 211, 108, 0.16);
    color: var(--hdr-green);
}

.hdr-chev {
    width: 10px;
    height: 10px;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.hdr-item.has-drop:hover .hdr-chev,
.hdr-item.has-drop:focus-within .hdr-chev,
.hdr-item.has-drop.is-open .hdr-chev {
    transform: rotate(180deg);
}

/* ---------- Выпадающее меню ---------- */

.hdr-drop {
    position: absolute;
    top: 100%;
    left: 50%;
    z-index: 10;
    min-width: 250px;
    padding-top: 14px; /* «мостик», чтобы курсор не терял меню */
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 8px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

.hdr-item.has-drop:hover > .hdr-drop,
.hdr-item.has-drop:focus-within > .hdr-drop,
.hdr-item.has-drop.is-open > .hdr-drop {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
    transition-delay: 0s;
}

.hdr-drop-panel {
    position: relative;
    padding: 8px;
    border: 1px solid var(--hdr-line);
    border-radius: 20px;
    background: rgba(26, 28, 38, 0.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 22px 50px rgba(0, 0, 0, 0.45);
}

/* Уголок-указатель */
.hdr-drop-panel::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    width: 12px;
    height: 12px;
    margin-left: -6px;
    transform: rotate(45deg);
    border-top: 1px solid var(--hdr-line);
    border-left: 1px solid var(--hdr-line);
    background: rgba(26, 28, 38, 0.97);
    border-top-left-radius: 3px;
}

.hdr-drop a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 13px;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.25;
    white-space: nowrap;
    color: #e3e6ed;
    transition: background 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
}

.hdr-drop a::before {
    content: "";
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.22);
    transition: background 0.15s ease, transform 0.15s ease;
}

.hdr-drop a:hover,
.hdr-drop a:focus-visible {
    background: rgba(98, 211, 108, 0.13);
    color: #fff;
}

.hdr-drop a:hover::before,
.hdr-drop a:focus-visible::before {
    background: var(--hdr-green);
    transform: rotate(45deg);
}

/* ---------- Корзина и соцсети ---------- */

.hdr-cart,
.hdr-soc a {
    position: relative;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: 50%;
    display: grid;
    place-items: center;
    transition: background 0.18s ease, transform 0.18s ease;
}

.hdr-cart:hover,
.hdr-soc a:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.hdr-cart.is-active {
    background: rgba(98, 211, 108, 0.16);
}

.hdr-cart img {
    display: block;
    width: 24px;
    height: 24px;
}

.hdr-cart-label {
    display: none;
}

.hdr-badge {
    position: absolute;
    top: 1px;
    right: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #f4a0d0;
    color: #2a0f1f;
    font-size: 11px;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px rgba(24, 26, 35, 0.95);
}

/* Быстрая корзина рядом с «Меню» — только на мобильных */
.hdr-cart--quick {
    display: none;
}

.hdr-sep {
    width: 1px;
    height: 24px;
    margin: 0 8px;
    background: var(--hdr-line);
}

.hdr-soc {
    display: flex;
    align-items: center;
    gap: 2px;
}

.hdr-soc img {
    display: block;
    width: 20px;
    height: auto;
    opacity: 0.92;
}

.hdr a:focus-visible,
.hdr-burger:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.hdr-burger {
    display: none;
    margin-left: auto;
    border: 1px solid var(--hdr-line);
    background: transparent;
    color: #fff;
    border-radius: 999px;
    padding: 10px 16px;
    font: inherit;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

/* ---------- Мобильная версия ---------- */

@media (max-width: 900px) {
    .hdr-inner {
        padding-left: 20px;
        border-radius: 30px;
    }

    .hdr-burger {
        display: inline-flex;
    }

    .hdr-menu {
        display: none;
        position: absolute;
        top: calc(100% + 8px);
        left: 0;
        right: 0;
        flex: none;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 12px;
        border: 1px solid var(--hdr-line);
        border-radius: 24px;
        background: #181a23;
        box-shadow: 0 22px 50px rgba(0, 0, 0, 0.5);
        max-height: calc(100vh - 110px);
        overflow-y: auto;
    }

    .hdr-menu.is-open {
        display: flex;
    }

    .hdr-nav {
        margin-left: 0;
    }

    .hdr-list {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }

    .hdr-link {
        justify-content: space-between;
        padding: 14px 16px;
        border-radius: 16px;
    }

    .hdr-drop {
        position: static;
        display: none;
        min-width: 0;
        padding: 0;
        opacity: 1;
        visibility: visible;
        transform: none;
    }

    .hdr-item.has-drop:hover > .hdr-drop,
    .hdr-item.has-drop:focus-within > .hdr-drop {
        display: none;
        transform: none;
    }

    .hdr-item.has-drop.is-open > .hdr-drop {
        display: block;
        transform: none;
    }

    .hdr-item.has-drop:hover .hdr-chev,
    .hdr-item.has-drop:focus-within .hdr-chev {
        transform: none;
    }

    .hdr-item.has-drop.is-open .hdr-chev {
        transform: rotate(180deg);
    }

    .hdr-drop-panel {
        margin: 2px 0 6px 12px;
        padding: 4px;
        border: 0;
        border-left: 2px solid rgba(98, 211, 108, 0.35);
        border-radius: 0 14px 14px 0;
        background: transparent;
        box-shadow: none;
        backdrop-filter: none;
    }

    .hdr-drop-panel::before {
        display: none;
    }

    .hdr-cart {
        width: auto;
        height: auto;
        padding: 12px 16px;
        border-radius: 16px;
        display: flex;
        justify-content: flex-start;
        gap: 12px;
    }

    .hdr-cart-label {
        display: inline;
        font-weight: 700;
        font-size: 14.5px;
    }

    .hdr-badge {
        position: static;
        margin-left: auto;
        box-shadow: none;
    }

    /* В раскрытом меню корзины нет — она вынесена слева от «Меню» */
    .hdr-menu .hdr-cart {
        display: none;
    }

    .hdr-inner > .hdr-cart--quick {
        display: grid;
        place-items: center;
        width: 40px;
        height: 40px;
        padding: 0;
        margin-left: auto;
        border-radius: 50%;
    }

    /* flex-gap у .hdr-inner (20px) гасим, чтобы корзина стояла вплотную к «Меню» */
    .hdr-inner > .hdr-cart--quick + .hdr-burger {
        margin-left: -14px;
    }

    .hdr-cart--quick .hdr-badge {
        position: absolute;
        top: 1px;
        right: 0;
        margin: 0;
        box-shadow: 0 0 0 2px rgba(24, 26, 35, 0.95);
    }

    .hdr-sep {
        width: auto;
        height: 1px;
        margin: 6px 4px;
    }

    .hdr-soc {
        padding: 0 8px 4px;
        gap: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hdr-drop,
    .hdr-chev,
    .hdr-link,
    .hdr-cart,
    .hdr-soc a,
    .hdr-drop a,
    .hdr-drop a::before {
        transition: none;
    }
}
