<?php

declare(strict_types=1);

/**
 * Vollflächiger Hero mit Hintergrundbild/-video, Titel, Intro und CTAs.
 * Props: $hero (array aus home.json: title, text, image, video?, ctas, align?, compact?,
 *               display?, kicker?, scroll_target?)
 * align-Varianten: 'center' (mittig zentriert), 'bottom-left' (Default).
 * compact: true → niedrigere Variante für Unterseiten-Header.
 * display: true → großer Editorial-Look (Riesen-Titel, Outline-Tagline, Kicker, Scroll-Cue).
 */
$align = in_array($hero['align'] ?? '', ['center', 'bottom-left'], true) ? $hero['align'] : 'bottom-left';
$compact = !empty($hero['compact']);
$display = !empty($hero['display']);
?>
        <section class="hero<?= $align === 'center' ? ' hero--center' : '' ?><?= $compact ? ' hero--compact' : '' ?><?= $display ? ' hero--display' : '' ?>">
            <div class="hero__media" aria-hidden="true">
<?php component('img', ['image' => $hero['image'], 'sizes' => '100vw', 'eager' => true, 'class' => 'hero__img']); ?>
<?php if (!empty($hero['video'])): ?>
                <?php /* Bild bleibt Poster/Fallback; reduced-motion blendet das Video per CSS aus */ ?>
                <video class="hero__video" src="<?= e(asset($hero['video'])) ?>" autoplay muted loop playsinline preload="none" tabindex="-1"></video>
<?php endif; ?>
            </div>
            <div class="container hero__content">
<?php if (!empty($hero['kicker'])): ?>
                <p class="hero__kicker"><?= e($hero['kicker']) ?></p>
<?php endif; ?>
                <h1 class="hero__title"><?= e($hero['title']) ?><?php if (!empty($hero['tagline'])): ?> <span class="hero__tagline"><?= e($hero['tagline']) ?></span><?php endif; ?></h1>
<?php if (!empty($hero['text'])): ?>
                <p class="hero__text"><?= e($hero['text']) ?></p>
<?php endif; ?>
<?php if (!empty($hero['ctas'])): ?>
                <div class="hero__actions">
<?php foreach ($hero['ctas'] as $cta): ?>
<?php component('cta', ['cta' => $cta]); ?>
<?php endforeach; ?>
                </div>
<?php endif; ?>
            </div>
<?php if ($display): ?>
            <a class="hero__scroll-cue" href="#<?= e($hero['scroll_target'] ?? 'aktuelles') ?>">
                <?= icon('chevron-down') ?><span class="visually-hidden">Zum Inhalt scrollen</span>
            </a>
<?php endif; ?>
        </section>
