<?php
/**
 * Homepage sections partial.
 *
 * @package EasySite_Pro
 */

$hero_bg = easysite_get_mod( 'easysite_hero_bg_image' );
if ( ! $hero_bg ) {
	$hero_bg = easysite_placeholder_image( 'hero' );
}
?>

<section class="easysite-hero easysite-section" style="background-image:url('<?php echo esc_url( $hero_bg ); ?>')">
	<div class="easysite-container easysite-hero-inner">
		<h1><?php echo esc_html( easysite_get_mod( 'easysite_hero_title', __( 'Welcome to Our Business', 'easysite-pro' ) ) ); ?></h1>
		<p class="easysite-hero-subtitle"><?php echo esc_html( easysite_get_mod( 'easysite_hero_subtitle' ) ); ?></p>
		<?php
		$btn_text = easysite_get_mod( 'easysite_hero_button_text' );
		$btn_link = easysite_get_mod( 'easysite_hero_button_link', '/contact' );
		if ( $btn_text ) :
			?>
			<a class="easysite-btn easysite-btn-lg" href="<?php echo esc_url( home_url( $btn_link ) ); ?>"><?php echo esc_html( $btn_text ); ?></a>
		<?php endif; ?>
	</div>
</section>

<?php if ( easysite_get_mod( 'easysite_about_show', true ) ) : ?>
<section class="easysite-section easysite-about">
	<div class="easysite-container easysite-split">
		<div>
			<h2><?php echo esc_html( easysite_get_mod( 'easysite_about_title', __( 'About Us', 'easysite-pro' ) ) ); ?></h2>
			<p><?php echo esc_html( easysite_get_mod( 'easysite_about_text' ) ); ?></p>
		</div>
		<div class="easysite-about-image">
			<?php
			$about_img = easysite_get_mod( 'easysite_about_image' );
			if ( ! $about_img ) {
				$about_img = easysite_placeholder_image( 'team' );
			}
			?>
			<img src="<?php echo esc_url( $about_img ); ?>" alt="" loading="lazy" />
		</div>
	</div>
</section>
<?php endif; ?>

<?php if ( easysite_get_mod( 'easysite_services_show', true ) ) : ?>
<section class="easysite-section easysite-services">
	<div class="easysite-container">
		<h2 class="easysite-section-title"><?php echo esc_html( easysite_get_mod( 'easysite_services_title', __( 'Our Services', 'easysite-pro' ) ) ); ?></h2>
		<div class="easysite-services-grid">
			<?php for ( $i = 1; $i <= 6; $i++ ) :
				$title = easysite_get_mod( "easysite_service_{$i}_title" );
				$desc  = easysite_get_mod( "easysite_service_{$i}_desc" );
				$price = easysite_get_mod( "easysite_service_{$i}_price" );
				if ( ! $title ) {
					continue;
				}
				?>
				<div class="easysite-service-card">
					<div class="easysite-service-icon"><?php echo easysite_icon( 'service' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
					<h3><?php echo esc_html( $title ); ?></h3>
					<p><?php echo esc_html( $desc ); ?></p>
					<?php if ( $price ) : ?>
						<p class="easysite-service-price"><?php echo esc_html( $price ); ?></p>
					<?php endif; ?>
				</div>
			<?php endfor; ?>
		</div>
	</div>
</section>
<?php endif; ?>

<?php
if ( easysite_is_bundle() && post_type_exists( 'easysite_testimonial' ) ) {
	easysite_display_testimonials();
} elseif ( easysite_get_mod( 'easysite_testimonials_show', true ) ) {
	easysite_display_basic_testimonials();
}
?>

<?php if ( easysite_is_bundle() ) : ?>
	<?php easysite_section_pricing_table(); ?>
<?php else : ?>
	<?php easysite_section_pricing_table_basic(); ?>
<?php endif; ?>

<?php if ( easysite_wc_active() && easysite_get_mod( 'easysite_shop_show', true ) ) : ?>
<section class="easysite-section easysite-shop-section">
	<div class="easysite-container">
		<h2 class="easysite-section-title"><?php echo esc_html( easysite_get_mod( 'easysite_shop_title', __( 'Featured Products', 'easysite-pro' ) ) ); ?></h2>
		<?php
		$count = absint( easysite_get_mod( 'easysite_shop_count', 4 ) );
		echo do_shortcode( '[products limit="' . $count . '" columns="4"]' );
		?>
		<?php if ( easysite_get_mod( 'easysite_shop_view_all', true ) ) : ?>
			<p class="easysite-text-center">
				<a class="easysite-btn" href="<?php echo esc_url( wc_get_page_permalink( 'shop' ) ); ?>"><?php esc_html_e( 'View all products', 'easysite-pro' ); ?></a>
			</p>
		<?php endif; ?>
	</div>
</section>
<?php endif; ?>

<section class="easysite-section easysite-cta">
	<div class="easysite-container easysite-cta-inner">
		<h2><?php esc_html_e( 'Ready to get started?', 'easysite-pro' ); ?></h2>
		<p><?php esc_html_e( 'Contact us today and let us help you reach your goals.', 'easysite-pro' ); ?></p>
		<a class="easysite-btn easysite-btn-lg" href="<?php echo esc_url( home_url( '/contact' ) ); ?>"><?php esc_html_e( 'Contact Us', 'easysite-pro' ); ?></a>
	</div>
</section>
