<?php
/**
 * Blog Article Card — 单个文章卡片组件。
 *
 * 变量作用域（由父模板注入）：
 * @var array $post_data 文章卡片数据。
 *
 * @package PufferGo
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$style = $post_data['category_style'] ?? array( 'color' => '#666', 'bgColor' => '#f0f0f1' );
?>
<article class="article-card">
	<a href="<?php echo esc_url( $post_data['url'] ); ?>" class="article-card-link">
		<div class="image-container">
			<?php if ( ! empty( $post_data['image_url'] ) ) : ?>
				<img src="<?php echo esc_url( $post_data['image_url'] ); ?>" alt="<?php echo esc_attr( $post_data['image_alt'] ); ?>" class="image" />
			<?php else : ?>
				<div class="image placeholder">
					<?php echo esc_html( $post_data['title'] ); ?>
				</div>
			<?php endif; ?>
			<?php if ( ! empty( $post_data['category_name'] ) ) : ?>
				<div class="tag" style="background-color: <?php echo esc_attr( $style['bgColor'] ); ?>;">
					<span style="color: <?php echo esc_attr( $style['color'] ); ?>;">
						<?php echo esc_html( $post_data['category_name'] ); ?>
					</span>
				</div>
			<?php endif; ?>
		</div>
		<div class="content">
			<div class="header">
				<h3 class="title"><?php echo esc_html( $post_data['title'] ); ?></h3>
				<div class="meta">
					<span class="author"><?php esc_html_e( 'Author:', 'puffergo' ); ?> <?php echo esc_html( $post_data['author'] ); ?></span>
					<span class="date"><?php echo esc_html( $post_data['date'] ); ?></span>
				</div>
			</div>
			<p class="excerpt"><?php echo esc_html( $post_data['excerpt'] ); ?></p>
		</div>
		<div class="read-more">
			<?php esc_html_e( 'Read more', 'puffergo' ); ?> →
		</div>
	</a>
</article>
