<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
$title = isset( $title ) ? (string) $title : '';
$sub = isset( $sub ) ? (string) $sub : '';
$cta = ( isset( $cta ) && is_array( $cta ) ) ? $cta : array();
$variant = isset( $variant ) ? (string) $variant : 'gold';
$bg = 'var(--avi-gradient-cta)';
$text = '#1A1A1A';
$btn_bg = '#1A1A1A';
$btn_text = '#FFFFFF';
if ( $variant === 'dark' ) {
	$bg = 'var(--avi-surface-2)';
	$text = '#FFFFFF';
	$btn_bg = 'var(--avi-gradient-cta)';
	$btn_text = '#1A1A1A';
} elseif ( $variant === 'primary' ) {
	$bg = 'var(--avi-gradient-primary)';
	$text = '#FFFFFF';
	$btn_bg = '#1A1A1A';
	$btn_text = '#FFFFFF';
}
// Sous-titre lisible sur fond dégradé or / jaune (variant gold)
$sub_color = ( $variant === 'gold' ) ? '#FFFFFF' : $text;
?>
<section style="padding:16px 0 60px;">
	<div style="max-width:1200px;margin:0 auto;background:<?php echo esc_attr( $bg ); ?>;color:<?php echo esc_attr( $text ); ?>;border-radius:14px;padding:28px 24px;display:flex;align-items:center;justify-content:space-between;gap:18px;flex-wrap:wrap;">
		<div>
			<h2 style="margin:0 0 8px;"><?php echo esc_html( $title ); ?></h2>
			<?php if ( $sub !== '' ) : ?>
				<p style="margin:0;color:<?php echo esc_attr( $sub_color ); ?>;opacity:<?php echo $variant === 'gold' ? '1' : '0.9'; ?>;"><?php echo esc_html( $sub ); ?></p>
			<?php endif; ?>
		</div>
		<?php if ( ! empty( $cta['label'] ) && ! empty( $cta['url'] ) ) : ?>
			<?php $btn_class = $btn_bg === '#1A1A1A' ? 'avi-btn avi-btn--dark' : 'avi-btn avi-btn--primary'; ?>
			<a href="<?php echo esc_url( (string) $cta['url'] ); ?>" class="<?php echo esc_attr( $btn_class ); ?>" style="background:<?php echo esc_attr( $btn_bg ); ?>;color:<?php echo esc_attr( $btn_text ); ?> !important;">
				<?php echo esc_html( (string) $cta['label'] ); ?>
			</a>
		<?php endif; ?>
	</div>
</section>
