<?php
if (! defined('ABSPATH')) {
    exit;
} ?>

<main class="puffergo-fullpage-layout">
	<?php puffergo_render_component('blog-hero', array('data' => $data)); ?>

	<!-- 面包屑：分类页展示完整祖先链，横幅只负责当前层的子分类 -->
	<div class="mx-auto max-w-canvas px-4 sm:px-6 lg:px-8">
		<?php puffergo_render_component('breadcrumb', array('items' => $data->get_breadcrumb_items())); ?>
	</div>

	<!-- 搜索区域（仅归档页显示） -->
	<?php if (! $data->is_category_page) : ?>
		<div class="search-section">
			<div class="search-wrapper">
				<form class="search-box" method="get" action="<?php echo esc_url($data->current_url); ?>">
					<input type="text" name="s" placeholder="<?php esc_attr_e('Search keywords...', 'puffergo'); ?>" class="search-input" value="<?php echo esc_attr($data->search_query); ?>" />
					<button class="search-button" type="submit">
						<svg width="20" height="20" viewBox="0 0 20 20" fill="none"><circle cx="9" cy="9" r="8" stroke="currentColor" stroke-width="2" fill="none"/><path d="M15 15L19 19" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>
					</button>
				</form>
			</div>
		</div>
	<?php endif; ?>

	<!-- 文章列表 -->
	<div class="blog-article-list">
		<?php if (! empty($data->posts)) : ?>
			<div class="articles-grid">
				<?php foreach ($data->posts as $post_item) : $post_data = $post_item;
				    puffergo_render_component('blog-article-card', array('post_data' => $post_data)); endforeach; ?>
			</div>
		<?php else : ?>
			<div class="no-posts">
				<p><?php esc_html_e('No posts found', 'puffergo'); ?></p>
			</div>
		<?php endif; ?>
	</div>

	<!-- 分页 -->
	<?php
 puffergo_render_component('blog-pagination', array('current_page' => $data->paged, 'max_pages' => $data->max_pages, 'current_url' => $data->pagination_base_url ?: $data->current_url, )); ?>
</main>
