<template>
  <NuxtLayout>
    <div class="relative overflow-hidden section-padding">
      <!-- Shadok alchemist: character stirring a cauldron with sparkles -->
      <svg class="shadok-alchemist" viewBox="0 0 240 320" fill="none" aria-hidden="true">
        <!-- Body -->
        <ellipse cx="120" cy="145" rx="40" ry="48" fill="currentColor" opacity="0.85"/>
        <!-- Head -->
        <circle cx="120" cy="82" r="24" fill="currentColor" opacity="0.8"/>
        <!-- Wizard hat -->
        <polygon points="120,30 100,80 140,80" fill="currentColor" opacity="0.5"/>
        <line x1="100" y1="80" x2="140" y2="80" stroke="currentColor" stroke-width="3" stroke-linecap="round" opacity="0.45"/>
        <!-- Hat star -->
        <circle cx="118" cy="55" r="3" fill="currentColor" opacity="0.25"/>
        <!-- Eyes (mischievous) -->
        <circle cx="111" cy="78" r="4.5" fill="currentColor" opacity="0.2"/>
        <circle cx="129" cy="78" r="4.5" fill="currentColor" opacity="0.2"/>
        <circle cx="112" cy="77" r="2" fill="currentColor" opacity="0.5"/>
        <circle cx="130" cy="77" r="2" fill="currentColor" opacity="0.5"/>
        <!-- Grin -->
        <path d="M112 92 Q120 98 128 92" stroke="currentColor" stroke-width="2" stroke-linecap="round" fill="none" opacity="0.35"/>
        <!-- Arm holding spoon/stick -->
        <line x1="158" y1="140" x2="175" y2="210" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" opacity="0.6"/>
        <!-- Other arm -->
        <path d="M82 145 Q65 165 70 185" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" fill="none" opacity="0.6"/>
        <!-- Cauldron -->
        <path d="M60 220 Q60 260 120 260 Q180 260 180 220" fill="currentColor" opacity="0.4"/>
        <ellipse cx="120" cy="220" rx="60" ry="15" fill="currentColor" opacity="0.3"/>
        <ellipse cx="120" cy="220" rx="60" ry="15" stroke="currentColor" stroke-width="2" fill="none" opacity="0.4"/>
        <!-- Cauldron legs -->
        <line x1="80" y1="258" x2="75" y2="280" stroke="currentColor" stroke-width="3" stroke-linecap="round" opacity="0.5"/>
        <line x1="160" y1="258" x2="165" y2="280" stroke="currentColor" stroke-width="3" stroke-linecap="round" opacity="0.5"/>
        <!-- Bubbles from cauldron -->
        <circle cx="100" cy="210" r="5" fill="currentColor" opacity="0.2"/>
        <circle cx="135" cy="205" r="4" fill="currentColor" opacity="0.18"/>
        <circle cx="115" cy="198" r="3" fill="currentColor" opacity="0.15"/>
        <!-- Sparkles -->
        <circle cx="90" cy="190" r="2" fill="currentColor" opacity="0.25"/>
        <circle cx="150" cy="195" r="2.5" fill="currentColor" opacity="0.2"/>
        <circle cx="105" cy="185" r="1.5" fill="currentColor" opacity="0.2"/>
        <!-- Character legs -->
        <line x1="105" y1="190" x2="95" y2="225" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" opacity="0.5"/>
        <line x1="135" y1="190" x2="145" y2="225" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" opacity="0.5"/>
      </svg>

      <div class="container-content max-w-3xl mx-auto">
        <!-- Back link -->
        <UiScrollReveal>
          <NuxtLink to="/" class="inline-flex items-center gap-2 text-sm text-white/50 hover:text-white/80 mb-8 transition-colors">
            <div class="i-lucide-arrow-left h-4 w-4" />
            Retour &agrave; l'accueil
          </NuxtLink>
        </UiScrollReveal>

        <!-- Header -->
        <UiScrollReveal>
          <div class="text-center mb-12">
            <span class="inline-block mb-3 rounded-full bg-amber-400/15 px-3 py-0.5 font-mono text-xs tracking-widest text-amber-400 uppercase">
              {{ content?.kicker }}
            </span>
            <h1 class="page-title font-display font-bold text-white">
              {{ content?.title }}
            </h1>
            <p class="mt-4 text-lg text-white/60 leading-relaxed max-w-xl mx-auto">
              {{ content?.description }}
            </p>
          </div>
        </UiScrollReveal>

        <!-- Explanation cards -->
        <div class="grid gap-6 md:grid-cols-2 mb-12">
          <UiScrollReveal
            v-for="(feature, i) in content?.features"
            :key="i"
            :delay="(i + 1) * 100"
          >
            <div class="gw-feature-card">
              <div :class="`i-lucide-${feature.icon}`" class="h-6 w-6 text-amber-400 mb-3" />
              <h3 class="font-display text-lg font-semibold text-white mb-2">{{ feature.title }}</h3>
              <p class="text-sm text-white/60 leading-relaxed">
                {{ feature.description }}
              </p>
            </div>
          </UiScrollReveal>
        </div>

        <!-- CTA -->
        <UiScrollReveal :delay="500">
          <div class="text-center">
            <p class="text-sm text-white/40 mb-4">
              {{ content?.cta.note }}
            </p>
            <UiBaseButton :href="url" target="_blank" @click="launch">
              <div class="i-lucide-external-link mr-2 h-5 w-5" />
              {{ content?.cta.label }}
            </UiBaseButton>
          </div>
        </UiScrollReveal>
      </div>
    </div>
  </NuxtLayout>
</template>

<script setup lang="ts">
const { data: content } = await usePageContent('gratewizard')

useHead({
  title: content.value?.meta?.title ?? 'grateWizard \u2014 Coefficients relatifs',
})

const { url, launch } = useGrateWizard()
</script>

<style scoped>
.page-title {
  font-size: clamp(2rem, 5vw, 2.75rem);
}

.gw-feature-card {
  padding: 1.5rem;
  border-radius: 0.75rem;
  border: 1px solid hsl(var(--color-text) / 0.1);
  background: hsl(var(--color-surface) / 0.5);
  transition: border-color 0.3s ease, background 0.3s ease;
}

.gw-feature-card:hover {
  border-color: hsl(40 80% 50% / 0.25);
  background: hsl(var(--color-surface-light) / 0.5);
}

code {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
  padding: 0.1em 0.3em;
  border-radius: 0.25em;
  background: hsl(40 80% 50% / 0.1);
}

.shadok-alchemist {
  position: absolute;
  right: 2%;
  top: 15%;
  width: clamp(100px, 14vw, 190px);
  opacity: 0.1;
  pointer-events: none;
  color: hsl(var(--color-accent));
  animation: shadok-float-alchemist 10s ease-in-out infinite;
}

@keyframes shadok-float-alchemist {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(1deg); }
}

@media (max-width: 768px) {
  .shadok-alchemist { display: none; }
}
</style>
