/* gallery.css - СТИЛИ ГАЛЕРЕИ (модернизировано) */

/* Шапка страницы */
.page-header {
    padding-top: 140px;
    padding-bottom: 4rem;
    background: linear-gradient(135deg, rgba(20, 44, 36, 0.86), rgba(10, 16, 18, 0.92)), url('/images/фонгалерея.jpg');
    background-size: cover;
    background-position: center;
    margin-bottom: 3rem;
    min-height: 340px;
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--on-dark);
}

.page-title {
    font-size: clamp(2.2rem, 4.5vw, 3.2rem);
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.page-subtitle {
    font-size: 1.15rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
    font-weight: 300;
}


/* Кнопка "наверх" */
.scroll-top-btn {
    position: fixed;
    left: 1.8rem;
    bottom: 1.8rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: var(--on-accent);
    border: none;
    box-shadow: var(--shadow);
    font-size: 1.15rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: var(--transition);
    z-index: 500;
}

.scroll-top-btn.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top-btn:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-3px);
}

.gallery-section {
    padding-bottom: 4rem;
}

/* ===========================================
   АЛЬБОМЫ-ОБЛОЖКИ
   =========================================== */
.gal-covers {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 2rem;
}

.gal-cover {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius-md);
    overflow: hidden;
    text-decoration: none;
    color: #FFFFFF;
    background: var(--muted-bg);
}

.gal-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s var(--ease);
}

.gal-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(10, 16, 18, 0) 40%, rgba(10, 16, 18, 0.82) 100%);
}

.gal-cover:hover img,
.gal-cover:focus-visible img {
    transform: scale(1.05);
}

.gal-cover-body {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 16px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gal-cover-title {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 1.2rem;
}

.gal-cover-meta {
    font-size: 0.88rem;
    color: #DCE3E0;
}

/* ===========================================
   ВКЛАДКИ (закреплены под шапкой при прокрутке)
   =========================================== */
.gal-tabs {
    position: sticky;
    top: 66px; /* высота шапки после прокрутки (она сжимается до ~67px) */
    z-index: 50;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -24px 1.5rem;
    padding: 10px 24px;
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.gal-tabs::-webkit-scrollbar { display: none; }

.gal-tab {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--secondary-bg);
    color: var(--primary-text);
    font: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    transition: var(--transition);
}

.gal-tab span {
    min-width: 24px;
    padding: 1px 7px;
    border-radius: var(--radius-full);
    background: var(--muted-bg);
    color: var(--secondary-color);
    font-size: 0.78rem;
    text-align: center;
}

.gal-tab.is-active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--on-accent);
}

.gal-tab.is-active span {
    background: rgb(255 255 255 / 0.2);
    color: var(--on-accent);
}

/* ===========================================
   АЛЬБОМЫ И МОЗАИКА
   =========================================== */
.gal-albums {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.gal-album[hidden] { display: none; }

.gal-album {
    scroll-margin-top: calc(var(--nav-height) + 80px);
}

.gal-album-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.8rem 1.5rem;
    margin-bottom: 1.1rem;
}

.gal-album-head h2 {
    font-size: clamp(1.4rem, 2.6vw, 1.9rem);
    margin-bottom: 0.2rem;
}

.gal-album-head p {
    color: var(--secondary-color);
}

.gal-book { flex-shrink: 0; }

/* Мозаика: первое фото альбома крупное, каждое пятое — широкое */
.gal-mosaic {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 190px;
    grid-auto-flow: dense;
    gap: 12px;
}

.gal-item {
    position: relative;
    display: block;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--muted-bg);
    cursor: zoom-in;
}

.gal-item.is-big  { grid-column: span 2; grid-row: span 2; }
.gal-item.is-wide { grid-column: span 2; }

.gal-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s var(--ease);
}

.gal-item:hover img,
.gal-item:focus-visible img {
    transform: scale(1.04);
}

.gal-cap {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 28px 14px 10px;
    background: linear-gradient(180deg, rgba(10, 16, 18, 0) 0%, rgba(10, 16, 18, 0.78) 100%);
    color: #FFFFFF;
    font-size: 0.88rem;
    font-weight: 500;
    text-align: left;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.gal-item:hover .gal-cap,
.gal-item:focus-visible .gal-cap,
.gal-item.is-big .gal-cap {
    opacity: 1;
    transform: none;
}

/* ===========================================
   ПРОСМОТРЩИК
   =========================================== */
.lb {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    background: rgba(8, 12, 13, 0.96);
    color: #FFFFFF;
    opacity: 0;
    transition: opacity 0.2s var(--ease);
}

.lb[hidden] { display: none; }
.lb.is-open { opacity: 1; }

.lb-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
}

.lb-title {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
}

.lb-album {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 1.05rem;
}

.lb-counter {
    font-size: 0.9rem;
    color: #B9C3C0;
    font-variant-numeric: tabular-nums;
}

.lb-close,
.lb-nav {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s var(--ease);
}

.lb-close:hover,
.lb-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lb-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 0 76px;
    touch-action: pan-y;
}

.lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.25s var(--ease), transform 0.2s var(--ease);
    user-select: none;
    -webkit-user-drag: none;
}

.lb-img.is-shown { opacity: 1; }

.lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.lb-prev { left: 16px; }
.lb-next { right: 16px; }

.lb-bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 20px;
    padding: 14px 18px 6px;
}

.lb-caption {
    margin: 0;
    font-size: 1rem;
    color: #E9EEEC;
}

.lb-book[hidden] { display: none; }

.lb .lb-book {
    background: #FFFFFF;
    color: var(--brand-pine);
}

.lb-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 18px 16px;
    scrollbar-width: thin;
}

.lb-thumb {
    flex-shrink: 0;
    width: 72px;
    height: 52px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    background: #1C2325;
    opacity: 0.55;
    cursor: pointer;
    transition: opacity 0.2s var(--ease), border-color 0.2s var(--ease);
}

.lb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lb-thumb:hover { opacity: 0.85; }

.lb-thumb.is-active {
    opacity: 1;
    border-color: #FFFFFF;
}

/* ===========================================
   АДАПТИВНОСТЬ
   =========================================== */
@media (max-width: 992px) {
    .page-header {
        padding-top: 120px;
        min-height: 300px;
    }

    .gal-mosaic {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-auto-rows: 170px;
    }
}

@media (max-width: 768px) {
    .page-header {
        padding-top: 110px;
        min-height: 240px;
        padding-bottom: 2.5rem;
        margin-bottom: 2rem;
    }

    .gal-covers {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .gal-cover-body { left: 12px; right: 12px; bottom: 10px; }
    .gal-cover-title { font-size: 1rem; }
    .gal-cover-meta { font-size: 0.78rem; }

    .gal-tabs {
        margin: 0 -16px 1.2rem;
        padding: 8px 16px;
    }

    .gal-mosaic {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: 140px;
        gap: 8px;
    }

    .gal-item.is-wide { grid-column: span 2; }

    /* На телефоне подписи видны всегда — наведения нет */
    .gal-cap {
        opacity: 1;
        transform: none;
        font-size: 0.78rem;
        padding: 22px 10px 8px;
    }

    .gal-book { width: 100%; }

    .lb-stage { padding: 0; }
    .lb-nav { display: none; }
    .lb-bottom .lb-book { width: 100%; }
    .lb-thumb { width: 58px; height: 42px; }
}

@media (max-width: 768px) {
    .scroll-top-btn {
        left: 1.1rem;
        bottom: 1.1rem;
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gal-item img,
    .gal-cover img,
    .lb-img { transition: none; }
}
