/* Импорт шрифта */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;700&display=swap');

/* Переменные */
:root {
    --bg-color: url('https://www.transparenttextures.com/patterns/dark-mosaic.png'), #1a1a1a;
    --panel-bg: #252525;
    --accent: #d4af37;
    --text: #e0d4b2;
    --text-secondary: #b8a578;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
    --border: 1px solid rgba(212, 175, 55, 0.5);
    --transition: all 0.3s ease;
}

/* Навигация */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--panel-bg);
    z-index: 1000;
    box-shadow: var(--shadow);
    border-bottom: var(--border);
    transition: transform 0.3s ease;
}

.nav-bar.hidden {
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

/* Контейнер */
.nav-wrapper {
    max-width: 100%;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Заголовок */
.nav-heading {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.6em, 4vw, 2em);
    font-weight: 600;
    color: var(--accent);
    text-align: center;
    margin-bottom: 12px;
}

.page-name {
    color: var(--text);
    margin-right: 6px;
}

/* Бургер */
.nav-burger {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 30px;
    height: 20px;
    position: absolute;
    top: 18px;
    right: 20px;
    z-index: 1002; /* Поверх меню */
}

.burger-line {
    display: block;
    width: 100%;
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
    position: absolute;
    left: 0;
    transition: all 0.3s ease;
}

.burger-line:nth-child(1) { top: 0; }
.burger-line:nth-child(2) { top: 8px; }
.burger-line:nth-child(3) { top: 16px; }

.nav-burger.active .burger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-burger.active .burger-line:nth-child(2) {
    opacity: 0;
}

.nav-burger.active .burger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Кнопка раскрытия */
.nav-reveal {
    position: fixed;
    top: 10px;
    right: 20px;
    background: var(--panel-bg);
    border: var(--border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: var(--transition);
}

.nav-reveal:hover {
    background: #3a3a3a;
}

.reveal-icon {
    color: var(--accent);
    font-size: 1.2em;
}

/* Меню */
.nav-links {
    width: 100%;
}

.nav-items {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    list-style: none;
    padding: 0;
    margin: 0;
    justify-content: center;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    background: #2a2a2a;
    color: var(--text);
    text-decoration: none;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 500;
    font-size: clamp(0.9em, 1.8vw, 0.95em);
    border-radius: 6px;
    border: var(--border);
    transition: var(--transition);
    width: 160px;
    height: 40px;
    text-align: center;
    white-space: nowrap;
}

.nav-item.long-item {
    width: 220px; /* Длиннее для Quests and Dungeon Guide */
}

.nav-item:hover {
    background: #3a3a3a;
    transform: translateY(-2px);
}

.nav-item:active {
    transform: scale(0.98);
}

.nav-item.active {
    border: 2px solid var(--accent);
    background: #2a2a2a;
}

/* Средние экраны */
@media (max-width: 1200px) {
    .nav-items {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 8px;
    }

    .nav-item {
        width: 100%;
        padding: 8px 12px;
        font-size: 0.85em;
        height: 36px;
    }

    .nav-item.long-item {
        width: 100%;
        max-width: 220px;
    }

    .nav-heading {
        font-size: 1.6em;
    }
}

/* Мобильные экраны */
@media (max-width: 768px) {
    body, html {
        height: 100%;
        margin: 0;
        overflow: auto; /* Прокрутка страницы по умолчанию */
    }

    /* Блокируем прокрутку страницы при открытом меню */
    body.nav-active {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        overscroll-behavior: none; /* Предотвращаем прокрутку фона */
    }

    .nav-heading {
        font-size: 1.4em;
        opacity: 0;
        transform: translateY(-20px);
        animation: slideDown 0.5s ease forwards;
    }

    @keyframes slideDown {
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .nav-burger {
        display: flex;
        flex-direction: column;
        justify-content: center;
        width: 30px;
        height: 20px;
    }

    .nav-reveal {
        display: none; /* Скрываем кнопку раскрытия */
    }

    .nav-links {
        position: fixed;
        top: 60px;
        left: 0;
        width: 100%;
        max-height: calc(100vh - 60px); /* Ограничиваем высоту */
        background: var(--panel-bg);
        padding: 20px 0;
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.3s ease, opacity 0.3s ease;
        border-bottom: var(--border);
        overflow-y: auto; /* Прокрутка внутри меню */
        -webkit-overflow-scrolling: touch; /* Плавная прокрутка на iOS */
        touch-action: pan-y; /* Разрешаем прокрутку по оси Y */
        overscroll-behavior: contain; /* Предотвращаем "проскальзывание" */
        z-index: 999; /* Поверх страницы */
        display: block; /* Гарантируем видимость */
    }

    .nav-links.active {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    /* Кастомный ползунок прокрутки */
    .nav-links::-webkit-scrollbar {
        width: 8px; /* Ширина ползунка */
    }

    .nav-links::-webkit-scrollbar-track {
        background: #2a2a2a; /* Фон трека */
        border-radius: 4px;
    }

    .nav-links::-webkit-scrollbar-thumb {
        background: var(--accent); /* Цвет ползунка */
        border-radius: 4px;
    }

    .nav-links::-webkit-scrollbar-thumb:hover {
        background: #b8972e; /* Цвет при наведении */
    }

    .nav-items {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 9px; /* Уменьшено на 25% (было 12px) */
        width: 100%;
        padding: 0 10px;
        margin: 0;
        box-sizing: border-box;
    }

    .nav-item {
        width: 100%;
        max-width: 240px; /* Уменьшено на 25% (было 320px) */
        text-align: center;
        margin: 0;
        font-size: 0.75em; /* Уменьшено на 25% (было 1em) */
        padding: 7.5px 11.25px; /* Уменьшено на 25% (было 10px 15px) */
        border: 2px solid rgba(212, 175, 55, 0.8);
        height: 33px; /* Уменьшено на 25% (было 44px) */
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-item.long-item {
        width: 100%;
        max-width: 240px; /* Уменьшено на 25% (было 320px) */
    }

    body {
        padding-top: 70px;
    }
}

/* Доступность */
.nav-item:focus,
.nav-burger:focus,
.nav-reveal:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Отступ для контента */
body {
    padding-top: 120px; /* Высота меню + запас */
}