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

$wte_details = wte_get_business_details();
if ( empty( $wte_details ) ) { return; }
?>
<section id="wte-business-info" class="wte-section wte-section--alt wte-section--business-details">
	<div class="wte-container">
		<header class="wte-section__header">
			<h2 class="wte-section__heading"><?php esc_html_e( '事業詳細', 'wte_' ); ?></h2>
		</header>
		<div class="wte-business-details">
			<?php foreach ( $wte_details as $item ) : ?>
				<?php $has_image = ! empty( $item['image_id'] ); ?>
				<div class="wte-business-detail<?php echo $has_image ? ' wte-business-detail--has-image' : ''; ?>">
					<?php if ( $has_image ) :
						$img = wp_get_attachment_image( (int) $item['image_id'], 'medium', false, [ 'class' => 'wte-business-detail__image', 'loading' => 'lazy' ] );
						if ( $img ) : ?>
							<div class="wte-business-detail__image-wrap"><?php echo $img; ?></div>
						<?php endif; ?>
					<?php endif; ?>
					<div class="wte-business-detail__content">
						<h3 class="wte-business-detail__title"><?php echo esc_html( $item['title'] ); ?></h3>
						<?php if ( ! empty( $item['body'] ) ) : ?>
							<p class="wte-business-detail__body"><?php echo nl2br( esc_html( $item['body'] ) ); ?></p>
						<?php endif; ?>
						<?php if ( ! empty( $item['link_url'] ) && ! empty( $item['link_text'] ) ) : ?>
							<a href="<?php echo esc_url( $item['link_url'] ); ?>" class="wte-business-detail__link"><?php echo esc_html( $item['link_text'] ); ?> →</a>
						<?php endif; ?>
					</div>
				</div>
			<?php endforeach; ?>
		</div>
	</div>
</section>
