'use strict';

// Listens for clicks on the mobile menu toggle and the main menu close toggle.
window.addEventListener('click', function(e) {
  const menu = document.getElementById('menu'),
    menuToggle = document.getElementById('menu-toggle'),
    body = document.body;

  if (e.target.matches('#menu-toggle, #menu-toggle i')) {
    menu.classList.toggle('active');
    menu.ariaHidden = false;
    menuToggle.ariaExpanded = true;
    body.style.overflow = 'hidden';
  }

  if (e.target.matches('#menu-close, #menu-close i')) {
    menu.classList.remove('active');
    menu.ariaHidden = true;
    menuToggle.ariaExpanded = false;
    body.style.overflow = 'auto';
  }
});
