/**
 * Login with OTP — account modal
 *
 * Values ported 1:1 from paramount-login-modal-preview.html.
 *
 * Everything is scoped to .otpl-modal; nothing here styles bare body/button/
 * input/a/h1 selectors. The only global rule is the scroll-lock class.
 *
 * Two defensive techniques against the storefront theme, which overrides form
 * controls hard enough to have collapsed the remember-me checkbox in v1.70:
 *   1. A scoped `all: revert` reset (section 3) drops theme declarations back to
 *      the user-agent baseline inside the modal only.
 *   2. `!important` on the specific control properties themes reach for
 *      (height/padding/font-size/border/background/appearance). Kept to the
 *      controls — layout, spacing and colour rules below are plain.
 */

/* ── 1. Scroll lock ─────────────────────────────────────────────────────── */

html.otpl-modal-open,
body.otpl-modal-open {
    overflow: hidden;
}

/* ── 2. Dialog shell ────────────────────────────────────────────────────── */

/* The card surface and its typography, shared by the dialog and the embedded
   [otp_login_form] copy so the two cannot drift. Both selectors are 0,1,1, so
   splitting this out costs no specificity against the theme. */
dialog.otpl-modal,
div.otpl-modal {
    border: 1px solid #e2e6ed;
    padding: 0;
    background: #fff;
    color: #1b1d1f;
    border-radius: 18px;
    box-shadow: 0 30px 110px #08142755;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    font-weight: 400;
    /* `normal`, not a ratio — the reference sets no body line-height, and a
       ratio here compounds into several px of drift down the card. */
    line-height: normal;
    letter-spacing: normal;
    text-align: left;
    text-transform: none;
}

/* Modal-only geometry: viewport-bound, scrolls internally, centred by the
   dialog's own layout. */
dialog.otpl-modal {
    width: 500px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    overflow: auto;
    overscroll-behavior: contain;
    margin: auto;
}

/* Embedded copy: flows with the page, no overlay, no internal scroller. */
.otpl-embed {
    display: block;
    width: 100%;
}

div.otpl-modal.otpl-modal--inline {
    position: static;
    width: 100%;
    max-width: var(--otpl-embed-width, 500px);
    max-height: none;
    overflow: visible;
    margin: 0 auto;
}

.otpl-embed--left > .otpl-modal--inline {
    margin-left: 0;
    margin-right: auto;
}

.otpl-embed--right > .otpl-modal--inline {
    margin-left: auto;
    margin-right: 0;
}

/* Nothing scrolls inside an embedded card, so the header does not stick. */
.otpl-modal--inline .otpl-top {
    position: static;
}

/* No logo bar: the body would otherwise start 4px from the card edge. Specificity
   raised so this beats .otpl-modal .otpl-body regardless of source order. */
div.otpl-modal.otpl-modal--nologo .otpl-body {
    padding-top: 32px;
}

dialog.otpl-modal::backdrop {
    background: rgba(15, 23, 34, .57);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

dialog.otpl-modal:not([open]) {
    display: none;
}

/* Fallback for browsers without <dialog> — JS adds .otpl-modal--fallback. */
dialog.otpl-modal.otpl-modal--fallback {
    display: block;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100000;
}

.otpl-backdrop--fallback {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 34, .57);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    z-index: 99999;
}

.otpl-modal[hidden] {
    display: none !important;
}

/* ── 3. Scoped reset ────────────────────────────────────────────────────── */
/* `all: revert` rolls these back to the user-agent sheet inside the modal, so
   theme declarations stop applying. Must come before every design rule. */

.otpl-modal h1,
.otpl-modal h2,
.otpl-modal p,
.otpl-modal label,
.otpl-modal span,
.otpl-modal div,
.otpl-modal form,
.otpl-modal section,
.otpl-modal input,
.otpl-modal button,
.otpl-modal a,
.otpl-modal img,
.otpl-modal strong {
    all: revert;
}

/* Must outrank the `all: revert` above, which would otherwise restore the UA's
   content-box and push every full-width control 32px past the modal edge.
   A universal selector inside .otpl-modal is only 0,1,0 — lower than the reset's
   0,1,1 — so this one property is forced. */
.otpl-modal,
.otpl-modal *,
.otpl-modal *::before,
.otpl-modal *::after {
    box-sizing: border-box !important;
}

.otpl-modal svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: block;
    flex-shrink: 0;
}

.otpl-modal a {
    color: #3e63af;
    text-decoration: none;
}

.otpl-modal a:hover {
    text-decoration: underline;
}

.otpl-modal button:focus-visible,
.otpl-modal a:focus-visible {
    outline: 3px solid #a9bfe8;
    outline-offset: 4px;
}

.otpl-modal button:disabled {
    opacity: .55;
    cursor: default;
}

/* ── 4. Sticky header: logo + close ─────────────────────────────────────── */

.otpl-modal .otpl-top {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
    padding: 25px 27px 20px 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-radius: 18px 18px 0 0;
}

.otpl-modal .otpl-logo {
    width: 204px;
    max-width: calc(100% - 58px);
    height: auto;
    display: block;
    margin: 0;
}

.otpl-modal .otpl-close {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e4e8ee !important;
    background: #f7f9fc !important;
    color: #637085;
    border-radius: 50% !important;
    font-family: inherit;
    font-size: 25px !important;
    font-weight: 300;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    padding: 0 !important;
    margin: 0;
    cursor: pointer;
    box-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
}

.otpl-modal .otpl-close:hover {
    background: #eaf0f9 !important;
    color: #3e63af;
}

/* ── 5. Body ────────────────────────────────────────────────────────────── */

.otpl-modal .otpl-body {
    padding: 4px 36px 30px;
    width: 100%;
    max-width: none;
}

/* ── 6. Tabs ────────────────────────────────────────────────────────────── */

.otpl-modal .otpl-tabs {
    display: flex;
    border-bottom: 1px solid #dce2eb;
    margin: 0 0 27px;
    padding: 0;
    gap: 29px;
}

.otpl-modal .otpl-tab {
    background: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 2px 15px !important;
    margin: 0;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    color: #697180;
    font-family: inherit;
    font-size: 14px !important;
    font-weight: 400;
    line-height: normal;
    letter-spacing: normal;
    text-transform: none;
    position: relative;
    cursor: pointer;
    box-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
}

.otpl-modal .otpl-tab[aria-selected="true"] {
    color: #3e63af;
    font-weight: 700;
}

.otpl-modal .otpl-tab[aria-selected="true"]::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 3px;
    background: #3e63af;
}

/* ── 7. Typography ──────────────────────────────────────────────────────── */

.otpl-modal .otpl-h1 {
    font-family: inherit;
    font-size: 30px;
    font-weight: 600;
    line-height: normal;
    letter-spacing: -1px;
    text-transform: none;
    color: #1b1d1f;
    margin: 0 0 12px;
    padding: 0;
    outline: none;
}

.otpl-modal .otpl-sub {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.7;
    color: #626b79;
    margin: 0 0 24px;
    padding: 0;
}

.otpl-modal .otpl-sub strong {
    font-weight: 700;
    color: #1b1d1f;
}

.otpl-modal .otpl-hint {
    text-align: center;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.6;
    color: #737c89;
    margin: 12px 0 0;
    padding: 0;
}

.otpl-modal .otpl-hint--left {
    text-align: left;
    margin: -7px 0 22px;
}

/* ── 8. Fields ──────────────────────────────────────────────────────────── */

.otpl-modal .otpl-field {
    margin: 0 0 18px;
}

.otpl-modal .otpl-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    line-height: normal;
    letter-spacing: normal;
    text-transform: none;
    color: #1b1d1f;
    margin: 0 0 9px;
    padding: 0;
}

.otpl-modal .otpl-input {
    width: 100% !important;
    height: 52px !important;
    min-height: 52px !important;
    padding: 0 15px !important;
    margin: 0 !important;
    display: block;
    background: #fff !important;
    color: #1b1d1f !important;
    border: 1px solid #bfc8d5 !important;
    border-radius: 7px !important;
    outline: none;
    font-family: inherit;
    font-size: 16px !important;
    font-weight: 400;
    line-height: normal;
    letter-spacing: normal;
    text-transform: none;
    box-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
}

.otpl-modal .otpl-input::placeholder {
    color: #8b929d;
    opacity: 1;
    letter-spacing: normal;
}

/* "Optional" / "Required for SMS updates" beside a field label. Floated rather
   than flexed so the label's own box model — and the measured 1:1 match with the
   reference — is untouched. */
.otpl-modal .otpl-label-note {
    float: right;
    font-size: 12px;
    font-weight: 400;
    color: #8b929d;
    letter-spacing: normal;
}

.otpl-modal .otpl-label-note--required {
    color: #3e63af;
}

/* Inline validation. Doubled class so the invalid state still reads as invalid
   while focused — a single class ties with .otpl-input:focus, which is declared
   later and would otherwise repaint the border blue. */
.otpl-modal .otpl-input.otpl-input--error {
    border-color: #c9484c !important;
}

.otpl-modal .otpl-input.otpl-input--error:focus {
    border-color: #c9484c !important;
    box-shadow: 0 0 0 3px rgba(201, 72, 76, .14) !important;
}

.otpl-modal .otpl-input:focus {
    border-color: #3e63af !important;
    box-shadow: 0 0 0 3px #3e63af16 !important;
}

.otpl-modal .otpl-input:focus-visible {
    outline: none;
}

.otpl-modal .otpl-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Verification code — single input, matches the reference treatment. */
.otpl-modal .otpl-code {
    letter-spacing: 12px !important;
    font-size: 24px !important;
    text-align: center;
    font-variant-numeric: tabular-nums;
    /* letter-spacing adds a trailing gap after the last digit; trimming the
       right padding keeps the digits optically centred. */
    padding-left: 15px !important;
    padding-right: 3px !important;
}

/* Password field with Show/Hide */
.otpl-modal .otpl-password {
    position: relative;
}

.otpl-modal .otpl-password .otpl-input {
    padding-right: 70px !important;
}

.otpl-modal .otpl-show {
    position: absolute;
    right: 8px;
    top: 6px;
    height: 40px !important;
    min-height: 0 !important;
    width: auto !important;
    padding: 0 12px !important;
    margin: 0;
    border: 0 !important;
    border-radius: 6px !important;
    background: transparent !important;
    color: #3e63af;
    font-family: inherit;
    font-size: 12px !important;
    font-weight: 400;
    letter-spacing: normal;
    text-transform: none;
    cursor: pointer;
    box-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
}

/* ── 9. Checkbox ────────────────────────────────────────────────────────── */
/* Drawn here rather than relying on accent-color: the theme applies
   appearance:none to checkboxes, which collapses a native box to a grey dash.
   Tick is a background image — pseudo-elements on <input> are unreliable. */

.otpl-modal .otpl-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: #505966;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.7;
    margin: 0 0 21px;
    cursor: pointer;
}

.otpl-modal .otpl-check a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* The consent labels are long sentences: let them wrap and shrink rather than
   push the card wide on a narrow phone. */
.otpl-modal .otpl-check > span {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: break-word;
}

/* Marketing pair sits tighter than a standalone check, with normal spacing
   restored after the last one. */
.otpl-modal .otpl-check--consent {
    margin-bottom: 14px;
}

.otpl-modal .otpl-check--consent:last-of-type {
    margin-bottom: 21px;
}

.otpl-modal .otpl-check input[type="checkbox"] {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    flex: 0 0 17px;
    width: 17px !important;
    height: 17px !important;
    min-width: 17px !important;
    max-width: 17px !important;
    min-height: 17px !important;
    max-height: 17px !important;
    margin: 1px 0 0 !important;
    padding: 0 !important;
    border: 1px solid #bfc8d5 !important;
    border-radius: 4px !important;
    background: #fff !important;
    box-shadow: none !important;
    display: inline-block;
    vertical-align: top;
    cursor: pointer;
    transition: background-color .15s, border-color .15s;
}

.otpl-modal .otpl-check input[type="checkbox"]:checked {
    background: #3e63af url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-6'/%3E%3C/svg%3E") center center / 12px 12px no-repeat !important;
    border-color: #3e63af !important;
}

.otpl-modal .otpl-check input[type="checkbox"]:focus-visible {
    outline: 3px solid #a9bfe8;
    outline-offset: 2px;
}

/* reCAPTCHA host (password sign-in only). The v2 widget is a fixed 304px, which
   fits the 426px content column and the 318px mobile one; on anything narrower
   it scrolls rather than forcing the card wide. */
.otpl-modal .otpl-recaptcha {
    margin: 0 0 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    /* min-height, not height: a v2 checkbox widget is 78px and a fixed 65 would
       clip it. This lifts the shorter invisible/v3 badge to 65 without capping
       anything taller. */
    min-height: 65px;
    max-width: 100%;
    overflow-x: auto;
}

.otpl-modal .otpl-recaptcha:empty {
    display: none;
}

/* ── 10. Buttons ────────────────────────────────────────────────────────── */

.otpl-modal .otpl-primary,
.otpl-modal .otpl-secondary {
    width: 100% !important;
    min-height: 52px !important;
    height: auto !important;
    padding: 12px 18px !important;
    margin: 0;
    border-radius: 7px !important;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    font-family: inherit;
    font-size: 14px !important;
    font-weight: 600;
    line-height: normal;
    letter-spacing: normal;
    text-transform: none;
    text-decoration: none;
    cursor: pointer;
    box-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
    transition: background-color .18s, color .18s, border-color .18s;
}

.otpl-modal .otpl-primary {
    color: #fff !important;
    background: #3e63af !important;
    border: 1px solid #3e63af !important;
}

.otpl-modal .otpl-primary:hover:not(:disabled) {
    background: #315297 !important;
    border-color: #315297 !important;
    color: #fff !important;
}

.otpl-modal .otpl-secondary {
    background: #fff !important;
    border: 1px solid #cbd3df !important;
    color: #35445b !important;
}

.otpl-modal .otpl-secondary:hover:not(:disabled) {
    background: #f3f6fa !important;
    border-color: #3e63af !important;
    color: #35445b !important;
}

.otpl-modal .otpl-arrow {
    font-size: 15px;
    line-height: 1;
}

.otpl-modal .otpl-textbtn {
    border: 0 !important;
    border-radius: 0 !important;
    background: none !important;
    color: #3e63af;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 10px 0 !important;
    margin: 0;
    font-family: inherit;
    font-size: 12px !important;
    font-weight: 400;
    letter-spacing: normal;
    text-transform: none;
    cursor: pointer;
    box-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
}

.otpl-modal .otpl-textbtn:hover:not(:disabled) {
    text-decoration: underline;
}

.otpl-modal .otpl-textbtn--block {
    display: block;
    margin: 4px auto;
}

/* Sits inside a sentence — no vertical padding, or it inflates the line box.
   A modifier rather than an inline style, which the !important above outranks. */
.otpl-modal .otpl-textbtn--inline {
    padding: 0 5px !important;
}

.otpl-modal .otpl-forgot {
    display: block;
    margin: -12px 0 14px auto;
}

/* ── 11. Divider, terms, support ────────────────────────────────────────── */

.otpl-modal .otpl-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    color: #8a929d;
    font-size: 11px;
    line-height: normal;
    margin: 20px 0;
}

.otpl-modal .otpl-divider::before,
.otpl-modal .otpl-divider::after {
    content: "";
    height: 1px;
    background: #e5e9ef;
    flex: 1;
}

.otpl-modal .otpl-terms {
    font-size: 11px;
    font-weight: 400;
    line-height: 1.8;
    color: #77808c;
    margin: 20px 0 0;
    padding: 0;
}

.otpl-modal .otpl-terms a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.otpl-modal .otpl-support {
    margin: 23px 0 0;
    padding: 19px 0 0;
    border-top: 1px solid #e9edf2;
    font-size: 12px;
    line-height: normal;
    color: #6f7885;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.otpl-modal .otpl-support svg {
    width: 16px;
    height: 16px;
}

.otpl-modal .otpl-support a {
    font-weight: 600;
}

/* ── 12. Notices ────────────────────────────────────────────────────────── */

.otpl-modal .otpl-mailicon {
    width: 52px;
    height: 52px;
    background: #eef3fc;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3e63af;
    margin: 0 0 22px;
}

.otpl-modal .otpl-notice {
    padding: 14px;
    background: #eef3fc;
    color: #325285;
    border: 1px solid #d4dff1;
    border-radius: 7px;
    margin: 15px 0 0;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.6;
}

.otpl-modal .otpl-notice--error {
    background: #fdf2f2;
    color: #8c2b2b;
    border-color: #f1d5d5;
}

.otpl-modal .otpl-notice--ok {
    background: #eff7f0;
    color: #29613a;
    border-color: #cfe6d5;
}

.otpl-modal .otpl-status:empty {
    display: none;
}

/* ── 13. Mobile / short screens ─────────────────────────────────────────── */

@media (max-width: 720px) {
    dialog.otpl-modal {
        max-width: calc(100vw - 24px);
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        border-radius: 14px;
    }

    div.otpl-modal.otpl-modal--inline {
        border-radius: 14px;
    }

    div.otpl-modal.otpl-modal--nologo .otpl-body {
        padding-top: 26px;
    }

    .otpl-modal .otpl-top {
        padding: 20px 20px 16px 24px;
        border-radius: 14px 14px 0 0;
    }

    .otpl-modal .otpl-logo {
        width: 190px;
    }

    .otpl-modal .otpl-body {
        padding: 5px 24px 24px;
    }

    .otpl-modal .otpl-h1 {
        font-size: 28px;
    }

    .otpl-modal .otpl-tabs {
        margin-bottom: 24px;
    }

    .otpl-modal .otpl-row {
        gap: 12px;
    }
}

/* Short landscape — keep the header compact so fields stay reachable. */
@media (max-height: 520px) and (orientation: landscape) {
    .otpl-modal .otpl-top {
        padding-top: 16px;
        padding-bottom: 12px;
    }

    .otpl-modal .otpl-logo {
        width: 170px;
    }

    .otpl-modal .otpl-h1 {
        font-size: 24px;
    }

    .otpl-modal .otpl-tabs {
        margin-bottom: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .otpl-modal * {
        transition: none !important;
    }
}
