/* ============================================================
   ФИКСИРОВАННЫЙ КОНТЕЙНЕР
   ============================================================ */
#nav { 
    position: fixed !important; 
    top: 0; 
    left: 0; 
    width: 100%; 
    z-index: 9999; 
}

:root {
    --color-1: #319b0f; /* Зеленый */
    --color-2: #cf4100; /* Оранжевый */
    --color-3: #c00000; /* Красный */
    --color-4: #d8a400; /* Желтый */
    --color-5: #2341b6; /* Синий */
    --default-gray: #888888; /* Серый для 404 */
}

/* Присваиваем цвета кнопкам по порядку */
.menu-links a:nth-child(1) { --btn-color: var(--color-1); }
.menu-links a:nth-child(2) { --btn-color: var(--color-2); }
.menu-links a:nth-child(3) { --btn-color: var(--color-3); }
.menu-links a:nth-child(4) { --btn-color: var(--color-4); }

/* Динамическая линия под меню */
.nav {
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    min-height: 60px;
    position: relative;
    border-bottom: 3px solid rgba(255, 255, 255, 0.1); 
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: border-color 0.3s ease;
}

/* Этот класс добавляется через JS */
.nav.color-loaded {
    border-bottom: 3px solid var(--active-color, var(--default-gray)) !important;
}

/* ============================================================
   ОБЩИЕ СТИЛИ ССЫЛОК
   ============================================================ */
.menu-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    font-family: Arial, Helvetica, sans-serif; 
    font-weight: bold;
    padding: 10px 20px;
    border-radius: 12px;
    transition: all 0.2s ease;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

.menu-links a:hover {
    background: var(--btn-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    border-color: transparent;
}

/* Переопределение для ЖЕЛТОЙ кнопки */
.menu-links a.is-yellow:hover,
.menu-links a.is-yellow.active {
    background: var(--btn-color) !important;
    color: #000 !important;
}

.menu-links a.is-yellow:hover .menu-icon,
.menu-links a.is-yellow.active .menu-icon {
    stroke: #000 !important;
}

.menu-links a.active {
    background: var(--btn-color);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.menu-icon {
    width: 20px;
    height: 20px;
    display: block;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.menu-links {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
    gap: 15px;
}

/* ============================================================
   ГАМБУРГЕР И МОБИЛЬНЫЙ ЗАГОЛОВОК
   ============================================================ */
.mobile-header {
    display: none;
    justify-content: center;
    align-items: center;
    width: 100%;
    gap: 15px;
}

.menu-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    border-radius: 8px;
    transition: background 0.3s ease;
    -webkit-tap-highlight-color: transparent; 
    outline: none;
}

/* Инверсия при нажатии: фон красится, полоски становятся прозрачными */
.menu-toggle:hover, 
.menu-toggle:active {
    background: var(--active-color, var(--default-gray));
}

.hamburger-icon span {
    display: block;
    width: 28px;
    height: 3px;
    background: var(--active-color, var(--default-gray));
    transition: all 0.3s ease;
    margin: 4px 0;
    border-radius: 2px;
}

.menu-toggle:hover .hamburger-icon span,
.menu-toggle:active .hamburger-icon span {
    background: rgba(0, 0, 0, 0.3);
}

.current-page-name {
    color: white;
    font-weight: bold;
    font-size: 18px;
    text-transform: uppercase;
    font-family: Arial, Helvetica, sans-serif; 
}

/* ============================================================
   АДАПТИВ (Мобильный режим)
   ============================================================ */
.nav.mobile-mode .mobile-header {
    display: flex;
}

.nav.mobile-mode .menu-links {
    display: none; 
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.95);
    padding: 20px 0;
    gap: 12px;
    border-bottom: 3px solid var(--active-color, var(--default-gray));
}

.nav.mobile-mode .menu-links.active {
    display: flex;
}

.nav.mobile-mode .menu-links a {
    width: 85%;
    margin: 0 auto;
    padding: 14px 20px;
    justify-content: flex-start;
}