let isInitialized = false;

export function btnGroupMobile() {
    if (isInitialized) return;
    const btnGroup = document.querySelector(".btn--group__mobile");
    let footer = document.querySelector("#site-footer");

    if (!btnGroup) return;

    function checkScroll() {

        const windowHeight = window.innerHeight;
        const scrollY = window.scrollY;
        const footerTop = footer.getBoundingClientRect().top;

        if (scrollY > windowHeight * 0.6) {
            btnGroup.classList.add('is-visible');

            if (footerTop < windowHeight) {
                   btnGroup.classList.remove('is-visible');
            }
        } else {
            btnGroup.classList.remove('is-visible');
        }
    }

    window.addEventListener('scroll', checkScroll);
    checkScroll();

    isInitialized = true;


}


