<template>
  <section id="skills" class="py-24 px-4 bg-gray-950">
    <div class="max-w-4xl mx-auto">
      <div class="section-hidden" ref="sectionRef">
        <h2 class="text-3xl md:text-4xl font-bold text-white mb-4">
          Технологии
        </h2>
        <div class="w-16 h-1 bg-indigo-500 mb-10 rounded-full" />
        <div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-4">
          <UCard
            v-for="skill in skills"
            :key="skill.name"
            class="bg-gray-900 border-gray-800 hover:border-indigo-500 transition-colors duration-300 cursor-default"
          >
            <div class="flex flex-col items-center gap-2 py-2">
              <span class="text-2xl">{{ skill.icon }}</span>
              <span class="text-white font-medium text-sm">{{ skill.name }}</span>
              <UBadge :color="skill.color" variant="soft" size="xs">
                {{ skill.level }}
              </UBadge>
            </div>
          </UCard>
        </div>
      </div>
    </div>
  </section>
</template>

<script setup lang="ts">
const sectionRef = ref<HTMLElement | null>(null);

const skills = [
  { name: 'NestJS', icon: '🏗️', level: 'Expert', color: 'error' as const },
  { name: 'Nuxt 3', icon: '💚', level: 'Expert', color: 'success' as const },
  { name: 'TypeScript', icon: '🔷', level: 'Expert', color: 'info' as const },
  { name: 'Node.js', icon: '🟩', level: 'Expert', color: 'success' as const },
  { name: 'PostgreSQL', icon: '🐘', level: 'Advanced', color: 'info' as const },
  { name: 'Redis', icon: '🔴', level: 'Advanced', color: 'error' as const },
  { name: 'Docker', icon: '🐳', level: 'Advanced', color: 'sky' as const },
  { name: 'Vue 3', icon: '💡', level: 'Expert', color: 'success' as const },
  { name: 'React', icon: '⚛️', level: 'Advanced', color: 'info' as const },
  { name: 'GraphQL', icon: '🔗', level: 'Intermediate', color: 'warning' as const },
  { name: 'Kubernetes', icon: '☸️', level: 'Intermediate', color: 'secondary' as const },
  { name: 'AWS', icon: '☁️', level: 'Intermediate', color: 'warning' as const },
];

onMounted(() => {
  const observer = new IntersectionObserver(
    (entries) => {
      entries.forEach((entry) => {
        if (entry.isIntersecting) {
          entry.target.classList.remove('section-hidden');
          entry.target.classList.add('section-visible');
          observer.unobserve(entry.target);
        }
      });
    },
    { threshold: 0.1 },
  );
  if (sectionRef.value) observer.observe(sectionRef.value);
});
</script>
