<?php
/**
 * Template Name: Home Template
 */

get_header(); 

?>

<main id="skip-content">
  <?php if (get_theme_mod('cinematic_videos_slider_section_setting', true) != '') { ?>
    <section id="top-slider">
      <?php $cinematic_videos_slide_pages = array();
        for ( $cinematic_videos_count = 1; $cinematic_videos_count <= 3; $cinematic_videos_count++ ) {
          $cinematic_videos_mod = intval( get_theme_mod( 'cinematic_videos_top_slider_page' . $cinematic_videos_count ));
          if ( 'page-none-selected' != $cinematic_videos_mod ) {
            $cinematic_videos_slide_pages[] = $cinematic_videos_mod;
          }
        }
        if( !empty($cinematic_videos_slide_pages) ) :
          $cinematic_videos_args = array(
            'post_type' => 'page',
            'post__in' => $cinematic_videos_slide_pages,
            'orderby' => 'post__in'
          );
          $cinematic_videos_query = new WP_Query( $cinematic_videos_args );
          if ( $cinematic_videos_query->have_posts() ) :
            $i = 1;
      ?>
      <div class="owl-carousel" role="listbox">
        <?php  while ( $cinematic_videos_query->have_posts() ) : $cinematic_videos_query->the_post(); ?>
          <div class="slide-box">
            <div class="slider-image">
              <?php if(has_post_thumbnail()){
                the_post_thumbnail();
                } else{?>
                <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/img/slider.png" alt="" />
              <?php } ?>
            </div>
            <div class="slider-inner-box">
              <h2 class="mb-3"><?php the_title(); ?></h2>
              <p class="content mb-4 pb-2"><?php echo esc_html( wp_trim_words( get_the_content(), esc_attr(get_theme_mod('cinematic_videos_slider_excerpt_length', 20)) )); ?></p>
              <div class="slide-btn ">
                <a href="<?php the_permalink(); ?>"><?php esc_html_e('Read More','cinematic-videos'); ?></a>
              </div>
            </div>
            <?php if(get_theme_mod('cinematic_videos_banner_counter_number_1') != '' || get_theme_mod('cinematic_videos_banner_counter_text_1') != '' || get_theme_mod('cinematic_videos_banner_counter_number_2') != '' || get_theme_mod('cinematic_videos_banner_counter_text_2') != ''){ ?>
              <div class="counter-box">
                <div class="counter-box-1">
                  <?php if(get_theme_mod('cinematic_videos_banner_counter_number_1') != ''){ ?>
                    <h3 class="counter-heading mb-2"><?php echo esc_html(get_theme_mod('cinematic_videos_banner_counter_number_1')); ?></h3>
                  <?php }?>
                  <?php if(get_theme_mod('cinematic_videos_banner_counter_text_1') != ''){ ?>
                    <p class="counter-heading mb-0"><?php echo esc_html(get_theme_mod('cinematic_videos_banner_counter_text_1')); ?></p>
                  <?php }?>
                </div>
                <div class="counter-box-2">
                  <?php if(get_theme_mod('cinematic_videos_banner_counter_number_2') != ''){ ?>
                    <h3 class="counter-heading mb-2"><?php echo esc_html(get_theme_mod('cinematic_videos_banner_counter_number_2')); ?></h3>
                  <?php }?>
                  <?php if(get_theme_mod('cinematic_videos_banner_counter_text_2') != ''){ ?>
                    <p class="counter-heading m-0"><?php echo esc_html(get_theme_mod('cinematic_videos_banner_counter_text_2')); ?></p>
                  <?php }?>
                </div>
              </div>
            <?php }?>
          </div>
        <?php $i++; endwhile;
        wp_reset_postdata();?>
      </div>
      <?php else : ?>
        <div class="no-postfound"></div>
      <?php endif;
      endif;?>
    </section>
  <?php } ?>
  <?php if (get_theme_mod('cinematic_videos_about_us_section_setting', true) != '') { ?>
    <section class="featured py-5">
      <div class="container">
        <div class="row">
          <div class="col-lg-6 col-md-6 col-sm-12 col-12 about-image align-self-center">
            <?php if(get_theme_mod('cinematic_videos_about_us_left_image') != ''){ ?>
              <img src="<?php echo esc_url( get_theme_mod( 'cinematic_videos_about_us_left_image' )); ?>">
            <?php }?>
          </div>
          <div class="col-lg-6 col-md-6 col-sm-12 col-12 align-self-center">
              <div class="about-text-box">
                <?php if(get_theme_mod('cinematic_videos_about_us_short_heading') != ''){ ?>
                  <h4 class="image-heading mb-4"><?php echo esc_html(get_theme_mod('cinematic_videos_about_us_short_heading')); ?></h4>
                <?php }?>
                <?php if(get_theme_mod('cinematic_videos_about_us_heading') != ''){ ?>
                  <h3 class="main-text mb-3"><?php echo esc_html(get_theme_mod('cinematic_videos_about_us_heading')); ?></h3>
                <?php }?>
                <?php if(get_theme_mod('cinematic_videos_about_us_content') != ''){ ?>
                  <p class="main-heading mb-4"><?php echo esc_html(get_theme_mod('cinematic_videos_about_us_content')); ?></p>
                <?php }?>
                <div class="row">
                  <?php for ($i=1; $i <=4 ; $i++) {  ?>
                    <?php if(get_theme_mod('cinematic_videos_about_us_list_heading'.$i) != ''){ ?>
                      <div class="col-lg-6 col-md-6 col-sm-12 col-12 mb-3">
                        <h5 class="tick-box"><i class="fas fa-check-circle me-2"></i><?php echo esc_html(get_theme_mod('cinematic_videos_about_us_list_heading'.$i)); ?></h5>
                      </div>
                    <?php } ?>
                  <?php }  ?>
                </div>
                <div class="abt-btns mt-4">
                  <?php if(get_theme_mod('cinematic_videos_about_us_button_url') != '' || get_theme_mod('cinematic_videos_about_us_button_text') != ''){ ?>
                    <span class="about-btn">
                      <a href="<?php echo esc_url(get_theme_mod('cinematic_videos_about_us_button_url')); ?>"><?php echo esc_html(get_theme_mod('cinematic_videos_about_us_button_text')); ?></a>
                    </span>
                  <?php } ?>
                </div>
              </div>
          </div>       
        </div>
      </div>
    </section>
  <?php } ?>
  <section id="page-content">
    <div class="container">
      <div class="py-5">
        <?php
          if ( have_posts() ) :
            while ( have_posts() ) : the_post();
              the_content();
            endwhile;
          endif;
        ?>
      </div>
    </div>
  </section>
</main>

<?php get_footer(); ?>