<template>
  <div class="min-h-dvh">
    <NuxtLoadingIndicator color="hsl(12, 76%, 48%)" />
    <NuxtRouteAnnouncer />

    <NuxtLayout>
      <NuxtPage />
    </NuxtLayout>

    <ClientOnly>
      <PlayerPersistent />
    </ClientOnly>
  </div>
</template>

<script setup lang="ts">
const paletteStore = usePaletteStore()
onMounted(() => paletteStore.applyToDOM())

// Umami analytics — inject script only when configured
const runtimeConfig = useRuntimeConfig()
if (runtimeConfig.public.umamiWebsiteId && runtimeConfig.public.umamiUrl) {
  useHead({
    script: [{
      src: `${runtimeConfig.public.umamiUrl}/script.js`,
      defer: true,
      'data-website-id': runtimeConfig.public.umamiWebsiteId,
    }],
  })
}

useHead({
  titleTemplate: (title) => {
    return title ? `${title} — Le Librodrome` : 'Le librodrome'
  },
  meta: [
    { name: 'description', content: 'Une économie du don — enfin concevable. Un livre et des chansons, lecture guidée et écoute libre.' },
  ],
})
</script>
