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

$wte_name      = get_theme_mod( 'wte_owner_name', '' );
$wte_name_kana = get_theme_mod( 'wte_owner_name_kana', '' );
$wte_title     = get_theme_mod( 'wte_owner_title', '' );
$wte_photo     = get_theme_mod( 'wte_owner_photo', '' );
$wte_bio       = get_theme_mod( 'wte_owner_bio', '' );
$wte_biz_name  = get_theme_mod( 'wte_business_name', '' );
$wte_address   = get_theme_mod( 'wte_business_address', '' );
$wte_tel       = get_theme_mod( 'wte_business_tel', '' );
$wte_hours     = get_theme_mod( 'wte_business_hours', '' );
$wte_founded   = get_theme_mod( 'wte_business_founded', '' );

if ( ! $wte_name && ! $wte_biz_name ) { return; }
?>
<section id="wte-profile" class="wte-section wte-section--alt wte-section--profile">
	<div class="wte-container">
		<div class="wte-profile">
			<div class="wte-profile__photo-wrap">
				<?php if ( $wte_photo ) : ?>
					<img src="<?php echo esc_url( $wte_photo ); ?>" alt="<?php echo esc_attr( $wte_name ); ?>" class="wte-profile__photo" width="200" height="200" loading="lazy">
				<?php else : ?>
					<div class="wte-profile__photo-placeholder" aria-hidden="true">
						<svg viewBox="0 0 100 100" width="200" height="200"><circle cx="50" cy="38" r="18" fill="#e8eaed"/><ellipse cx="50" cy="80" rx="30" ry="20" fill="#e8eaed"/></svg>
					</div>
				<?php endif; ?>
			</div>
			<div class="wte-profile__info">
				<?php if ( $wte_name_kana ) : ?>
					<span class="wte-kana wte-profile__kana"><?php echo esc_html( $wte_name_kana ); ?></span>
				<?php endif; ?>
				<?php if ( $wte_name ) : ?>
					<h2 class="wte-profile__name"><?php echo esc_html( $wte_name ); ?></h2>
				<?php endif; ?>
				<?php if ( $wte_title ) : ?>
					<p class="wte-profile__title"><?php echo esc_html( $wte_title ); ?></p>
				<?php endif; ?>
				<?php if ( $wte_biz_name ) : ?>
					<p class="wte-business__name"><?php echo esc_html( $wte_biz_name ); ?></p>
				<?php endif; ?>
				<?php if ( $wte_bio ) : ?>
					<p class="wte-profile__bio"><?php echo esc_html( $wte_bio ); ?></p>
				<?php endif; ?>

				<?php if ( $wte_address || $wte_tel || $wte_hours || $wte_founded ) : ?>
					<dl class="wte-profile__details">
						<?php if ( $wte_address ) : ?>
							<div class="wte-profile__detail-row">
								<dt><?php esc_html_e( '所在地', 'wte_' ); ?></dt>
								<dd><?php echo nl2br( esc_html( $wte_address ) ); ?></dd>
							</div>
						<?php endif; ?>
						<?php if ( $wte_tel ) : ?>
							<div class="wte-profile__detail-row">
								<dt><?php esc_html_e( '電話番号', 'wte_' ); ?></dt>
								<dd><a href="tel:<?php echo esc_attr( preg_replace( '/[^0-9+]/', '', $wte_tel ) ); ?>"><?php echo esc_html( $wte_tel ); ?></a></dd>
							</div>
						<?php endif; ?>
						<?php if ( $wte_hours ) : ?>
							<div class="wte-profile__detail-row">
								<dt><?php esc_html_e( '営業時間', 'wte_' ); ?></dt>
								<dd><?php echo nl2br( esc_html( $wte_hours ) ); ?></dd>
							</div>
						<?php endif; ?>
						<?php if ( $wte_founded ) : ?>
							<div class="wte-profile__detail-row">
								<dt><?php esc_html_e( '創業', 'wte_' ); ?></dt>
								<dd><?php echo esc_html( $wte_founded ); ?><?php esc_html_e( '年', 'wte_' ); ?></dd>
							</div>
						<?php endif; ?>
					</dl>
				<?php endif; ?>
			</div>
		</div>
	</div>
</section>
