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

// Gather active services.
$wte_services = [];
for ( $n = 1; $n <= 6; $n++ ) {
	if ( ! get_theme_mod( "wte_service_{$n}_display", ( $n <= 3 ) ) ) { continue; }
	$title = get_theme_mod( "wte_service_{$n}_title", '' );
	if ( empty( $title ) ) { continue; }
	$wte_services[] = [
		'title' => $title,
		'desc'  => get_theme_mod( "wte_service_{$n}_desc", '' ),
		'icon'  => get_theme_mod( "wte_service_{$n}_icon", 'star' ),
	];
}
if ( empty( $wte_services ) ) { return; }

$wte_heading = get_theme_mod( 'wte_service_section_heading', __( 'サービス', 'wte_' ) );
$wte_subtext = get_theme_mod( 'wte_service_section_subtext', '' );
?>
<section id="wte-services" class="wte-section wte-section--alt wte-section--services">
	<div class="wte-container">
		<header class="wte-section__header">
			<h2 class="wte-section__heading"><?php echo esc_html( $wte_heading ); ?></h2>
			<?php if ( $wte_subtext ) : ?>
				<p class="wte-section__subtext"><?php echo esc_html( $wte_subtext ); ?></p>
			<?php endif; ?>
		</header>
		<div class="wte-services__grid">
			<?php foreach ( $wte_services as $service ) : ?>
				<article class="wte-service-card">
					<div class="wte-service-card__icon">
						<?php wte_render_icon( $service['icon'] ); ?>
					</div>
					<h3 class="wte-service-card__title"><?php echo esc_html( $service['title'] ); ?></h3>
					<?php if ( $service['desc'] ) : ?>
						<p class="wte-service-card__desc"><?php echo esc_html( $service['desc'] ); ?></p>
					<?php endif; ?>
				</article>
			<?php endforeach; ?>
		</div>
	</div>
</section>
