<template>
  <div id="app">
    <HeaderComponent />
    <main class="content-section">
      <div class="left-column">
        <div class="right-column-overlay" v-if="showOverlay">
          <router-view name="rightColumn" />
        </div>
        <router-view />
      </div>
      <div class="right-column rightcolumnvisibility" v-if="showRightColumn">
        <router-view name="rightColumn" />
      </div>
    </main>
    <FooterComponent />
  </div>
</template>

<script>
import HeaderComponent from './common/components/HeaderComponent.vue';
import FooterComponent from './common/components/FooterComponent.vue';

export default {
  name: 'AppComponent',
  components: {
    HeaderComponent,
    FooterComponent,
  },
  data() {
    return {
      windowWidth: window.innerWidth,
    };
  },
  computed: {
    showRightColumn() {
      return this.windowWidth > 1200;
    },
    showOverlay() {
      return this.windowWidth <= 1200 && this.windowWidth >= 768;
    },
  },
  mounted() {
    window.addEventListener('resize', this.handleResize);
    document.title = 'Evangelische Miriamgemeinde Frankfurt';
  },
  beforeUnmount() { // eslint-disable-line vue/no-deprecated-destroyed-lifecycle
    window.removeEventListener('resize', this.handleResize);
  },
  methods: {
    handleResize() {
      this.windowWidth = window.innerWidth;
    },
  },
};
</script>

<style>
/* eslint-disable */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  background-color: #ffffff;
  font-family: Arial, sans-serif;
  width: 100%;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.content-section {
  flex: 1;
  display: flex;
  color: #000;
  overflow-y: hidden;
  overflow-x: auto;
}

.left-column {
  flex: 1;
  min-width: 1000px;
  margin: 0.5em 0 0.5em 0.5em;
  padding-right: 0.5em;
  background-color: #ffffff;
  overflow-y: auto;
}

.right-column {
  flex: 1;
  background-color: #d9e2f3;
  overflow-y: auto;
}

.right-column h2 {
  text-align: center;
  color: #000;
}

.right-column img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

.right-column-overlay {
  max-height: 150px;
  overflow-y: hidden;
  margin-top: 10px;
  background-color: #d9e2f3;
}

@media (max-width: 1400px) and (min-width: 1201px) {

  .left-column,
  .right-column {
    flex: 0 0 50%;
  }
}

@media (max-width: 1200px) {
  .content-section {
    flex-direction: column;
  }

  .left-column,
  .right-column {
    padding: 10px;
  }

  .rightcolumnvisibility {
    display: none;
  }
}

@media (max-width: 767px) {
  .content-section {
    flex-direction: column;
  }

  .left-column,
  .right-column {
    padding: 10px;
  }

  .rightcolumnvisibility {
    display: none;
  }

  .right-column-overlay {
    display: block;
  }
}

.right-column-overlay > .right-column > img {
  max-height: 130px;
  margin: 0;
}
/* eslint-enable */
</style>
