/**
 * Fire Brigade Theme - Main JavaScript
 * Handles theme interactive functionality
 */

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

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

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

  // Service / Category Slider
  var $serviceCarousel = $('.cat-position.owl-carousel');

  // Wrap title, content and btn in an overlay div before init
  $serviceCarousel.find('.service-box').each(function () {
      var $box = $(this);
      var $title   = $box.find('.service-title');
      var $content = $box.find('.service-content');
      var $btn     = $box.find('.service-btn');
      if ($title.length || $content.length || $btn.length) {
          $title.add($content).add($btn).wrapAll('<div class="service-overlay"></div>');
      }
  });

  $serviceCarousel.owlCarousel({
      nav: false,
      margin: 0,
      autoplay: true,
      margin: 20,
      lazyLoad: true,
      autoplayTimeout: 2000,
      loop: true,
      dots: false,
      responsive: {
        0: { items: 1 },
        768: { items: 2 },
        992: { items: 3 },
        1200: { items: 3 }
      },
      autoplayHoverPause: true,
      mouseDrag: true
  });
});