<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 class="right-column-overlay" v-if="showAsFooter">
          <router-view name="rightColumn" />
        </div>
      </div>
      <div class="right-column" 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;
    },
    showAsFooter() {
      return 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 */
/* Layout: globale Typografie/Farben in design-tokens.css */
.content-section {
  flex: 1;
  min-height: 0;
  display: flex;
  color: var(--color-text);
  overflow-y: hidden;
}

.left-column {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  margin: var(--space-2) 0 var(--space-2) var(--space-2);
  padding-right: var(--space-2);
  background-color: var(--color-bg-page);
  overflow-y: auto;
}

.right-column {
  flex: 1;
  min-width: 0;
  background-color: var(--color-bg-sidebar);
  overflow-y: auto;
  margin: 0 var(--space-2) var(--space-2) 0;
}

.right-column h2 {
  text-align: center;
  color: var(--color-text);
}

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

.right-column-overlay {
  max-height: 150px;
  overflow-y: hidden;
  margin-top: var(--space-3);
  background-color: var(--color-bg-sidebar);
  display: flex;
  justify-content: center;
  align-items: center;
}

.right-column-overlay img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

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

  .left-column {
    padding: var(--space-3);
    margin-left: 0;
    margin-right: 0;
  }

  .right-column {
    display: none;
  }

  .right-column-overlay {
    display: flex;
    max-height: 150px;
    background-color: var(--color-bg-page);
  }

  .right-column-overlay img {
    max-height: 150px;
    max-width: 100%;
    object-fit: contain;
  }
}

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

  .left-column,
  .right-column {
    padding: var(--space-3);
  }

  .right-column {
    display: none;
  }

  .right-column-overlay {
    display: flex;
  }
}
/* eslint-enable */
</style>
