<?php

declare(strict_types=1);

/**
 * FAQ-Accordion. Props:
 *   $faq    array [{q, a}, …]
 *   $title  string (optional, Default 'Häufige Fragen')
 *   $anchor string (optional, Default 'faq')
 * Natives <details>/<summary> → ohne JS bedienbar. Das FAQPage-Schema liefert
 * die Seite über $meta['schema'] (helpers: faq_schema/team_schema), nicht diese Komponente.
 */
$title = $title ?? 'Häufige Fragen';
$anchor = $anchor ?? 'faq';
$faq = array_values(array_filter(
    $faq ?? [],
    static fn (array $i): bool => !empty($i['q']) && !empty($i['a'])
));
if ($faq === []) {
    return;
}
?>
        <section class="section faq" id="<?= e($anchor) ?>">
            <div class="container faq__inner">
                <h2><?= e($title) ?></h2>
                <div class="faq__list">
<?php foreach ($faq as $item): ?>
                    <details class="faq__item">
                        <summary class="faq__q"><span><?= e($item['q']) ?></span><?= icon('chevron-down', 'faq__chevron') ?></summary>
                        <div class="faq__a"><p><?= inline_links_html($item['a']) ?></p></div>
                    </details>
<?php endforeach; ?>
                </div>
            </div>
        </section>
