<template>
  <div id="main">
    <h1 id="main-title">
      <span id="burger-toggle" @click="toggleMainMenu">{{
        mainMenu == true ? "▼" : "☰"
      }}</span>
      Cellular Automata Explorer
    </h1>
    <div id="container">
      <MainMenu v-if="mainMenu || windowWidth >= 800" />
      <CanvasBoard />
    </div>
    <MenuReset row-title="" />
  </div>
</template>

<script>
  import MainMenu from "./components/MainMenu.vue";
  import CanvasBoard from "./components/CanvasBoard.vue";
  import MenuReset from "./components/MenuReset.vue";

  export default {
    name: "App",
    components: {
      MainMenu,
      MenuReset,
      CanvasBoard,
    },
    data() {
      return {
        mainMenu: false,
        windowWidth: window.innerWidth,
      };
    },
    methods: {
      toggleMainMenu() {
        this.mainMenu = !this.mainMenu;
      },
      onResize() {
        this.windowWidth = window.innerWidth;
      },
    },
    mounted() {
      this.$nextTick(() => {
        window.addEventListener("resize", this.onResize);
      });
    },
    beforeDestroy() {
      window.removeEventListener("resize", this.onResize);
    },
  };
</script>

<style scope>
  :root {
    --dark1: #000000;
    --dark2: #333333;
    --dark3: #666666;
    --light1: #999999;
    --light2: #cccccc;
    --light3: #eeeeee;
  }

  #app {
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    /* color: #2c3e50; */
  }

  * {
    margin: 0;
    padding: 0;
  }

  body {
    background: var(--dark1);
    color: var(--light3);
    font-family: Courier New;
  }

  canvas {
    flex: auto;
    background: rgb(0, 0, 0);
    background: linear-gradient(
      90deg,
      rgba(0, 0, 0, 1) 0%,
      rgba(131, 131, 131, 1) 52%,
      rgba(0, 0, 0, 1) 100%
    );
  }

  h1,
  h2 {
    font-weight: bold;
  }

  h1 {
    margin: 10px auto;
    font-size: larger;
    text-transform: uppercase;
  }

  #container {
    display: flex;
    height: calc(100vh - 100px);
    overflow: hidden;
    flex-direction: column;
  }

  #burger-toggle {
    display: none;
    cursor: pointer;
    font-size: 1.5em;
    vertical-align: middle;
    color: var(--light2);
  }

  @media screen and (max-width: 800px) {
    h1 {
      font-size: medium;
      display: flex;
      justify-content: space-around;
      align-items: center;
    }

    #burger-toggle {
      display: inline;
    }

    #main-menu {
      background: var(--dark2);
      margin: 0 auto;
    }
  }
</style>
