<!--
The main scaffold for the website's basic pages, like home, about, contact, etc.
It displays a simple header with links, alongside the selected page content in
the router view component.

See src/router/index.ts to see the nested set of routes that use this component.
-->
<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="/hiking">Hiking</NavLink>
        <NavLink path="/logbook">Logbook</NavLink>
        <NavLink path="/contact">Contact</NavLink>
        <div id="badges" style="text-align: right; margin: 1rem 0">
          <a href="https://cadence.moe/blog/2024-10-05-created-by-a-human-badges">
            <img src="@/assets/images/created-by-a-human-with-a-brain-1x.png" />
          </a>
        </div>
      </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;

  /* Gradient text color for the header. */
  background-image: linear-gradient(90deg, var(--text-color), var(--code-color));
  color: transparent;
  background-clip: text;
}

.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>
