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

// Load Friends data
$friendsFile = __DIR__ . '/data/friends.json';
$friends = file_exists($friendsFile) ? json_decode(file_get_contents($friendsFile), true) : [];
?>

<main class="content-area">

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

    <div class="content-wrapper">

        <section class="content-card center-text">
            <h1>🤝 Our Friends & Partners 🤝</h1>
            <h2>Supporting Smurfette’s Country Delights</h2>
        </section>

        <div class="friends-grid">

            <?php if (!empty($friends)): ?>
                <?php foreach ($friends as $friend): ?>
                    <div class="friend-card">

                        <div class="friend-image">
                            <img src="/img/friends/<?= htmlspecialchars($friend['image']) ?>" alt="<?= htmlspecialchars($friend['name']) ?>">
                        </div>

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

                        <p class="friend-desc">
                            <?= nl2br(htmlspecialchars($friend['description'])) ?>
                        </p>

                        <?php if (!empty($friend['link'])): ?>
                            <a class="friend-link" href="<?= htmlspecialchars($friend['link']) ?>" target="_blank">
                                Visit Website
                            </a>
                        <?php endif; ?>

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

        </div>

    </div>

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

</main>

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