<?php include 'includes/header.php';
function ht_asset_url(string $path, string $fallbackDir = ''): string {
  $path = trim($path);
  if ($path === '') return '';
  if (preg_match('#^(https?:)?//#i', $path) || str_starts_with($path, 'data:')) return $path;
  $path = str_replace('\\', '/', $path);
  $path = ltrim($path, '/');
  if ($fallbackDir !== '' && strpos($path, '/') === false) $path = trim($fallbackDir, '/') . '/' . $path;
  return '/' . $path;
}
$djs=file_exists(__DIR__.'/data/djs.json')?json_decode((string)file_get_contents(__DIR__.'/data/djs.json'),true):[]; if(!is_array($djs))$djs=[]; ?>
<style>
.person-card{background:rgba(59,43,32,.95);border:2px solid var(--accent-color);border-radius:18px;padding:1.25rem;height:100%;box-shadow:0 10px 24px rgba(0,0,0,.26);}
.person-card img{width:100%;height:260px;object-fit:cover;border-radius:14px;border:2px solid var(--accent-color);background:#000;}
.person-card h4{margin-top:1rem;margin-bottom:.4rem;}
.person-card .show-title{color:var(--accent-color);font-weight:700;margin-bottom:.7rem;}
.person-card .bio{white-space:pre-wrap;color:#fff;}
</style>
<div class="container content-box mt-5"><div class="text-center mb-5"><h1>Meet Our DJs</h1><p class="subtext">The voices and personalities behind Home Time Radio</p></div><div class="row g-4"><?php foreach($djs as $dj): $img=ht_asset_url((string)($dj['image']??''),'img/djs'); ?><div class="col-md-6 col-xl-4"><div class="person-card"><?php if($img): ?><img src="<?= htmlspecialchars($img, ENT_QUOTES, 'UTF-8') ?>" alt="<?= htmlspecialchars((string)($dj['name']??''), ENT_QUOTES, 'UTF-8') ?>"><?php endif; ?><h4><?= htmlspecialchars((string)($dj['name']??''), ENT_QUOTES, 'UTF-8') ?></h4><?php if(!empty($dj['show'])): ?><div class="show-title"><?= htmlspecialchars((string)$dj['show'], ENT_QUOTES, 'UTF-8') ?></div><?php endif; ?><div class="bio"><?= nl2br(htmlspecialchars((string)($dj['bio']??''), ENT_QUOTES, 'UTF-8')) ?></div></div></div><?php endforeach; ?><?php if(empty($djs)): ?><div class="col-12"><div class="dj-box">No DJs added yet.</div></div><?php endif; ?></div></div><?php include 'includes/footer.php'; ?>
