/**
 * UX2 code field (appjs/common/ux2/codeBoxes.js): <input data-code-boxes> drawn as six boxes, 3 + 3.
 * One transparent input over the boxes, so paste and one-time-code autofill work. The look of the reset-password
 * page's code (assets/luxfp.css), in the UX2 tokens. Loaded on every UX2 page (engine/ux2.php); pages don't restyle it.
 */
.ux2-code {
    position: relative;
    display: flex;
    gap: 10px;
    align-items: center;
    max-width: 420px;
}

.ux2-code-input {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    font-size: 16px; /* 16px: no zoom on iOS */
    color: transparent;
    text-indent: -9999px;
    letter-spacing: 0;
    caret-color: transparent;
    background: transparent;
    border: 0;
    outline: none;
}

.ux2-code-input::selection {
    background: transparent;
}

.ux2-code-input[readonly] {
    cursor: progress;
}

.ux2-code-box {
    display: inline-flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 56px;
    font-family: var(--ux2-font-mono, 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: 24px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--ux2k-ink, #181c32);
    background: #fff;
    border: 1px solid var(--ux2k-line, #e4e7ec);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.ux2-code-gap {
    flex: none;
    width: 10px;
    height: 2px;
    background: #c9d1d2;
    border-radius: 1px;
}

.ux2-code-box.is-filled {
    border-color: #b9cfd1;
}

.ux2-code.is-focused .ux2-code-box.is-active {
    border-color: var(--ux2k-brand, var(--sko-primary, #1e5f69));
    box-shadow: 0 0 0 4px var(--ux2k-ring, rgba(30, 95, 105, .2));
}

.ux2-code.is-focused .ux2-code-box.is-active:empty::after {
    width: 2px;
    height: 24px;
    content: "";
    background: var(--ux2k-brand, var(--sko-primary, #1e5f69));
    animation: ux2-code-blink 1s steps(1) infinite;
}

.ux2-code.is-error .ux2-code-box {
    border-color: var(--ux2k-red, #c62828);
}

.ux2-code.is-done .ux2-code-box {
    color: var(--ux2k-green, #147a4b);
    border-color: var(--ux2k-green, #147a4b);
}

.ux2-code.is-shake {
    animation: ux2-code-shake .4s ease;
}

@keyframes ux2-code-shake {
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

@keyframes ux2-code-blink {
    50% { opacity: 0; }
}

@media (max-width: 420px) {
    .ux2-code {
        gap: 6px;
    }

    .ux2-code-box {
        height: 50px;
        font-size: 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ux2-code.is-shake,
    .ux2-code.is-focused .ux2-code-box.is-active:empty::after {
        animation: none;
    }
}
