/* ========================================
   MENU.CSS
   * Методология: БЭМ (Блок-Элемент-Модификатор)
   ======================================== */

/* ========================================
   1. БАЗОВЫЕ СТИЛИ МЕНЮ
   ======================================== */

/* 1.1 Категории и подкатегории */
.menu__categories li {
    text-align: left;
}

.menu__categories li .menu__subcategories li:first-child {
    display: list-item;
}

/* Разрешаем клики по второму пункту в подкатегориях */
.menu__categories li .menu__subcategories li:nth-child(2) a {
    pointer-events: all;
}

/* Скрываем первый пункт (картинку) в списке категорий */
.menu__categories li:first-child {
    display: none;
}

/* ВАЖНО: Блокируем переход по ссылке "Технологии" (второй пункт)
   чтобы при клике раскрывалось подменю вместо перехода на страницу */
.menu__categories li:nth-child(2) a {
    pointer-events: none;
}

.menu__subcategories {
    padding-left: 0;
    list-style: none;
}

ul.menu__categories li {
    list-style-type: none;
}

.menu__submenu li {
    list-style: none;
}

/* 1.2 Кнопка бургер-меню (мобильная версия) */
.menu__toggle {
    background-color: transparent;
    border: none;
    cursor: pointer;
    left: auto;
    outline: none;
    right: 0;
    top: -70px;
    display: block;
}

.menu__toggle span {
    background-color: #424242;
    display: block;
    height: 2px;
    margin: 5px 0;
    transition: all .3s ease;
    width: 25px;
}

/* Анимация бургер-кнопки при открытии меню (три полоски → крестик) */
body.menu--open .menu__toggle span:first-child {
    transform: rotate(45deg) translate(5px, 5px);
}

body.menu--open .menu__toggle span:last-child {
    transform: rotate(135deg) translate(-5px, 5px);
}

body.menu--open .menu__toggle span:nth-child(2) {
    opacity: 0; /* Средняя полоска исчезает */
}

/* 1.3 Основной контейнер меню */
.menu {
    left: 0;
    top: 0;
    background-color: #c00;
    bottom: auto;
    height: auto;
    margin: 0;
    padding: 0;
    position: absolute !important;
    z-index: 10;
}

.menu .menu__submenu li:nth-child(2) a {
    padding: 0;
}

.menu a {
    display: flex;
    padding: 10px 25px;
    text-decoration: none;
    transition: all .3s ease;
}

/* 1.4 Подменю */
.menu__submenu {
    box-shadow: 1px 1px rgba(255, 255, 255, 0.2);
    position: absolute;
    visibility: hidden; /* По умолчанию скрыто */
    top: 95% !important;
    z-index: 10;
}

/* 1.5 Пункты меню */
li.menu__item {
    display: inline;
    width: auto;
}

/* 1.6 Переопределение подчеркивания */
u {
    text-decoration: none;
}

/* ========================================
   2. DESKTOP ВЕРСИЯ (≥768px)
   ======================================== */

@media (min-width: 768px) {

    /* Анимация подменю (плавное появление) */
    .menu__submenu {
        transition: all .3s ease-in;
    }

    /* На desktop разрешаем клики по второму пункту "Технологии" */
    .menu__categories li:nth-child(2) a {
        pointer-events: auto;
    }

    /* Отступы для подкатегорий */
    .menu__subcategories > li:first-child a {
        margin-top: 32px !important;
    }

    .menu__subcategories > li a {
        padding-top: 0 !important;
    }

    .menu__subcategories li a {
        line-height: 21px;
        padding: 3px 0 !important;
    }

    /* Скрываем бургер-кнопку на desktop */
    .menu__toggle {
        display: none;
    }

    /* Desktop layout - горизонтальное меню */
    .menu {
        background-color: transparent;
        display: flex;
        justify-content: space-around;
        position: relative !important; /* Перебиваем базовый absolute, чтобы меню было в потоке */
        width: 100%;
    }

    .menu .menu__link--hovered {
        color: white;
    }

    .menu .menu__submenu a {
        color: white;
        padding: 0;
        text-align: inherit;
        width: 100%;
    }

    .menu .menu__submenu a img {
        padding: 0;
        width: 100% !important;
    }

    .menu .menu__submenu a:hover {
        text-decoration: underline !important;
    }

    .menu .menu__link:hover {
        text-decoration: underline;
    }

    .menu .menu__submenu li {
        width: 100%;
    }

    .menu .menu__submenu li:first-child {
        display: flex;
    }

    .menu .menu__submenu li:nth-child(2n) a {
        display: block;
        margin: 0;
        padding: 0;
    }

    .menu a {
        background-color: transparent !important;
        display: inline-block;
        padding: 20px 25px;
    }

    .menu a.active.menu__link--hovered {
        color: #ffffff;
    }

    .menu li {
        display: inline-block;
        width: auto;
    }

    .menu__submenu {
        background: #cc0000;
        opacity: 0;
        visibility: hidden;
    }

    img {
        padding-left: 0;
    }

    li.menu__item {
        display: inline-block;
        margin-bottom: 0;
        padding-bottom: 10px; /* Зона ховера — мостик от текста пункта до выпадающего подменю */
        width: auto;
    }

    li.menu__item:first-child {
        padding-left: 0;
    }

    li.menu__item:last-child {
        padding-right: 0;
    }

    u {
        text-decoration: underline;
    }

    /* ВАЖНО: Показываем подменю когда добавлен класс menu__item--open
       Это происходит при клике на пункт меню (см. menu.js) */
    ul .menu__item.menu__item--open .menu__submenu {
        opacity: 1;
        visibility: visible;
    }
}

/* ========================================
   3. MOBILE ВЕРСИЯ (≤768px)
   ======================================== */

@media (max-width: 768px) {

    /* Анимация всего меню при открытии/закрытии */
    .menu {
        transition: all 0.5s ease;
    }

    /* ВАЖНО: Блокируем переход по ссылке "Технологии" (второй пункт) ТОЛЬКО в первом подменю
       чтобы при клике раскрывалось подменю вместо перехода на страницу */
    .menu__category:first-child .menu__categories li:nth-child(2) a {
        pointer-events: none;
    }

    /* Стили категорий для mobile */
    .menu__categories {
        padding-left: 0;
    }

    .menu__categories > li:last-child {
        border: none !important;
    }

    .menu__categories > li:nth-child(3) {
        height: auto;
    }

    .menu__subcategories {
        border: none;
        padding-left: 20px !important;
        display: none;
    }

    /* Показываем подкатегории когда родительская категория активна */
    .menu__category.active .menu__subcategories {
        display: block;
    }

    /* Иконки стрелок для раскрытия подменю */
    .menu__category i {
        position: relative;
        width: 10px;
        height: 10px;
        transition: .5s;
    }

    /* Стрелка для главных пунктов меню (Услуги, Наружная реклама и т.д.) */
    .menu__link-icon:before {
        content: "";
        display: block;
        align-self: center;
        background-image: url(arrow-for-css.svg);
        background-position: center;
        background-repeat: no-repeat;
        background-size: 100%;
        height: 10px;
        position: relative;
        right: -11px;
        top: 7px;
        transform: rotate(90deg); /* Стрелка вправо по умолчанию */
        transition: .2s ease-in-out;
        width: 10px;
    }

    /* Поворот стрелки вниз когда подменю открыто */
    .menu__categories--active .menu__link-icon:before {
        transform: rotate(270deg);
    }

    /* Стрелка для вложенных категорий (Технологии, Изделия и т.д.) */
    .menu__category i:before {
        content: '';
        align-self: center;
        background-image: url(arrow-for-css.svg);
        background-position: center;
        background-repeat: no-repeat;
        background-size: 100%;
        height: 10px;
        position: absolute;
        right: -11px;
        top: 7px;
        transform: rotate(90deg); /* Стрелка вправо по умолчанию */
        transition: .2s ease-in-out;
        width: 10px;
    }

    /* Раскрытая категория - высота автоматическая */
    .menu__category.active {
        height: auto !important;
        overflow: visible !important;
    }

    /* Поворот стрелки вниз когда категория открыта */
    .menu__category.active i:before {
        transform: rotate(270deg);
    }

    /* Стили ссылок в мобильном меню */
    .menu .menu__categories a {
        border: none;
        padding-left: 20px !important;
    }

    .menu a,
    .menu .menu__submenu li:nth-child(2) a {
        padding: 10px 0;
    }

    .menu__link {
        position: relative;
        /* Запрещаем выделение текста при клике (эстетическое улучшение) */
        user-select: none;
    }

    .menu__item {
        border-bottom: 1px solid #fff;
    }

    /* По умолчанию мобильное меню скрыто */
    .menu {
        opacity: 0;
        padding: 10px 20px;
        visibility: hidden;
        overflow-y: hidden;
        overflow-x: hidden;
        margin-bottom: 20px;
    }

    /* Кастомный скроллбар для мобильного меню */
    nav.menu ::-webkit-scrollbar {
        -webkit-appearance: none;
    }

    nav.menu::-webkit-scrollbar:vertical {
        width: 12px;
    }

    nav.menu::-webkit-scrollbar:horizontal {
        height: 12px;
    }

    nav.menu::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, .5);
        border-radius: 0;
        border-right: 2px solid #ffffff;
        border-left: 2px solid #ffffff;
        border-top: 0;
        border-bottom: 0;
    }

    nav.menu::-webkit-scrollbar-track {
        border-radius: 0;
        background-color: #ffffff;
    }

    .menu__submenu ul.menu__categories li a {
        padding-left: 20px !important;
    }

    .menu__submenu ul.menu__categories > li:nth-child(1) > a {
        padding-left: 20px !important;
    }

    /* Показываем подменю когда добавлен класс active (см. menu.js) */
    .menu__submenu.active {
        display: contents;
        opacity: 1;
        visibility: visible;
    }

    /* Ограничиваем высоту элементов подменю для overflow */
    .menu__submenu > li {
        height: 40px;
        overflow: hidden;
    }

    /* Когда подменю открыто - убираем ограничения высоты для категорий */
    .menu__submenu.active > li {
        height: auto !important;
        overflow: visible !important;
    }

    /* ВАЖНО: Показываем меню когда на body добавлен класс menu--open
       Это происходит при клике на бургер-кнопку (см. menu.js) */
    body.menu--open .menu {
        opacity: 1;
        visibility: visible;
    }

    /* Принудительно белый цвет текста в мобильном меню */
    .menu * {
        color: white !important;
    }
}

/* ========================================
   4. TAILWIND-ПОДОБНЫЕ КЛАССЫ
   Портированы из /src/index.css
   ======================================== */

/* Обертка подменю - содержит колонки категорий */
.menu__submenu-wrapper {
    display: flex;
    margin-left: 0;
    margin-right: 0;
    margin-top: auto;
    margin-bottom: auto;
    max-width: max-content;
    padding: 15px;
    width: auto;
}

/* Обертка категорий - одна колонка в подменю */
.menu__categories-wrapper {
    font-weight: 300;
}

@media (min-width: 768px) {
    .menu__categories-wrapper {
        padding: 15px;
        width: 210px; /* Фиксированная ширина колонок на desktop */
        margin-bottom: 0;
        font-weight: 300;
    }
}

/* Текстовые стили - серый вариант (для главного меню) */
.menu__text--gray {
    font-size: 16px;
    line-height: 1.5;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    color: rgb(17 24 39);
}

.menu__text--gray:hover {
    color: rgb(55 65 81);
    text-decoration: underline;
}

/* Стили для верхнего меню (О компании, Контакты и т.д.) */
a.menu__top-link {
    color: #111827; /* Чёрный */
    font-weight: 600 !important; /* Не жирнеет при hover */
    line-height: 1.4;
    transition-property: all;
    transition-duration: 200ms;
    text-decoration: none;
}

/* Эффекты при наведении на верхнее меню */
a.menu__top-link:hover {
    color: #dc2626 !important; /* Красный цвет */
    text-decoration: underline !important;
}

/* Красная кнопка - используем btn-primary из global.css */

/* ========================================
   6. КОНВЕРТИРОВАННЫЕ TAILWIND КЛАССЫ
   ======================================== */

/* 6.1 Desktop меню (dm) */
#dm {
    display: none;
    width: 100%;
    z-index: 50;
}

@media (min-width: 768px) {
    #dm {
        display: block;
    }
}

.dm__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    padding-bottom: 10px;
}

.dm__logo {
    height: 40px;
}

.dm__inner nav {
    display: flex;
    justify-content: center; /* Центрирование содержимого nav */
    flex: 1; /* Растягиваем nav на всё доступное пространство */
}

.dm__nav-list {
    display: flex;
    align-items: center;
    padding: 0;
    gap: 24px;
    list-style: none;
    margin: 0;
}

.dm__nav-link--company {
    display: none;
    font-size: 14px;
    line-height: 1.4;
}

@media (min-width: 1024px) {
    .dm__nav-link--company {
        display: block;
    }
}

.dm__nav-link--portfolio {
    display: none;
    font-size: 14px;
    line-height: 1.4;
}

@media (min-width: 1280px) {
    .dm__nav-link--portfolio {
        display: block;
    }
}

.dm__nav-link--contacts {
    font-size: 14px;
    line-height: 1.4;
}

.dm__right-block {
    display: flex;
    align-items: center;
    gap: 16px;
}

.dm__phone-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.dm__phone-link {
    font-size: 14px;
    line-height: 1.4;
}

.dm__phone--short {
    display: block;
}

.dm__phone--full {
    display: none;
}

@media (min-width: 1024px) {
    .dm__phone--short {
        display: none;
    }

    .dm__phone--full {
        display: block;
    }
}

.dm__callback-link {
    font-size: 14px;
    line-height: 1.4;
    text-decoration: underline;
    transition: all 200ms;
    display: none;
}

@media (min-width: 900px) {
    .dm__callback-link {
        display: block;
    }
}

.dm__callback-link:hover {
    color: #2563eb;
    text-decoration: underline;
}

.dm__social-link {
    transition: opacity 200ms;
}

.dm__social-link:hover {
    opacity: 0.7;
}

.dm__social-icon {
    width: 20px;
    height: 20px;
}

.dm__email-link {
    font-size: 14px;
    line-height: 1.4;
}

/* 6.2 Mobile меню (mm) */
#mm {
    width: 100%;
    z-index: 50;
}

@media (min-width: 768px) {
    #mm {
        display: none;
    }
}

#top-menu {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.mm__logo {
    display: block;
    padding: 0;
    height: 40px;
    max-width: 150px;
}

/* 6.3 Основное меню контейнер */
.main-menu__container {
    height: 0;
    margin-bottom: 0;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 500;
}

@media (min-width: 768px) {
    .main-menu__container {
        margin-bottom: 0;
        height: auto;
    }
}

.main-menu__inner {
    display: flex;
    justify-content: space-between;
    position: relative;
}

#rc-menu {
    right: 0;
}

@media (min-width: 640px) {
    #rc-menu {
        right: auto;
        min-width: 50%;
    }
}

#rc-list {
    margin: 0;
    padding-left: 0;
}

@media (min-width: 768px) {
    #rc-list {
        display: flex;
        justify-content: space-between;
        width: 100%;
    }
}

/* 6.4 Подменю позиционирование */
.menu__submenu--left {
    left: 0;
}

.menu__submenu--center {
    left: 50%;
    transform: translateX(-50%);
}

/* 6.5 Изображения категорий */
.menu__category-img {
    display: none;
}

@media (min-width: 768px) {
    .menu__category-img {
        display: flex;
    }
}

.menu__category-img-wrapper {
    margin-bottom: 0;
}

@media (min-width: 768px) {
    .menu__category-img-wrapper {
        margin-bottom: 15px;
    }
}

/* 6.6 Шрифты в подменю */
.menu__submenu-title {
    font-weight: 400;
}

@media (min-width: 768px) {
    .menu__submenu-title {
        font-weight: 500;
    }
}

.menu__link--thin {
    font-weight: 400;
}

@media (min-width: 768px) {
    .menu__link--thin {
        font-weight: 100;
    }
}

/* 6.7 Ховер эффект для ссылок меню */
.menu__link--hover {
    cursor: pointer;
}

.menu__link--hover:hover {
    color: white;
}

/* Активный пункт меню (класс-маркер для JS) */
.menu__link--active {
    /* без визуальных отличий */
}

