<?php
$post_id = get_the_ID();
$page_breadcrumbs = carbon_get_post_meta( $post_id, 'page_breadcrumbs' );
?>
<section class="banner">
	<?php if ( ! empty( $page_breadcrumbs ) ) { ?>
		<nav class="container" aria-label="Хлебные крошки">
			<ul class="breadcrumbs">
				<li>
					<a href="<?php echo esc_url( home_url() ); ?>/" class="home fa-home" title="Главная страница">
						<span style="display:none;">Главная</span>
						<svg width="21" height="16" viewBox="0 0 21 16" fill="none">
							<path d="M11.6473 10.6896H12.1473V11.1896V15.4691H16.4353C16.5143 15.4691 16.5756 15.4462 16.6432 15.3788C16.7108 15.3113 16.7333 15.2505 16.7333 15.1725V9.36976L10.0513 3.8712L3.36922 9.36976V15.1725C3.36922 15.2505 3.39178 15.3113 3.45937 15.3788C3.52698 15.4462 3.5883 15.4691 3.66723 15.4691H7.95527V11.1896V10.6896H8.45527H11.6473ZM10.3711 1.74407L18.9226 8.86174L19.5643 8.09722L16.9141 5.8987L16.7333 5.74874V5.51388V0.537319H14.5413V2.86272V3.93127L13.7209 3.2466L10.6815 0.709949C10.5114 0.572829 10.3095 0.499981 10.0513 0.499981C9.79293 0.499981 9.59094 0.572914 9.42075 0.710194L0.538196 8.09712L1.17996 8.86174L9.73142 1.74407L10.0513 1.47783L10.3711 1.74407Z" fill="white" stroke="white"/>
						</svg>
					</a>
				</li>
				<?php foreach ( $page_breadcrumbs as $index => $item ) :
					$breadcrumbs_name = $item['breadcrumbs_name'];
					$breadcrumbs_link = $item['breadcrumbs_link'];
					$is_last = ( $index === count( $page_breadcrumbs ) - 1 );
					?>
					<li>
						<?php if ( $is_last ) : ?>
							<span class="last_item"><?php echo esc_html( $breadcrumbs_name ); ?></span>
						<?php else : ?>
							<a href="<?php echo esc_url( $breadcrumbs_link ); ?>" title="<?php echo esc_attr( $breadcrumbs_name ); ?>">
								<?php echo esc_html( $breadcrumbs_name ); ?>
							</a>
						<?php endif; ?>
					</li>
				<?php endforeach; ?>
			</ul>
		</nav>
	<?php } ?>

	<div class="banner-wrapper">
		<?php
		$foto = carbon_get_post_meta( $post_id, 'banner_img_desktop' );
		$foto_mobile = carbon_get_post_meta( $post_id, 'banner_img_mobile' );
		if ( empty( $foto_mobile ) ) {
			$foto_mobile = $foto;
		}
		if ( $foto ) :
			?>
			<picture class="banner-fon">
				<source srcset="<?php echo esc_url( wp_get_attachment_url( $foto ) ); ?>" media="(min-width: 860px)">
				<img src="<?php echo esc_url( wp_get_attachment_url( $foto_mobile ) ); ?>" alt="<?php echo esc_attr( get_post_meta( $foto, '_wp_attachment_image_alt', true ) ); ?>">
			</picture>
		<?php endif; ?>
		<div class="banner__content desktop">
			<h1 class="page_title"><?php echo esc_html( carbon_get_post_meta( $post_id, 'banner_h1' ) ); ?></h1>
			<?php if ( carbon_get_post_meta( $post_id, 'banner_text' ) !== '' ) : ?>
				<p class="banner_text"><?php echo esc_html( carbon_get_post_meta( $post_id, 'banner_text' ) ); ?></p>
			<?php endif; ?>
			<button class="btn-free-lesson-header btn-lilac btn-banner btn-write">Оставить заявку</button>
		</div>
	</div>
</section>

<div class="banner__content mobile">
	<p class="page_title"><?php echo esc_html( carbon_get_post_meta( $post_id, 'banner_h1' ) ); ?></p>
	<?php if ( carbon_get_post_meta( $post_id, 'banner_text' ) !== '' ) : ?>
		<p class="banner_text"><?php echo esc_html( carbon_get_post_meta( $post_id, 'banner_text' ) ); ?></p>
	<?php endif; ?>
</div>

<button class="mobile btn-write btn-lilac btn-page">Записаться</button>
