@php
    $links = $block->get('use_settings', true)
        ? collect(($settings->social_links ?? []))->map(fn ($url, $platform) => ['platform' => $platform, 'url' => $url, 'label' => $platform])->filter(fn ($l) => filled($l['url']))->values()
        : collect($block->get('links') ?: []);
    $size = ['sm' => 'w-9 h-9', 'md' => 'w-11 h-11', 'lg' => 'w-14 h-14'][$block->get('size', 'md')] ?? 'w-11 h-11';
    $icon = ['sm' => 'w-4 h-4', 'md' => 'w-5 h-5', 'lg' => 'w-6 h-6'][$block->get('size', 'md')] ?? 'w-5 h-5';
@endphp
<div class="max-w-4xl mx-auto px-4 text-center">
    @if ($block->get('title'))
        <h2 class="ec-heading text-2xl font-bold mb-6">{{ $block->get('title') }}</h2>
    @endif
    <div class="flex flex-wrap items-center justify-center gap-3">
        @foreach ($links as $link)
            @php $linkHref = safe_url(data_get($link, 'url')); @endphp
            @continue (! $linkHref)
            <a href="{{ $linkHref }}" target="_blank" rel="noopener noreferrer"
               aria-label="{{ website_text(data_get($link, 'label')) ?: data_get($link, 'platform') }}"
               class="inline-flex items-center justify-center {{ $variant === 'icons' ? $size . ' rounded-full border' : 'gap-2 rounded-full border px-5 py-2.5' }} transition hover:-translate-y-0.5">
                <x-website.icon :name="data_get($link, 'platform')" :class="$icon" />
                @if ($variant !== 'icons')
                    <span class="font-medium">{{ website_text(data_get($link, 'label')) ?: data_get($link, 'platform') }}</span>
                @endif
            </a>
        @endforeach
    </div>
</div>
