<?php

declare(strict_types=1);

/**
 * Hauptnavigation aus data/navigation.json. Props: $current (Slug).
 * Burger-Toggle übernimmt assets/js/nav.js (aria-expanded/aria-controls).
 */
$nav = json_load('navigation');

$href = static function (string $slug): string {
    // Anker-Slugs ("#aktuelles") zeigen auf Startseiten-Sektionen.
    return str_starts_with($slug, '#') ? url() . $slug : url($slug);
};
?>
            <nav class="site-nav" aria-label="Hauptnavigation">
                <button class="site-nav__toggle" type="button" aria-expanded="false" aria-controls="site-nav-list">
                    <span class="site-nav__toggle-bar" aria-hidden="true"></span>
                    <span class="visually-hidden">Menü öffnen</span>
                </button>
                <ul class="site-nav__list" id="site-nav-list">
<?php foreach ($nav['main'] as $item): ?>
                    <li>
                        <a href="<?= e($href($item['slug'])) ?>"<?= $item['slug'] === $current ? ' aria-current="page"' : '' ?>><?= e($item['label']) ?></a>
                    </li>
<?php endforeach; ?>
<?php if (!empty($nav['cta'])): ?>
                    <li>
                        <a class="btn" href="<?= e($href($nav['cta']['slug'])) ?>"><?= e($nav['cta']['label']) ?></a>
                    </li>
<?php endif; ?>
                </ul>
            </nav>
