Apto para Daltónicos
document.addEventListener("DOMContentLoaded", function () {
const container = document.querySelector("#nsbn_faq-accordion");
const headers = container.querySelectorAll(".faqs-accordion__question");
const contents = container.querySelectorAll(".faqs-accordion__answer");
// Inicializar: asegurar que todos los contenidos están colapsados
contents.forEach(content => {
content.style.maxHeight = "0";
content.style.overflow = "hidden";
content.style.transition = "max-height 0.2s cubic-bezier(0, 0.1, 0, 1)";
});
headers.forEach(header => {
header.addEventListener("click", function () {
const content = header.nextElementSibling;
if (content.style.maxHeight && content.style.maxHeight !== "0px") {
// Colapsar si ya está expandido
content.style.maxHeight = "0";
} else {
// Cerrar todos los contenidos primero
contents.forEach(c => {
c.style.maxHeight = "0";
});
// Expandir el contenido actual
content.style.maxHeight = content.scrollHeight + "px";
}
});
});
});