<?php 
$class = isset($args['class']) ? $args['class'] : '';
?>

<section class="section how-works-portal-3pl <?php echo $class;?>">
  <div class="container">

    <div class="text-cont text-center">
      <?php if (get_field('lcps_section_title')) : ?>
        <h2 class="section-title"><?php echo get_field('lcps_section_title'); ?></h2>
      <?php endif; ?>

      <?php if (get_field('lcps_section_text')) : ?>
        <p class="section-content"><?php echo get_field('lcps_section_text'); ?></p>
      <?php endif; ?>
    </div>

    <?php if (have_rows('lcps_section_steps')) : ?>
      <div class="how-works-3pl-cards-wrapper">
        <div class="row g-4 justify-content-center">

          <?php
          $count = 1;
          while (have_rows('lcps_section_steps')) : the_row();

            $title = get_sub_field('lcps_section_step_title');
            $text  = get_sub_field('lcps_section_step_text');
            $icon  = get_sub_field('lcps_section_step_icon'); 
          ?>

            <div class="col-md-6 col-lg-4 col-xl-3">
              <div class="how-works-card-3pl">

                <div class="content-wrapper">
                  <?php if ($title) : ?>
                    <h3 class="card-title"><?php echo $title; ?></h3>
                  <?php endif; ?>

                  <?php if ($text) : ?>
                    <p class="card-text"><?php echo $text; ?></p>
                  <?php endif; ?>
                </div>

                <?php if ($icon) : ?>
                  <div class="card-image-wrapper">
                    <?php
                    echo $icon;
                    ?>
                  </div>
                <?php endif; ?>

                <div class="card-numbering">
                  <?php echo str_pad($count, 2, '0', STR_PAD_LEFT); ?>
                </div>

              </div>
            </div>

          <?php
            $count++;
          endwhile; ?>

        </div>
      </div>
    <?php endif; ?>

  </div>
</section>
