<template>
  <header class="sticky top-0 z-40 border-b border-[hsl(var(--color-text)/0.08)] bg-[hsl(var(--color-bg)/0.85)] backdrop-blur-xl">
    <div class="container-content flex h-[var(--header-height)] items-center justify-between px-4">
      <!-- Logo -->
      <NuxtLink to="/" class="logo-link flex items-center gap-2.5">
        <svg class="logo-icon" viewBox="0 0 64 80" fill="none" aria-hidden="true">
          <path d="M38 8 C28 6 18 10 18 20 C18 28 26 32 34 34 C42 36 48 40 48 48 C48 52 46 55 42 57 L44 40 C44 36 40 32 34 30 C28 28 22 24 22 18 C22 14 24 11 28 10Z" fill="currentColor" opacity="0.9"/>
          <path d="M26 72 C36 74 46 70 46 60 C46 52 38 48 30 46 C22 44 16 40 16 32 C16 28 18 25 22 23 L20 40 C20 44 24 48 30 50 C36 52 42 56 42 62 C42 66 40 69 36 70Z" fill="currentColor" opacity="0.9"/>
          <path d="M20 16 C20 8 28 4 36 6 C42 8 46 14 44 20" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" fill="none" opacity="0.7"/>
          <path d="M44 64 C44 72 36 76 28 74 C22 72 18 66 20 60" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" fill="none" opacity="0.7"/>
          <path d="M36 4 Q42 2 46 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" fill="none" opacity="0.5"/>
          <path d="M28 76 Q22 78 18 74" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" fill="none" opacity="0.5"/>
        </svg>
        <span class="logo-text">{{ site?.identity.name }}</span>
      </NuxtLink>

      <!-- Desktop navigation -->
      <nav class="hidden md:flex items-center gap-1" aria-label="Navigation principale">
        <NuxtLink
          v-for="item in site?.navigation"
          :key="item.to"
          :to="item.to"
          class="btn-ghost text-sm"
          active-class="!text-[hsl(var(--color-text))] bg-[hsl(var(--color-text)/0.06)]"
        >
          {{ item.label }}
        </NuxtLink>
        <UiPaletteSelector />
      </nav>

      <!-- Mobile menu button -->
      <button
        class="btn-ghost md:hidden !p-2"
        aria-label="Menu"
        @click="isMobileMenuOpen = true"
      >
        <div class="i-lucide-menu h-5 w-5" />
      </button>
    </div>

    <!-- Mobile menu -->
    <LayoutNavMobile v-model:open="isMobileMenuOpen" :nav="site?.navigation ?? []" />
  </header>
</template>

<script setup lang="ts">
const { data: site } = await useSiteContent()
const isMobileMenuOpen = ref(false)
</script>

<style scoped>
.logo-link {
  transition: opacity 0.2s;
}
.logo-link:hover {
  opacity: 0.8;
}

.logo-icon {
  width: 1.6rem;
  height: 2rem;
  color: hsl(var(--color-primary));
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: hsl(var(--color-primary));
}
</style>
