@php
    $gray = $block->get('grayscale', true) ? 'grayscale opacity-70 hover:grayscale-0 hover:opacity-100' : '';
    $speed = ['slow' => '45s', 'normal' => '30s', 'fast' => '18s'][$block->get('speed', 'normal')] ?? '30s';
    $logo = fn ($p) => is_array($p) ? (data_get($p, 'logo') ?: data_get($p, 'logo_path')) : $p;
    $name = fn ($p) => is_array($p) ? (data_get($p, 'name') ?: data_get($p, 'name_ar')) : '';
@endphp
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
    @if ($block->get('title') || $block->get('subtitle'))
        <header class="text-center max-w-2xl mx-auto mb-10">
            @if ($block->get('title'))
                <h2 class="ec-heading text-2xl sm:text-3xl font-bold">{{ $block->get('title') }}</h2>
            @endif
            @if ($block->get('subtitle'))
                <p class="ec-muted mt-3">{{ $block->get('subtitle') }}</p>
            @endif
        </header>
    @endif

    @if ($variant === 'marquee')
        <div class="ec-marquee overflow-hidden" style="--marquee-duration:{{ $speed }}">
            <div class="ec-marquee-track flex items-center gap-12">
                {{-- Duplicated once so the loop has no visible seam. --}}
                @foreach ($items->concat($items) as $p)
                    <img src="{{ $logo($p) }}" alt="{{ $name($p) }}" loading="lazy"
                         class="h-12 w-auto object-contain shrink-0 transition {{ $gray }}">
                @endforeach
            </div>
        </div>
    @else
        <div class="flex flex-wrap items-center justify-center gap-x-12 gap-y-8">
            @foreach ($items as $p)
                @php $url = safe_url(data_get($p, 'url')); @endphp
                <{{ $url ? 'a' : 'div' }} @if ($url) href="{{ $url }}" target="_blank" rel="noopener noreferrer" @endif
                    class="ec-stagger-item {{ $variant === 'bordered' ? 'px-8 border-e last:border-e-0' : '' }}">
                    <img src="{{ $logo($p) }}" alt="{{ $name($p) }}" loading="lazy"
                         class="h-12 w-auto object-contain transition {{ $gray }}">
                </{{ $url ? 'a' : 'div' }}>
            @endforeach
        </div>
    @endif
</div>
