/* CSS-Only Gallery Lightbox - Alternative to JavaScript gallery.js */

/* Hide gallery checkboxes */
.gallery-toggle {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

/* Gallery image wrapper - replaces JavaScript trigger */
.gallery-item {
    position: relative;
    display: inline-block;
    cursor: pointer;
    /* Preserve original layout behavior */
    vertical-align: top;
}

.gallery-item label {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.gallery-item img {
    transition: transform 0.3s ease;
    display: block;
    width: 100%;
    height: auto;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

/* Ensure the layout structure matches the original slider_cascade */
.section_osteopathy__main .gallery-cascade {
    /* Match the original swiper container styling */
    width: 100%;
    height: auto;
    display: flex;
    align-items: flex-start;
}

/* Lightbox overlay - replaces JavaScript background element */
.gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1111;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show lightbox when checkbox is checked */
.gallery-toggle:checked + .gallery-lightbox {
    display: block;
    opacity: 1;
}

/* Lightbox content container - replaces JavaScript blockgallery */
.gallery-lightbox-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 4444;
    background-color: #000;
    max-width: calc(100vw - 200px);
    max-height: calc(100vh - 50px);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Image inside lightbox */
.gallery-lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* Close button - replaces JavaScript close button */
.gallery-close {
    position: fixed;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    cursor: pointer;
    z-index: 4444;
    background: url(/publ/src/img/gcloses.png) center center no-repeat;
    background-size: contain;
    transition: background-image 0.2s ease;
}

.gallery-close:hover {
    background-image: url(/publ/src/img/gcloses1.png);
}

/* Navigation areas - replaces JavaScript prev/next functionality */
.gallery-nav-prev,
.gallery-nav-next {
    position: fixed;
    top: 0;
    width: 50%;
    height: 100%;
    z-index: 3333;
    cursor: pointer;
}

.gallery-nav-prev {
    left: 0;
    background: url(/publ/src/img/gprev.png) 41px 41px no-repeat;
    transition: background-image 0.2s ease;
}

.gallery-nav-prev:hover {
    background-image: url(/publ/src/img/gprev1.png);
}

.gallery-nav-next {
    right: 0;
}

/* Image title - replaces JavaScript gal_text */
.gallery-title {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 14px;
    z-index: 4445;
}

/* Gallery grid layout */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

/* Loading state simulation */
.gallery-lightbox-content::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: url(/publ/src/img/loading.gif) center center no-repeat;
    background-size: contain;
    z-index: 4443;
}

.gallery-lightbox-image:not([src=""]) + .gallery-lightbox-content::before {
    display: none;
}

/* Responsive adjustments to match original JavaScript behavior */
@media (max-width: 1200px) {
    .gallery-lightbox-content {
        max-width: calc(100vw - 100px);
    }
}

@media (max-width: 768px) {
    .gallery-lightbox-content {
        max-width: calc(100vw - 40px);
        max-height: calc(100vh - 40px);
    }
    
    .gallery-close {
        width: 60px;
        height: 60px;
    }
    
    .gallery-nav-prev {
        background-position: 20px 20px;
    }
}

/* Match the original zoom behavior and ensure proper scaling */
@media (min-width: 1001px) {
    .gallery-lightbox {
        /* Account for body zoom: 0.8 - reverse the scaling effect */
        zoom: 1.25;
    }
    
    .gallery-lightbox-content {
        /* Keep normal transform without additional scaling */
        transform: translate(-50%, -50%);
    }
}

/* Alternative gallery styles - EXACT MATCH to original slider_cascade */
.gallery-cascade {
    /* Match original slider_cascade container exactly */
    margin: -110px auto -60px auto;
    padding: 0 0 60px 0;
    max-width: 1980px;
    overflow: hidden;
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
}

.gallery-cascade .gallery-item {
    /* Match original slider_cascade__slide dimensions exactly */
    width: 50vw;
    max-width: 960px;
    flex: 0 0 auto;
    position: relative;
}

/* Match original image container with exact aspect ratio */
.gallery-cascade .slider_cascade__img {
    position: relative;
    width: 100%;
    padding-top: 61%; /* EXACT match to original aspect ratio */
    transition: all 1s ease-in-out;
    transform: translate(0, 0);
}

.gallery-cascade .slider_cascade__img img {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Simulate the cascade effect with transforms */
.gallery-cascade .gallery-item:nth-child(2) .slider_cascade__img {
    transform: translate(0, 60px); /* Active slide */
}

.gallery-cascade .gallery-item:nth-child(1) .slider_cascade__img,
.gallery-cascade .gallery-item:nth-child(3) .slider_cascade__img {
    transform: translate(0, 30px); /* Previous/next slides */
}

/* Responsive breakpoints - EXACT MATCH to original */
@media screen and (max-width: 1280px) {
    .gallery-cascade {
        margin: -60px auto -45px auto;
        padding: 0 0 45px 0;
    }
    
    .gallery-cascade .gallery-item:nth-child(1) .slider_cascade__img,
    .gallery-cascade .gallery-item:nth-child(3) .slider_cascade__img {
        transform: translate(0, 22px);
    }
    
    .gallery-cascade .gallery-item:nth-child(2) .slider_cascade__img {
        transform: translate(0, 45px);
    }
}

@media screen and (max-width: 700px) {
    .gallery-cascade {
        margin: -40px auto -30px auto;
        padding: 0 0 30px 0;
    }
    
    .gallery-cascade .gallery-item {
        width: 55vw; /* Match original mobile width */
    }
    
    .gallery-cascade .gallery-item:nth-child(1) .slider_cascade__img,
    .gallery-cascade .gallery-item:nth-child(3) .slider_cascade__img {
        transform: translate(0, 15px);
    }
    
    .gallery-cascade .gallery-item:nth-child(2) .slider_cascade__img {
        transform: translate(0, 30px);
    }
}

.gallery-slide {
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding: 10px 0;
}

.gallery-slide .gallery-item {
    flex: 0 0 auto;
    width: 200px;
}

/* Photo gallery specific styles (matching existing CSS structure) */
.photo_gallery .gallery-item {
    border-radius: 8px;
    overflow: hidden;
}

.photo_gallery .gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

/* Animation enhancements */
.gallery-lightbox {
    animation: fadeIn 0.3s ease;
}

.gallery-lightbox-content {
    animation: scaleIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { 
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
    to { 
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Accessibility improvements */
.gallery-toggle:focus + .gallery-lightbox .gallery-close {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.gallery-lightbox[aria-hidden="false"] {
    display: block;
    opacity: 1;
}

/* Print styles */
@media print {
    .gallery-lightbox {
        display: none !important;
    }
}