<script setup lang="ts">
import { RouterView } from 'vue-router'
import NavLink from './components/NavLink.vue'
</script>

<template>
  <div class="bisection-container">
    <header class="page-bisection">
      <h1 class="site-header-text">Andrew Lalis</h1>
      <nav>
        <NavLink path="/">Home</NavLink>
        <NavLink path="/about">About</NavLink>
        <NavLink path="/software">Software</NavLink>
        <NavLink path="/gardening">Gardening</NavLink>
        <NavLink path="/logbook">Logbook</NavLink>
        <NavLink path="/contact">Contact</NavLink>
      </nav>
    </header>

    <RouterView v-slot="{ Component }">
      <Transition name="page">
        <Component :is="Component" class="page-bisection content-page" />
      </Transition>
    </RouterView>
  </div>
</template>

<style>
.bisection-container {
  text-align: center;
}
.page-bisection {
  width: 50ch;
  display: inline-block;
  vertical-align: top;
  padding-left: 1rem;
  padding-right: 1rem;
}
.content-page {
  text-align: left;
  margin-top: 1rem;
}

.site-header-text {
  font-family: Sacramento;
  container-type: inline-size;
  font-size: calc(min(60px, max(5cqw, 42px)));
  text-align: right;
  margin-top: 1rem;
  margin-bottom: 0;
}

.page-enter-active {
  transition: all 0.5s ease;
}

.page-enter-from {
  opacity: 0;
  transform: translateX(30px);
}

/*
Activates once the left and right half of the page stack due to width constraints.
We remove a lot of the vertical spacing to make things fit better.
*/
@media (width < calc(100ch - 2.5rem)) {
  .site-header-text {
    margin-top: 0;
  }
  .content-page {
    margin-top: 0;
  }
}

/*
Once the device width is smaller than one of the halves, sync the page half to the device width.
*/
@media (width < 50ch) {
  .page-bisection {
    width: calc(100% - 2rem);
  }
}
</style>
