<?php
$main_news_query = new WP_Query( $main_news_args );
if ( $main_news_query->have_posts() ) {
	$banner_title      = get_theme_mod( 'hyper_news_main_banner_title', __( 'Main News', 'hyper-news' ) );
	$banner_button     = get_theme_mod( 'hyper_news_main_banner_button_label', __( 'View All', 'hyper-news' ) );
	$banner_button_url = get_theme_mod( 'hyper_news_main_banner_button_link', '#' );
	?>
	<div class="banner-main-part">
		<?php if ( ! empty( $banner_title || $banner_button ) ) { ?>
			<div class="title-heading">
				<?php if ( ! empty( $banner_title ) ) : ?>
					<h3 class="section-title"><?php echo esc_html( $banner_title ); ?></h3>
				<?php endif; ?>
				<?php if ( ! empty( $banner_button ) ) { ?>
					<a href="<?php echo esc_url( $banner_button_url ); ?>" class="view-all"><?php echo esc_html( $banner_button ); ?></a>
				<?php } ?>
			</div>
		<?php } ?>
		<div class="banner-main-wrap banner-slider slick-button">
			<?php
			$i = 1;
			while ( $main_news_query->have_posts() ) :
				$main_news_query->the_post();
				$class = $i === 1 ? 'tile-layout' : 'grid-layout';

				?>
				<div class="blog-post-container <?php echo esc_attr( $class ); ?>">
					<div class="blog-post-inner">
						<?php if ( has_post_thumbnail() ) { ?>
							<div class="blog-post-image">
								<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'full' ); ?></a>
								<?php if ( $i !== 1 ) : ?>
									<?php hyper_news_categories_list(); ?>
								<?php endif; ?>
							</div>
						<?php } ?>
						<div class="blog-post-detail">
							<?php if ( $i === 1 ) : ?>
								<?php hyper_news_categories_list(); ?>
							<?php endif; ?>
							<h2 class="entry-title">
								<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
							</h2>
							<div class="post-meta">
								<?php
								hyper_news_posted_by();
								hyper_news_posted_on();
								?>
							</div>
						</div>
					</div>
				</div>
				<?php
				$i++;
			endwhile;
			wp_reset_postdata();
			?>
		</div>
	</div>
	<?php
}
