<?php
declare(strict_types=1);
$values = is_array($values ?? null) ? $values : [];
?>
<section class="content-section form-section">
    <div class="container narrow-container">
        <p class="eyebrow"><?= quaeriva_t($translator, 'contact.eyebrow') ?></p>
        <h1><?= quaeriva_t($translator, 'contact.title') ?></h1>
        <p class="section-lede"><?= quaeriva_t($translator, 'contact.intro') ?></p>
        <?php if (($error ?? '') !== ''): ?><div class="notice notice-error" role="alert"><?= quaeriva_escape($error) ?></div><?php endif; ?>
        <?php if (isset($_GET['sent'])): ?><div class="notice" role="status"><?= quaeriva_t($translator, 'contact.success') ?></div><?php endif; ?>
        <form class="question-form" method="post" action="<?= quaeriva_escape(quaeriva_url('contact')) ?>">
            <input type="hidden" name="_csrf" value="<?= quaeriva_escape($csrfToken ?? '') ?>">
            <?= quaeriva_bot_guard_fields() ?>
            <div class="form-grid-2">
                <div class="field-group"><label for="contact-name"><?= quaeriva_t($translator, 'contact.name') ?></label><input id="contact-name" name="name" required maxlength="120" value="<?= quaeriva_escape($values['name'] ?? '') ?>"></div>
                <div class="field-group"><label for="contact-email"><?= quaeriva_t($translator, 'contact.email') ?></label><input id="contact-email" name="email" type="email" dir="ltr" required maxlength="191" value="<?= quaeriva_escape($values['email'] ?? '') ?>"></div>
            </div>
            <div class="field-group"><label for="contact-subject"><?= quaeriva_t($translator, 'contact.subject') ?></label><input id="contact-subject" name="subject" maxlength="191" dir="auto" value="<?= quaeriva_escape($values['subject'] ?? '') ?>"></div>
            <div class="field-group"><label for="contact-message"><?= quaeriva_t($translator, 'contact.message') ?></label><textarea id="contact-message" name="message" dir="auto" required rows="8" maxlength="5000"><?= quaeriva_escape($values['message'] ?? '') ?></textarea></div>
            <?= quaeriva_turnstile_widget($site ?? null) ?>
            <button class="button" type="submit"><?= quaeriva_t($translator, 'contact.send') ?></button>
        </form>
    </div>
</section>
