<?php 
  $expert_makeup_stylist_slider = get_theme_mod('expert_makeup_stylist_slider_setting',false);
  
  if ($expert_makeup_stylist_slider == '1') :
?>

<section id="slider-section" class="slider-area">
  <div id="carouselExampleInterval" class="carousel slide" data-bs-ride="carousel">
    <?php 

      $expert_makeup_stylist_pages = array();
        for ($expert_makeup_stylist_count = 1; $expert_makeup_stylist_count <= 3; $expert_makeup_stylist_count++) {
            $expert_makeup_stylist_mod = intval(get_theme_mod('expert_makeup_stylist_slider' . $expert_makeup_stylist_count));
        
            // Check that the value is valid and not the placeholder value 'page-none-selected'
            if ('page-none-selected' !== $expert_makeup_stylist_mod && $expert_makeup_stylist_mod > 0) {
                $expert_makeup_stylist_pages[] = $expert_makeup_stylist_mod;
            }
        }

      if( !empty($expert_makeup_stylist_pages) ) :
        $args = array(
          'post_type' => 'page',
          'post__in' => $expert_makeup_stylist_pages,
          'orderby' => 'post__in'
        );
        $query = new WP_Query( $args );
        if ( $query->have_posts() ) :
          $i = 1;
    ?>
    <div class="carousel-inner" role="listbox">
      <?php while ( $query->have_posts() ) : $query->the_post(); ?>
        <div <?php if($i == 1){echo 'class="carousel-item active"';} else{ echo 'class="carousel-item"';}?>>
        <div class="row">
          <div class="col-lg-7 col-md-7 col-12">
            <div class="carousel-caption">
              <div class="inner_carousel wow fadeInUp" data-wow-delay="0.5s">
                <div class="slidercontent-bg">
                  <?php
                    $expert_makeup_stylist_slider_text = get_theme_mod( 'expert_makeup_stylist_slider_text' );
                    if( $expert_makeup_stylist_slider_text != ''){?>
                    <div class="border-heading">
                      <p class="mb-3 slider-top-text"><?php echo esc_html( apply_filters('expert_makeup_stylist_topheader', $expert_makeup_stylist_slider_text)); ?></p>
                    </div>
                  <?php } ?>
                  <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                  <p><?php echo esc_html(wp_trim_words(get_the_content(),'20') );?></p>
                </div>
                <div class="read-btn mt-md-4 mt-3">
                  <a href="<?php the_permalink(); ?>"><?php echo esc_html('Shop Now','expert-makeup-stylist'); ?></a>
                </div>
                <div class="slider-call mt-4">
                  <?php if( get_theme_mod( 'expert_makeup_stylist_slider_call' ) != '') { ?>
                    <a class="phn" href="tel:<?php echo esc_url( get_theme_mod('expert_makeup_stylist_slider_call','' )); ?>"><i class="fas fa-phone-alt me-3"></i><?php echo esc_html( get_theme_mod('expert_makeup_stylist_slider_call','')); ?></a>
                  <?php } ?>
                </div>
              </div>
            </div>
          </div>
          <div class="col-lg-5 col-md-5 col-12 slider-img-col">
            <div class="sliderimg">
              <?php if (has_post_thumbnail()) { ?>
                <img src="<?php the_post_thumbnail_url('full'); ?>" class="masked-img"/>
              <?php } else { ?>
                <div class="slider-color-box"></div>
              <?php } ?>
            </div>
          </div>
        </div>
      </div>
      <?php $i++; endwhile;
      wp_reset_postdata();?>
    </div>
    <?php else : ?>
      <div class="no-postfound"></div>
    <?php endif;
    endif;?>
    <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleInterval" id="prev" data-bs-slide="prev">
    <i class="fas fa-angle-left" aria-hidden="true"></i>
    <span class="screen-reader-text"><?php echo esc_html('Previous','expert-makeup-stylist'); ?></span>
    </button>
    <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleInterval" data-bs-slide="next" id="next">
    <i class="fas fa-angle-right" aria-hidden="true"></i>
    <span class="screen-reader-text"><?php echo esc_html('Next','expert-makeup-stylist'); ?></span>
    </button>
  </div>
</section>
<?php endif; ?>