<?php
use function App\Core\{e, url};

$genre = $genre ?? ['name' => 'Music', 'slug' => 'music', 'description' => ''];
$tracks = $tracks ?? [];
$sort = $sort ?? 'newest';
$sorts = [
    'newest' => 'En yeni',
    'popular' => 'Populer',
    'plays' => 'En cok dinlenen',
    'premium' => 'Premium',
    'free' => 'Ucretsiz',
];
?>
<section class="music-genre-hero">
    <div class="container">
        <p class="eyebrow">Tarz</p>
        <h1><?= e($genre['name'] ?? 'Music') ?></h1>
        <p><?= e($genre['description'] ?? 'Bu tarza ait sarkilar.') ?></p>
    </div>
</section>

<section class="container section music-section">
    <form class="music-sortbar" action="<?= url('/music/tarz/' . ($genre['slug'] ?? 'music')) ?>" method="get">
        <?php foreach ($sorts as $value => $label): ?>
            <button class="<?= $sort === $value ? 'is-active' : '' ?>" type="submit" name="sirala" value="<?= e($value) ?>"><?= e($label) ?></button>
        <?php endforeach; ?>
    </form>

    <?php if ($tracks !== []): ?>
        <div class="grid music-grid">
            <?php foreach ($tracks as $track): ?>
                <?php require BASE_PATH . '/app/Views/partials/music-card.php'; ?>
            <?php endforeach; ?>
        </div>
    <?php else: ?>
        <div class="empty-state">
            <strong>Bu tarzda sarki yok.</strong>
            <p>Arsiv genisledikce <?= e($genre['name'] ?? 'Music') ?> kayitlari burada gorunecek.</p>
        </div>
    <?php endif; ?>
</section>
