<?php get_header(); 
  if ( get_option('show_on_front') == 'posts' && is_home() && is_front_page() && get_theme_mod( 'amberd_custom_homepage_display_option' ) == '1' ) {
    ?>
	
	<?php 
	  if ( !get_theme_mod( 'amberd_online_store_custom_homepage_banner_theme' ) OR (get_theme_mod( 'amberd_online_store_custom_homepage_banner_theme' ) == 'banner-first-theme' ))  {
		get_template_part( 'template-parts/partials/custom-homepage/banner/banner-first-theme' );
	  } 
	  elseif ( get_theme_mod( 'amberd_online_store_custom_homepage_banner_theme' ) == 'banner-second-theme') {
		get_template_part( 'template-parts/partials/custom-homepage/banner/banner-second-theme' );
	  } 
    ?>

    <?php if (get_theme_mod( 'amberd_custom_homepage_hide_call_action', '1' )) { } else { ?> 
            <div class="amberd-homepage-title-description">   
                <div class="amberd-custom-desctiption"><?php echo esc_html( get_theme_mod( 'amberd_custom_homepage_call_action_desc' ) ); ?></div>
                <div class="amberd-custom-title"><h3 class="amberd-custom-title-content"><?php echo esc_html( get_theme_mod( 'amberd_custom_homepage_call_action_title' ) ); ?></h3></div>
            </div>
            <div class="<?php if (empty(get_theme_mod( 'amberd_call_action_bg_gradient_color' ))) 
                        { echo esc_attr( 'amberd-action-section-bg' ); } 
                        else { echo esc_attr('amberd-action-section-bg-gradient'); } ?>">
									
					<div class="amberd-action-section">
						<div class="amberd-image-section">
						  <?php if ( ! get_theme_mod( 'amberd_custom_homepage_call_to_action_image' )) { ?> <img src="<?php echo esc_url(get_theme_file_uri('/images/call-to-action.jpg')); ?>"> <?php } else { ?>
							<img src="<?php echo esc_url( get_theme_mod( 'amberd_custom_homepage_call_to_action_image' ) ); ?>">
						  <?php } ?>
						</div>
						<div class="amberd-action-text-button-section">
						  <div class="amberd-action-text-content">
								  <h2 class="amberd-action-text-content-font"><?php echo esc_html( get_theme_mod( 'amberd_custom_homepage_call_action_sub_title' ) ); ?></h2> 
								  <p><?php echo esc_html( get_theme_mod( 'amberd_custom_homepage_call_action_text' ) ); ?></p>
						  </div>
						  <div class="amberd-action-button-content">
							<p class="amberd_hover_button <?php echo esc_attr( get_theme_mod( 'amberd_custom_homepage_call_action_button_style' ) ); ?>"><a href="<?php echo esc_url( get_theme_mod( 'amberd_custom_homepage_call_action_button_url' ) );  ?>"><?php echo esc_html( get_theme_mod( 'amberd_custom_homepage_call_action_button_text' ) );  ?></a></p>
						  </div>
						</div>
					</div>
								
            </div>
    <?php }; ?>
	 
    <?php if (get_theme_mod( 'amberd_custom_homepage_hide_latest_post_section', '1' )) { } else { ?> 
          <div class="amberd-homepage-title-description">   
                <div class="amberd-custom-desctiption"><?php echo esc_html( get_theme_mod( 'amberd_custom_homepage_latest_post_desctiption' ) ); ?></div>
                <div class="amberd-custom-title"><h3 class="amberd-custom-title-content"><?php echo esc_html( get_theme_mod( 'amberd_custom_homepage_latest_post_title' ) ); ?></h3></div>
          </div>

          <div class="amberd-homepage-posts-section">
          <div class="amberd-homepage-post-container">
                <?php 
                $the_query = new WP_Query( array (
                'posts_per_page' => esc_html( get_theme_mod( 'amberd_custom_homepage_number_of_latest_posts' ) ),
                'post_type' => 'post',
                'orderby' => 'date',
                'order' => 'DESC',
                'post__not_in' => get_option( 'sticky_posts' )
                ));
                if ( $the_query->have_posts() ) :
                  while ( $the_query->have_posts() ) : $the_query->the_post();
                ?>
                <div class="amberd-homepage-posts-content">
                <?php if (has_post_thumbnail() ){
                ?> 
                    <div class="amberd-images-hover-effect"><a href="<?php the_permalink(); ?>"> <div class="<?php echo esc_attr( get_theme_mod( 'amberd_posts_list_images_hover_effect' ) ); ?>"><img src="<?php echo esc_url(get_the_post_thumbnail_url()); ?>" /></div></a></div>
                <?php }  ?>      
                        <div class="amberd-home-posts-list-title"><h5 class="amberd-home-latest-post-title"><a href="<?php the_permalink(); ?>">
                        <?php if( empty( $post->post_title ) ) { echo esc_html__( 'No Title', 'amberd-online-store'); } else { echo esc_html(wp_trim_words(get_the_title(), 3)); } ?>
                        </a></h5></div>
						<span class="wpdevart-home-latest-post-date"><?php echo esc_html(get_the_date('F j, Y')); ?></span>
                        <div class="amberd-home-latest-post-text"><p><?php echo esc_html(wp_trim_words(get_the_content(), 20)); ?></p></div>
						<span class="wpdevart-home-latest-post-read-more"><a href="<?php the_permalink(); ?>"><?php echo esc_html("Read More"); ?><svg width="16" height="19" class="wpdevart-home-arrow-right" x="0px" y="0px" viewBox="0 0 24 10" enable-background="new 0 0 24 10" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path d="m14.523 18.787s4.501-4.505 6.255-6.26c.146-.146.219-.338.219-.53s-.073-.383-.219-.53c-1.753-1.754-6.255-6.258-6.255-6.258-.144-.145-.334-.217-.524-.217-.193 0-.385.074-.532.221-.293.292-.295.766-.004 1.056l4.978 4.978h-14.692c-.414 0-.75.336-.75.75s.336.75.75.75h14.692l-4.979 4.979c-.289.289-.286.762.006 1.054.148.148.341.222.533.222.19 0 .378-.072.522-.215z" fill-rule="nonzero"/></svg></a></span>						
                </div>
                    <?php endwhile; wp_reset_postdata(); ?>
                <?php 
                ?>
            
                <?php else : ?>
                <div class="amberd-homepage-posts-content">
                      <div><a href="<?php echo esc_url( home_url( 'wp-admin/post-new.php' ) ); ?>"> <div class="<?php echo esc_attr( get_theme_mod( 'amberd_posts_list_images_hover_effect' ) ); ?>"><img src="<?php echo esc_url(get_theme_file_uri('/images/banner-homepage-image.jpg')); ?>" /></div></a></div>
                      <div class="amberd-posts-list-title"><h5 class="amberd-home-latest-post-title"><a href="<?php echo esc_url( home_url( 'wp-admin/post-new.php' ) ); ?>"><?php echo esc_html__('Demo Post', 'amberd-online-store'); ?></a></h5></div>
                      <div class="amberd-home-latest-post-text"><p><?php echo esc_html__( 'These are just demo posts. Once you add your first post, this demo content will simply disappear.', 'amberd-online-store'); ?></p></div>
                </div>
                <div class="amberd-homepage-posts-content">
                      <div><a href="<?php echo esc_url( home_url( 'wp-admin/post-new.php' ) ); ?>"> <div class="<?php echo esc_attr( get_theme_mod( 'amberd_posts_list_images_hover_effect' ) ); ?>"><img src="<?php echo esc_url(get_theme_file_uri('/images/banner-homepage-image.jpg')); ?>" /></div></a></div>
                      <div class="amberd-posts-list-title"><h5 class="amberd-home-latest-post-title"><a href="<?php echo esc_url( home_url( 'wp-admin/post-new.php' ) ); ?>"><?php echo esc_html__('Demo Post', 'amberd-online-store'); ?></a></h5></div>
                      <div class="amberd-home-latest-post-text"><p><?php echo esc_html__( 'These are just demo posts. Once you add your first post, this demo content will simply disappear.', 'amberd-online-store'); ?></p></div>
                </div>
                <div class="amberd-homepage-posts-content">
                      <div><a href="<?php echo esc_url( home_url( 'wp-admin/post-new.php' ) ); ?>"> <div class="<?php echo esc_attr( get_theme_mod( 'amberd_posts_list_images_hover_effect' ) ); ?>"><img src="<?php echo esc_url(get_theme_file_uri('/images/banner-homepage-image.jpg')); ?>" /></div></a></div>
                      <div class="amberd-posts-list-title"><h5 class="amberd-home-latest-post-title"><a href="<?php echo esc_url( home_url( 'wp-admin/post-new.php' ) ); ?>"><?php echo esc_html__('Demo Post', 'amberd-online-store'); ?></a></h5></div>
                      <div class="amberd-home-latest-post-text"><p><?php echo esc_html__( 'These are just demo posts. Once you add your first post, this demo content will simply disappear.', 'amberd-online-store'); ?></p></div>
                </div>
                <?php endif; ?>
                </div>
          </div>	  
		  
          <?php }; ?>
          </div>    
    <?php 
    } 
    
    else if ( get_option('show_on_front') == 'posts' && is_home() && is_front_page() && get_theme_mod( 'amberd_custom_homepage_display_option' ) != '1' ) { 
      get_template_part( 'template-parts/content/content' );
    }

    else {
            while(have_posts()) {
              the_post(); 
              ?>
                  <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                      <div class="page-banner">
                          <div class="amberd-page-banner__bg"></div>
                          <div class="container <?php if ( get_theme_mod( 'amberd_single_page_banner_width' ) == 'narrow' ) { echo esc_attr('amberd-banner-narrow-container'); } ?>">
                              <div class="page-banner-content"><h1 class="page-banner__title"><?php the_title(); ?></h1>
                              </div>
                          </div>
                      </div>

                      <div class="amberd-main-container">
                      <div role="main" class="container <?php if (( get_theme_mod( 'amberd_single_page_layout' ) != 'sidebarnone' ) && ( get_theme_mod( 'amberd_single_page_layout' ) == 'sidebarleft' ))
                                                    { echo esc_attr('container-with-sidebar amberd-main-content-sidebarleft'); } 
                                                else if (( get_theme_mod( 'amberd_single_page_layout' ) != 'sidebarnone' ) && ( get_theme_mod( 'amberd_single_page_layout' ) != 'sidebarleft' )) 
                                                    { echo esc_attr('container-with-sidebar'); } 
                                                ?> amberd-main-content" id="content_navigator">
                            <div class="generic-content <?php if ( get_theme_mod( 'amberd_single_page_layout' ) == 'sidebarnone' ) { echo esc_attr('generic-content-full-width'); } ?>">
                                <?php get_template_part( 'template-parts/content/generic-content' ); ?>
                            </div>
                            <?php if ( get_theme_mod( 'amberd_single_page_layout' ) != 'sidebarnone' ) { get_template_part( 'template-parts/sidebar/sidebar-default' ); } ?>
                      </div>
                      </div>
                  </article>
              <?php }
    }

get_footer(); ?>