<?php
/**
 * Bandeau hero unifié pour les pages Volade.
 *
 * @package Volade\SDK
 * @license GPL-2.0-or-later
 * @var string      $hero_kicker
 * @var string      $hero_title
 * @var string      $hero_lead
 * @var string      $hero_variant   indigo|dark|soft
 * @var array       $hero_orbs
 * @var string      $hero_actions_html
 * @var string      $hero_aside_html
 * @var string|null $hero_extra_class
 */

defined( 'ABSPATH' ) || exit;

$hero_variant      = $hero_variant ?? 'indigo';
$hero_orbs         = $hero_orbs ?? array();
$hero_actions_html = $hero_actions_html ?? '';
$hero_aside_html   = $hero_aside_html ?? '';
$hero_extra_class  = $hero_extra_class ?? '';
$hero_kicker       = $hero_kicker ?? '';
$hero_lead         = $hero_lead ?? '';

$classes = array(
	'volade-page-hero',
	'volade-discover-hero',
	'volade-page-hero--' . sanitize_html_class( $hero_variant ),
);

if ( 'dark' === $hero_variant ) {
	$classes[] = 'volade-hub-hero';
}

if ( $hero_extra_class ) {
	$classes[] = $hero_extra_class;
}
?>
<header class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>">
	<div class="volade-page-hero-content volade-discover-hero-content">
		<?php if ( $hero_kicker ) : ?>
			<span class="volade-page-hero-kicker volade-discover-hero-kicker"><?php echo esc_html( $hero_kicker ); ?></span>
		<?php endif; ?>
		<h1><?php echo esc_html( $hero_title ); ?></h1>
		<?php if ( $hero_lead ) : ?>
			<p class="volade-page-hero-lead volade-discover-hero-lead"><?php echo esc_html( $hero_lead ); ?></p>
		<?php endif; ?>
		<?php if ( $hero_actions_html ) : ?>
			<div class="volade-page-hero-actions volade-discover-hero-actions volade-hero-actions-on-dark">
				<?php
                // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- boutons déjà échappés dans la vue appelante
				echo $hero_actions_html;
				?>
			</div>
		<?php endif; ?>
	</div>
	<?php if ( $hero_aside_html ) : ?>
		<div class="volade-page-hero-aside">
			<?php
            // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
			echo $hero_aside_html;
			?>
		</div>
	<?php elseif ( ! empty( $hero_orbs ) ) : ?>
		<div class="volade-page-hero-visual volade-discover-hero-visual" aria-hidden="true">
			<?php foreach ( array_values( $hero_orbs ) as $i => $orb ) : ?>
				<span class="volade-page-orb volade-discover-orb volade-discover-orb--<?php echo (int) $i + 1; ?>"><?php echo esc_html( $orb ); ?></span>
			<?php endforeach; ?>
		</div>
	<?php endif; ?>
</header>
