<?php
declare(strict_types=1);
$siteName = trim((string) ($site['name'] ?? ''));
if ($siteName === '') {
    $siteName = trim($translator->get('app.name'));
}
?>
<section class="content-section form-section">
    <div class="container narrow-container auth-card">
        <p class="eyebrow"><?= quaeriva_t($translator, 'auth.register') ?></p>
        <h1><?= quaeriva_t($translator, 'auth.register_title', ['site' => $siteName]) ?></h1>
        <p class="section-lede"><?= quaeriva_t($translator, 'auth.register_intro') ?></p>
        <?php if (($error ?? '') !== ''): ?><p class="notice notice-error" role="alert"><?= quaeriva_escape($error) ?></p><?php endif; ?>
        <form class="question-form" method="post" action="<?= quaeriva_escape(quaeriva_url('register')) ?>">
            <input type="hidden" name="_csrf" value="<?= quaeriva_escape($csrfToken) ?>">
            <?= quaeriva_bot_guard_fields() ?>
            <div class="field-group"><label for="register-name"><?= quaeriva_t($translator, 'auth.name') ?></label><input id="register-name" name="name" type="text" required maxlength="100" autocomplete="name" value="<?= quaeriva_escape($values['name'] ?? '') ?>"></div>
            <div class="field-group"><label for="register-email"><?= quaeriva_t($translator, 'auth.email') ?></label><input id="register-email" name="email" type="email" required autocomplete="email" value="<?= quaeriva_escape($values['email'] ?? '') ?>"></div>
            <div class="field-group"><label for="register-password"><?= quaeriva_t($translator, 'auth.password') ?></label><input id="register-password" name="password" type="password" required minlength="8" autocomplete="new-password"></div>
            <?= quaeriva_turnstile_widget($site) ?>
            <button class="button" type="submit"><?= quaeriva_t($translator, 'auth.register') ?></button>
        </form>
        <div class="auth-links"><a href="<?= quaeriva_escape(quaeriva_url('login')) ?>"><?= quaeriva_t($translator, 'auth.have_account') ?></a></div>
    </div>
</section>
