import type { ReactNode } from 'react';
import Reveal from '@/components/landing/reveal';
import { cn } from '@/lib/utils';

/** Eyebrow, title and optional intro used at the top of landing sections. */
export default function SectionHeading({
    id,
    eyebrow,
    title,
    description,
    align = 'left',
    tone = 'dark',
    className,
}: {
    id: string;
    eyebrow: string;
    title: ReactNode;
    description?: ReactNode;
    align?: 'left' | 'center';
    tone?: 'dark' | 'light';
    className?: string;
}) {
    return (
        <Reveal
            className={cn(
                'flex max-w-2xl flex-col gap-4',
                align === 'center' && 'mx-auto items-center text-center',
                className,
            )}
        >
            <p
                className={cn(
                    'inline-flex items-center gap-2 text-xs font-semibold tracking-[0.14em] uppercase',
                    tone === 'dark' ? 'text-highlight-dark' : 'text-highlight',
                )}
            >
                <span
                    aria-hidden="true"
                    className="h-px w-6 bg-current opacity-60"
                />
                {eyebrow}
            </p>
            <h2
                id={id}
                className={cn(
                    'font-display text-[clamp(30px,3.6vw,44px)] leading-[1.12] font-semibold tracking-[-0.015em] text-balance',
                    tone === 'dark' ? 'text-ink' : 'text-white',
                )}
            >
                {title}
            </h2>
            {description && (
                <p
                    className={cn(
                        'text-[16.5px] leading-[1.7]',
                        tone === 'dark' ? 'text-ink-500' : 'text-white/70',
                    )}
                >
                    {description}
                </p>
            )}
        </Reveal>
    );
}
