<?php
/**
 * The front page template file.
 */

get_header();

$hero_bg = get_theme_mod('hero_background_image', get_template_directory_uri() . '/assets/images/hero-default.png');
?>

<section class="hero-section text-white d-flex align-items-center position-relative"
	style="background-image: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.6)), url('<?php echo esc_url($hero_bg); ?>'); background-size: cover; background-position: center; min-height: 80vh;">
	<div class="container text-center py-5">
		<h1 class="display-3 fw-bold mb-4 font-serif text-white">
			<?php echo get_theme_mod('hero_headline', 'Ancient Wisdom for a Modern World.'); ?>
		</h1>
		<p class="lead fw-normal mb-5 w-75 mx-auto font-sans text-light">
			<?php echo get_theme_mod('hero_subheadline', 'A collection of biblical insights curated for the thoughtful leader.'); ?>
		</p>
		<a href="#primary"
			class="btn btn-secondary btn-lg px-5 py-3 rounded-pill text-uppercase fw-bold shadow-sm"><?php echo get_theme_mod('hero_cta_text', 'Start Reading'); ?></a>
	</div>
</section>

<div class="container my-5 py-4">
	<main id="primary" class="site-main">
		<header class="text-center mb-5">
			<h2 class="display-5 fw-bold font-serif mb-3">Seek Truth. Lead with Grace.</h2>
			<p class="lead text-muted font-sans font-italic">Explorations into the heart of the Kingdom.</p>
		</header>

		<div class="row g-4 mb-5">
			<?php
			if (have_posts()):
				while (have_posts()):
					the_post();
					?>
							<?php get_template_part('template-parts/content', 'card'); ?>
					<?php
				endwhile;

				echo '</div>'; // close row
			
				the_posts_navigation(array(
					'screen_reader_text' => 'Posts navigation',
					'prev_text' => '<span class="btn btn-outline-primary">&larr; Older Posts</span>',
					'next_text' => '<span class="btn btn-outline-primary">Newer Posts &rarr;</span>',
					'class' => 'd-flex justify-content-between my-5'
				));
			else:
				echo '<div class="col-12"><div class="alert alert-info text-center">' . esc_html__('No posts found.', 'wisdom1') . '</div></div></div>';
			endif;
			?>
	</main><!-- #main -->
</div><!-- .container -->

<section class="bg-primary text-white py-5 mt-5">
	<div class="container text-center py-5">
		<h3 class="display-6 fw-bold mb-4 font-serif text-white">Receive weekly insights directly in your inbox.</h3>
		<p class="lead mb-4 font-sans text-light">Join our community and get our latest thoughts sent straight to you.
		</p>
		<form class="mx-auto" style="max-width: 500px;">
			<div class="input-group input-group-lg shadow">
				<input type="email" placeholder="Your email address" class="form-control border-0 px-4" required>
				<button type="submit" class="btn btn-secondary px-5 border-0 fw-bold text-uppercase h-100">
					Subscribe
				</button>
			</div>
		</form>
	</div>
</section>

<?php
get_footer();
