{#
# Instagram CTA Component
# Reusable section with gold accents – editable via Page Builder or use defaults.
#
# With block (from Page Builder):
#   {% include 'components/instagram-cta.twig' with { block: block } %}
#
# Without block (defaults):
#   {% include 'components/instagram-cta.twig' %}
#}
{% set messageRaw = block is defined ? (block.message ?? block.tagline ?? null) : null %}
{% set handleRaw = block is defined ? (block.instahandle ?? block.instagramHandle ?? null) : null %}
{% set urlRaw = block is defined ? (block.instagramUrl ?? block.url ?? null) : null %}

{% set message = messageRaw ? (messageRaw.value ?? messageRaw) : null %}
{% set handle = handleRaw ? (handleRaw.value ?? handleRaw) : null %}
{% set linkHref = null %}
{% if urlRaw %}
    {% if urlRaw.url is defined %}{% set linkHref = urlRaw.url %}
    {% elseif urlRaw.value is defined and urlRaw.value.url is defined %}{% set linkHref = urlRaw.value.url %}
    {% elseif urlRaw is not iterable %}{% set linkHref = urlRaw %}{% endif %}
{% endif %}

{% if message or (handle and linkHref) %}
<section class="py-20 bg-secondary/40 relative">
    <div class="absolute inset-0 bg-gradient-to-r from-transparent via-gold/5 to-transparent"></div>
    <div class="max-w-5xl mx-auto px-6 text-center relative">
        <div class="flex flex-col sm:flex-row items-center justify-center gap-8">
            {% if message %}
            <div class="flex items-center gap-4">
                <div class="w-14 h-14 rounded-full bg-gold/10 flex items-center justify-center">
                    <svg class="w-7 h-7 text-gold" fill="currentColor" viewBox="0 0 24 24">
                        <path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zm0-2.163c-3.259 0-3.667.014-4.947.072-4.358.2-6.78 2.618-6.98 6.98-.059 1.281-.073 1.689-.073 4.948 0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98 1.281.058 1.689.072 4.948.072 3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98-1.281-.059-1.69-.073-4.949-.073zm0 5.838c-3.403 0-6.162 2.759-6.162 6.162s2.759 6.163 6.162 6.163 6.162-2.759 6.162-6.163c0-3.403-2.759-6.162-6.162-6.162zm0 10.162c-2.209 0-4-1.79-4-4 0-2.209 1.791-4 4-4s4 1.791 4 4c0 2.21-1.791 4-4 4zm6.406-11.845c-.796 0-1.441.645-1.441 1.44s.645 1.44 1.441 1.44c.795 0 1.439-.645 1.439-1.44s-.644-1.44-1.439-1.44z"/>
                    </svg>
                </div>
                <p class="text-navy text-lg font-medium">{{ message }}</p>
            </div>
            {% endif %}
            {% if handle and linkHref %}
            <a href="{{ linkHref }}" target="_blank" rel="noopener noreferrer" class="btn-gold inline-flex items-center whitespace-nowrap">
                <span>{{ handle }}</span>
                <svg class="w-4 h-4 ml-2" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"/>
                </svg>
            </a>
            {% endif %}
        </div>
    </div>
</section>
{% endif %}
