import {
  BellRingIcon,
  DownloadIcon,
  GlobeIcon,
  KeyRoundIcon,
  type LucideIcon
} from 'lucide-react'
import { nbspDash } from '@/shared/lib/typography'
import { DrawLine, Stagger, StaggerItem } from './motion'
import { SectionHeading } from './section-heading'

const STEPS: { Icon: LucideIcon; title: string; text: string }[] = [
  {
    Icon: DownloadIcon,
    title: 'Скачайте приложение',
    text: 'В App Store или RuStore — или откройте веб-версию. Регистрация по email занимает минуту.'
  },
  {
    Icon: GlobeIcon,
    title: 'Добавьте сайт',
    text: 'Укажите домен и название — приложение выдаст 6-значный код синхронизации.'
  },
  {
    Icon: KeyRoundIcon,
    title: 'Введите код на сайте',
    text: 'В админ-панели сайта откройте раздел «Корзилла.Админ» и вставьте код. Он действует 5 минут.'
  },
  {
    Icon: BellRingIcon,
    title: 'Получайте уведомления',
    text: 'Новые заказы и заявки сразу приходят на телефон и в веб-версию.'
  }
]

export const HowItWorks = () => (
  <section
    id='how'
    className='scroll-mt-20 border-y bg-muted/40 py-20 sm:py-28'
  >
    <div className='mx-auto max-w-7xl px-4 lg:px-6'>
      <SectionHeading
        eyebrow='Подключение'
        title='Первый сайт — за пару минут'
        description='Никаких программистов и настроек сервера: всё делается в приложении и в админ-панели вашего сайта.'
      />

      <div className='relative mt-16 lg:mt-20'>
        {/* Connector: horizontal on desktop, vertical on mobile */}
        <DrawLine className='absolute left-[12.5%] right-[12.5%] top-6 hidden h-0.5 bg-gradient-to-r from-primary/60 via-primary to-primary/60 lg:block' />
        <DrawLine
          vertical
          className='absolute bottom-6 left-6 top-6 w-0.5 bg-gradient-to-b from-primary/60 via-primary to-primary/60 lg:hidden'
        />

        <Stagger
          stagger={0.15}
          className='grid gap-10 lg:grid-cols-4 lg:gap-6'
        >
          {STEPS.map(({ Icon, title, text }, index) => (
            <StaggerItem
              key={title}
              className='relative flex gap-5 lg:flex-col lg:items-center lg:text-center'
            >
              <span className='relative z-10 flex size-12 shrink-0 items-center justify-center rounded-full border-2 border-primary bg-background font-display text-lg font-bold text-primary shadow-lg shadow-primary/10'>
                {index + 1}
              </span>
              <div className='lg:mt-6'>
                <h3 className='flex items-center gap-2 font-display text-xl font-semibold tracking-tight lg:justify-center'>
                  <Icon className='size-5 text-primary' />
                  {title}
                </h3>
                <p className='mt-2 text-muted-foreground text-pretty'>
                  {nbspDash(text)}
                </p>
              </div>
            </StaggerItem>
          ))}
        </Stagger>
      </div>
    </div>
  </section>
)
