<?php
declare(strict_types=1);
if ( ! defined( 'ABSPATH' ) ) { exit; }

$wte_has_content = false;
for ( $n = 1; $n <= 3; $n++ ) {
	if ( get_theme_mod( "wte_appeal_{$n}_heading", '' ) ) { $wte_has_content = true; break; }
}
if ( ! $wte_has_content ) { return; }

$wte_heading = get_theme_mod( 'wte_appeal_section_heading', __( '選ばれる理由', 'wte_' ) );
?>
<section id="wte-appeal" class="wte-section wte-section--appeal">
	<div class="wte-container">
		<header class="wte-section__header">
			<h2 class="wte-section__heading"><?php echo esc_html( $wte_heading ); ?></h2>
		</header>
		<div class="wte-appeal__grid">
			<?php for ( $n = 1; $n <= 3; $n++ ) :
				$heading = get_theme_mod( "wte_appeal_{$n}_heading", '' );
				$body    = get_theme_mod( "wte_appeal_{$n}_body", '' );
				$number  = get_theme_mod( "wte_appeal_{$n}_number", '' );
				if ( ! $heading ) { continue; }
			?>
				<div class="wte-appeal-card" data-appeal="<?php echo esc_attr( (string) $n ); ?>">
					<?php if ( $number ) : ?>
						<div class="wte-appeal-card__number"><?php echo esc_html( $number ); ?></div>
					<?php endif; ?>
					<h3 class="wte-appeal-card__heading"><?php echo esc_html( $heading ); ?></h3>
					<?php if ( $body ) : ?>
						<p class="wte-appeal-card__body"><?php echo esc_html( $body ); ?></p>
					<?php endif; ?>
				</div>
			<?php endfor; ?>
		</div>
	</div>
</section>
