<?php
/**
 * GALLERY SECTION — Product Images
 */

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

// Images source (priority)
// 1. product images gallery
// 2. featured image
// 3. placeholder
$images = [];

if (!empty($product['images']) && is_array($product['images'])) {
    $images = $product['images'];
} elseif (!empty($product['featured_image'])) {
    $images = [$product['featured_image']];
} else {
    $images = ['/themes/matjari/assets/img/placeholder.png'];
}
?>

<section class="home-section gallery-section" id="gallery">

    <div class="container">

        <div class="gallery-grid">

            <?php foreach ($images as $img): ?>
                <div class="gallery-item">
                    <img src="<?= htmlspecialchars($img, ENT_QUOTES, 'UTF-8') ?>" alt="">
                </div>
            <?php endforeach; ?>

        </div>

    </div>

</section>
