<?php
declare(strict_types=1);
/**
 * Contact Page Template.
 * @package WTE_Business_Card
 */
get_header();
$wte_email     = get_theme_mod( 'wte_contact_email', '' );
$wte_title     = get_theme_mod( 'wte_contact_page_title', __( 'お問い合わせ', 'wte_' ) );
$wte_intro     = get_theme_mod( 'wte_contact_page_intro', '' );
$wte_cta_label = get_theme_mod( 'wte_contact_cta_label', __( 'メールで問い合わせる', 'wte_' ) );

// Split email for spam protection.
$wte_email_parts = $wte_email ? explode( '@', $wte_email ) : [ '', '' ];
$wte_user_part   = $wte_email_parts[0] ?? '';
$wte_domain_part = $wte_email_parts[1] ?? '';
?>
<main id="wte-main" class="wte-main" role="main">
	<div class="wte-contact-page">
		<div class="wte-container wte-container--narrow">
			<header class="wte-contact-page__header">
				<h1 class="wte-contact-page__title"><?php echo esc_html( $wte_title ); ?></h1>
				<?php if ( $wte_intro ) : ?>
					<p class="wte-contact-page__intro"><?php echo nl2br( esc_html( $wte_intro ) ); ?></p>
				<?php endif; ?>
			</header>
			<?php if ( $wte_email ) : ?>
				<div class="wte-contact-page__action">
					<a href="#" class="wte-btn wte-btn--primary wte-btn--lg wte-contact__email-btn" data-user="<?php echo esc_attr( str_rot13( $wte_user_part ) ); ?>" data-domain="<?php echo esc_attr( str_rot13( $wte_domain_part ) ); ?>">
						<?php echo esc_html( $wte_cta_label ); ?>
					</a>
				</div>
				<div class="wte-contact-page__email-display">
					<span class="wte-email-protect" data-user="<?php echo esc_attr( str_rot13( $wte_user_part ) ); ?>" data-domain="<?php echo esc_attr( str_rot13( $wte_domain_part ) ); ?>"></span>
				</div>
			<?php else : ?>
				<p class="wte-contact-page__notice"><?php esc_html_e( 'お問い合わせ先が設定されていません。', 'wte_' ); ?></p>
			<?php endif; ?>
		</div>
	</div>
</main>
<?php get_footer();
