<?php
/**
 * Blog archive card.
 *
 * @package Shabnam_MuchWOW
 */
defined( 'ABSPATH' ) || exit;

$show_featured = function_exists( 'shabnam_get_setting' ) ? (bool) shabnam_get_setting( 'blog_show_featured', true ) : true;
$show_excerpt  = function_exists( 'shabnam_get_setting' ) ? (bool) shabnam_get_setting( 'blog_show_excerpt', true ) : true;
$excerpt_words = function_exists( 'shabnam_get_setting' ) ? absint( shabnam_get_setting( 'blog_excerpt_words', 24 ) ) : 24;
$excerpt_words = max( 8, min( 80, $excerpt_words ) );
?>
<article id="post-<?php the_ID(); ?>" <?php post_class( 'shabnam-post-card panel h-100 p-2 sm:p-3 border border-1 border-gray-100 border-opacity-40 rounded-3 bg-white bg-opacity-5' ); ?>>
	<?php if ( $show_featured ) : ?>
		<a class="shabnam-post-card-media panel overflow-hidden rounded-2 ratio ratio-16x10 d-block" href="<?php the_permalink(); ?>" aria-label="<?php the_title_attribute(); ?>">
			<?php if ( has_post_thumbnail() ) : ?>
				<?php the_post_thumbnail( 'shabnam-card', array( 'class' => 'w-100 h-100 object-cover' ) ); ?>
			<?php else : ?>
				<img class="w-100 h-100 object-cover" src="<?php echo esc_url( shabnam_asset_uri( 'images/common/seo-image.jpg' ) ); ?>" alt="<?php the_title_attribute(); ?>">
			<?php endif; ?>
		</a>
	<?php endif; ?>
	<div class="vstack gap-2 p-2 sm:p-3">
		<?php if ( function_exists( 'shabnam_post_card_meta' ) ) { shabnam_post_card_meta(); } ?>
		<h2 class="h5 xl:h4 m-0"><a class="text-none text-white hover:text-secondary" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
		<?php if ( $show_excerpt ) : ?><div class="fs-6 text-white text-opacity-80"><?php echo esc_html( wp_trim_words( get_the_excerpt(), $excerpt_words ) ); ?></div><?php endif; ?>
		<div><a class="text-secondary fw-semibold" href="<?php the_permalink(); ?>"><?php esc_html_e( 'مطالعه نوشته', 'shabnam-muchwow' ); ?> ←</a></div>
	</div>
</article>
