/* Неоклассическая галерея - Стили */

:root {
    --primary-color: #1a1a1a;
    --secondary-color: #f8f8f8;
    --accent-gold: #d4af37;
    --accent-bronze: #cd7f32;
    --text-light: #aaa;
    --background-dark: #0f0f0f;
    --transition-smooth: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --shadow-elegant: 0 20px 40px rgba(0, 0, 0, 0.1);
    --border-classic: 1px solid rgba(212, 175, 55, 0.2);
}

/* --- Общие стили --- */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 50%, #0f0f0f 100%);
    color: var(--secondary-color);
    margin: 0;
    padding: 0;
    overflow: hidden; /* Отключаем скролл на body */
    min-height: 100dvh; /* Используем dvh для мобильных */
}

/* --- Контейнер галереи --- */
.gallery-container {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Используем dvh для мобильных */
    overflow: hidden;
}

.gallery-viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* Отключаем стандартные жесты браузера */
}

/* Стили для интеграции с навигацией */
/* Обнуляем отступ, который добавляет общий style.css, чтобы убрать черную полосу */
body.gallery-with-nav {
    padding-top: 0;
}

body.gallery-with-nav .search-container {
    top: calc(1rem + 70px); /* Располагаем поиск поверх галереи, ниже меню */
}
body.gallery-with-nav .gallery-viewport {
    height: calc(100% - 70px); /* Уменьшаем высоту галереи */
}
body.gallery-with-nav .nav-logo {
    color: #ccc; /* Делаем логотип светлым, но не ярким */
}

.gallery-grid {
    position: absolute;
    top: 0;
    left: 0;
    will-change: transform;
    transform-origin: 0 0;
}

/* --- Элементы галереи --- */
.gallery-item {
    position: absolute;
    background: var(--primary-color);
    border: var(--border-classic);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: var(--transition-smooth);
    cursor: pointer;
    opacity: 0;
    animation: fadeIn 0.5s ease-out forwards;
}

.gallery-item:hover {
    transform: translateY(-8px) scale(1.03);
    box-shadow: 0 20px 40px rgba(212, 175, 55, 0.1);
    border-color: var(--accent-gold);
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.gallery-item:hover .gallery-image {
    transform: scale(1.1);
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    color: var(--secondary-color);
    transform: translateY(100%);
    transition: transform 0.4s ease;
    opacity: 0;
}

.gallery-item:hover .gallery-overlay {
    transform: translateY(0);
    opacity: 1;
}

.overlay-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.overlay-number {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* --- Поиск --- */
.search-container {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    width: max-content; /* Ограничиваем ширину по содержимому */
    display: flex;
    align-items: center;
    background: rgba(26, 26, 26, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 0.5rem 1rem;
    border: var(--border-classic);
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    transition: all 0.3s ease;
}

.search-container.suggestions-active {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.search-icon {
    color: var(--text-light);
    margin-right: 0.75rem;
}

.search-input {
    background: transparent;
    border: none;
    color: var(--secondary-color);
    font-size: 1.1rem;
    outline: none;
    width: 300px;
    padding: 0.5rem 0;
}

/* 2. Скрываем стандартный крестик очистки в браузерах на основе WebKit */
.search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    display: none;
}

.search-input::placeholder {
    color: var(--text-light);
}

.clear-search-button {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.5rem;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(36, 36, 36, 0.9);
    backdrop-filter: blur(10px);
    border: var(--border-classic);
    border-top: none;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    padding: 0.5rem 0;
    display: none;
}

.search-container.suggestions-active .search-suggestions {
    display: block;
}

.suggestion-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.suggestion-item:hover {
    background-color: rgba(212, 175, 55, 0.1);
}

.suggestion-item .icon {
    margin-right: 1rem;
    color: var(--accent-gold);
}

.suggestion-item .text {
    display: flex;
    flex-direction: column;
}

.no-results-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 400;
    color: var(--text-light);
    display: none; /* Скрыто по умолчанию */
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.no-results-message h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
}

/* --- Анимации --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Экран загрузки --- */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-title {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    color: var(--secondary-color);
    letter-spacing: 0.2rem;
}

.loading-title span {
    display: inline-block;
    opacity: 0;
    animation: letterFadeIn 1s ease-out forwards;
}

.loading-title span.space {
    width: 1rem;
}

/* Анимация для каждой буквы с задержкой */
.loading-title span:nth-child(1) { animation-delay: 0.1s; }
.loading-title span:nth-child(2) { animation-delay: 0.2s; }
.loading-title span:nth-child(3) { animation-delay: 0.3s; }
.loading-title span:nth-child(4) { animation-delay: 0.4s; }
.loading-title span:nth-child(5) { animation-delay: 0.5s; }
.loading-title span:nth-child(6) { animation-delay: 0.6s; }
.loading-title span:nth-child(8) { animation-delay: 0.7s; }
.loading-title span:nth-child(9) { animation-delay: 0.8s; }
.loading-title span:nth-child(10) { animation-delay: 0.9s; }
.loading-title span:nth-child(11) { animation-delay: 1.0s; }
.loading-title span:nth-child(12) { animation-delay: 1.1s; }
.loading-title span:nth-child(13) { animation-delay: 1.2s; }
.loading-title span:nth-child(14) { animation-delay: 1.3s; }

@keyframes letterFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Модальное окно --- */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.image-modal.active {
    display: block;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    height: 90%;
    max-width: 1600px;
    max-height: 1000px;
    background: var(--primary-color);
    border: var(--border-classic);
    border-radius: 12px;
    box-shadow: var(--shadow-elegant);
    display: flex;
    overflow: hidden;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2.5rem;
    color: var(--text-light);
    background: none;
    border: none;
    cursor: pointer;
    z-index: 10;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--secondary-color);
}

.modal-image-container {
    flex: 3;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto; /* Для зума */
}

.modal-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease;
}

.modal-image-container.zoomed .modal-image {
    cursor: zoom-out;
}

.modal-info {
    flex: 1;
    min-width: 350px;
    padding: 3rem;
    overflow-y: auto;
    background: var(--background-dark);
    transition: transform 0.4s ease, opacity 0.4s ease;
}

/* 1. Когда информационный блок скрыт, обнуляем его размеры,
   чтобы контейнер с изображением мог занять всё пространство. */
.modal-content.info-hidden .modal-info {
    transform: translateX(100%); /* Добавляем transform для корректной анимации скрытия */
    flex-basis: 0;
    min-width: 0;
    padding: 0;
    border: none; /* Используем none вместо 0 для большей надежности */
    opacity: 0;
    overflow: hidden;
}

.modal-header {
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

/* Уточняем селектор, чтобы он был более приоритетным, чем общий стиль для h3 */
.modal-content .modal-title {
    color: var(--secondary-color);
}

.modal-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.modal-author {
    font-size: 1.1rem;
    color: var(--text-light);
}

.modal-details {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.modal-description {
    line-height: 1.7;
    color: var(--secondary-color);
}

.detail-section {
    opacity: 0; /* Начальное состояние для анимации */
}

.detail-label {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-content {
    line-height: 1.6;
}

.curator-comment {
    font-style: italic;
    color: var(--accent-gold);
    border-left: 3px solid var(--accent-gold);
    padding-left: 1rem;
}

/* --- Навигация в модальном окне --- */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 5;
    opacity: 0.5;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.modal-nav:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.modal-nav::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    border-top: 2px solid white;
    border-left: 2px solid white;
}

.modal-nav.prev {
    left: 1.5rem;
}

.modal-nav.prev::before {
    transform: translate(-30%, -50%) rotate(-45deg);
}

.modal-nav.next {
    right: 1.5rem;
}

.modal-nav.next::before {
    transform: translate(-70%, -50%) rotate(135deg);
}

/* --- Панель инструментов в модальном окне --- */
.modal-toolbar {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    background: rgba(26, 26, 26, 0.8);
    backdrop-filter: blur(10px);
    padding: 0.5rem;
    border-radius: 50px;
    border: var(--border-classic);
    z-index: 10;
}

.toolbar-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
}

.toolbar-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.toolbar-btn.lang-btn {
    font-weight: 600;
    font-size: 0.9rem;
    width: 48px;
    height: 48px;
}

.toolbar-counter {
    color: var(--text-light);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

/* --- Адаптивность --- */
@media (max-width: 1200px) {
    .modal-content {
        flex-direction: column;
        width: 95%;
        height: 95%;
    }

    .modal-info {
        flex: none;
        height: 45%;
        min-width: auto;
        border-top: var(--border-classic);
    }
}

@media (max-width: 768px) {
    .search-container {
        width: 70%;
        top: 5rem; /* 3. Опускаем поиск ещё ниже на мобильных устройствах */
    }

    .search-input {
        width: 100%;
    }

    .modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
    }
    
    .modal-info {
        height: 55%;
        padding: 1.5rem 1.5rem 3rem; /* Увеличиваем нижний отступ */
    }

    .modal-content.info-hidden .modal-info {
        height: 0;
        min-height: 0;
        padding: 1.5rem 1.5rem 3rem; /* Увеличиваем нижний отступ */
    }
    
    .modal-header {
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }

    .modal-title {
        font-size: 1.8rem;
    }

    .loading-title {
        font-size: 2.2rem; /* Уменьшаем шрифт на мобильных */
    }

    .modal-author {
        font-size: 1rem;
    }

    .modal-details {
        gap: 1.5rem;
    }
    
    .modal-nav {
        display: none; /* Скрываем стрелки на мобильных, так как используется свайп */
    }

    /* Делаем панель инструментов всегда видимой на мобильных устройствах */
    .modal-toolbar {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
        bottom: 1rem;
    }
}

/* Секретный режим */
.secret-mode-active {
    --primary-color: #3d0000;
    --accent-gold: #ff4141;
    --border-classic: 1px solid rgba(255, 65, 65, 0.3);
}