<?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'] ?? '';
$colorScheme = $data['color_scheme'] ?? '';
$sectionTextColor = $data['section_text_color'] ?? '';
$columns     = $data['columns'] ?? '';
$steps       = (isset($data['steps']) && is_array($data['steps'])) ? $data['steps'] : [];

// Build CSS classes
$cls = 'process-steps-section';
if ($colorScheme !== '') {
    $cls .= ' section--scheme-' . e($colorScheme);
}
$sectionSurface = $data['section_surface'] ?? '';
if ($sectionSurface !== '') {
    $cls .= ' section--surface-' . e($sectionSurface);
}
if ($sectionTextColor !== '') {
    $cls .= ' section--text-' . e($sectionTextColor);
}
if ($columns !== '') {
    $cls .= ' section--cols-' . e($columns);
}

$gridCls = 'process-steps-grid';
if ($columns !== '') {
    $gridCls .= ' cols-' . e($columns);
}
?>
<section class="<?= $cls ?>" 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>
