/* Six-box one-time-code entry (Phase 6). Paired with Scripts/airtime.otpinput.js. */

.otp-input {
    display: flex;
    justify-content: center;
    direction: ltr;
    width: 100%;
    /* flex-wrap is what stops this row blowing out the page on phones. body is
       display:grid and #content is a grid item, so the grid track is sized to the
       item's min-content width. A nowrap flex row reports the SUM of its items'
       min-content contributions, and each box contributes its max-width - about
       376px for six boxes, which forced ~86px of horizontal overflow at 360px wide.
       Allowing wrap drops the reported minimum to a single box (62px). The boxes
       still never actually wrap, because min-width:0 lets them shrink to fit. */
    flex-wrap: wrap;
}

/* SetupMfa step sections: each step owns the content it refers to. */
.mfa-step {
    margin-bottom: 18px;
}

/* Step 3's text doubles as the label for the code field, so override Bootstrap's
   bold label weight and let the <strong> supply the emphasis, matching steps 1 and 2. */
.mfa-step__label {
    display: block;
    font-weight: normal;
    margin-bottom: 10px;
}

/* Never let the QR force the page wider than a narrow phone. */
.mfa-qr {
    width: 180px;
    max-width: 100%;
    height: auto;
}

/* The manual key is a single 32-character token with no spaces, so it has to be
   allowed to break or it sets a minimum width wider than a phone screen. */
.mfa-secret {
    display: inline-block;
    max-width: 100%;
    min-width: 0;
    white-space: normal;
    word-break: break-all;
}

/* Flex keeps the copy button on the same line as the key: the key can wrap or shrink
   inside its own cell without pushing the button onto a line of its own. */
.mfa-secret-row {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hidden until the script confirms clipboard.js is present, so it is never shown
   in a state where clicking it would do nothing. */
.mfa-copy {
    display: none;
    margin-left: 6px;
    flex: 0 0 auto;
}

.mfa-expiry {
    font-size: 12px;
    margin-top: 6px;
    margin-bottom: 12px;
}

.mfa-help {
    font-size: 12px;
    margin-top: 18px;
    margin-bottom: 4px;
}

.mfa-submit.is-busy {
    cursor: progress;
}

/* A corner-aligned button is an awkward target on a phone. */
@media (max-width: 480px) {
    .mfa-submit {
        display: block;
        width: 100%;
    }
}

/* Prompt sitting directly above the boxes. Also used as the label for the single
   input in the no-JavaScript fallback. */
.otp-input__prompt {
    display: block;
    margin-bottom: 10px;
    text-align: center;
    font-weight: 600;
    color: #555;
}

.otp-input__box {
    flex: 1 1 0;
    min-width: 0;
    max-width: 56px;
    height: 56px;
    margin: 0 4px;
    padding: 0;
    text-align: center;
    font-size: 24px;
    line-height: 1;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #333;
    background-color: #fff;
    border: 2px solid #ccc;
    border-radius: 6px;
    box-shadow: none;
    transition: border-color .12s ease, box-shadow .12s ease;
}

.otp-input__box:first-child { margin-left: 0; }
.otp-input__box:last-child  { margin-right: 0; }

.otp-input__box.is-filled {
    border-color: #999;
}

.otp-input__box:focus {
    outline: none;
    border-color: #5b9dd9;
    box-shadow: 0 0 0 3px rgba(91, 157, 217, .25);
}

.otp-input--error .otp-input__box {
    border-color: #a94442;
}

.otp-input--error .otp-input__box:focus {
    box-shadow: 0 0 0 3px rgba(169, 68, 66, .25);
}

/* The original single input stays in the form so it still posts, but is removed from view. */
.otp-input__source {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 480px) {
    .otp-input__box {
        height: 48px;
        margin: 0 3px;
        font-size: 20px;
    }
}
