<?php
/**
 * Not found template.
 *
 * @package Gustavo_Portfolio
 */

get_header();

$gustavoo_recent_posts = get_posts(
	array(
		'post_type'           => 'post',
		'post_status'         => 'publish',
		'posts_per_page'      => 3,
		'ignore_sticky_posts' => true,
		'no_found_rows'       => true,
	)
);
?>

<main id="primary" class="site-main error-404">
	<section class="page-hero page-hero--error" aria-labelledby="error-title">
		<div class="site-shell page-hero__inner">
			<p class="eyebrow">404</p>
			<h1 id="error-title" class="page-hero__title"><?php esc_html_e( 'Esta página saiu do mapa.', 'gustavoo-portfolio' ); ?></h1>
			<p class="page-hero__description"><?php esc_html_e( 'O endereço pode ter mudado ou não existir mais. Pesquise pelo conteúdo ou retorne ao início.', 'gustavoo-portfolio' ); ?></p>
			<div class="page-hero__actions">
				<a class="button button--primary" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php esc_html_e( 'Voltar ao início', 'gustavoo-portfolio' ); ?> <span aria-hidden="true">→</span></a>
			</div>
			<div class="page-hero__search"><?php get_search_form(); ?></div>
		</div>
	</section>

	<?php if ( $gustavoo_recent_posts ) : ?>
		<section class="section section--error-posts" aria-labelledby="error-posts-title">
			<div class="site-shell">
				<header class="section__header">
					<p class="eyebrow"><?php esc_html_e( 'Continue explorando', 'gustavoo-portfolio' ); ?></p>
					<h2 id="error-posts-title" class="section__title"><?php esc_html_e( 'Artigos recentes', 'gustavoo-portfolio' ); ?></h2>
				</header>
				<div class="posts-grid">
					<?php
					global $post;
					foreach ( $gustavoo_recent_posts as $post ) {
						setup_postdata( $post );
						get_template_part( 'template-parts/global/post-card' );
					}
					wp_reset_postdata();
					?>
				</div>
			</div>
		</section>
	<?php endif; ?>
</main>

<?php
get_footer();
