jQuery(document).ready(function($){
const faqItems=$('.wp-faq-item');
$(document).on('click', '.wp-faq-question', function(e){
e.preventDefault();
const $question=$(this);
const $answer=$question.siblings('.wp-faq-answer');
const $icon=$question.find('.wp-faq-icon');
$question.toggleClass('open');
$answer.toggleClass('open');
});
$(document).on('keydown', '.wp-faq-question', function(e){
if(e.keyCode===13||e.keyCode===32){
e.preventDefault();
$(this).click();
}});
handleAnchorLinks();
function handleAnchorLinks(){
const hash=window.location.hash;
if(!hash) return;
const targetIndex=parseInt(hash.substring(1));
if(isNaN(targetIndex)) return;
const targetQuestion=$('.wp-faq-question').eq(targetIndex);
if(targetQuestion.length){
targetQuestion.click();
}}
});