/*
╔═══════════════════════════════════════════════════════════════╗
║  СЕКЦИЯ ФОТОАЛЬБОМ - Gallery Section                         ║
║  Стили для секции фотогалереи с плавными анимациями           ║
║  Источник: Figma макет (Главная страница)                     ║
╚═══════════════════════════════════════════════════════════════╝
*/

/* ========================================
   ОСНОВНАЯ СЕКЦИЯ ГАЛЕРЕИ
======================================== */

.gallery {
    position: relative;
    width: 100%;
    max-width: 1728px;
    margin: 0 auto;
    padding: 120px 28px 40px;
    overflow: hidden;
    background: #ffffff;
}

/* Декоративный текст "Фотоальбом" (огромный фоновый) */
.gallery__decorative-text {
    position: absolute;
    top: 0;
    left: 0;
    font-family: 'Coolvetica', sans-serif;
    font-weight: 900; /* Coolvetica Heavy */
    font-size: clamp(80px, 20vw, 280px);
    line-height: 1;
    color: #e0dcf2;
    pointer-events: none;
    user-select: none;
    z-index: 0;
    /* Плавная анимация при прокрутке */
    animation: floatText 20s ease-in-out infinite;
}

@keyframes floatText {
    0%, 100% {
        transform: translateY(0) translateX(0);
    }
    50% {
        transform: translateY(-20px) translateX(10px);
    }
}

/* Фоновый округлый элемент - УБРАН */
.gallery__background {
    display: none;
}

/* Контейнер секции */
.gallery__container {
    position: relative;
    max-width: 1662px;
    margin: 0 auto;
    height: 382.19px;
    z-index: 1;
}

/* ========================================
   СЕТКА ФОТОГРАФИЙ
======================================== */

.gallery__grid {
    position: relative;
    width: 100%;
    height: 100%;
}

.gallery__error {
    grid-column: 1 / -1;
    padding: 60px 40px;
    text-align: center;
    background: #fff3cd;
    border: 2px dashed #ffc107;
    border-radius: 20px;
}

.gallery__error-title {
    color: #856404;
    font-size: 24px;
    margin-bottom: 20px;
}

.gallery__error-text {
    color: #856404;
    font-size: 16px;
    margin-bottom: 15px;
}

.gallery__error-list {
    color: #856404;
    text-align: left;
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.8;
}

.gallery__error-note {
    color: #856404;
    margin-top: 20px;
    font-size: 14px;
}

/* ========================================
   КАРТОЧКИ ФОТОГРАФИЙ (АБСОЛЮТНОЕ ПОЗИЦИОНИРОВАНИЕ)
======================================== */

.gallery__item {
    position: absolute;
    border-radius: 26.3px;
    overflow: hidden;
    cursor: pointer;
    background: #f0f0f0;
    
    /* Плавная анимация при появлении */
    opacity: 0;
    transform: translateY(30px) scale(0.95);
    animation: fadeInUp 0.8s ease-out forwards;
    
    /* Анимация парения */
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), 
                box-shadow 0.6s ease;
}

.gallery__item:hover {
    transform: scale(1.0) !important;
    box-shadow: 0 8px 20px rgba(149, 138, 209, 0.2);
    z-index: 10;
}

/* Задержка анимации для каждой карточки (воздушный эффект) */
.gallery__item:nth-child(1) { animation-delay: 0.1s; }
.gallery__item:nth-child(2) { animation-delay: 0.2s; }
.gallery__item:nth-child(3) { animation-delay: 0.3s; }
.gallery__item:nth-child(4) { animation-delay: 0.4s; }
.gallery__item:nth-child(5) { animation-delay: 0.5s; }
.gallery__item:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Изображение внутри карточки */
.gallery__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s ease, filter 0.6s ease;
}

.gallery__item:hover .gallery__image {
    transform: scale(1.05);
    filter: brightness(1.05);
}

/* Оверлей при наведении - плавная подсветка */
.gallery__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(149, 138, 209, 0.15) 0%,
        rgba(149, 138, 209, 0.35) 100%
    );
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.gallery__item:hover .gallery__overlay {
    opacity: 1;
}

/* Кнопка увеличения - скрыта */
.gallery__zoom {
    display: none;
}

.gallery__zoom-icon {
    display: none;
}

/* ========================================
   РАЗМЕРЫ И ПОЗИЦИОНИРОВАНИЕ КАРТОЧЕК
   (ТОЧНЫЕ КООРДИНАТЫ ИЗ FIGMA)
======================================== */

/* Фото 1 (большое) - 296.28px × 306.80px */
.gallery__item--1 {
    left: 0;
    top: 47.34px;
    width: 296.28px;
    height: 306.80px;
}

/* Фото 2 (вертикальное) - 180.58px × 273.49px */
.gallery__item--2 {
    left: 312.06px;
    top: 10.52px;
    width: 180.58px;
    height: 273.49px;
}

/* Фото 3 (большое квадратное) - 317.32px × 317.32px */
.gallery__item--3 {
    left: 508.42px;
    top: 64.87px;
    width: 317.32px;
    height: 317.32px;
}

/* Темная карточка - 322.58px × 264.73px */
.gallery__item--dark {
    left: 841.52px;
    top: 0;
    width: 322.58px;
    height: 264.73px;
    background: #1d1d1d;
    cursor: pointer;
}

/* Фото 4 (маленькое) - 182.33px × 231.42px */
.gallery__item--4 {
    left: 1179.88px;
    top: 112.20px;
    width: 182.33px;
    height: 231.42px;
}

/* Фото 5 (среднее) - 284.01px × 255.96px */
.gallery__item--5 {
    left: 1377.99px;
    top: 47.33px;
    width: 284.01px;
    height: 255.96px;
}

/* ========================================
   ТЕМНАЯ ТЕКСТОВАЯ КАРТОЧКА
======================================== */

.gallery__text-card {
    padding: 40px 30px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    
    /* Плавная анимация фона */
    transition: background 0.6s ease;
}

.gallery__item--dark:hover .gallery__text-card {
    background: linear-gradient(135deg, rgba(149, 138, 209, 0.2) 0%, rgba(142, 126, 232, 0.2) 100%);
}

/* Заголовок карточки */
.gallery__card-title {
    font-family: 'Coolvetica', sans-serif;
    font-weight: 400; /* Coolvetica Book */
    font-size: 38.02px;
    line-height: 1.2;
    color: #fff0f0;
    margin: 0 0 10px 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    
    /* Плавное появление */
    transform: translateY(10px);
    opacity: 0.8;
    transition: transform 0.5s ease, opacity 0.5s ease;
}

.gallery__item--dark:hover .gallery__card-title {
    transform: translateY(0);
    opacity: 1;
}

/* Описание карточки */
.gallery__card-description {
    font-family: 'Coolvetica', sans-serif;
    font-weight: 300; /* Coolvetica Light */
    font-size: 18.69px;
    line-height: 1.2;
    color: #fff0f0;
    margin: 0 0 20px 0;
    opacity: 0.9;
    
    /* Плавное появление */
    transform: translateY(10px);
    transition: transform 0.5s ease 0.1s, opacity 0.5s ease 0.1s;
}

.gallery__item--dark:hover .gallery__card-description {
    transform: translateY(0);
    opacity: 1;
}

/* Кнопка открытия полной галереи */
.gallery__open-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: #efefef;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    position: relative;
    overflow: hidden;
    
    /* Плавная анимация */
    transform: scale(0.95);
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.2s,
                background 0.4s ease;
}

.gallery__item--dark:hover .gallery__open-btn {
    transform: scale(1);
    background: #ffffff;
}

/* Иконка стрелки */
.gallery__arrow-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    transition: transform 0.4s ease;
}

.gallery__item--dark:hover .gallery__arrow-icon {
    transform: translateX(0);
}

/* Эффект пульсации для кнопки */
.gallery__open-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* ========================================
   LIGHTBOX (МОДАЛЬНОЕ ОКНО)
======================================== */

.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

/* Оверлей фона */
.lightbox__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    cursor: pointer;
}

/* Контент lightbox */
.lightbox__content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.lightbox.active .lightbox__content {
    transform: scale(1);
}

/* Изображение в lightbox */
.lightbox__image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
}

/* Кнопка закрытия */
.lightbox__close {
    position: absolute;
    top: -60px;
    right: 0;
    width: 50px;
    height: 50px;
    background: #ffffff;
    border: none;
    border-radius: 50%;
    font-size: 36px;
    color: #2f2f2f;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: transform 0.3s ease, background 0.3s ease;
}

.lightbox__close:hover {
    transform: rotate(90deg) scale(1.1);
    background: #958ad1;
    color: #ffffff;
}

/* Кнопки навигации */
.lightbox__prev,
.lightbox__next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    font-size: 48px;
    color: #2f2f2f;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: transform 0.3s ease, background 0.3s ease;
}

.lightbox__prev {
    left: -80px;
}

.lightbox__next {
    right: -80px;
}

.lightbox__prev:hover,
.lightbox__next:hover {
    background: #958ad1;
    color: #ffffff;
    transform: translateY(-50%) scale(1.1);
}

/* Счетчик фотографий */
.lightbox__counter {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    color: #ffffff;
    font-family: 'Coolvetica', sans-serif;
    font-size: 20px;
    font-weight: 400; /* Coolvetica Book */
}

/* ========================================
   АДАПТИВНОСТЬ
======================================== */

@media (max-width: 1700px) {
    .gallery__container {
        max-width: 100%;
        height: auto;
        min-height: 400px;
    }
    
    .gallery__grid {
        display: flex;
        flex-wrap: wrap;
        gap: 16px;
        justify-content: center;
    }
    
    .gallery__item {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        flex: 0 0 auto;
    }
    
    .gallery__item--1 { width: 296px; height: 307px; }
    .gallery__item--2 { width: 181px; height: 273px; }
    .gallery__item--3 { width: 317px; height: 317px; }
    .gallery__item--dark { width: 323px; height: 265px; }
    .gallery__item--4 { width: 182px; height: 231px; }
    .gallery__item--5 { width: 284px; height: 256px; }
}

@media (max-width: 1400px) {
    .gallery__decorative-text {
        font-size: clamp(70px, 18vw, 240px);
        top: 0;
    }
}

@media (max-width: 1024px) {
    .gallery {
        padding: 80px 28px 40px;
    }
    
    .gallery__grid {
        gap: 14px;
    }
    
    .gallery__item--1 { width: 250px; height: 260px; }
    .gallery__item--2 { width: 150px; height: 230px; }
    .gallery__item--3 { width: 270px; height: 270px; }
    .gallery__item--dark { width: 280px; height: 230px; }
    .gallery__item--4 { width: 150px; height: 200px; }
    .gallery__item--5 { width: 240px; height: 220px; }
    
    .gallery__decorative-text {
        font-size: clamp(60px, 15vw, 200px);
        top: 0;
    }
    
    /* Адаптация текста в темной карточке */
    .gallery__card-title {
        font-size: 32px;
    }
    
    .gallery__card-description {
        font-size: 16px;
    }
    
    .gallery__text-card {
        padding: 30px 20px;
    }
    
    .lightbox__prev { left: 20px; }
    .lightbox__next { right: 20px; }
}

@media (max-width: 768px) {
    .gallery {
        padding: 60px 20px 30px;
    }
    
    .gallery__grid {
        gap: 12px;
    }
    
    .gallery__item--1,
    .gallery__item--2,
    .gallery__item--3,
    .gallery__item--dark,
    .gallery__item--4,
    .gallery__item--5 {
        width: calc(50% - 6px);
        height: 220px;
    }
    
    .gallery__decorative-text {
        font-size: clamp(50px, 12vw, 150px);
        top: 0;
    }
    
    .gallery__card-title {
        font-size: 24px;
    }
    
    .gallery__card-description {
        font-size: 13px;
        line-height: 1.3;
    }
    
    .gallery__text-card {
        padding: 20px 16px;
    }
    
    .gallery__open-btn {
        width: 50px;
        height: 50px;
    }
    
    .gallery__arrow-icon {
        width: 14px;
        height: 14px;
    }
    
    .lightbox__prev,
    .lightbox__next {
        width: 45px;
        height: 45px;
        font-size: 32px;
    }
    
    .lightbox__close {
        top: 20px;
        right: 20px;
    }
}

@media (max-width: 480px) {
    .gallery__grid {
        gap: 10px;
    }
    
    .gallery__item--1,
    .gallery__item--2,
    .gallery__item--3,
    .gallery__item--dark,
    .gallery__item--4,
    .gallery__item--5 {
        width: 100%;
        height: 250px;
    }
    
    .gallery__decorative-text {
        font-size: clamp(40px, 10vw, 100px);
        top: 0;
    }
    
    /* Скрываем полное слово "Фотоальбом" */
    .gallery__card-title {
        font-size: 28px;
    }
    
    /* Скрываем описание на совсем маленьких экранах */
    .gallery__card-description {
        font-size: 12px;
    }
    
    .gallery__text-card {
        padding: 16px 14px;
    }
    
    .gallery__open-btn {
        width: 45px;
        height: 45px;
    }
    
    .lightbox__prev { left: 10px; }
    .lightbox__next { right: 10px; }
}

/* Для очень узких экранов */
@media (max-width: 360px) {
    .gallery__decorative-text {
        font-size: clamp(30px, 8vw, 80px);
        top: 0;
    }
    
    .gallery__card-title {
        font-size: 24px;
    }
    
    .gallery__card-description {
        font-size: 11px;
    }
    
    .gallery__text-card {
        padding: 14px 12px;
    }
}

/* ========================================
   ПЛАВНАЯ ПРОКРУТКА ДЛЯ СЕКЦИИ
======================================== */

@media (prefers-reduced-motion: no-preference) {
    .gallery__item {
        animation-play-state: running;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery__item,
    .gallery__decorative-text {
        animation: none;
        opacity: 1;
        transform: none;
    }
}
