<?php
/**
 * Solar Services homepage section.
 *
 * @package ttsunsolar
 */

if ( ! ttsunsolar_show_services_section() ) {
	return;
}

$tagline = get_theme_mod( 'ttsunsolar_services_tagline', __( 'What we install', 'ttsunsolar' ) );
$title   = get_theme_mod( 'ttsunsolar_services_title', __( 'Solar Services', 'ttsunsolar' ) );
$cards   = ttsunsolar_get_services_cards();
?>
<section id="services" class="section section--services">
	<div class="container">
		<div class="section-heading">
			<?php if ( $tagline ) : ?>
				<p class="section_tagline"><?php echo esc_html( $tagline ); ?></p>
			<?php endif; ?>
			<?php if ( $title ) : ?>
				<h2><?php echo esc_html( $title ); ?></h2>
			<?php endif; ?>
		</div>

		<div class="services-grid">
			<?php foreach ( $cards as $card ) : ?>
				<article class="service-card">
					<a class="service-card__image" href="<?php echo esc_url( $card['url'] ); ?>">
						<img src="<?php echo esc_url( $card['image'] ); ?>" alt="<?php echo esc_attr( $card['title'] ); ?>" />
					</a>
					<div class="service-card__body">
						<h3><a href="<?php echo esc_url( $card['url'] ); ?>"><?php echo esc_html( $card['title'] ); ?></a></h3>
						<p><?php echo esc_html( $card['excerpt'] ); ?></p>
					</div>
				</article>
			<?php endforeach; ?>
		</div>
	</div>
</section>
