/**
 * Financial Advisor Theme - Main JavaScript
 * Handles theme interactive functionality
 */

// Faq
document.addEventListener("DOMContentLoaded", function () {
  const financial_advisor_game_details = document.querySelectorAll(".faq-btm-title");

  financial_advisor_game_details.forEach((targetDetail) => {
    targetDetail.addEventListener("toggle", () => {
      if (targetDetail.open) {
        financial_advisor_game_details.forEach((financial_advisor_game_detail) => {
          if (financial_advisor_game_detail !== targetDetail) {
            financial_advisor_game_detail.removeAttribute("open");
          }
        });
      }
    });
  });
});

jQuery(document).ready(function ($) {

  // Category Slider
  $('.cat-position.owl-carousel').owlCarousel({
      nav: false,
      autoplay: true,
      lazyLoad: true,
      autoplayTimeout: 2000,
      loop: true,
      dots: false,
      responsive: {
        0: { items: 1 },
        768: { items: 2 },
        992: { items: 2 },
        1200: { items: 3 }
      },
      autoplayHoverPause: true,
      mouseDrag: true
  });
});

jQuery(document).ready(function () {
  jQuery("h2.banner-heading").each(function () {
    var text = jQuery(this).text().trim();
    var words = text.split(" ");

    if (words.length >= 2) {
      words[1] = "<span style='color:var(--wp--preset--color--secondary)'>" + words[1] + "</span>";
    }

    jQuery(this).html(words.join(" "));
  });
});