/* ==========================================================================
   LITB GALLERY BLOCK STYLES
   Swiper.js Carousel + GLightbox Lightbox
   1200px max width on desktop
   ========================================================================== */

:root {
    --litb-gallery-font-family: var(--wp--preset--font-family--public-sans, "Public Sans", sans-serif);
    --litb-gallery-color-text: var(--wp--preset--color--neutral-black, #000000);
    --litb-gallery-color-muted: var(--wp--preset--color--neutral-gray-01, #A5A5A5);
    --litb-gallery-color-surface: var(--wp--preset--color--neutral-white, #FFFFFF);
    --litb-gallery-color-subtle: var(--wp--preset--color--neutral-gray-02, #D5D5D5);
    --litb-gallery-color-frame: #000000;
    --litb-gallery-color-accent: var(--wp--preset--color--brand-dark-blue, #56677C);
    --litb-gallery-color-accent-hover: var(--wp--preset--color--brand-light-blue, #93A1B2);
    --litb-gallery-space-xs: 0.5rem;
    --litb-gallery-space-sm: 0.75rem;
    --litb-gallery-space-md: 1rem;
    --litb-gallery-space-lg: 1.5rem;
    --litb-gallery-radius-sm: 4px;
    --litb-gallery-transition-fast: 150ms ease;
    --litb-gallery-transition-base: 200ms ease;
}

/* ==========================================================================
   GALLERY WRAPPER - 1200px max
   ========================================================================== */

.bop-gallery-wrapper {
    position: relative;
    width: 100%;
    margin: var(--litb-gallery-space-lg) auto;
    color: var(--litb-gallery-color-text);
    font-family: var(--litb-gallery-font-family);
}

.bop-gallery-wrapper.has-black-background {
    --litb-gallery-color-frame: #000000;
    --litb-gallery-pagination-color: var(--litb-gallery-color-surface);
}

.bop-gallery-wrapper.has-white-background {
    --litb-gallery-color-frame: var(--litb-gallery-color-surface);
    --litb-gallery-pagination-color: var(--litb-gallery-color-muted);
}

.bop-gallery-wrapper:not(.alignfull) {
    max-width: 1200px;
}

.bop-gallery-wrapper.alignfull {
    max-width: 100vw;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}

/* ==========================================================================
   GALLERY CONTROLS
   ========================================================================== */

.bop-gallery-controls {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 12;
    display: flex;
    justify-content: flex-end;
    gap: var(--litb-gallery-space-sm);
    margin-bottom: 0;
}

.bop-caption-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--litb-gallery-space-xs);
    padding: var(--litb-gallery-space-xs) var(--litb-gallery-space-md);
    font-family: var(--litb-gallery-font-family);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
    text-transform: uppercase;
    letter-spacing: 0;
    color: var(--litb-gallery-color-accent);
    background: var(--litb-gallery-color-surface);
    border: 2px solid var(--litb-gallery-color-accent);
    border-radius: var(--litb-gallery-radius-sm);
    cursor: pointer;
    transition: color var(--litb-gallery-transition-fast), background-color var(--litb-gallery-transition-fast), border-color var(--litb-gallery-transition-fast);
}

.bop-caption-toggle:hover,
.bop-caption-toggle:focus {
    background: var(--litb-gallery-color-accent);
    border-color: var(--litb-gallery-color-accent);
    color: var(--litb-gallery-color-surface);
}

.bop-caption-toggle[aria-pressed="true"] .toggle-show,
.bop-caption-toggle[aria-pressed="false"] .toggle-hide {
    display: none;
}

.bop-caption-toggle[aria-pressed="false"] .toggle-show,
.bop-caption-toggle[aria-pressed="true"] .toggle-hide {
    display: inline;
}

/* ==========================================================================
   SWIPER CAROUSEL
   ========================================================================== */

.bop-gallery-swiper {
    width: 100%;
    position: relative;
    overflow: hidden;
    border-radius: var(--litb-gallery-radius-sm);
    background: var(--litb-gallery-color-frame);
}

.bop-gallery-swiper .swiper-slide {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--litb-gallery-color-frame);
}

.bop-gallery-media {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.bop-gallery-media .glightbox-item {
    width: auto;
}

.bop-gallery-image {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    cursor: zoom-in;
}

/* Image overlay on hover */
.glightbox-item {
    position: relative;
    display: block;
    width: 100%;
}

.bop-image-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    transition: background var(--litb-gallery-transition-base);
    pointer-events: none;
}

.glightbox-item:hover .bop-image-overlay,
.glightbox-item:focus .bop-image-overlay {
    background: rgba(0, 0, 0, 0.3);
}

.bop-expand-icon {
    color: var(--litb-gallery-color-surface);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity var(--litb-gallery-transition-base), transform var(--litb-gallery-transition-base);
}

.glightbox-item:hover .bop-expand-icon,
.glightbox-item:focus .bop-expand-icon {
    opacity: 1;
    transform: scale(1);
}

/* Swiper Navigation Arrows */
.bop-gallery-swiper .swiper-button-prev,
.bop-gallery-swiper .swiper-button-next {
    color: var(--litb-gallery-color-surface);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    transition: background-color var(--litb-gallery-transition-fast), opacity var(--litb-gallery-transition-fast);
    z-index: 10;
}

.bop-gallery-swiper .swiper-button-prev {
    left: max(16px, calc((100% - 1200px) / 2 + 16px));
}

.bop-gallery-swiper .swiper-button-next {
    right: max(16px, calc((100% - 1200px) / 2 + 16px));
}

.bop-gallery-swiper .swiper-button-prev::after,
.bop-gallery-swiper .swiper-button-next::after {
    font-size: 18px;
    font-weight: 700;
}

.bop-gallery-swiper .swiper-button-prev:hover,
.bop-gallery-swiper .swiper-button-next:hover {
    background: var(--litb-gallery-color-accent);
}

.bop-gallery-swiper .swiper-button-disabled {
    opacity: 0.3;
    pointer-events: none;
    visibility: hidden;
}

/* Swiper Pagination */
.bop-gallery-swiper .swiper-pagination {
    bottom: 16px;
}

.bop-gallery-swiper .swiper-pagination-bullet {
    width: 10px;
    height: 10px;
    background: var(--litb-gallery-pagination-color, var(--litb-gallery-color-surface));
    opacity: 0.5;
    transition: background-color var(--litb-gallery-transition-fast), opacity var(--litb-gallery-transition-fast), transform var(--litb-gallery-transition-fast);
}

.bop-gallery-swiper .swiper-pagination-bullet-active {
    opacity: 1;
    background: var(--litb-gallery-color-accent);
    transform: scale(1.2);
}

/* ==========================================================================
   CAPTIONS
   ========================================================================== */

.bop-caption-wrapper {
    width: 100%;
    padding: var(--litb-gallery-space-md);
    background: var(--litb-gallery-color-surface);
    border-top: 3px solid var(--litb-gallery-color-accent);
    display: none;
    animation: slideDown 0.3s ease;
}

.bop-caption-wrapper.show {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bop-caption {
    color: var(--litb-gallery-color-text);
    font-family: var(--litb-gallery-font-family);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
}

.bop-caption p {
    margin: 0;
}

/* Expandable long captions */
.bop-caption.expandable .caption-full {
    display: none;
}

.bop-caption.expandable.expanded .caption-short {
    display: none;
}

.bop-caption.expandable.expanded .caption-full {
    display: block;
}

.bop-caption-expand {
    display: inline-flex;
    align-items: center;
    gap: var(--litb-gallery-space-xs);
    margin-top: var(--litb-gallery-space-sm);
    padding: 0;
    font-family: var(--litb-gallery-font-family);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--litb-gallery-color-accent);
    background: none;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0;
}

.bop-caption-expand:hover {
    color: var(--litb-gallery-color-accent-hover);
    text-decoration: underline;
}

.bop-caption-expand .collapse-text {
    display: none;
}

.bop-caption.expanded .bop-caption-expand .expand-text {
    display: none;
}

.bop-caption.expanded .bop-caption-expand .collapse-text {
    display: inline;
}

/* ==========================================================================
   GALLERY COUNTER
   ========================================================================== */

.bop-gallery-counter {
    text-align: center;
    padding: var(--litb-gallery-space-sm) 0;
    font-family: var(--litb-gallery-font-family);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--litb-gallery-color-muted);
    letter-spacing: 0;
}

.bop-gallery-counter .current-slide {
    color: var(--litb-gallery-color-accent);
    font-weight: 700;
}

/* ==========================================================================
   GLIGHTBOX CUSTOMIZATION
   Fix whitespace below images and style captions
   ========================================================================== */

/* Force the lightbox to size to content, not viewport */
.glightbox-container {
    width: 100%;
    height: 100%;
}

.goverlay {
    background: rgba(0, 0, 0, 0.95) !important;
}

/* The slide wrapper - remove fixed height */
.glightbox-container .gslide {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: auto !important;
    max-height: 100vh !important;
}

/* Inner content wrapper */
.glightbox-container .gslide-inner-content {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    max-height: 100vh !important;
    height: auto !important;
}

/* The media container - this is often the culprit */
.glightbox-container .gslide-media {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    max-height: calc(100vh - 100px) !important;
    height: auto !important;
    width: auto !important;
    max-width: 100% !important;
}

/* Image container */
.glightbox-container .gslide-image {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: auto !important;
    max-height: calc(100vh - 100px) !important;
}

/* The actual image */
.glightbox-container .gslide-image img {
    max-width: 100% !important;
    max-height: calc(100vh - 100px) !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
}

/* Remove any min-height that causes whitespace */
.gslide,
.gslide-inner-content,
.gslide-media,
.gslide-image {
    min-height: 0 !important;
}

/* Description/caption area */
.gslide-description {
    background: rgba(0, 0, 0, 0.9) !important;
    padding: var(--litb-gallery-space-md) var(--litb-gallery-space-lg) !important;
    position: relative !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    max-width: 900px !important;
    margin: 0 auto !important;
}

.gslide-description .gdesc-inner {
    color: var(--litb-gallery-color-surface) !important;
    font-family: var(--litb-gallery-font-family) !important;
    font-size: 16px !important;
    font-weight: 400 !important;
    line-height: 1.5 !important;
}

.glightbox-clean .gslide-description {
    background: rgba(0, 0, 0, 0.9) !important;
}

/* Hide overlay-style captions */
.glightbox-clean .goverlay {
    background: rgba(0, 0, 0, 0.95);
}

/* Navigation in lightbox */
.glightbox-clean .gnext,
.glightbox-clean .gprev {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 48px;
    height: 48px;
}

.glightbox-clean .gnext:hover,
.glightbox-clean .gprev:hover {
    background: var(--litb-gallery-color-accent);
}

/* Close button */
.glightbox-clean .gclose {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 40px;
    height: 40px;
}

.glightbox-clean .gclose:hover {
    background: var(--litb-gallery-color-accent);
}

/* ==========================================================================
   SINGLE IMAGE (NO CAROUSEL)
   ========================================================================== */

.bop-single-image {
    position: relative;
    width: 100%;
}

.bop-single-image img {
    width: 100%;
    height: auto;
    display: block;
}

.bop-single-image .bop-image-overlay {
    position: absolute;
    inset: 0;
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 768px) {

    .bop-gallery-swiper .swiper-button-prev,
    .bop-gallery-swiper .swiper-button-next {
        width: 36px;
        height: 36px;
    }

    .bop-gallery-swiper .swiper-button-prev {
        left: 12px;
    }

    .bop-gallery-swiper .swiper-button-next {
        right: 12px;
    }

    .bop-gallery-swiper .swiper-button-prev::after,
    .bop-gallery-swiper .swiper-button-next::after {
        font-size: 14px;
    }

    .bop-caption-wrapper {
        padding: var(--litb-gallery-space-sm) var(--litb-gallery-space-md);
    }

    .bop-gallery-image {
        max-height: 50vh;
    }

    .bop-gallery-controls {
        top: 12px;
        right: 12px;
        justify-content: flex-end;
    }

    /* Disable lightbox visual cues on mobile */
    .bop-image-overlay {
        display: none !important;
    }

    .glightbox-item {
        cursor: default;
    }
}

@media (max-width: 480px) {

    .bop-gallery-swiper .swiper-button-prev,
    .bop-gallery-swiper .swiper-button-next {
        width: 32px;
        height: 32px;
    }

    .bop-gallery-swiper .swiper-button-prev::after,
    .bop-gallery-swiper .swiper-button-next::after {
        font-size: 12px;
    }
}
