<template>
  <section class="section-what-is relative overflow-hidden py-20">
    <!-- 背景 -->
    <div class="absolute inset-0 pointer-events-none" style="background: linear-gradient(180deg, rgba(245,243,255,0) 0%, rgba(237,233,254,0.5) 50%, rgba(245,243,255,0) 100%);"></div>

    <div class="relative z-10 max-w-6xl mx-auto px-6">
      <!-- 标题 -->
      <div class="text-center mb-14 observe-fade">
        <span class="inline-flex items-center gap-2 bg-violet-100 border border-violet-200 text-violet-700 text-xs font-bold px-4 py-1.5 rounded-full mb-5 uppercase tracking-wide">
          <span class="w-1.5 h-1.5 bg-violet-500 rounded-full animate-pulse"></span>
          新手指南
        </span>
        <h2 class="text-3xl lg:text-4xl font-black text-gray-900 mb-3">
          什么是 <span class="bg-gradient-to-r from-violet-600 to-indigo-600 bg-clip-text text-transparent">AI 工作流</span>？
        </h2>
        <p class="text-gray-500 text-base max-w-xl mx-auto">3 步理解 AI 工作流的核心价值，让重复性工作彻底自动化</p>
      </div>

      <!-- 3 步说明 -->
      <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-12">
        <div v-for="(step, idx) in steps" :key="step.title"
          class="step-card observe-fade group"
          :style="{ transitionDelay: idx * 120 + 'ms' }">
          <!-- 步骤号 -->
          <div class="step-number">{{ idx + 1 }}</div>
          <!-- 图标 -->
          <div class="step-icon-wrap" :style="{ background: step.iconBg }">
            <span class="text-3xl">{{ step.icon }}</span>
          </div>
          <!-- 内容 -->
          <h3 class="text-gray-900 font-bold text-lg mb-2">{{ step.title }}</h3>
          <p class="text-gray-500 text-sm leading-relaxed">{{ step.desc }}</p>
          <!-- 示例标签 -->
          <div class="mt-4 flex flex-wrap gap-2">
            <span v-for="tag in step.examples" :key="tag"
              class="text-xs px-2.5 py-1 rounded-full font-medium"
              :style="{ background: step.tagBg, color: step.tagColor }">
              {{ tag }}
            </span>
          </div>
          <!-- 连接箭头（非最后一个） -->
          <div v-if="idx < steps.length - 1" class="step-arrow">→</div>
        </div>
      </div>

      <!-- 底部 CTA -->
      <div class="text-center observe-fade">
        <p class="text-gray-400 text-sm mb-4">已有 <strong class="text-violet-600">50,000+</strong> 用户通过暴米AI实现工作自动化</p>
        <button class="inline-flex items-center gap-2 bg-gradient-to-r from-violet-600 to-indigo-600 text-white font-bold px-8 py-3.5 rounded-2xl shadow-lg shadow-violet-200 hover:shadow-violet-300 hover:-translate-y-0.5 transition-all duration-300">
          <span>免费体验工作流</span>
          <span class="text-lg">→</span>
        </button>
      </div>
    </div>
  </section>
</template>

<script setup>
import { onMounted } from 'vue'

const steps = [
  {
    icon: '🎯',
    title: '定义触发条件',
    desc: '设置工作流的启动时机——可以是定时任务、Webhook 回调、表单提交，或任何外部事件。',
    iconBg: 'linear-gradient(135deg, rgba(139,92,246,0.15), rgba(99,102,241,0.1))',
    examples: ['定时触发', 'Webhook', '表单提交', '邮件接收'],
    tagBg: 'rgba(139,92,246,0.1)',
    tagColor: '#7c3aed'
  },
  {
    icon: '⚡',
    title: '连接 AI 节点',
    desc: '拖拽连接 GPT、Claude 等 AI 模型节点，配合数据处理、条件判断、循环等逻辑节点，构建智能管道。',
    iconBg: 'linear-gradient(135deg, rgba(245,158,11,0.15), rgba(251,191,36,0.1))',
    examples: ['GPT-4', 'Claude', '数据处理', '条件分支'],
    tagBg: 'rgba(245,158,11,0.1)',
    tagColor: '#d97706'
  },
  {
    icon: '🚀',
    title: '自动执行输出',
    desc: '工作流自动运行，将结果推送到微信、飞书、数据库、邮件等任意目标，全程无需人工干预。',
    iconBg: 'linear-gradient(135deg, rgba(34,197,94,0.15), rgba(16,185,129,0.1))',
    examples: ['微信推送', '飞书通知', '数据库写入', '邮件发送'],
    tagBg: 'rgba(34,197,94,0.1)',
    tagColor: '#059669'
  }
]

onMounted(() => {
  const observer = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
      if (entry.isIntersecting) {
        entry.target.classList.add('in-view')
      }
    })
  }, { threshold: 0.15 })
  document.querySelectorAll('.section-what-is .observe-fade').forEach(el => observer.observe(el))
})
</script>

<style scoped>
.section-what-is {
  background: #fff;
}

/* 步骤卡片 */
.step-card {
  position: relative;
  background: #fff;
  border: 1px solid rgba(139, 92, 246, 0.12);
  border-radius: 24px;
  padding: 32px 28px;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.step-card:hover {
  border-color: rgba(139, 92, 246, 0.35);
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(139, 92, 246, 0.12);
}
.step-number {
  position: absolute;
  top: -14px;
  left: 28px;
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}
.step-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  transition: transform 0.3s ease;
}
.step-card:hover .step-icon-wrap {
  transform: scale(1.08) rotate(-3deg);
}
.step-arrow {
  position: absolute;
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 24px;
  color: rgba(139, 92, 246, 0.4);
  z-index: 10;
  display: none;
}

@media (min-width: 768px) {
  .step-arrow {
    display: block;
  }
}

/* 滚动入场动画 */
.observe-fade {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.observe-fade.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* 响应式 */
.section-what-is h2 {
  font-size: clamp(1.6rem, 4vw, 2.5rem);
}
@media (max-width: 768px) {
  .section-what-is { padding-top: 3rem; padding-bottom: 3rem; }
  .step-card { padding: 24px 20px; }
  .step-icon-wrap { width: 56px; height: 56px; }
}
@media (max-width: 480px) {
  .section-what-is { padding-top: 2.5rem; padding-bottom: 2.5rem; }
  .step-card { padding: 20px 16px; }
}
</style>
