<?php
/**
 * TESTIMONIALS SECTION — Product Based
 */

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

$testimonials = $product['testimonials'] ?? null;

if (!is_array($testimonials) || empty($testimonials)) {
    return;
}
?>

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

    <div class="container">

        <div class="section-head">
            <h2><?= __('sections.testimonials', 'Testimonials') ?></h2>
        </div>

        <div class="testimonials-grid">

            <?php foreach ($testimonials as $t): ?>
                <?php
                    $name = $t['name'] ?? '';
                    $text = $t['text'] ?? '';

                    if ($text === '') {
                        continue;
                    }
                ?>
                <div class="testimonial-card">
                    <div class="testimonial-text">
                        “<?= htmlspecialchars($text, ENT_QUOTES, 'UTF-8') ?>”
                    </div>

                    <?php if ($name): ?>
                        <div class="testimonial-name">
                            — <?= htmlspecialchars($name, ENT_QUOTES, 'UTF-8') ?>
                        </div>
                    <?php endif; ?>
                </div>
            <?php endforeach; ?>

        </div>

    </div>

</section>
