<?php
/**
 * Search results.
 *
 * @package Gustavo_Portfolio
 */

get_header();
$gustavoo_search_query = get_search_query();
?>

<main id="primary" class="site-main search-main">
	<header class="page-hero page-hero--search">
		<div class="site-shell page-hero__inner">
			<p class="eyebrow"><?php esc_html_e( 'Pesquisa', 'gustavoo-portfolio' ); ?></p>
			<h1 class="page-hero__title">
				<?php
				printf(
					/* translators: %s: search query. */
					esc_html__( 'Resultados para “%s”', 'gustavoo-portfolio' ),
					esc_html( $gustavoo_search_query )
				);
				?>
			</h1>
			<div class="page-hero__search"><?php get_search_form(); ?></div>
		</div>
	</header>

	<div class="site-shell article-layout">
		<div class="article-layout__main">
			<?php if ( have_posts() ) : ?>
				<p class="results-count">
					<?php
					global $wp_query;
					printf(
						/* translators: %s: number of search results. */
						esc_html( _n( '%s resultado encontrado', '%s resultados encontrados', (int) $wp_query->found_posts, 'gustavoo-portfolio' ) ),
						esc_html( number_format_i18n( (int) $wp_query->found_posts ) )
					);
					?>
				</p>
				<div class="posts-grid">
					<?php
					while ( have_posts() ) {
						the_post();
						get_template_part( 'template-parts/global/post-card' );
					}
					?>
				</div>
				<?php gustavoo_portfolio_pagination(); ?>
			<?php else : ?>
				<?php get_template_part( 'template-parts/content/content', 'none' ); ?>
			<?php endif; ?>
		</div>

		<?php get_sidebar(); ?>
	</div>
</main>

<?php
get_footer();
