/**
 * Стили фотогалереи ButGallery на фронтенде
 */

.butgallery-album-wrap,
.butgallery-collection-wrap,
.butgallery-all-albums-wrap {
    margin: 25px 0;
    font-family: inherit;
    box-sizing: border-box;
}

.butgallery-album-wrap *,
.butgallery-collection-wrap *,
.butgallery-all-albums-wrap * {
    box-sizing: border-box;
}

/* Заголовок и описание альбома */
.bg-album-header,
.bg-collection-header {
    margin-bottom: 25px;
    text-align: left;
}

.bg-album-title,
.bg-collection-title {
    font-size: 1.8rem;
    margin: 0 0 10px 0;
    color: #1a1a1a;
}

.bg-album-description,
.bg-collection-description {
    font-size: 1.05rem;
    line-height: 1.6;
    color: #4a4a4a;
}

/* Адаптивная сетка фотографий */
.bg-photos-grid {
    display: grid;
    gap: 20px;
    margin: 20px 0;
}

.bg-cols-1 { grid-template-columns: 1fr; }
.bg-cols-2 { grid-template-columns: repeat(2, 1fr); }
.bg-cols-3 { grid-template-columns: repeat(3, 1fr); }
.bg-cols-4 { grid-template-columns: repeat(4, 1fr); }
.bg-cols-5 { grid-template-columns: repeat(5, 1fr); }
.bg-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* Карточка фотографии */
.bg-photo-card {
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    display: flex;
    flex-direction: column;
}

.bg-photo-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

/* Блок картинки */
.bg-card-image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #f3f4f6;
    cursor: pointer;
}

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

.bg-photo-card:hover .bg-gallery-image {
    transform: scale(1.04);
}

.bg-image-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bg-photo-card:hover .bg-image-overlay {
    opacity: 1;
}

.bg-zoom-icon {
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transform: scale(0.85);
    transition: transform 0.2s ease;
}

.bg-photo-card:hover .bg-zoom-icon {
    transform: scale(1);
}

/* Тело карточки */
.bg-card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.bg-card-title {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.35;
}

.bg-card-description {
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    color: #4b5563;
    line-height: 1.5;
    flex-grow: 1;
}

/* Метаданные (Дата, Автор, Источник) */
.bg-card-metadata {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid #f3f4f6;
    margin-top: auto;
    font-size: 0.85rem;
}

.bg-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #6b7280;
}

.bg-meta-date svg {
    color: #9ca3af;
}

.bg-meta-label {
    font-weight: 600;
    color: #4b5563;
}

.bg-meta-link {
    color: #2563eb;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.15s ease;
}

.bg-meta-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.bg-meta-text {
    color: #374151;
}

/* Футер карточки с кнопкой скачивания */
.bg-card-footer {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #f3f4f6;
}

.bg-btn-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #334155;
    text-decoration: none;
    transition: all 0.2s ease;
}

.bg-btn-download:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.bg-btn-download svg {
    transition: transform 0.2s ease;
}

.bg-btn-download:hover svg {
    transform: translateY(1px);
}

/* Сетка списка альбомов (Archive View) */
.bg-albums-grid {
    display: grid;
    gap: 24px;
    margin: 25px 0;
}

.bg-album-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.bg-album-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.08);
}

.bg-album-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.bg-album-card-cover {
    position: relative;
    aspect-ratio: 16 / 10;
    background: #e5e7eb;
    overflow: hidden;
}

.bg-album-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.bg-album-card:hover .bg-album-card-cover img {
    transform: scale(1.05);
}

.bg-album-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}

.bg-album-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    backdrop-filter: blur(4px);
}

.bg-album-card-body {
    padding: 18px;
}

.bg-album-card-title {
    margin: 0 0 8px 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: #111827;
}

.bg-album-card-desc {
    margin: 0;
    font-size: 0.9rem;
    color: #6b7280;
    line-height: 1.5;
}

/* Адаптивность для мобильных */
@media screen and (max-width: 1024px) {
    .bg-cols-4, .bg-cols-5, .bg-cols-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media screen and (max-width: 768px) {
    .bg-cols-3, .bg-cols-4, .bg-cols-5, .bg-cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }
    .bg-albums-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    /* По одному кадру/альбому на строку для мобильных устройств */
    .bg-mobile-1col,
    .bg-photos-grid.bg-mobile-1col,
    .bg-albums-grid.bg-mobile-1col {
        grid-template-columns: 1fr !important;
    }
}

@media screen and (max-width: 540px) {
    .bg-cols-2, .bg-cols-3, .bg-cols-4, .bg-cols-5, .bg-cols-6 {
        grid-template-columns: 1fr;
    }
    .bg-albums-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   СЛАЙДЕР ПОДБОРКИ (Режим слайдов с выступающими краями и свайпом)
   ========================================================================== */

/* Соотношения сторон кадров (Aspect Ratios) */
.bg-ratio-1-1 .bg-card-image-wrap { aspect-ratio: 1 / 1; }
.bg-ratio-4-5 .bg-card-image-wrap { aspect-ratio: 4 / 5; }
.bg-ratio-16-9 .bg-card-image-wrap { aspect-ratio: 16 / 9; }
.bg-ratio-9-16 .bg-card-image-wrap { aspect-ratio: 9 / 16; }

.bg-slider-wrapper {
    position: relative;
    width: 100%;
    margin: 25px 0;
    overflow: hidden;
    user-select: none;
}

.bg-slider-track-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    overflow: hidden;
    padding: 15px 0;
}

.bg-slider-track {
    display: flex;
    gap: 24px;
    transition: transform 0.45s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: transform;
    width: 100%;
    align-items: center;
}

/* Слайды на ПК: ширина зависит от настроек peek (15% или 25%) */
.bg-slider-slide {
    flex: 0 0 66%;
    max-width: 66%;
    transition: transform 0.4s ease, opacity 0.4s ease;
    opacity: 0.55;
    transform: scale(0.92);
    cursor: pointer;
    box-sizing: border-box;
}

.bg-slider-wrapper.bg-slider-peek-15 .bg-slider-slide {
    flex: 0 0 70%;
    max-width: 70%;
}

.bg-slider-wrapper.bg-slider-peek-25 .bg-slider-slide {
    flex: 0 0 50%;
    max-width: 50%;
}

.bg-slider-slide.active {
    opacity: 1;
    transform: scale(1);
    cursor: default;
}

.bg-slider-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s ease;
}

.bg-slider-slide.active .bg-slider-card {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
}

.bg-slider-card .bg-card-image-wrap {
    width: 100%;
    position: relative;
    overflow: hidden;
    background: #e5e7eb;
}

.bg-slider-card .bg-gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Навигационные стрелки */
.bg-slider-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #1f2937;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(8px);
    transition: all 0.25s ease;
}

.bg-slider-nav:hover {
    background: #ffffff;
    color: #2563eb;
    transform: translateY(-50%) scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

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

/* Пагинация (точки) */
.bg-slider-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
}

.bg-slider-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d1d5db;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.bg-slider-dot:hover {
    background: #9ca3af;
}

.bg-slider-dot.active {
    width: 28px;
    border-radius: 14px;
    background: #2563eb;
}

/* Кнопка перехода в полный альбом */
.bg-collection-album-btn-wrap {
    margin-top: 25px;
    text-align: center;
}

.bg-album-redirect-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.bg-album-redirect-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.bg-album-redirect-btn.bg-radius-rounded { border-radius: 8px; }
.bg-album-redirect-btn.bg-radius-pill { border-radius: 40px; }
.bg-album-redirect-btn.bg-radius-square { border-radius: 0px; }

.bg-album-redirect-btn.bg-btn-outline {
    background-color: transparent !important;
}

.bg-album-redirect-btn.bg-btn-minimal {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 8px 14px;
}

.bg-album-redirect-btn.bg-btn-minimal:hover {
    transform: translateX(4px);
}

/* Мобильная адаптация слайдера (Touch Swipe & Visible Peek) */
@media screen and (max-width: 768px) {
    .bg-slider-track-container {
        padding: 10px 0;
    }

    .bg-slider-track {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        padding: 10px 10%;
        gap: 14px;
        scrollbar-width: none;
    }

    .bg-slider-track::-webkit-scrollbar {
        display: none;
    }

    .bg-slider-slide {
        flex: 0 0 80%;
        max-width: 80%;
        scroll-snap-align: center;
        opacity: 0.75;
        transform: scale(0.96);
    }

    .bg-slider-slide.active {
        opacity: 1;
        transform: scale(1);
    }

    .bg-slider-nav {
        width: 38px;
        height: 38px;
    }

    .bg-slider-prev { left: 6px; }
    .bg-slider-next { right: 6px; }
}

/* ==========================================================================
   3. ПОЛАРОИД-СТАЙЛ (POLAROID LINE CAROUSEL)
   ========================================================================== */

.bg-polaroid-carousel-wrap {
    position: relative;
    width: 100%;
    margin: 35px 0 25px 0;
    padding: 30px 0 70px 0;
    border-radius: 14px;
    overflow: hidden;
    user-select: none;
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

.bg-polaroid-carousel-wrap.has-custom-bg {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.bg-polaroid-carousel-wrap.no-bg {
    background: transparent !important;
}

/* Натянутая верёвка / струна */
.bg-polaroid-rope-container {
    position: absolute;
    top: 36px;
    left: 0;
    width: 100%;
    height: 38px;
    pointer-events: none;
    z-index: 2;
}

.bg-polaroid-rope-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

.bg-rope-anchor {
    position: absolute;
    top: 13px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #94a3b8, #334155);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 3;
}

.bg-rope-anchor.anchor-left { left: 16px; }
.bg-rope-anchor.anchor-right { right: 16px; }

/* Сцена и трек карусели */
.bg-polaroid-stage {
    position: relative;
    width: 100%;
    padding-top: 15px;
    overflow: hidden;
}

.bg-polaroid-track {
    display: flex;
    gap: 28px;
    padding: 15px 40px 25px 40px;
    cursor: grab;
    will-change: transform;
    transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1);
    align-items: flex-start;
}

.bg-polaroid-track.is-dragging {
    cursor: grabbing;
    transition: none !important;
}

/* Отдельная подвешенная карточка Полароид */
.bg-polaroid-item {
    flex: 0 0 auto;
    width: 270px;
    position: relative;
    transform-origin: 50% -8px;
    transform: rotate(var(--bg-rot, 0deg));
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
    cursor: pointer;
    box-sizing: border-box;
}

.bg-polaroid-item:hover {
    transform: rotate(0deg) translateY(-4px) scale(1.02);
    z-index: 6;
}

.bg-polaroid-item.active {
    transform: rotate(0deg) translateY(-2px) scale(1.03);
    z-index: 8;
    cursor: default;
}

/* Деревянная прищепка */
.bg-polaroid-peg {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 38px;
    z-index: 7;
    pointer-events: none;
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.22));
}

.bg-peg-svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Рамка карточки Полароид */
.bg-polaroid-frame {
    background: #ffffff;
    padding: 12px 12px 16px 12px;
    border-radius: 4px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12), 0 3px 6px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.bg-polaroid-item.active .bg-polaroid-frame {
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.18), 0 6px 12px rgba(0, 0, 0, 0.08);
}

/* Внутренняя область фотографии */
.bg-polaroid-photo-inner {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #e2e8f0;
    border-radius: 2px;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.12);
}

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

.bg-polaroid-item:hover .bg-gallery-image {
    transform: scale(1.04);
}

/* Подпись названия кадра на белом поле под фото */
.bg-polaroid-caption {
    margin-top: 10px;
    padding: 0 4px;
    text-align: center;
    min-height: 24px;
}

.bg-polaroid-caption-text {
    font-family: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive, sans-serif;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.25;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

/* Стрелки навигации Полароида */
.bg-polaroid-nav {
    position: absolute;
    top: 52%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
    color: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 12;
    transition: all 0.2s ease;
    backdrop-filter: blur(6px);
}

.bg-polaroid-nav:hover {
    background: #ffffff;
    color: #2563eb;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
    transform: translateY(-50%) scale(1.06);
}

.bg-polaroid-prev { left: 14px; }
.bg-polaroid-next { right: 14px; }

/* Нижний левый угол: название фото и строка "В альбоме..." */
.bg-polaroid-corner-info {
    position: absolute;
    bottom: 18px;
    left: 28px;
    z-index: 10;
    pointer-events: auto;
    text-align: left;
    max-width: 60%;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.bg-corner-photo-title {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 3px;
    letter-spacing: -0.01em;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bg-corner-album-line {
    font-size: 0.92rem;
    line-height: 1.3;
    opacity: 0.88;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bg-corner-album-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

.bg-corner-album-link:hover {
    opacity: 0.75;
}

/* Адаптивность Полароида на смартфонах и планшетах */
@media screen and (max-width: 768px) {
    .bg-polaroid-carousel-wrap {
        padding: 24px 0 65px 0;
        margin: 20px 0;
    }

    .bg-polaroid-rope-container {
        top: 28px;
    }

    .bg-polaroid-track {
        gap: 18px;
        padding: 10px 20px 20px 20px;
    }

    .bg-polaroid-item {
        width: 220px;
    }

    .bg-polaroid-caption-text {
        font-size: 16px;
    }

    .bg-polaroid-nav {
        width: 36px;
        height: 36px;
    }

    .bg-polaroid-prev { left: 6px; }
    .bg-polaroid-next { right: 6px; }

    .bg-polaroid-corner-info {
        left: 16px;
        bottom: 12px;
        max-width: 85%;
    }

    .bg-corner-photo-title {
        font-size: 1.05rem;
    }

    .bg-corner-album-line {
        font-size: 0.85rem;
    }
}
