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

$cover = $mod['cover_image'] ?? $mod['cover'] ?? '/uploads/covers/mod-1.svg';
$title = $mod['title'] ?? 'Untitled Mod';
$slug = $mod['slug'] ?? '#';
$category = $mod['category'] ?? $mod['category_name'] ?? 'Mods';
$categorySlug = $mod['category_slug'] ?? '';
$author = $mod['author_name'] ?? $mod['author'] ?? 'Creator';
$downloads = (int) ($mod['download_count'] ?? $mod['downloads'] ?? 0);
$views = (int) ($mod['view_count'] ?? $mod['views'] ?? 0);
$rating = $mod['rating'] ?? '0.0';
$isPremium = !empty($mod['premium']) || !empty($mod['is_premium']);
$isFeatured = !empty($mod['featured']);
?>
<article class="mod-card<?= $isFeatured ? ' is-featured' : '' ?>">
    <a class="mod-card-link" href="<?= url('/mod/' . $slug) ?>" aria-label="<?= e($title) ?>">
        <div class="mod-card-media">
            <img loading="lazy" decoding="async" src="<?= url($cover) ?>" alt="<?= e($title) ?>">
            <span class="mod-card-shade" aria-hidden="true"></span>
            <div class="mod-card-badges">
                <span class="badge <?= $isPremium ? 'premium' : 'free' ?>"><?= $isPremium ? 'Premium' : 'Free' ?></span>
                <?php if ($isFeatured): ?><span class="badge featured">One cikan</span><?php endif; ?>
            </div>
            <span class="rating-badge">Rating <?= e($rating) ?></span>
        </div>
        <div class="card-body">
            <h3><?= e($title) ?></h3>
            <p>
                <span><?= e($category) ?></span>
                <span>@<?= e($author) ?></span>
            </p>
            <div class="meta" aria-label="Mod istatistikleri">
                <span>Indirme <?= number_format($downloads, 0, ',', '.') ?></span>
                <span>Goruntu <?= number_format($views, 0, ',', '.') ?></span>
            </div>
        </div>
    </a>
</article>
