//Scroll Animations
const observer = new IntersectionObserver((entries) => {
    entries.forEach((entry) => {
      // console.log(entry);
      if (entry.isIntersecting) {
        entry.target.classList.add('animations-show-item');
        observer.unobserve(entry.target);
      } else {
        entry.target.classList.remove('animations-show-item');
      }
    });
  });
  
  const hiddenElements = document.querySelectorAll('.animations-hidden-item');
  hiddenElements.forEach((el) => observer.observe(el));

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

  var owl = jQuery('.our-projects .owl-carousel');
    owl.owlCarousel({
    margin:25,
    stagePadding: 5,
    nav: false,
    autoplay : true,
    lazyLoad: true,
    autoplayTimeout: 3000,
    loop: true,
    dots:false,
    navText : ['<span class="dashicons dashicons-arrow-left-alt2"></span>','<span class="dashicons dashicons-arrow-right-alt2"></span> '],
    responsive: {
      0: {
        items: 1,
        nav: false,
      },
      600: {
        items: 2,
        nav: false,
      },
      1000: {
        items: 3
      },
      1200: {
        items: 4
      }
    },
    autoplayHoverPause : true,
    mouseDrag: true
  });
});
jQuery(document).ready(function($) {
  var $sidebar = $(".sidebar");
  var $toggleBtn = $(".toggle-btn-main");
  var $crossBtn = $(".cross-btn-main");

  // Toggle button click
  $toggleBtn.on("click", function() {
    if ($sidebar.hasClass("is-hidden")) {
      // Show sidebar
      $sidebar
        .removeClass("is-hidden")
        .attr({
          "aria-hidden": "false",
          "tabindex": "-1"
        })
        .focus();

      $toggleBtn
        .removeClass("dashiconss-menu")
        .addClass("dashiconss-no-alt")
        .attr("aria-expanded", "true");
    } else {
      // Hide sidebar
      $sidebar
        .addClass("is-hidden")
        .attr("aria-hidden", "true");

      $toggleBtn
        .removeClass("dashiconss-no-alt")
        .addClass("dashiconss-menu")
        .attr("aria-expanded", "false")
        .trigger("focus"); // explicitly return focus
    }
  });

  // Cross button click → hide safely
  $crossBtn.on("click", function(e) {
    e.preventDefault(); // prevent unwanted focus loss
    e.stopPropagation();

    $sidebar
      .addClass("is-hidden")
      .attr("aria-hidden", "true");

    // Return focus *asynchronously* to avoid Chrome accessibility reset
    setTimeout(function() {
      $toggleBtn
        .removeClass("dashiconss-no-alt")
        .addClass("dashiconss-menu")
        .attr("aria-expanded", "false")
        .trigger("focus");
    }, 50);
  });
});

