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

get_header(); 

$villa_estate_zone_banner_backgroud_image = get_theme_mod('villa_estate_zone_banner_background_image');
?>

<main id="skip-content">
  <section id="top-slider" >
    <?php $villa_estate_zone_slide_pages = array();
      for ( $villa_estate_zone_count = 1; $villa_estate_zone_count <= 3; $villa_estate_zone_count++ ) {
        $villa_estate_zone_mod = intval( get_theme_mod( 'villa_estate_zone_top_slider_page' . $villa_estate_zone_count ));
        if ( 'page-none-selected' != $villa_estate_zone_mod ) {
          $villa_estate_zone_slide_pages[] = $villa_estate_zone_mod;
        }
      }
      if( !empty($villa_estate_zone_slide_pages) ) :
        $villa_estate_zone_args = array(
          'post_type' => 'page',
          'post__in' => $villa_estate_zone_slide_pages,
          'orderby' => 'post__in'
        );
        $villa_estate_zone_query = new WP_Query( $villa_estate_zone_args );
        if ( $villa_estate_zone_query->have_posts() ) :
          $i = 1;
    ?>
    <div class="owl-carousel" role="listbox">
      <?php  while ( $villa_estate_zone_query->have_posts() ) : $villa_estate_zone_query->the_post(); ?>
        <div class="slide-box">
          <div class="slide-half"></div>
          <div class="slider-image">
            <?php if(has_post_thumbnail()){
              the_post_thumbnail();
              } else{?>
              <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/image/slider.png" alt="" />
            <?php } ?>
          </div>
          <div class="slider-inner-box">
            <?php if(get_theme_mod('villa_estate_zone_slider_short_heading') != ''){ ?>
             <h3 class="short-heading mb-4"><?php echo esc_html(get_theme_mod('villa_estate_zone_slider_short_heading')); ?></h3>
            <?php }?>
             <a href="<?php the_permalink(); ?>"><h2 class="mb-2"><?php the_title(); ?></h2></a>
            <p class="content mb-3"><?php echo esc_html( wp_trim_words( get_the_content(),20 )); ?></p>
              <?php if(get_theme_mod('villa_estate_zone_slider_video_button_url') != ''){ ?>
                <span class="slide-btn">
                  <!-- Button to open the modal -->
                  <a id="openModalButton" data-modal-src="<?php echo esc_url(get_theme_mod('villa_estate_zone_slider_video_button_url')); ?>"><i class="fas fa-play"></i>
                    <?php esc_html_e('Play Video','villa-estate-zone') ?></a>
                  <!-- The modal -->
                  <div id="myModal" class="modal">
                    <!-- Modal content -->
                    <div class="modal-content">
                      <span id="closeModalButton" class="close">&times;</span>
                      <?php if( get_theme_mod('villa_estate_zone_slider_video_button_url') != ''){ ?>
                      <embed id="videoPlayer" height="369" src="<?php echo esc_url(get_theme_mod('villa_estate_zone_slider_video_button_url')); ?>"  allow="accelerometer; autoplay; classipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></embed>
                      <?php }else{ ?>
                        <h3><?php esc_html_e('Add Video Url In Customizer To Display Video Here','villa-estate-zone'); ?></h3>
                      <?php } ?>
                    </div>
                  </div> 
                </span>
              <?php } ?>
          </div>
        </div>
      <?php $i++; endwhile;
      wp_reset_postdata();?>
    </div>
    <?php else : ?>
      <div class="no-postfound"></div>
    <?php endif;
    endif;?>
  </section>
  <section class="featured py-5">
    <div class="container">
      <div class="row">
        <div class="col-lg-8 col-md-7 col-sm-12 col-12 align-self-center">
          <div class="about-text-box">
            <?php if(get_theme_mod('villa_estate_zone_about_us_short_heading') != ''){ ?>
              <h4 class="image-heading mb-2"><?php echo esc_html(get_theme_mod('villa_estate_zone_about_us_short_heading')); ?></h4>
            <?php }?>
            <?php if(get_theme_mod('villa_estate_zone_about_us_image_heading') != ''){ ?>
              <h3 class="image-heading mb-2"><?php echo esc_html(get_theme_mod('villa_estate_zone_about_us_image_heading')); ?></h3>
            <?php }?>
            <?php if(get_theme_mod('villa_estate_zone_about_us_content') != ''){ ?>
              <p class="main-heading mb-2"><?php echo esc_html(get_theme_mod('villa_estate_zone_about_us_content')); ?></p>
            <?php }?>
            <?php if(get_theme_mod('villa_estate_zone_about_us_main_content') != ''){ ?>
              <p class="main-heading mb-4"><?php echo esc_html(get_theme_mod('villa_estate_zone_about_us_main_content')); ?></p>
            <?php }?>
            <?php if(get_theme_mod('villa_estate_zone_about_us_button_url') != '' || get_theme_mod('villa_estate_zone_about_us_button_text') != ''){ ?>
              <div class="abt-btns mt-4">
                <span class="about-btn">
                  <a href="<?php echo esc_url(get_theme_mod('villa_estate_zone_about_us_button_url')); ?>"><?php echo esc_html(get_theme_mod('villa_estate_zone_about_us_button_text')); ?><i class="fas fa-chevron-right"></i></a>
                </span>
              </div>
            <?php } ?>
          </div>
        </div>   
        <div class="col-lg-4 col-md-5 col-sm-12 col-12 about-image align-self-center">
          <?php if(get_theme_mod('villa_estate_zone_about_us_left_image') != ''){ ?>
            <img src="<?php echo esc_url( get_theme_mod( 'villa_estate_zone_about_us_left_image' )); ?>">
          <?php }?>
          <div class="main-box">
            <?php if(get_theme_mod('villa_estate_zone_about_us_counter_icon') != '' || get_theme_mod('villa_estate_zone_about_us_counter_number') != '' || get_theme_mod('villa_estate_zone_about_us_counter_heading') != ''){ ?>
              <div class="counter-box">
                <?php if(get_theme_mod('villa_estate_zone_about_us_counter_icon') != ''){ ?>
                  <i class="<?php echo esc_attr(get_theme_mod('villa_estate_zone_about_us_counter_icon')); ?> me-2"></i>
                <?php }?>
                <?php if(get_theme_mod('villa_estate_zone_about_us_counter_number') != ''){ ?>
                  <h5 class="tick-box "><?php echo esc_html(get_theme_mod('villa_estate_zone_about_us_counter_number')); ?></h5>
                <?php }?>
                <?php if(get_theme_mod('villa_estate_zone_about_us_counter_heading') != ''){ ?>
                  <p class="tick-box"><?php echo esc_html(get_theme_mod('villa_estate_zone_about_us_counter_heading')); ?></p>
                <?php }?>
              </div>
            <?php }?>
            <div class="main-count-box">
              <?php if(get_theme_mod('villa_estate_zone_about_us_counter_icon_1') != '' || get_theme_mod('villa_estate_zone_about_us_counter_number_1') != '' || get_theme_mod('villa_estate_zone_about_us_counter_heading_1') != ''){ ?>
                <div class="counter-box bg-box-count">
                  <?php if(get_theme_mod('villa_estate_zone_about_us_counter_icon_1') != ''){ ?>
                    <i class="<?php echo esc_attr(get_theme_mod('villa_estate_zone_about_us_counter_icon_1')); ?> me-2"></i>
                  <?php }?>
                  <?php if(get_theme_mod('villa_estate_zone_about_us_counter_number_1') != ''){ ?>
                    <h5 class="tick-box "><?php echo esc_html(get_theme_mod('villa_estate_zone_about_us_counter_number_1')); ?></h5>
                  <?php }?>
                  <?php if(get_theme_mod('villa_estate_zone_about_us_counter_heading_1') != ''){ ?>
                    <p class="tick-box"><?php echo esc_html(get_theme_mod('villa_estate_zone_about_us_counter_heading_1')); ?></p>
                  <?php }?>
                </div>
              <?php }?>
              <?php if(get_theme_mod('villa_estate_zone_about_us_counter_icon_2') != '' || get_theme_mod('villa_estate_zone_about_us_counter_number_2') != '' || get_theme_mod('villa_estate_zone_about_us_counter_heading_2') != ''){ ?>
              <div class="counter-box">
                <?php if(get_theme_mod('villa_estate_zone_about_us_counter_icon_2') != ''){ ?>
                  <i class="<?php echo esc_attr(get_theme_mod('villa_estate_zone_about_us_counter_icon_2')); ?> me-2"></i>
                <?php }?>
                <?php if(get_theme_mod('villa_estate_zone_about_us_counter_number_2') != ''){ ?>
                  <h5 class="tick-box "><?php echo esc_html(get_theme_mod('villa_estate_zone_about_us_counter_number_2')); ?> </h5>
                <?php }?>
                <?php if(get_theme_mod('villa_estate_zone_about_us_counter_heading_2') != ''){ ?>
                  <p class="tick-box"><?php echo esc_html(get_theme_mod('villa_estate_zone_about_us_counter_heading_2')); ?></p>
                <?php }?>
              </div>
            <?php }?>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
  <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(); ?>