<?php
/**
 * HERO SECTION — Product Landing
 * يعتمد كليًا على المنتج النشط
 */

if (!isset($product) || empty($product)) {
    return;
}

// Product data (SOURCE OF TRUTH)
$title    = $product['title'] ?? __('products.default_title', 'Amazing Product');
$subtitle = $product['short_description'] ?? '';
$price    = $product['price'] ?? null;

// Image priority:
// 1. featured_image
// 2. first gallery image
// 3. placeholder
$image = $product['featured_image']
    ?? ($product['images'][0] ?? '/themes/matjari/assets/img/placeholder.png');

$ctaText = __('actions.order_now', 'Order Now');
?>

<section class="home-section hero-section">

    <!-- Background Image -->
    <div class="hero-bg"
         style="background-image:url('<?= htmlspecialchars($image, ENT_QUOTES, 'UTF-8') ?>')">
        <div class="hero-overlay"></div>
    </div>

    <div class="container hero-content">

        <div class="hero-grid">

            <!-- TEXT -->
            <div class="hero-text">

                <h1 class="hero-title">
                    <?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8') ?>
                </h1>

                <?php if ($subtitle): ?>
                    <p class="hero-subtitle">
                        <?= htmlspecialchars($subtitle, ENT_QUOTES, 'UTF-8') ?>
                    </p>
                <?php endif; ?>

                <?php if ($price): ?>
                    <div class="hero-price">
                        <span class="price-label">
                            <?= __('products.price_label', 'Only') ?>
                        </span>
                        <span class="price-value">
                            <?= htmlspecialchars($price, ENT_QUOTES, 'UTF-8') ?>
                        </span>
                    </div>
                <?php endif; ?>

                <!-- TRUST BADGES -->
                <ul class="hero-trust">
                    <li><?= __('trust.cod', 'Cash on Delivery') ?></li>
                    <li><?= __('trust.fast_shipping', 'Fast Shipping') ?></li>
                    <li><?= __('trust.guarantee', 'Money Back Guarantee') ?></li>
                </ul>

                <a href="#checkout" class="btn-primary hero-btn">
                    <?= $ctaText ?>
                </a>

            </div>

            <!-- MEDIA -->
            <div class="hero-media">
                <img src="<?= htmlspecialchars($image, ENT_QUOTES, 'UTF-8') ?>"
                     alt="<?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8') ?>">
            </div>

        </div>

    </div>

</section>
