@props(['event' => []])

@php
$accent = $event['accent'] ?? 'violet';
$name = $event['name'] ?? 'Event';
$url = $event['url'] ?? '#';
$date = !empty($event['start_date']) ? \Carbon\Carbon::parse($event['start_date'])->format('M d') : 'TBA';
$prize = (int) ($event['prize_pool'] ?? 0);
$cover = $event['cover'] ?? null;
$bg = $cover ?: asset('assets/images/generated/tournaments/tournament-cover-1.webp');
if ($bg && !str_starts_with($bg, 'http') && !str_starts_with($bg, 'data:')) {
    $bg = asset(ltrim(str_replace(asset(''), '', $bg), '/'));
}
@endphp

<a href="{{ $url }}" class="event-card event-card--{{ $accent }}" role="listitem">
    <div class="event-card__art" style="background-image:url('{{ $bg }}')" aria-hidden="true"></div>
    <div class="event-card__body">
        <div class="event-card__game">{{ $event['game_name'] ?? 'Esports' }}</div>
        <h3 class="event-card__name">{{ $name }}</h3>
        <div class="event-card__meta">
            <span>{{ $date }}</span>
            @if($prize > 0)
                <span class="event-card__prize">${{ number_format($prize) }}</span>
            @endif
            <span>{{ $event['participants'] ?? '0/0' }}</span>
        </div>
    </div>
</a>
