<?php
/**
 * Project Archive Template
 *
 * @package KsPortfolio
 */

namespace KsPortfolio;

get_header();

$hero_intro = get_field( 'archive_intro', (int) get_queried_object_id() );
if ( ! $hero_intro ) {
	$hero_intro = __( 'A comprehensive catalog of WordPress plugins, custom themes, and open-source contributions developed for scalable enterprise environments. Focused on modern development practices, performant architectures, and secure integrations.', 'ks-portfolio' );
}
?>
<section class="archive-projects">
	<div class="container mx-auto my-section">
		<header class="archive-projects__head">
			<h1 class="archive-projects__title"><?php echo esc_html__( 'Project Archive', 'ks-portfolio' ); ?></h1>
			<p class="archive-projects__intro"><?php echo esc_html( $hero_intro ); ?></p>
		</header>

		<?php if ( have_posts() ) : ?>
			<div class="archive-projects__grid grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
				<?php
				while ( have_posts() ) :
					the_post();
					get_template_part( 'views/components/project-card' );
				endwhile;
				?>
			</div>

			<div class="archive-projects__pagination">
				<?php
				the_posts_pagination(
					array(
						'mid_size'  => 2,
						'prev_text' => '&laquo; ' . esc_html__( 'Previous', 'ks-portfolio' ),
						'next_text' => esc_html__( 'Next', 'ks-portfolio' ) . ' &raquo;',
					)
				);
				?>
			</div>
		<?php else : ?>
			<div class="archive-projects__empty">
				<h2 class="archive-projects__empty-title"><?php echo esc_html__( 'Nothing here yet&hellip;', 'ks-portfolio' ); ?></h2>
				<p class="archive-projects__empty-desc"><?php echo esc_html__( 'No published projects found.', 'ks-portfolio' ); ?></p>
			</div>
		<?php endif; ?>
	</div>
</section>

<?php
get_footer();
