/*
 * The payment-method modal.
 *
 * What this replaces: the options were plain radio labels stacked with an mt-2, and the
 * "different number" box was a bare input-group dropped underneath them. Nothing showed which
 * option was selected apart from the small custom radio dot, the fields for the chosen option
 * appeared with no visual connection to the option they belonged to, and on a phone the whole
 * thing ran edge to edge with no breathing room.
 *
 * Scoped to .payment-option / .option-wrapper / .ob-otp-panel so it cannot reach the rest of
 * the storefront, and written to sit on top of the theme rather than fight it -- the accent is
 * taken from --theme-deafult, which is the theme's own variable (spelling included).
 */

:root {
    --ob-pay-accent: var(--theme-deafult, #e2973e);
    --ob-pay-border: #e6e6e6;
    --ob-pay-muted: #6b7280;
    --ob-pay-danger: #f44336;
}

/* ------------------------------------------------------------------ */
/* One option in the list                                             */
/* ------------------------------------------------------------------ */

.payment-option {
    border: 1px solid var(--ob-pay-border);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.payment-option:hover {
    border-color: var(--ob-pay-accent);
}

/* The selected option is outlined, so which one is chosen is obvious at arm's length and not
   only from the small dot. :focus-within keeps it visible for anybody using a keyboard. */
.payment-option:focus-within,
.payment-option.is-selected {
    border-color: var(--ob-pay-accent);
    box-shadow: 0 0 0 1px var(--ob-pay-accent) inset;
    background-color: rgba(226, 151, 62, .04);
}

.payment-option__label {
    display: block;
    margin: 0;
    cursor: pointer;
    font-weight: 500;
    line-height: 1.35;
}

/* ------------------------------------------------------------------ */
/* The fields belonging to the chosen option                          */
/* ------------------------------------------------------------------ */

.payment-option .option-wrapper {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--ob-pay-border);
}

.payment-option .phone-selection .form-check {
    padding: 6px 0;
}

.payment-option .phone-selection .form-check-label {
    cursor: pointer;
}

.payment-option .registered-number {
    font-weight: 600;
    white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* The number field                                                   */
/* ------------------------------------------------------------------ */

.payment-option .input-group > .input-group-text,
.payment-option .input-group > .form-control {
    height: 46px;
}

/* Bootstrap 4 puts the prefix in an .input-group-prepend; some of these markup blocks use a
   bare .input-group-text. Style both so the "+250" never floats away from the box. */
.payment-option .input-group-text {
    background: #f6f6f6;
    border: 1px solid var(--ob-pay-border);
    border-right: 0;
    border-radius: 8px 0 0 8px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    font-weight: 600;
    color: #333;
}

.payment-option .input-group .form-control {
    border: 1px solid var(--ob-pay-border);
    border-radius: 0 8px 8px 0;
    font-size: 16px;              /* 16px stops iOS zooming the page on focus */
    letter-spacing: .04em;
}

.payment-option .input-group .form-control:focus {
    border-color: var(--ob-pay-accent);
    box-shadow: 0 0 0 .18rem rgba(226, 151, 62, .22);
    z-index: 2;
}

.payment-option .form-control.is-invalid {
    border-color: var(--ob-pay-danger);
}

.payment-option .form-control.is-valid {
    border-color: #2e7d32;
}

/* Hidden by default and revealed by JavaScript. The theme's own rule only reveals a message
   that is a sibling of the input, which it is not once the input sits inside an input-group --
   so the rule never matched and the message could never be seen. */
.payment-option .invalid-feedback {
    display: none;
    color: var(--ob-pay-danger);
    font-size: 13px;
    margin-top: 6px;
    padding: 0;
    font-weight: 500;
}

.payment-option .form-text {
    font-size: 12.5px;
    color: var(--ob-pay-muted);
    margin-top: 6px;
}

/* ------------------------------------------------------------------ */
/* Confirm-your-number panel                                          */
/* ------------------------------------------------------------------ */

.ob-otp-panel {
    border: 1px solid var(--ob-pay-border);
    border-left: 3px solid var(--ob-pay-accent);
    border-radius: 8px;
    background: #fcfbf9;
    padding: 12px 14px;
}

.ob-otp-panel .ob-otp-code {
    letter-spacing: .5em;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    height: 46px;
}

.ob-otp-panel .ob-otp-done {
    font-weight: 600;
}

.ob-otp-panel .ob-otp-message:empty {
    display: none;
}

/* ------------------------------------------------------------------ */
/* Buttons that are working                                           */
/* ------------------------------------------------------------------ */

.btn.is-busy {
    cursor: progress;
    opacity: .85;
}

.btn.is-busy .spinner-border {
    vertical-align: -0.125em;
}

/* Bootstrap 4.0 shipped without .spinner-border. Defined here so the loader still spins on a
   theme pinned to an older build rather than showing an empty box. */
@supports (animation: spin 1s linear infinite) {
    .btn.is-busy .spinner-border {
        display: inline-block;
        width: 1rem;
        height: 1rem;
        border: .17em solid currentColor;
        border-right-color: transparent;
        border-radius: 50%;
        animation: ob-btn-spin .75s linear infinite;
    }
}

@keyframes ob-btn-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .btn.is-busy .spinner-border {
        animation-duration: 2s;
    }
}

/* ------------------------------------------------------------------ */
/* Small screens                                                      */
/* ------------------------------------------------------------------ */

@media (max-width: 575.98px) {
    .payment-option {
        padding: 10px 12px;
    }

    .payment-option .input-group > .input-group-text,
    .payment-option .input-group > .form-control {
        height: 44px;
    }

    .ob-otp-panel .ob-otp-code {
        letter-spacing: .35em;
    }
}
