<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/** EVENTS LISTING — Expects: $upcoming, $past, $event_types. */
?>
<section class="page-hero">
	<div class="container">
		<div class="page-hero-inner" data-reveal>
			<div class="breadcrumb"><a href="<?= base_url() ?>">Home</a> / <span>Events</span></div>
			<span class="eyebrow">Experiences</span>
			<h1>Events &amp; <span class="serif-italic text-iris">activations</span></h1>
			<p>Fashion events, brand activations and pop-ups — produced from concept to final curtain.</p>
		</div>
	</div>
</section>

<!-- UPCOMING -->
<section class="section">
	<div class="container">
		<div class="section-head" data-reveal><span class="eyebrow">Save the Date</span><h2 style="margin-top:14px;">Upcoming events</h2></div>
		<?php if ($upcoming): ?>
			<div class="card-grid cols-2" style="gap:24px;">
				<?php foreach ($upcoming as $i => $ev): ?>
					<a href="<?= base_url('events/view/'.$ev['slug']) ?>" class="event-card" data-reveal data-delay="<?= ($i % 2) + 1 ?>">
						<div class="event-date">
							<span class="d"><?= nice_date($ev['event_date'], 'd') ?></span>
							<span class="m"><?= nice_date($ev['event_date'], 'M') ?></span>
						</div>
						<div class="event-info">
							<span style="font-size:.78rem;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--iris);">
								<?= html_escape($event_types[$ev['event_type']] ?? $ev['event_type']) ?>
							</span>
							<h3><?= html_escape($ev['title']) ?></h3>
							<span class="where"><?= bloom_icon('pin', 15) ?> <?= html_escape($ev['location']) ?> · <?= html_escape($ev['event_time']) ?></span>
							<?php if ($ev['is_paid']): ?>
								<span class="event-pill">Ticketed · <?= money($ev['ticket_price']) ?></span>
							<?php else: ?>
								<span class="event-pill">Free Entry</span>
							<?php endif; ?>
						</div>
					</a>
				<?php endforeach; ?>
			</div>
		<?php else: ?>
			<?= empty_state('No upcoming events right now — check back soon.', 'calendar') ?>
		<?php endif; ?>
	</div>
</section>

<!-- PAST -->
<?php if ($past): ?>
<section class="section section--cream">
	<div class="container">
		<div class="section-head" data-reveal><span class="eyebrow">The Archive</span><h2 style="margin-top:14px;">Past events</h2></div>
		<div class="card-grid cols-3">
			<?php foreach ($past as $i => $ev): ?>
				<a href="<?= base_url('events/view/'.$ev['slug']) ?>" class="work-card" data-reveal data-delay="<?= ($i % 3) + 1 ?>">
					<div class="work-media" style="aspect-ratio:16/10;">
						<span class="work-tag"><?= nice_date($ev['event_date'], 'M Y') ?></span>
						<img src="<?= upload_url($ev['cover_image'], 'img/event-fallback.jpg') ?>" alt="<?= html_escape($ev['title']) ?>" loading="lazy">
					</div>
					<div class="work-body">
						<span class="meta"><?= html_escape($event_types[$ev['event_type']] ?? $ev['event_type']) ?></span>
						<h3><?= html_escape($ev['title']) ?></h3>
						<p class="brand"><?= bloom_icon('pin', 14) ?> <?= html_escape($ev['location']) ?></p>
					</div>
				</a>
			<?php endforeach; ?>
		</div>
	</div>
</section>
<?php endif; ?>
