<?php
/**
 * ITSWEBER CMS – Default Theme: Process Steps 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'] ?? '';
$steps       = (isset($data['steps']) && is_array($data['steps'])) ? $data['steps'] : [];

$extra = [];
if ($columns !== '') $extra[] = 'section--cols-' . $columns;

$gridCls = 'process-steps-grid';
if ($columns !== '') $gridCls .= ' cols-' . e($columns);
?>
<section class="<?= build_section_classes('process-steps', $data, $extra) ?>" id="<?= e($sectionId) ?>">
    <div class="container">
        <?php if ($title !== '' || $subtitle !== ''): ?>
        <div class="process-steps-header reveal">
            <?php if ($title !== ''): ?>
            <h2 class="process-steps-title"><?= e($title) ?></h2>
            <?php endif; ?>
            <?php if ($subtitle !== ''): ?>
            <p class="process-steps-subtitle"><?= e($subtitle) ?></p>
            <?php endif; ?>
        </div>
        <?php endif; ?>

        <?php if (!empty($steps)): ?>
        <div class="<?= $gridCls ?>">
            <?php foreach ($steps as $num => $step): ?>
            <div class="process-step reveal">
                <div class="process-step-number"><?= $num + 1 ?></div>
                <h3 class="process-step-title"><?= e($step['title'] ?? '') ?></h3>
                <?php if (!empty($step['text'])): ?>
                <p class="process-step-text"><?= e($step['text']) ?></p>
                <?php endif; ?>
            </div>
            <?php endforeach; ?>
        </div>
        <?php endif; ?>
    </div>
</section>
