<?php
$s = settings();
$cur = $s['currency'] ?? '₺';
?>
<div class="page-hero">
    <div class="container">
        <a class="back-link" href="<?= e(url('menu')) ?>">← Menü</a>
        <h1 class="page-title"><?= e($cat['name']) ?></h1>
        <?php if (!empty($cat['description'])): ?><p class="page-sub"><?= e($cat['description']) ?></p><?php endif; ?>
    </div>
</div>

<div class="container section">
    <div class="product-list">
        <?php foreach ($products as $p): ?>
            <a class="product-row reveal" href="<?= e(url('urun/'.$p['slug'])) ?>">
                <div class="pr-media">
                    <?php if (!empty($p['video'])): ?>
                        <video muted loop playsinline webkit-playsinline preload="metadata" poster="<?= e(media_poster($p['image'] ?? null)) ?>"><source src="<?= e(media_url($p['video'])) ?>" type="video/mp4"></video>
                    <?php elseif (!empty($p['image'])): ?>
                        <img loading="lazy" decoding="async" src="<?= e(media_poster($p['image'])) ?>" alt="<?= e($p['name']) ?>">
                    <?php else: ?>
                        <span class="pr-emoji">🍽️</span>
                    <?php endif; ?>
                </div>
                <div class="pr-body">
                    <h3><?= e($p['name']) ?></h3>
                    <?php if (!empty($p['description'])): ?>
                        <p class="pr-desc"><?= e(mb_strimwidth($p['description'],0,90,'…')) ?></p>
                    <?php endif; ?>
                    <div class="pr-meta">
                        <?php if (!empty($p['calories'])): ?><span class="mini">🔥 <?= (int)$p['calories'] ?> kcal</span><?php endif; ?>
                        <?php if (!empty($p['allergens'])): ?><span class="mini">⚠️ <?= e($p['allergens']) ?></span><?php endif; ?>
                    </div>
                </div>
                <div class="pr-price"><?= e(money($p['price'], $cur)) ?></div>
            </a>
        <?php endforeach; ?>
        <?php if (empty($products)): ?>
            <p class="empty-note">Bu kategoride henüz ürün bulunmuyor.</p>
        <?php endif; ?>
    </div>
</div>
