/* One-time code input: six boxes that behave like one field, for sign-in codes and (in time)
 * guest passcodes. The boxes are Shared/FormControl's .form-control, so they take the
 * field's border, focus and error state; this sheet only lays them out and sets the code
 * font. Needs a .sw-form-vertical ancestor, like any Form row field.
 *
 * Markup:
 *   .sw-code-field                 the boxes and their message share one width
 *     .sw-code-input  role=group   six input.form-control, a .sw-code-input__dash after the third
 *     .alert / .field-validation-error   the message, at the boxes' width
 *
 * A wrong code marks each box .input-validation-error with aria-invalid="true". */

.sw-code-field {
    /* The box size: 48px, enough to tap and to read a 20px digit. */
    --sw-code-box: 3rem;
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
}

/* The message takes the boxes' width and wraps inside it, rather than widening the field
 * to the length of its sentence. */
.sw-code-field > :not(.sw-code-input) {
    width: 0;
    min-width: 100%;
}

.sw-code-input {
    display: flex;
    justify-content: center;
    gap: var(--sw-space-2);
}

.sw-form-vertical .sw-code-input .form-control {
    flex: 1 1 0;
    min-width: 0;
    max-width: var(--sw-code-box);
    height: var(--sw-code-box);
    padding: 0;
    text-align: center;
    /* !important only because a tenant with its own font gets Theme.cshtml's
     * "input, textarea, button, select { font-family: ... !important }", which would put the
     * digits back in a proportional face. */
    font-family: var(--sw-font-family-code) !important;
    font-size: var(--sw-font-size-xl);
    font-weight: var(--sw-font-weight-bold);
}

/* Reads as two halves, like the email's "482 916". Decorative (aria-hidden); paste strips a
 * typed dash anyway. */
.sw-code-input__dash {
    flex: none;
    align-self: center;
    width: var(--sw-space-2);
    height: 0.125rem;
    background: var(--sw-border-strong);
    border-radius: var(--sw-radius-sm);
}
