function fashion_outfits_trend_mobile_menu_open() {
  jQuery(".side_nav").addClass('show');
}
function fashion_outfits_trend_mobile_menu_close() {
  jQuery(".side_nav").removeClass('show');
}

jQuery(function($){
  $('.toggle').click(function () {
    fashion_outfits_trend_Keyboard_loop($('.side_nav'));
  });
});

var fashion_outfits_trend_Keyboard_loop = function (elem) {
  var fashion_outfits_trend_tabbable = elem.find('select, input, textarea, button, a').filter(':visible');
  var fashion_outfits_trend_firstTabbable = fashion_outfits_trend_tabbable.first();
  var fashion_outfits_trend_lastTabbable = fashion_outfits_trend_tabbable.last();
  fashion_outfits_trend_firstTabbable.focus();

  fashion_outfits_trend_lastTabbable.on('keydown', function (e) {
    if ((e.which === 9 && !e.shiftKey)) {
      e.preventDefault();
      fashion_outfits_trend_firstTabbable.focus();
    }
  });

  fashion_outfits_trend_firstTabbable.on('keydown', function (e) {
    if ((e.which === 9 && e.shiftKey)) {
      e.preventDefault();
      fashion_outfits_trend_lastTabbable.focus();
    }
  });

  elem.on('keyup', function (e) {
    if (e.keyCode === 27) {
      elem.hide();
    };
  });
};

jQuery('.tabs-stage .owl-carousel').owlCarousel({
  loop: true,
  margin: 30,
  nav: false,
  dots: false,
  navText: [
    '<i class="fas fa-chevron-left"></i>', // Left arrow
    '<i class="fas fa-chevron-right"></i>' // Right arrow
  ],
  responsive: {
    0: {
      items: 1,
    },
    600: {
      items: 2,
    },
    1000: {
      items: 4,
    }
  }
});

jQuery(window).scroll(function () {
    if (jQuery(this).scrollTop() >= 200) {
        jQuery("#return-to-top").fadeIn();
    } else {
        jQuery("#return-to-top").fadeOut();
    }
});

jQuery("#return-to-top").click(function () {
    jQuery("html, body").animate({ scrollTop: 0 }, 600);
});

jQuery(".myHeading").each(function () {
  const $heading = jQuery(this);

  // Skip if already processed
  if ($heading.hasClass("processed-heading")) return;

  const text = $heading.text().trim();
  const words = text.split(" ");

  if (words.length > 2) {
      const lastThree = words.splice(-2).join(" ");
      const rest = words.join(" ");
      $heading.html(`${rest} <span>${lastThree}</span>`);
  } else {
      $heading.html(`<span>${text}</span>`);
  }

  // Mark as processed
  $heading.addClass("processed-heading");
});

// Countdown Timer

var countdownTargetDate = "<?php echo esc_js($fashion_outfits_trend_target_date); ?>";

jQuery(document).ready(function ($) {
  function fashion_outfits_trend_updateCountdown() {
      var targetDate = new Date(countdownData.targetDate).getTime();
      var now = new Date().getTime();
      var distance = targetDate - now;

      if (distance < 0) {
          $('#countdown').html("<h3>Time's Up!</h3>");
          return;
      }

      var days = Math.floor(distance / (1000 * 60 * 60 * 24));
      var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
      var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
      var seconds = Math.floor((distance % (1000 * 60)) / 1000);

      $('#days').text(days < 10 ? '0' + days : days);
      $('#hours').text(hours < 10 ? '0' + hours : hours);
      $('#minutes').text(minutes < 10 ? '0' + minutes : minutes);
      $('#seconds').text(seconds < 10 ? '0' + seconds : seconds);
  }

  fashion_outfits_trend_updateCountdown();
  setInterval(fashion_outfits_trend_updateCountdown, 1000);
});

jQuery(document).ready(function($) {
  $(window).scroll(function() {
      if ($('.sticky-header').length) {
          if ($(this).scrollTop() > 50) {
              $('.upper-header-area.sticky-header').addClass('sticky-active');
          } else {
              $('.upper-header-area.sticky-header').removeClass('sticky-active');
          }
      }
  });
});