const swiper = new Swiper(".gallerySwiper",{

    effect:"coverflow",

    grabCursor:true,

    centeredSlides:true,

    loop:true,

    slidesPerView:"auto",

    spaceBetween:10,
preventClicks:true,

    preventClicksPropagation:true,
    coverflowEffect:{

        rotate:0,

        stretch:0,

        depth:250,

        modifier:1.8,

        scale:0.85,

        slideShadows:false

    },

    navigation:{

        nextEl:".swiper-button-next",

        prevEl:".swiper-button-prev"

    },

    pagination:{

        el:".swiper-pagination",

        clickable:true

    },

    breakpoints:{

        0:{

            slidesPerView:1.2

        },

        768:{

            slidesPerView:2.2

        },

        1200:{

            slidesPerView:3

        }

    }

});

document.addEventListener("DOMContentLoaded",()=>{

const items=document.querySelectorAll(".gallery-item");

const lightbox=document.getElementById("lightbox");

const img=document.getElementById("lightbox-img");

const current=document.getElementById("current-photo");

const total=document.getElementById("total-photo");

const next=document.querySelector(".lb-next");

const prev=document.querySelector(".lb-prev");

const close=document.querySelector(".lb-close");

let index=0;

total.textContent=items.length;

function open(i){

index=i;

img.src=items[index].href;

current.textContent=index+1;

lightbox.classList.add("show");

document.body.style.overflow="hidden";

}

function hide(){

lightbox.classList.remove("show");

document.body.style.overflow="auto";

}

items.forEach((item,i)=>{

item.onclick=(e)=>{

e.preventDefault();

open(i);

};

});

next.onclick=()=>{

index++;

if(index>=items.length){

index=0;

}

open(index);

};

prev.onclick=()=>{

index--;

if(index<0){

index=items.length-1;

}

open(index);

};

close.onclick=hide;

lightbox.onclick=(e)=>{

if(e.target===lightbox){

hide();

}

};

document.addEventListener("keydown",(e)=>{

if(!lightbox.classList.contains("show")) return;

if(e.key==="ArrowRight") next.click();

if(e.key==="ArrowLeft") prev.click();

if(e.key==="Escape") hide();

});

});