<?php
/**
 * Hero-секция страницы Подготовки к школе
 * .section-bg .ds-hero
 *
 * @package Dekart
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$data = Pksh_Data::instance();

$opt_address       = $data->get_address();
$branch_city_clean = $data->get_city_clean();
$h1_hero           = $data->get_h1();
$subtitle_hero     = $data->get_subtitle();
$ext_review_count  = $data->get_ext_review_count();
$opt_phone         = $data->get_phone();
$hero_phone_clean  = $data->get_phone_clean();
$banner_img_id     = $data->get_banner_image_id();
$hero_metrics      = $data->get_social_counters();
?>

<section class="section-bg ds-hero" data-bg="hero" id="ds-hero" aria-label="Подготовка к школе">
	<div class="ds-container">
		<div class="ds-hero__inner">

			<div class="ds-hero__content">

				<div class="ds-hero__address">
					<svg aria-hidden="true" width="16" height="16"><use href="#icon-location-pin"/></svg>
					<span><?php echo esc_html( $opt_address ?: 'ул. Талсинская, 24' ); ?> — центр <?php echo esc_html( $branch_city_clean ?: 'Щёлково' ); ?></span>
				</div>

				<h1 class="ds-hero__h1"><?php echo esc_html( $h1_hero ?: 'Подготовка к школе в Щёлково' ); ?></h1>

<?php if ( '' !== $subtitle_hero ) :
				$footnote_url = $data->get_subtitle_footnote_link();
			?>
				<p class="ds-hero__subtitle"><?php echo esc_html( $subtitle_hero ); ?><?php if ( $footnote_url ) : ?><sup><a href="<?php echo esc_url( $footnote_url ); ?>" class="ds-hero__footnote-link" target="_blank" rel="noopener noreferrer">*</a></sup><?php else : ?><sup class="ds-hero__footnote">*</sup><?php endif; ?></p>
			<?php endif; ?>

				<?php if ( ! empty( $hero_metrics ) && is_array( $hero_metrics ) ) : ?>
				<div class="ds-hero__metrics">
					<?php foreach ( $hero_metrics as $metric ) :
						$num = $metric['counter_number'] ?? '';
						$lbl = $metric['counter_label'] ?? '';
						if ( empty( $num ) ) { continue; }
					?>
					<div class="ds-hero__metric reveal">
						<span class="ds-hero__metric-number"><?php echo esc_html( $num ); ?></span>
						<span class="ds-hero__metric-label"><?php echo esc_html( $lbl ); ?></span>
					</div>
					<?php endforeach; ?>
				</div>
				<?php endif; ?>

				<div class="ds-hero__rating-badge">
					<span class="ds-hero__rating-stars" aria-hidden="true">★★★★★</span>
					<span class="ds-hero__rating-text">4.9 из 5 на основе <?php echo esc_html( $ext_review_count ); ?> отзывов на внешних площадках</span>
				</div>

				<button class="ds-hero__cta-btn open-bitrix-form">Записаться на бесплатное пробное</button>

				<?php if ( $opt_phone ) : ?>
				<p class="ds-hero__phone">Или позвоните: <a href="tel:<?php echo esc_attr( $hero_phone_clean ); ?>" aria-label="Позвонить в школу Декарт: <?php echo esc_attr( $opt_phone ); ?>"><?php echo esc_html( $opt_phone ); ?></a></p>
				<?php endif; ?>

			</div>

			<div class="ds-hero__visual">
				<div class="ds-hero__visual-glow" aria-hidden="true"></div>

				<div class="ds-hero__photo-wrap">
					<div class="ds-hero__photo-frame">
						<?php if ( $banner_img_id ) : ?>
							<?php echo wp_get_attachment_image( $banner_img_id, 'full', false, array(
								'class'    => 'ds-hero__photo',
								'loading'  => 'eager',
								'decoding' => 'async',
								'alt'      => 'Подготовка к школе в Щёлково — занятия для детей 5–7 лет',
							) ); ?>
						<?php else : ?>
							<img class="ds-hero__photo" loading="eager" decoding="async"
								 src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/girl_and_a_boy.webp' ); ?>"
								 alt="Подготовка к школе в Щёлково — занятия для детей 5–7 лет"
								 width="689" height="689">
						<?php endif; ?>
					</div>
					<div class="ds-hero__photo-ring" aria-hidden="true"></div>
				</div>

				<div class="ds-hero__float ds-hero__float--1">
					<span class="ds-hero__float-icon">👩‍🏫</span>
					<span>Педагоги с опытом 15+ лет</span>
				</div>
				<div class="ds-hero__float ds-hero__float--2">
					<span class="ds-hero__float-icon">🎮</span>
					<span>Игровая методика</span>
				</div>
				<div class="ds-hero__float ds-hero__float--3">
					<span class="ds-hero__float-icon">📚</span>
					<span>Авторская программа</span>
				</div>
				<div class="ds-hero__float ds-hero__float--4">
					<span class="ds-hero__float-icon">🌟</span>
					<span>Рейтинг 4.8</span>
				</div>

				<div class="ds-hero__deco ds-hero__deco--1" aria-hidden="true"></div>
				<div class="ds-hero__deco ds-hero__deco--2" aria-hidden="true"></div>
				<div class="ds-hero__deco ds-hero__deco--3" aria-hidden="true"></div>
				<div class="ds-hero__deco ds-hero__deco--4" aria-hidden="true"></div>

				<div class="ds-hero__sparkles" aria-hidden="true">
					<div class="ds-hero__sparkle"></div>
					<div class="ds-hero__sparkle"></div>
					<div class="ds-hero__sparkle"></div>
					<div class="ds-hero__sparkle"></div>
					<div class="ds-hero__sparkle"></div>
				</div>
			</div>

		</div>
	</div>
</section>
