(function () {
  /*==================== Sticky header ====================*/
  let header = document.querySelector("header")
  let sticky = header.offsetTop

  window.addEventListener('scroll', stickyNav)

  function stickyNav() {
    if (window.pageYOffset > sticky) {
      header.classList.add("sticky")
    } else {
      header.classList.remove("sticky")
    }
  }

  /*==================== Burger menu ====================*/
  let hamburger = document.querySelector('#sandwich-menu')
  let navbar = document.querySelector('nav')

  hamburger.addEventListener('click', toggleHamburger)

  function toggleHamburger() {
    this.classList.toggle('change')
    if (navbar.style.maxHeight) {
      navbar.style.maxHeight = null
    } else {
      navbar.style.maxHeight = navbar.scrollHeight + 'px'
    }
  }
})()