<?php
/**
 * ITSWEBER CMS – Default Theme: Features 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
 */

$extra = [];
if (!empty($data['card_style'])) $extra[] = 'section--card-' . $data['card_style'];
if (!empty($data['columns']))    $extra[] = 'section--cols-' . $data['columns'];
?>
<section id="<?= e($sectionId) ?>" class="<?= build_section_classes('features', $data, $extra) ?>">
    <div class="container">
        <h2 class="reveal"><?= e($data['title'] ?? '') ?></h2>
        <?php if (!empty($data['subtitle'])): ?>
        <p class="section-subtitle reveal"><?= e($data['subtitle']) ?></p>
        <?php endif; ?>
        <?php if (!empty($data['items']) && is_array($data['items'])): ?>
        <div class="features-grid">
            <?php foreach ($data['items'] as $item): ?>
            <?php $fUrl = trim($item['url'] ?? ''); ?>
            <div class="feature-card reveal">
                <?php if (!empty($item['icon'])): ?>
                <div class="feature-card-icon"><?= render_icon($item['icon'], 32) ?></div>
                <?php endif; ?>
                <h3><?= e($item['title'] ?? '') ?></h3>
                <p><?= e($item['text'] ?? '') ?></p>
                <?php if ($fUrl): ?>
                <a href="<?= e($fUrl) ?>" class="feature-card-link">Learn more →</a>
                <?php endif; ?>
            </div>
            <?php endforeach; ?>
        </div>
        <?php endif; ?>
    </div>
</section>
