<?php
/**
 * Universal page template: renders the editor content full-width
 * so block patterns control their own sections and backgrounds.
 *
 * An automatic page hero (title + excerpt) is shown only when the content
 * does not already include a hero ([hero] shortcode or a block pattern with
 * the hl-hero / hl-page-hero class).
 */
get_header();
?>

<main>
	<?php
	while ( have_posts() ) :
		the_post();

		$content = get_the_content();

		$has_hero_pattern = ( false !== strpos( $content, 'hl-hero' ) )
			|| ( false !== strpos( $content, 'hl-page-hero' ) );

		if ( ! has_shortcode( $content, 'hero' ) && ! $has_hero_pattern ) {
			?>
			<section class="hl-page-hero">
				<div class="hl-container">
					<h1 class="hl-page-hero__title"><?php the_title(); ?></h1>
					<?php if ( has_excerpt() ) : ?>
						<p class="hl-page-hero__subtitle"><?php echo esc_html( get_the_excerpt() ); ?></p>
					<?php endif; ?>
				</div>
			</section>
			<?php
		}

		echo '<div class="entry-content">';
		the_content();
		echo '</div>';
	endwhile;
	?>
</main>

<?php
get_footer();