/* ==========================================================================
   ОГЛАВЛЕНИЕ
   1. Шрифты и Сброс (Reset)
   2. Навигация (Navbar)
   3. Глобальный поиск (Search)
   4. Анимации (Keyframes)
   5. Адаптивность (Media Queries)
   ========================================================================== */

/* ==========================================================================
   1. ШРИФТЫ И СБРОС
   ========================================================================== */
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400;
  /* OPTIMIZED: Лучше использовать woff2, он весит в 2-3 раза меньше ttf */
  src: url('/static/fonts/Montserrat-VariableFont_wght.ttf') format('truetype'); 
  font-display: swap;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    min-height: 100vh;
    font-family: 'Montserrat', sans-serif;
    
    background-color: var(--bg-page); 
    background-image: var(--bg-page-gradient); 
    
    /* OPTIMIZED: УБРАЛИ background-attachment: fixed! 
       На мобильных он вызывает дикие тормоза при скролле. 
       Если нужен фиксированный фон, используйте JS или отдельный fixed pseudo-element. */
    background-attachment: scroll; 
    background-size: cover;
    
    color: var(--text-primary); 
    
    /* OPTIMIZED: Указываем конкретные свойства вместо 'all' */
    transition: background-color 0.5s ease, color 0.4s ease; 
}

/* ==========================================================================
   2. НАВИГАЦИЯ
   ========================================================================== */
.nav-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-nav); 
    
    /* OPTIMIZED: Оставляем blur только для десктопа. 
       Для мобилок мы его отключим в media queries, чтобы не грузить GPU при скролле */
    backdrop-filter: blur(12px); 
    -webkit-backdrop-filter: blur(12px);
    
    border-bottom: 1px solid var(--border-color); 
    transition: background 0.4s ease, border-color 0.4s ease; 
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.nav-logo {
    font-family: 'Rajdhani', sans-serif;
    font-size: 24px;
    font-weight: 700;
    background: var(--gradient-primary); 
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    letter-spacing: 1px;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 6px;
}

.nav-menu a {
    display: block;
    padding: 10px 18px;
    color: var(--text-secondary); 
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border-radius: 12px;
    /* OPTIMIZED: Заменяем 'all' на конкретные свойства */
    transition: color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
    letter-spacing: 0.5px;
}

.nav-menu a:hover {
    color: var(--text-primary); 
    background: var(--bg-hover); 
    /* OPTIMIZED: Уменьшаем радиус свечения. 20px - слишком тяжело для мобилок */
    box-shadow: 0 0 10px var(--accent-glow); 
}

.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-color); 
    color: var(--text-primary); 
    font-size: 20px;
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.nav-toggle:hover {
    background: var(--accent-glow); 
    border-color: var(--border-hover); 
}

.page-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

/* ==========================================================================
   3. ГЛОБАЛЬНЫЙ ПОИСК
   ========================================================================== */
.search-box {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-family: 'Montserrat', sans-serif;
    background: var(--bg-input); 
    border: 1px solid var(--border-color); 
    border-radius: 25px;
    color: var(--text-primary); 
    outline: none;
    transition: border-color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.search-input::placeholder {
    color: var(--text-muted); 
    transition: color 0.3s ease;
}

.search-input:focus {
    border-color: var(--border-focus); 
    background: var(--bg-input-focus); 
    /* OPTIMIZED: Уменьшаем box-shadow */
    box-shadow: 0 0 12px var(--accent-glow); 
}

.search-loader {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.loader-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color); 
    border-top-color: var(--accent-pink); 
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.suggestions-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-dropdown); 
    
    /* OPTIMIZED: Уменьшаем blur до 10px */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    
    border: 1px solid var(--border-color); 
    border-radius: 16px;
    box-shadow: var(--shadow-dropdown); 
    overflow: hidden;
    z-index: 1000;
    display: none;
    max-height: 400px;
    overflow-y: auto;
    /* OPTIMIZED: Убираем transition с box-shadow, он тяжелый */
    transition: background 0.3s ease, border-color 0.3s ease; 
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-primary); 
    border-bottom: 1px solid var(--border-color); 
    transition: background-color 0.2s ease, padding 0.2s ease;
    animation: slideIn 0.3s ease backwards;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--bg-hover); 
    padding-left: 20px;
}

.suggestion-flag {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
    /* OPTIMIZED: drop-shadow очень тяжелый. Заменяем на обычный box-shadow или убираем */
    filter: none; 
}

.suggestion-content {
    flex: 1;
    min-width: 0; 
}

.suggestion-artist {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary); 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.3s ease;
}

.suggestion-song {
    font-size: 0.85rem;
    color: var(--text-secondary); 
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.3s ease;
}

.suggestion-meta {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    font-size: 0.75rem;
}

.suggestion-country {
    color: var(--accent-cyan); 
    font-weight: 600;
    transition: color 0.3s ease;
}

.suggestion-year {
    color: var(--text-muted); 
    transition: color 0.3s ease;
}

.youtube-icon {
    flex-shrink: 0;
    color: #ff0000; 
    opacity: 0.6;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.suggestion-item:hover .youtube-icon {
    opacity: 1;
    transform: scale(1.1);
    /* OPTIMIZED: Убираем drop-shadow при ховере, он вызывает repaint */
    filter: none; 
}

.no-suggestions {
    padding: 20px;
    text-align: center;
    color: var(--text-muted); 
    font-style: italic;
    transition: color 0.3s ease;
}

/* ==========================================================================
   4. АНИМАЦИИ
   ========================================================================== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   5. АДАПТИВНОСТЬ (Media Queries)
   ========================================================================== */
@media (max-width: 768px) {
    /* OPTIMIZED: Полностью отключаем backdrop-filter на мобильных для плавного скролла.
       Прозрачность обеспечиваем за счет solid цвета в var(--bg-nav) */
    .nav-bar,
    .suggestions-dropdown,
    .nav-menu {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    .nav-toggle { 
        display: block; 
    }

    .nav-menu {
        display: none;
        position: absolute;
        top: calc(100% + 8px);
        left: 16px;
        right: 16px;
        flex-direction: column;
        /* OPTIMIZED: Делаем фон более плотным, раз мы убрали blur */
        background: var(--bg-nav); 
        padding: 12px;
        gap: 4px;
        border: 1px solid var(--border-color);
        border-radius: 16px;
        box-shadow: var(--shadow-card);
    }

    .nav-menu.active { 
        display: flex; 
    }

    .nav-menu a {
        padding: 14px 18px;
        width: 100%;
    }

    .page-content { 
        padding: 24px 16px 40px; 
    }
    
    .search-box {
        max-width: 100%;
    }

    .suggestions-dropdown {
        position: fixed; 
        top: 60px; 
        left: 5px;
        right: 5px;
        width: auto; 
        max-width: 100vw;
        border-radius: 0 0 16px 16px;
        z-index: 1000;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); 
        animation: none;
    }

    .suggestion-item {
        padding: 14px 24px; 
        min-height: 56px;
    }
    
    .suggestion-flag {
        width: 32px;
        height: 32px;
    }
    
    .suggestion-artist {
        font-size: 1rem;
    }
    
    .suggestion-song {
        font-size: 0.85rem;
    }

    .no-suggestions {
        padding: 24px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .suggestion-meta {
        display: none;
    }
    
    .nav-logo {
        font-size: 14px;
        margin: 5px;
    }
}