<?php
/**
 * The main template file.
 *
 * Fallback for any content type that does not have a more specific template.
 *
 * @package Northfield_Theatre
 * @since 1.0.0
 */

get_header();
?>

<div class="container">
	<div class="page-header">
		<?php if ( is_home() && ! is_front_page() ) : ?>
			<h1 class="page-header__title"><?php single_post_title(); ?></h1>
		<?php elseif ( is_archive() ) : ?>
			<h1 class="page-header__title"><?php the_archive_title(); ?></h1>
			<?php the_archive_description( '<p class="page-header__subtitle">', '</p>' ); ?>
		<?php elseif ( is_search() ) : ?>
			<h1 class="page-header__title">
				<?php
				printf(
					/* translators: %s: search query */
					esc_html__( 'Search results for: %s', 'northfield-theatre' ),
					'<span>' . esc_html( get_search_query() ) . '</span>'
				);
				?>
			</h1>
		<?php else : ?>
			<h1 class="page-header__title"><?php esc_html_e( 'Latest Posts', 'northfield-theatre' ); ?></h1>
		<?php endif; ?>
	</div>

	<?php if ( have_posts() ) : ?>
		<div class="posts-list">
			<?php while ( have_posts() ) : the_post(); ?>
				<article id="post-<?php the_ID(); ?>" <?php post_class( 'post-summary' ); ?>>
					<header class="post-summary__header">
						<h2 class="post-summary__title">
							<a href="<?php the_permalink(); ?>">
								<?php the_title(); ?>
							</a>
						</h2>
						<time class="post-summary__date" datetime="<?php echo esc_attr( get_the_date( 'c' ) ); ?>">
							<?php echo esc_html( get_the_date() ); ?>
						</time>
					</header>
					<div class="post-summary__excerpt">
						<?php the_excerpt(); ?>
					</div>
				</article>
			<?php endwhile; ?>
		</div>

		<?php the_posts_pagination( array(
			'prev_text' => esc_html__( 'Previous', 'northfield-theatre' ),
			'next_text' => esc_html__( 'Next', 'northfield-theatre' ),
		) ); ?>

	<?php else : ?>
		<div class="no-results">
			<h2><?php esc_html_e( 'Nothing found', 'northfield-theatre' ); ?></h2>
			<p><?php esc_html_e( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Try searching for it.', 'northfield-theatre' ); ?></p>
			<?php get_search_form(); ?>
		</div>
	<?php endif; ?>
</div>

<?php
get_footer();
