<?php
/**
 * ITSWEBER CMS – Default Theme: Trust Showcase Section Template
 * Page Builder section template (3.2.0)
 *
 * Variables: $data (array), $section (DB row), $sectionId (string)
 *
 * @author  Benny Weber
 * @copyright ITSWEBER, www.itsweber.de
 */

$title            = $data['title'] ?? '';
$subtitle         = $data['subtitle'] ?? '';
$columns          = $data['columns'] ?? '4';
$cards            = (isset($data['cards']) && is_array($data['cards'])) ? $data['cards'] : [];

if (empty($cards)) return;

$defaultIcon = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>';
?>
<section class="<?= build_section_classes('trust-showcase', $data, ['tss--cols-' . $columns]) ?>" id="<?= e($sectionId) ?>">
    <div class="container">
        <?php if ($title !== '' || $subtitle !== ''): ?>
        <div class="tss-header reveal">
            <?php if ($subtitle !== ''): ?>
            <div class="tss-label"><?= e($subtitle) ?></div>
            <?php endif; ?>
            <?php if ($title !== ''): ?>
            <h2 class="tss-title"><?= e($title) ?></h2>
            <?php endif; ?>
        </div>
        <?php endif; ?>

        <div class="tss-grid">
            <?php foreach ($cards as $card): ?>
            <div class="tss-card reveal">
                <div class="tss-card-icon">
                    <?php
                    $icon = $card['icon'] ?? '';
                    $rendered = ($icon !== '') ? render_icon($icon, 32) : '';
                    echo ($rendered !== '' && $rendered !== e($icon)) ? $rendered : ($icon !== '' ? $icon : $defaultIcon);
                    ?>
                </div>
                <h3 class="tss-card-title"><?= e($card['title'] ?? '') ?></h3>
                <?php if (!empty($card['text'])): ?>
                <p class="tss-card-text"><?= e($card['text']) ?></p>
                <?php endif; ?>
            </div>
            <?php endforeach; ?>
        </div>
    </div>
</section>
