<?php
if (! defined('ABSPATH')) {
    exit;
} $post_data = isset($args['post_data']) && is_array($args['post_data']) ? $args['post_data'] : array();
$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>
				<?php if (! empty($post_data['author']) || ! empty($post_data['date'])) : ?>
					<div class="meta">
						<?php if (! empty($post_data['author'])) : ?>
							<span class="author"><?php esc_html_e('Author:', 'puffergo'); ?> <?php echo esc_html($post_data['author']); ?></span>
						<?php endif; ?>
						<?php if (! empty($post_data['date'])) : ?>
							<span class="date"><?php echo esc_html($post_data['date']); ?></span>
						<?php endif; ?>
					</div>
				<?php endif; ?>
			</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>
