<template>
  <div class="page-container">
    <div class="page">
      <div class="page-overlay"
           :class="{ 'is-active': isMenuOpen }"
           @click="closeMenu"
      >
      </div>
      <nuxt />
    </div>
    <SiteMenu class="menu"
              :is-open="isMenuOpen"
              @toggleMenu="toggleMenu"
    />
  </div>
</template>

<script>
import SiteMenu from '~/components/SiteMenu'

export default {
  components: {
    SiteMenu
  },

  data() {
    return {
      isMenuOpen: true,
    }
  },

  methods: {
    toggleMenu () {
      this.isMenuOpen = !this.isMenuOpen
    },
    closeMenu () {
      this.isMenuOpen = false
    },
  }
}
</script>

<style scoped lang="scss">
.page-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;

  background-color: #333;
}

.page {
  z-index: $z-index__page;
  position: relative;
  width: 100%;
  height: 100%;
}

.page-overlay {
  $color: $color__primary-100;
  z-index: $z-index__page-overlay;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;

  background-color: rgba($color, .6);
  background: linear-gradient(
    to right,
    rgba($color, 1),
    rgba($color, 1) $site-menu__width + 3rem,
    rgba($color, .8),
    rgba($color, 1)
  );
  box-shadow: 0 0 70px 40px $color inset;

  transition: opacity .5s .2s;
  opacity: 0;
  pointer-events: none;

  @media (min-width: $bp__layout) {
    &.is-active {
      opacity: 1;
      pointer-events: auto;
    }
  }
}

.menu {
  z-index: $z-index__menu;
}
</style>
