/* =====================================================
   MENU.CSS — СТАБИЛЬНАЯ ВЕРСИЯ
   -----------------------------------------------------
   Изменения:
   - оставлена рабочая логика меню
   - theme toggle переведён с кружка на SVG
   - цвет иконки темы зависит от темы и контекста
===================================================== */


/* =====================================================
   1. КНОПКА МЕНЮ
===================================================== */

.menu-toggle {
    position: relative;
    width: 30px;
    height: 24px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    z-index: 10000;
}


/* =====================================================
   2. БУРГЕР ЛИНИИ
===================================================== */

.menu-toggle-icon {
    position: absolute;
    top: 50%;
    left: 0;
    width: 30px;
    height: 3px;
    background: #000;
    transform: translateY(-50%);
    transition: 0.3s;
}

.menu-toggle-icon::before,
.menu-toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 30px;
    height: 3px;
    background: #000;
    transition: 0.3s;
}

.menu-toggle-icon::before { top: -10px; }
.menu-toggle-icon::after  { top: 10px; }


/* =====================================================
   3. КРЕСТИК
===================================================== */

.main-navigation.toggled .menu-toggle-icon {
    background: transparent;
}

.main-navigation.toggled .menu-toggle-icon::before {
    top: 0;
    transform: rotate(45deg);
    background: #fff;
}

.main-navigation.toggled .menu-toggle-icon::after {
    top: 0;
    transform: rotate(-45deg);
    background: #fff;
}


/* =====================================================
   4. РАМКА
===================================================== */

.menu-toggle::after {
    content: "";
    position: absolute;
    top: -9px;
    left: -8px;
    right: -8px;
    bottom: -9px;
    border: 1px solid transparent;
    border-radius: 3px;
}

.main-navigation.toggled .menu-toggle::after {
    border-color: #fff;
}


/* =====================================================
   5. BODY LOCK
===================================================== */

body.modal-open {
    overflow: hidden;
}


/* =====================================================
   6. БАЗА МЕНЮ
===================================================== */

.menu-panel ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.menu-panel li {
    position: relative;
}

.menu-panel a {
    text-decoration: none;
}


/* =====================================================
   7. ПОДМЕНЮ
===================================================== */

.menu-panel .sub-menu {
    display: none;
}

.menu-panel li.open > .sub-menu {
    display: block;
}


/* =====================================================
   8. СТРЕЛКА
===================================================== */

.menu-item-has-children > a {
    position: relative;
}

.menu-item-has-children > a::after {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-50%) rotate(45deg);
    transition: transform 0.3s ease;
}

.menu-item-has-children.open > a::after {
    transform: translateY(-50%) rotate(-135deg);
}


/* =====================================================
   9. ACTIONS
===================================================== */

.menu-actions {
    margin-top: 20px;
}

/* Theme toggle:
   полноценная кнопка под SVG-иконки */
.theme-toggle {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
}

/* Обёртка иконок:
   абсолютное наложение двух SVG */
.theme-toggle-icons {
    position: relative;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Базовый стиль SVG */
.theme-icon {
    position: absolute;
    inset: 0;
    width: 22px;
    height: 22px;
    color: currentColor;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* По умолчанию видно солнце */
.theme-icon-sun {
    opacity: 1;
    transform: scale(1);
}

/* В тёмной теме видно луну */
body.dark .theme-icon-sun {
    opacity: 0;
    transform: scale(0.9);
}

body.dark .theme-icon-moon {
    opacity: 1;
    transform: scale(1);
}

.search-toggle {
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
}

.search-toggle .search-icon {
    width: 22px;
    height: 22px;
    stroke: #fff;
}

.menu-extra {
    margin-top: 20px;
}


/* =====================================================
   🔴 MOBILE
===================================================== */
@media (max-width: 767px) {

    /* Обычный гамбургер живёт внутри шапки и уезжает вместе с ней. */
    .main-navigation > .menu-toggle {
        position: relative;
        top: auto;
        right: auto;
    }

    /* Крестик поиска остаётся поверх overlay. */
    .search-close-toggle {
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 10001;
    }

    .menu-panel {
        position: fixed;
        top: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        background: #2f6fed;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 9999;
        padding: 80px 20px;
        overflow-y: auto;
    }

    .main-navigation.toggled .menu-panel {
        transform: translateX(0);
    }

    .menu-panel a {
        display: block;
        width: 100%;
        padding: 12px 0;
        color: #fff;
        font-size: 18px;
    }

    .menu-panel .sub-menu {
        padding-left: 15px;
    }

    .menu-actions {
        display: block;
        margin-top: 24px;
    }

    /* В мобильном меню иконка темы светлая */
    .theme-toggle {
        color: #fff;
    }
}


/* =====================================================
   🔵 DESKTOP
===================================================== */
@media (min-width: 768px) {

    .menu-toggle {
        display: none;
    }

    .menu-panel {
        position: static;
        display: flex;
        align-items: center;
        gap: 20px;
        background: transparent;
    }

    .menu-panel > ul {
        display: flex;
        gap: 15px;
    }

    .menu-item-has-children > a {
        padding-right: 18px;
    }

    .menu-panel a {
        display: inline-flex;
        align-items: center;
        color: #111;
    }

    .menu-panel .sub-menu {
        display: block;
        position: absolute;
        top: 100%;
        left: -999em;
        background: #fff;
        padding: 10px;
    }

    .menu-panel li:hover > .sub-menu,
    .menu-panel li:focus-within > .sub-menu {
        left: 0;
    }

    .menu-item-has-children:hover > a::after,
    .menu-item-has-children:focus-within > a::after {
        transform: translateY(-50%) rotate(-135deg);
    }

    .search-toggle .search-icon {
        stroke: #111;
    }

    .menu-actions {
        display: flex;
        gap: 15px;
        margin-left: 20px;
    }

    /* На десктопе тема тёмная на светлом фоне */
    .theme-toggle {
        color: #111;
    }

    /* В тёмной теме — светлая */
    body.dark .theme-toggle {
        color: #fff;
    }

    .menu-extra {
        display: none;
    }
}