<?php

$categories = isset($categories) && is_array($categories)
    ? $categories
    : [];
?>
<nav
    class="category-nav"
    aria-label="Kategori permainan"
>
    <div class="category-track">
        <?php foreach ($categories as $category): ?>
            <?php
            $categoryKey = isset($category['key'])
                ? (string) $category['key']
                : '';

            $categoryUrl = isset($category['url'])
                ? (string) $category['url']
                : '#';

            $categoryLabel = isset($category['label'])
                ? (string) $category['label']
                : 'Menu';

            $categoryIcon = isset($category['icon'])
                ? (string) $category['icon']
                : '•';
            ?>
            <a
                class="category-item <?= $activeMenu === $categoryKey ? 'is-active' : ''; ?>"
                href="<?= e($categoryUrl); ?>"
            >
                <span class="category-icon">
                    <?= e($categoryIcon); ?>
                </span>
                <strong><?= e($categoryLabel); ?></strong>
            </a>
        <?php endforeach; ?>
    </div>
</nav>
