'use client';

import { Section } from '@/ui/Section';
import { Container } from '@/ui/Container';
import { Heading } from '@/ui/Heading';
import { MockupStack } from '@/components/mockups/MockupStack';
import { Stack } from '@/ui/Stack';
import { Text } from '@/ui/Text';
import { LeagueHomeMockup } from '@/components/mockups/LeagueHomeMockup';
import { StandingsTableMockup } from '@/components/mockups/StandingsTableMockup';
import { TeamCompetitionMockup } from '@/components/mockups/TeamCompetitionMockup';
import { ProtestWorkflowMockup } from '@/components/mockups/ProtestWorkflowMockup';
import { LeagueDiscoveryMockup } from '@/components/mockups/LeagueDiscoveryMockup';
import { DriverProfileMockup } from '@/components/mockups/DriverProfileMockup';

const features = [
  {
    title: "A Real Home for Your League",
    description: "Stop juggling Discord, spreadsheets, and iRacing admin panels. GridPilot brings everything into one dedicated platform built specifically for league racing.",
    MockupComponent: LeagueHomeMockup
  },
  {
    title: "Automatic Results & Standings",
    description: "Race happens. Results appear. Standings update. No manual data entry, no spreadsheet formulas, no waiting for someone to publish.",
    MockupComponent: StandingsTableMockup
  },
  {
    title: "Real Team Racing",
    description: "Constructors' championships that actually matter. Driver lineups. Team strategies. Multi-class racing done right.",
    MockupComponent: TeamCompetitionMockup
  },
  {
    title: "Clean Protests & Penalties",
    description: "Structured incident reporting with video clip references. Steward review workflows. Transparent penalty application. Professional race control.",
    MockupComponent: ProtestWorkflowMockup
  },
  {
    title: "Find Your Perfect League",
    description: "Search and discover leagues by game, region, and skill level. Browse featured competitions, check driver counts, and join communities that match your racing style.",
    MockupComponent: LeagueDiscoveryMockup
  },
  {
    title: "Your Racing Identity",
    description: "Cross-league driver profiles with career stats, achievements, and racing history. Build your reputation across multiple championships and showcase your progression.",
    MockupComponent: DriverProfileMockup
  }
];

function FeatureCard({ feature, index }: { feature: typeof features[0], index: number }) {
  return (
    <Stack
      display="flex"
      flexDirection="column"
      gap={6}
      className="p-8 bg-panel-gray/20 border border-border-gray/20 rounded-none hover:border-primary-accent/20 transition-all duration-300 ease-smooth group relative overflow-hidden"
    >
      <Stack aspectRatio="video" fullWidth position="relative" className="bg-graphite-black rounded-none overflow-hidden border border-border-gray/20">
        <MockupStack index={index}>
          <feature.MockupComponent />
        </MockupStack>
      </Stack>
      <Stack gap={4}>
        <Stack display="flex" alignItems="center" gap={3}>
          <Stack w="1" h="3" bg="primary-accent" />
          <Heading level={3} weight="bold" fontSize="lg" className="tracking-tighter uppercase">
            {feature.title}
          </Heading>
        </Stack>
        <Text size="sm" color="text-gray-500" leading="relaxed" weight="normal" className="group-hover:text-gray-400 transition-colors">
          {feature.description}
        </Text>
      </Stack>
      {/* Subtle hover effect */}
      <Stack 
        position="absolute" 
        bottom="0" 
        left="0" 
        w="full" 
        h="0.5" 
        bg="primary-accent" 
        className="scale-x-0 group-hover:scale-x-100 transition-transform duration-500 origin-left" 
      />
    </Stack>
  );
}

export function FeatureGrid() {
  return (
    <Section className="bg-graphite-black border-b border-border-gray/20 py-32">
      <Container position="relative" zIndex={10}>
        <Stack gap={16}>
          <Stack maxWidth="2xl">
            <Stack borderLeft borderStyle="solid" borderColor="primary-accent" pl={4} mb={4} bg="primary-accent/5" py={1}>
              <Text size="xs" weight="bold" color="text-primary-accent" className="uppercase tracking-[0.3em]">
                Engineered for Competition
              </Text>
            </Stack>
            <Heading level={2} weight="bold" fontSize={{ base: '3xl', md: '5xl' }} className="tracking-tighter uppercase leading-none">
              Building for League Racing
            </Heading>
            <Text size="lg" color="text-gray-500" block mt={6} leading="relaxed" className="border-l border-border-gray/20 pl-6">
              Every feature is designed to reduce friction and increase immersion. Join our Discord to help shape the future of the platform.
            </Text>
          </Stack>
          
          <Stack display="grid" gridCols={{ base: 1, md: 2, lg: 3 }} gap={6}>
            {features.map((feature, index) => (
              <FeatureCard key={feature.title} feature={feature} index={index} />
            ))}
          </Stack>
        </Stack>
      </Container>
    </Section>
  );
}
