<?php
$pageTitle='Underground FX News'; include 'includes/header.php'; require_once __DIR__ . '/includes/content_store.php';
$items = array_values(array_filter(ht_load_news_items(__DIR__), fn($item) => !empty($item['published'])));
function n_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; }
?>
<section class="container-fluid container-xxl fx-page-hero"><div class="fx-section-card"><div class="fx-section-kicker">News room</div><h1>Station news with artwork that actually shows.</h1><p>Every story uses the same card system and image treatment so homepage, news page and featured blocks stay consistent.</p></div></section>
<section class="container-fluid container-xxl fx-section-block"><div class="row g-4"><?php foreach($items as $item): $img=n_asset((string)($item['image'] ?? '')); ?><div class="col-lg-6"><article class="fx-story-panel h-100"><?php if($img!==''): ?><img src="<?= htmlspecialchars($img, ENT_QUOTES, 'UTF-8') ?>" alt="<?= htmlspecialchars((string)($item['title'] ?? 'News'), ENT_QUOTES, 'UTF-8') ?>"><?php endif; ?><div class="p-4"><div class="fx-chip-row mb-3"><?php if(!empty($item['date'])): ?><span class="fx-chip"><?= htmlspecialchars((string)$item['date'], ENT_QUOTES, 'UTF-8') ?></span><?php endif; ?><?php if(!empty($item['tag'])): ?><span class="fx-chip"><?= htmlspecialchars((string)$item['tag'], ENT_QUOTES, 'UTF-8') ?></span><?php endif; ?></div><h3><?= htmlspecialchars((string)($item['title'] ?? 'Station update'), 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 news posts available yet.</div></div><?php endif; ?></div></section>
<?php include 'includes/footer.php'; ?>