document.addEventListener('DOMContentLoaded', function () { const buttons = document.querySelectorAll('[aria-controls^="faq-"]'); const answers = []; // First question open buttons.forEach(function (btn, idx) { const faqId = btn.getAttribute('aria-controls'); const answer = document.getElementById(faqId); answers.push(answer); if (idx === 0) { btn.setAttribute('aria-expanded', 'true'); answer.classList.remove('max-h-0', 'opacity-0'); answer.classList.add('max-h-40', 'opacity-100'); // Icons const icons = btn.querySelectorAll('svg'); if (icons.length === 2) { icons[0].classList.add('hidden'); icons[1].classList.remove('hidden'); } } else { btn.setAttribute('aria-expanded', 'false'); answer.classList.remove('max-h-40', 'opacity-100'); answer.classList.add('max-h-0', 'opacity-0'); // Icons const icons = btn.querySelectorAll('svg'); if (icons.length === 2) { icons[0].classList.remove('hidden'); icons[1].classList.add('hidden'); } } }); // Only one open buttons.forEach(function (btn, idx) { btn.addEventListener('click', function () { buttons.forEach(function (otherBtn, otherIdx) { const otherFaqId = otherBtn.getAttribute('aria-controls'); const otherAnswer = document.getElementById(otherFaqId); const otherIcons = otherBtn.querySelectorAll('svg'); if (btn === otherBtn) { // Expand otherBtn.setAttribute('aria-expanded', 'true'); otherAnswer.classList.remove('max-h-0', 'opacity-0'); otherAnswer.classList.add('max-h-40', 'opacity-100'); if (otherIcons.length === 2) { otherIcons[0].classList.add('hidden'); otherIcons[1].classList.remove('hidden'); } } else { // Hide otherBtn.setAttribute('aria-expanded', 'false'); otherAnswer.classList.remove('max-h-40', 'opacity-100'); otherAnswer.classList.add('max-h-0', 'opacity-0'); if (otherIcons.length === 2) { otherIcons[0].classList.remove('hidden'); otherIcons[1].classList.add('hidden'); } } }); }); }); });