export default function initAccordion() {
   const accordions = document.querySelectorAll(".accordion") || null;

   if (accordions.length > 0) {
      accordions.forEach((accordion) => {
         const accordionItems = accordion.querySelectorAll(".accordion__f-a-q");

         accordionItems.forEach((item) => {
            const question = item.querySelector(".accordion__question");
            const content = item.querySelector(".accordion__content");

            question.addEventListener("click", () => {
               const isOpen = question.classList.contains("is-open");

               if (!isOpen) {
                  content.style.maxHeight = content.scrollHeight + "px";
               } else {
                  content.style.maxHeight = null;
               }

               question.classList.toggle("is-open");
            });
         });
      });
   }
}
