<?php require_once __DIR__ . '/includes/bootstrap.php';
$slug = trim($_GET['slug'] ?? '');
$page = $slug !== '' ? ugfx_get_page_by_slug($slug) : null;
if (!$page || empty($page['published'])) {
    http_response_code(404);
}
$pageTitle = ($page['title'] ?? 'Page Not Found') . ' | Underground FX Radio';
$currentPage = basename(__FILE__);
include __DIR__ . '/includes/header.php';
?>
<section class="ugfx-page-hero">
  <div class="container-xxl">
    <div class="ugfx-kicker"><i class="bi bi-file-earmark-text"></i> Custom page system</div>
    <h1 class="page-title"><?= htmlspecialchars($page['title'] ?? 'Page not found') ?></h1>
    <p class="page-copy"><?= htmlspecialchars($page['excerpt'] ?? 'This custom page could not be found.') ?></p>
  </div>
</section>
<section class="section-pad pt-3">
  <div class="container-xxl">
    <div class="ugfx-card p-4 p-lg-5 ugfx-page-body">
      <?php if ($page && !empty($page['published'])): ?>
        <?= ugfx_safe_links($page['content'] ?? '') ?>
      <?php else: ?>
        <div class="alert alert-warning mb-0">That page is missing or unpublished.</div>
      <?php endif; ?>
    </div>
  </div>
</section>
<?php include __DIR__ . '/includes/footer.php'; ?>
