import { Check } from 'lucide-react';

import { Container, Section, SectionHeading } from '@/components/layout/container';
import { FeatureMock } from '@/components/marketing/feature-mocks';
import { FinalCta } from '@/components/marketing/final-cta';
import { Reveal } from '@/components/motion/reveal';
import { Card } from '@/components/ui/card';
import { features } from '@/lib/marketing';
import { cn } from '@/lib/utils';

export function FeaturesContent() {
  return (
    <>
      <section className="relative overflow-hidden pb-14 pt-32 md:pb-20 md:pt-40">
        <div className="pointer-events-none absolute inset-0 bg-mesh" aria-hidden="true" />
        <Container className="relative">
          <Reveal>
            <SectionHeading
              as="h1"
              eyebrow="Features"
              title="Everything you need to ship"
              text="Rates, labels, tracking, wallet and team controls in one calm workspace."
            />
          </Reveal>
        </Container>
      </section>

      <Section className="!pt-4 md:!pt-8">
        <Container className="grid gap-20 md:gap-28">
          {features.map((feature, index) => {
            const Icon = feature.icon;
            const reversed = index % 2 === 1;
            return (
              <article key={feature.title} className="grid items-center gap-10 lg:grid-cols-2 lg:gap-16">
                <Reveal className={cn(reversed && 'lg:order-2')}>
                  <div className="grid h-11 w-11 place-items-center rounded-xl bg-primary-soft text-primary">
                    <Icon className="h-5 w-5" aria-hidden="true" />
                  </div>
                  <h2 className="mt-5 text-balance font-display text-[1.75rem] font-extrabold leading-9 tracking-[-0.02em] md:text-[2.25rem] md:leading-[2.75rem]">
                    {feature.title}
                  </h2>
                  <p className="mt-4 max-w-xl text-pretty text-[1.0625rem] leading-7 text-muted-foreground">{feature.body}</p>
                  <ul className="mt-6 grid gap-3">
                    {feature.bullets.map((bullet) => (
                      <li key={bullet} className="flex items-center gap-2.5 text-body text-foreground">
                        <span className="grid h-5 w-5 shrink-0 place-items-center rounded-full bg-success-soft">
                          <Check className="h-3 w-3 text-success" strokeWidth={3} aria-hidden="true" />
                        </span>
                        {bullet}
                      </li>
                    ))}
                  </ul>
                </Reveal>
                <Reveal index={1} className={cn(reversed && 'lg:order-1')}>
                  <Card variant="muted" className="relative overflow-hidden p-5 md:p-8">
                    <div className="pointer-events-none absolute -right-16 -top-16 h-48 w-48 rounded-full bg-primary/10 blur-3xl" aria-hidden="true" />
                    <div className="relative" aria-hidden="true">
                      <FeatureMock kind={feature.title} />
                    </div>
                  </Card>
                </Reveal>
              </article>
            );
          })}
        </Container>
      </Section>

      <FinalCta />
    </>
  );
}
