<?php
$pageTitle='Underground FX Events'; include 'includes/header.php'; require_once __DIR__ . '/includes/content_store.php';
$items = array_values(array_filter(ht_load_event_items(__DIR__), fn($item) => !empty($item['published'])));
function e_asset(string $path, string $fallback='img/content'): string { $path=trim($path); if($path==='') return ''; if(preg_match('#^(https?:)?//#i',$path)) return $path; $path=ltrim(str_replace('\\','/',$path),'/'); if(strpos($path,'/')===false) $path=trim($fallback,'/').'/'.$path; return '/'.$path; }
$sent = !empty($_GET['sent']);
$error = trim((string)($_GET['err'] ?? ''));
?>
<section class="container-fluid container-xxl fx-page-hero"><div class="fx-section-card"><div class="fx-section-kicker">Promotions</div><h1>Events, contests and station pushes</h1><p>Events now sit inside the same flagship shell as the rest of the site, with visible artwork and stronger calls to action.</p></div></section>
<section class="container-fluid container-xxl fx-section-block">
<?php if($sent): ?><div class="alert alert-success">Your promo entry has been sent.</div><?php endif; ?>
<?php if($error!==''): ?><div class="alert alert-danger"><?= htmlspecialchars($error, ENT_QUOTES, 'UTF-8') ?></div><?php endif; ?>
<div class="row g-4"><div class="col-lg-8"><div class="row g-4"><?php foreach($items as $item): $img=e_asset((string)($item['image'] ?? '')); ?><div class="col-12"><article class="fx-story-panel"><?php if($img!==''): ?><img src="<?= htmlspecialchars($img, ENT_QUOTES, 'UTF-8') ?>" alt="<?= htmlspecialchars((string)($item['title'] ?? 'Event'), ENT_QUOTES, 'UTF-8') ?>"><?php endif; ?><div class="p-4"><div class="fx-chip-row mb-3"><?php if(!empty($item['start'])): ?><span class="fx-chip">Starts <?= htmlspecialchars((string)$item['start'], ENT_QUOTES, 'UTF-8') ?></span><?php endif; ?><?php if(!empty($item['end'])): ?><span class="fx-chip">Ends <?= htmlspecialchars((string)$item['end'], ENT_QUOTES, 'UTF-8') ?></span><?php endif; ?></div><h3><?= htmlspecialchars((string)($item['title'] ?? 'Event'), ENT_QUOTES, 'UTF-8') ?></h3><p><?= nl2br(htmlspecialchars((string)($item['content'] ?? ''), ENT_QUOTES, 'UTF-8')) ?></p></div></article></div><?php endforeach; if(!$items): ?><div class="col-12"><div class="fx-section-card">No events are published yet.</div></div><?php endif; ?></div></div><div class="col-lg-4"><div class="fx-section-card sticky-top" style="top:120px"><div class="fx-section-kicker">Promo entry</div><h3>Send an event or promo entry</h3><form action="/send_promo_entry.php" method="post" class="fx-form-grid"><input class="form-control" type="text" name="name" placeholder="Your name" required><input class="form-control" type="email" name="email" placeholder="Email"><input class="form-control" type="text" name="title" placeholder="Event title" required><textarea class="form-control" name="message" rows="6" placeholder="Tell us about the promotion"></textarea><button class="btn btn-primary" type="submit">Send to station</button></form></div></div></div>
</section>
<?php include 'includes/footer.php'; ?>