/* Code typed one character per box (Components/Account/Shared/CodeBoxes.razor), the same look as the verification boxes
   of WebbuilderWeb's VerifyOTP page. */

/* One equal column per box, whatever the code length */
.cbx {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 10px;
}

.cbx-box {
    width: 100%;
    aspect-ratio: 1;
    min-width: 0;
    padding: 0;
    border: 1px solid var(--app-field-line);
    border-radius: 14px;
    background: var(--app-field-bg);
    font-family: inherit;
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
    color: var(--app-text-strong);
    caret-color: var(--app-accent);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, transform 0.25s var(--app-ease-out);
}

.cbx-box::placeholder {
    color: var(--app-placeholder);
    opacity: 1;
}

.cbx-box:focus {
    border-color: var(--app-accent);
    background: var(--app-field-bg-focus);
    box-shadow: var(--app-field-focus);
    transform: translateY(-2px);
}

/* A typed character pops in */
.cbx-box:not(:placeholder-shown) {
    border-color: rgba(118, 61, 232, 0.45);
    animation: cbx-pop 0.35s var(--app-ease-spring);
}

/* A refused code: red boxes that shake once */
.cbx-invalid .cbx-box {
    border-color: var(--app-danger);
    background: var(--app-danger-soft);
}

.cbx-invalid {
    animation: cbx-shake 0.4s var(--app-ease-out);
}

@keyframes cbx-pop {
    from {
        transform: scale(0.86);
    }

    to {
        transform: none;
    }
}

@keyframes cbx-shake {
    20%,
    60% {
        transform: translateX(-6px);
    }

    40%,
    80% {
        transform: translateX(6px);
    }
}

/* Eight boxes (the activation code) on a narrow phone */
@media (max-width: 575.98px) {
    .cbx {
        gap: 7px;
    }

    .cbx-box {
        border-radius: 12px;
        font-size: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cbx,
    .cbx-box,
    .cbx-box:not(:placeholder-shown) {
        animation: none;
        transition: none;
    }
}
