<?php
session_start();
include __DIR__ . '/includes/header.php';
include __DIR__ . '/includes/nav.php';

// Load DJ data
$djsFile = __DIR__ . '/data/djs.json';
$djs = file_exists($djsFile) ? json_decode(file_get_contents($djsFile), true) : [];
?>

<main class="content-area">

    <div class="smurf-divider"></div>

    <div class="content-wrapper">

        <section class="content-card center-text">
            <h1>🎙️ Meet Our DJs 🎙️</h1>
            <h2>The Heart & Soul of Smurfette’s Country Delights</h2>
        </section>

        <div class="dj-grid">

            <?php if (!empty($djs)): ?>
                <?php foreach ($djs as $dj): ?>
                    <div class="content-card dj-card">

                        <div class="dj-image">
                            <?php
                            $img = $dj['image'] ?? '';
                            $src = (preg_match('~^https?://~i', $img)) ? $img : ('/img/djs/' . $img);
                          ?>
                          <img src="<?= htmlspecialchars($src) ?>" alt="<?= htmlspecialchars($dj['name'] ?? '') ?>">
                        </div>

                        <h3 class="dj-name"><?= htmlspecialchars($dj['name']) ?></h3>
                        <p class="dj-show"><?= htmlspecialchars($dj['show']) ?></p>

                        <p class="dj-bio">
                            <?= nl2br(htmlspecialchars($dj['bio'])) ?>
                        </p>

                    </div>
                <?php endforeach; ?>
            <?php else: ?>
                <p style="text-align:center;">No DJs found.</p>
            <?php endif; ?>

        </div>

    </div>

    <div class="smurf-divider"></div>

</main>

<?php include __DIR__ . '/includes/footer.php'; ?>
