<?php
/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package    Wira
 * @since      1.0.0
 */

?>


<!-- Content Columns Grid -->
<div class="col">

	<!-- Main Post Wrapper -->
	<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

		<!-- Blog Card Wrapper -->
		<div class="position-relative theme-blog-card theme-rounded theme-box-shadow theme-box-shadow-hover p-0 theme-bg-white">

			<!-- Sticky Post Badge -->
			<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
				<span class="theme-sticky-post theme-text-subheading theme-bg-primary theme-color-white text-center py-1">
					<?php esc_html_e( 'Featured', 'wira' ); ?>
				</span>
			<?php endif; ?>

			<!-- Post Thumbnail -->
			<figure class="thumbnail theme-thumbnail-post-grid mb-0">
				<a href="<?php echo esc_url( get_permalink() ); ?>">
					<?php if ( has_post_thumbnail() ) : ?>
						<?php
						the_post_thumbnail(
							'wira-post-thumb',
							array(
								'class' => 'img-fluid',
								'alt'   => esc_attr( get_the_title() ),
							)
						);
						?>
					<?php else : ?>
						<img src="<?php echo esc_url( WIRA_URI . '/assets/img/default-thumbnail.jpg' ); ?>" class="img-fluid" alt="No thumbnail">
					<?php endif; ?>
				</a>
			</figure>
			
			<!-- Post Category -->
			<div class="theme-post-category"><?php echo wp_kses_post( get_the_category_list( ', ' ) ); ?></div>

			<!-- Post Content Box -->
			<div class="theme-space-small">

				<!-- Post Meta -->
				<div class="theme-post-meta mb-1">
					<span class="theme-text-small theme-color-placeholder me-3">
						<i class="fas fa-calendar theme-color-secondary me-1"></i> <?php echo esc_html( get_the_date() ); ?>
					</span>
					<span class="theme-text-small theme-color-placeholder me-3">
						<i class="fas fa-user-circle theme-color-secondary me-1"></i> <?php echo esc_html( get_the_author() ); ?>
					</span>
				</div>

				<!-- Post Title -->
				<h4 class="theme-blog-title theme-post-title-light mt-3 mb-2"><a href="<?php echo esc_url( get_permalink() ); ?>"><?php echo esc_html( get_the_title() ); ?></a></h4>

				<!-- Read More -->
				<p class="theme-color-body"><?php echo esc_html( wp_trim_words( get_the_excerpt(), 20 ) ); ?></p>
				<a href="<?php echo esc_url( get_permalink() ); ?>" class="theme-btn-text-two theme-btn-arrow-end mt-2"><?php echo esc_html__( 'Continue Reading', 'wira' ); ?></a>
			</div> <!-- Post Content Box /End -->
		</div> <!-- Blog Card Wrapper /End -->
	</article> <!-- Main Post Wrapper /End -->
</div> <!-- Content Columns Grid /End -->
