/* ==========================================
   Shared Auth Page Styles
   Used by: login (sign-in and the two-factor code step), signup,
   verify, resend-verification, forgot-password, reset-password.

   The shell, card, fields, buttons, switches, alerts and links are the
   shared components in includes/styles.css; this file only places
   them. Page template:

     <div class="page-shell page-shell--form auth-shell">
       <div class="auth-card surface-panel is-reading">
         <div class="auth-header">
           <div class="auth-icon icon-tile icon-tile--lg" aria-hidden="true">
             <i class="ti ti-key"></i></div>
           <h1 class="auth-title">Forgot Password</h1>
           <p class="auth-lead">One short line.</p>
         </div>
         .alert-danger role="alert" tabindex="-1" (focused on load)
         <form> .form-label + .form-control (autocomplete set),
           .form-check.form-switch, a full-width .btn-primary.btn-lg </form>
         <div class="auth-footer"> .text-link or .btn-ghost </div>
       </div>
     </div>

   No unscoped .form-control, .form-label or .alert rules belong here.
   ========================================== */

/* Shell: .page-shell--form is the 600px column with the responsive
   gutter (1rem on phones). Above 600px auth pages sit 4rem lower. */
@media (min-width: 601px) {
    .auth-shell {
        padding-block: var(--space-16);
    }
}

/* Header: icon tile, the page's h1, one lead line */
.auth-header {
    margin-bottom: var(--space-8);
    text-align: center;
}

.auth-icon {
    display: flex;
    margin: 0 auto var(--space-4);
}

/* .is-success comes from .icon-tile; .is-error is the failure tone. */
.auth-icon.is-error {
    background: var(--danger-tint);
    color: var(--danger-text);
}

.auth-title {
    margin: 0 0 var(--space-2);
    color: var(--text-primary);
    font-size: var(--fs-page-title);
    text-wrap: balance;
}

.auth-lead {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--fs-lead);
    line-height: 1.5;
    text-wrap: balance;
    /* A long email address in the lead wraps inside the card. */
    overflow-wrap: anywhere;
}

/* Fields: the shared recipe at the large control height, so a field
   lines up with the .btn-lg submit. */
.auth-card .form-control {
    padding: 0.625rem 0.875rem;
}

.auth-card .form-select {
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
}

/* A field the server rejected: aria-invalid on the field, the message
   in an .invalid-feedback line under it (Bootstrap only shows that
   line beside .is-invalid, whose icon and colours are its own reds). */
.auth-card .form-control[aria-invalid="true"],
.auth-card .form-select[aria-invalid="true"] {
    border-color: var(--danger-text);
}

.auth-card .invalid-feedback {
    display: block;
    color: var(--danger-text);
    font-size: var(--fs-sm);
    font-weight: 600;
}

/* Password field with the show/hide .icon-btn inside its right edge */
.auth-password {
    position: relative;
}

.auth-card .auth-password .form-control {
    padding-right: 3.25rem;
}

.auth-password .icon-btn {
    position: absolute;
    top: 50%;
    right: 0.25rem;
    transform: translateY(-50%);
}

/* Two-factor code: large, spaced, centred digits (two classes, so the
   phone rule that sets fields to 16px does not shrink it). */
.auth-card .auth-code-input {
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.2em;
    text-align: center;
}

/* The switch row above the submit (remember me / trust this device),
   with "Forgot password?" on the right when there is room. */
.auth-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-3);
    margin-bottom: var(--space-6);
    font-size: var(--fs-body-sm);
}

.auth-options .form-check {
    margin-bottom: 0;
}

/* A submit error is focused on load so it is announced; the alert's
   own frame marks it, so the browser ring is not drawn. */
.auth-card .alert[tabindex="-1"]:focus {
    outline: none;
}

/* Secondary row under the form: one line of text with a .text-link,
   or (two-factor step) .btn-ghost actions at either end. */
.auth-footer {
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border-soft);
    color: var(--text-secondary);
    text-align: center;
}

.auth-footer > :last-child {
    margin-bottom: 0;
}

.auth-footer-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-2);
}

.auth-footer-actions form {
    margin: 0;
}

/* Resend code stays at the right edge when a narrow phone wraps it. */
.auth-footer-actions > :last-child {
    margin-inline-start: auto;
}

/* A failed sign-in shakes the card once (not under reduced motion). */
@media (prefers-reduced-motion: no-preference) {
    .auth-card.shake {
        animation: auth-shake 0.5s ease-in-out;
    }
}

@keyframes auth-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}
