<?php $s = settings(); ?>
<div class="page-hero">
    <div class="container">
        <a class="back-link" href="<?= e(url('/')) ?>">← Anasayfa</a>
        <h1 class="page-title">Etkinlikler</h1>
        <p class="page-sub"><?= e($s['business_name'] ?? '') ?>'de sizi bekleyen özel etkinlikler.</p>
    </div>
</div>

<div class="container section">
    <div class="event-grid">
        <?php foreach ($events as $ev): ?>
            <article class="event-card reveal">
                <?php if (!empty($ev['video']) || !empty($ev['image'])): ?>
                    <div class="event-media">
                        <?php if (!empty($ev['video'])): ?>
                            <video autoplay muted loop playsinline preload="metadata"><source src="<?= e(media_url($ev['video'])) ?>" type="video/mp4"></video>
                        <?php else: ?>
                            <img loading="lazy" src="<?= e(media_url($ev['image'])) ?>" alt="<?= e($ev['title']) ?>">
                        <?php endif; ?>
                    </div>
                <?php endif; ?>
                <div class="event-body">
                    <?php if (!empty($ev['date_text'])): ?><span class="event-date"><?= e($ev['date_text']) ?></span><?php endif; ?>
                    <h3><?= e($ev['title']) ?></h3>
                    <p><?= e($ev['description']) ?></p>
                    <div class="event-foot">
                        <?php if (!empty($ev['price_text'])): ?><span class="event-price"><?= e($ev['price_text']) ?></span><?php endif; ?>
                        <?php if (!empty($ev['badge'])): ?><span class="badge-pill"><?= e($ev['badge']) ?></span><?php endif; ?>
                    </div>
                    <?php $evLink = safe_url($ev['link_url'] ?? ''); if ($evLink !== ''): ?>
                        <a class="btn btn-primary btn-sm" href="<?= e($evLink) ?>" target="_blank" rel="noopener nofollow"><?= e($ev['link_text'] ?: 'Detaylar') ?></a>
                    <?php endif; ?>
                </div>
            </article>
        <?php endforeach; ?>
        <?php if (empty($events)): ?>
            <p class="empty-note">Şu anda planlanmış etkinlik yok.</p>
        <?php endif; ?>
    </div>
</div>
