<script lang="ts">
    import ExternalLinkIcon from '$lib/components/Icon/ExternalLink.svelte';

    interface SecondaryCta {
        href: string;
        label: string;
        umamiEventLabel: string;
    }

    const {
        title,
        subtitle,
        bookingLinkTitle,
        bookingLinkUrl,
        secondaryCta,
    }: {
        title: string;
        subtitle: string;
        bookingLinkTitle: string;
        bookingLinkUrl: string;
        secondaryCta?: SecondaryCta;
    } = $props();
</script>

<header id="header" class="hero">
    <div class="container">
        <h1 class="title">
            {title}
        </h1>
        <p class="subtitle">
            {subtitle}
        </p>
        <div class="cta-group">
            <a
                href={bookingLinkUrl}
                class="btn btn-primary icon-button"
                target="_blank"
                rel="noopener noreferrer"
                aria-label={`${bookingLinkTitle} (opens in new tab)`}
                data-umami-event="book discovery call"
                data-umami-event-location="hero"
            >
                {bookingLinkTitle}
                <ExternalLinkIcon aria-label="Opens in new tab" size={17} />
            </a>
            {#if secondaryCta}
                <a
                    href={secondaryCta.href}
                    class="btn btn-secondary"
                    data-umami-event={secondaryCta.umamiEventLabel}
                    data-umami-event-location="hero"
                >
                    {secondaryCta.label}
                </a>
            {/if}
        </div>
    </div>
</header>

<style>
    .hero {
        padding: var(--space-xxxl) 0 var(--space-xxl) 0;
        text-align: center;
        background-color: var(--color-bg);
        border-bottom: 1px solid var(--color-border);
    }

    .title {
        margin-bottom: var(--space-lg);
        font-family: var(--font-family-heading);
        font-size: var(--font-size-xxl);
        font-weight: var(--font-weight-bold);
        letter-spacing: -0.03em;
        max-width: var(--max-text-width);
        margin-left: auto;
        margin-right: auto;
    }

    .subtitle {
        max-width: var(--max-narrow-width);
        margin: 0 auto var(--space-xl) auto;
        font-size: var(--font-size-large);
        font-weight: var(--font-weight-normal);
        color: var(--color-text-secondary);
        line-height: var(--line-height-relaxed);
    }

    .cta-group {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-md);
        justify-content: center;
        align-items: center;
        margin-top: var(--space-lg);
    }

    @media (max-width: 768px) {
        .cta-group {
            flex-direction: column;
            width: 100%;
        }
    }
</style>
