<script setup lang="ts">
import { RouterLink } from 'vue-router'
</script>

<template>
  <nav class="site-nav">
    <RouterLink
      v-for="(route, idx) in $router.getRoutes()"
      :key="idx"
      :to="route.path"
      class="site-nav__link"
    >
      {{ route.name }}
    </RouterLink>
  </nav>
</template>

<style lang="scss">
.site-nav {
  display: flex;
  flex-flow: row nowrap;
  height: auto;
  margin: 0 0 1em 0;
  overflow-x: scroll;
  scrollbar-width: none;
  padding: max(var(--page-padding), env(safe-area-inset-top))
    max(var(--page-padding), env(safe-area-inset-right))
    max(var(--page-padding), env(safe-area-inset-bottom))
    max(var(--page-padding), env(safe-area-inset-left));

  &::-webkit-scrollbar {
    display: none;
  }

  &__link {
    font-weight: 300;
    text-decoration: none;
    text-transform: capitalize;
    padding: 0.5em 1em;
    transition: box-shadow 0.2s ease-in-out;

    @media (hover: hover) {
      &:hover {
        box-shadow: inset 0 calc(1em * -0.125) 0 0 rgba(#fff, 1);
      }
    }

    &.router-link-exact-active {
      box-shadow:
        inset 0 calc(1em * -0.125) 0 0 rgba(#fff, 1),
        inset 0 calc(2.5em * -1) 0 0 rgba(#fff, 0.2);
    }
  }

  &__underline {
    position: relative;
    display: block;
    width: 100%;

    &::before,
    &::after {
      content: '';
      position: absolute;
      bottom: 0;
      width: 0;
      height: 0.125rem;
      transition: all 0.2s ease-in-out;
    }

    &::before {
      left: 50%;
    }
  }
}
</style>
