/*
 * Signup, step 2: the 3D card.
 *
 * The number, expiry and CVC are Stripe Elements - iframes that belong to Stripe, so the digits never touch this page.
 * They are drawn ON the card face (transparent, white, monospace), which is what makes the card look like it is being
 * written on. The cardholder name is an ordinary input styled the same way and is the only field we can read.
 *
 * Rules that keep it working (each one cost a browser to find out):
 *  - Never preserve-3d / backface-visibility on anything that contains an iframe: Safari paints the iframe through the
 *    other face. The flip is therefore two phases (turn to edge-on, swap faces, turn back) on a flat element.
 *  - The inactive face is hidden with opacity + pointer-events, NOT display / visibility: a hidden iframe cannot be
 *    focused, and the CVC lives on the back face while the card is still facing front.
 *  - The card is a physical object: it stays left-to-right in right-to-left pages.
 */

/* Self-hosted (OFL): the page's CSP does not allow Google Fonts inside Stripe's frames, and it keeps visitors' IPs off Google. */
@font-face {
    font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap;
    src: url('../../fonts/ibm-plex-mono-500-latin.woff2') format('woff2');
}

@property --sc-a    { syntax: '<color>';      inherits: true; initial-value: #1a0a38; }
@property --sc-b    { syntax: '<color>';      inherits: true; initial-value: #3d1b86; }
@property --sc-glow { syntax: '<color>';      inherits: true; initial-value: rgba(168, 85, 247, .5); }
@property --sc-sx   { syntax: '<percentage>'; inherits: true; initial-value: 30%; }

.sc { font-family: var(--px-font, 'Plus Jakarta Sans', sans-serif); color: #111827; }
.sc[hidden] { display: none; }

/* ── heading block ─────────────────────────────────────────────── */
.sc-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: clamp(4px, 1vh, 10px); }
.sc-back {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 2px; margin-inline-start: -2px;
    background: none; border: 0; border-radius: 8px; cursor: pointer;
    font: 600 13px/1 var(--px-font, 'Plus Jakarta Sans', sans-serif); color: #6b7280;
    transition: color .15s ease;
}
.sc-back:hover, .sc-back:focus-visible { color: var(--px-purple, #7c3aed); }
.sc-back:focus-visible { outline: 2px solid var(--px-purple, #7c3aed); outline-offset: 2px; }
.sc-back svg { width: 14px; height: 14px; }
[dir="rtl"] .sc-back svg { transform: scaleX(-1); }
.sc-step { margin: 0; font-size: 12px; font-weight: 600; color: #9ca3af; }
.sc-title { margin: 0 0 4px; font-size: clamp(19px, 3vh, 24px); font-weight: 800; letter-spacing: -.01em; color: #111827; outline: 0; }
.sc-sub { margin: 0 0 clamp(6px, 1.4vh, 14px); font-size: clamp(12px, 1.6vh, 13.5px); line-height: 1.5; color: #6b7280; }

/* ── the card ──────────────────────────────────────────────────── */
.sc-stage { display: flex; justify-content: center; perspective: 1100px; margin: clamp(8px, 1.4vh, 14px) 0 clamp(4px, 1vh, 10px); }
.sc-card {
    --sc-a: #1a0a38; --sc-b: #3d1b86; --sc-glow: rgba(168, 85, 247, .5);
    --ink: #f6f2ff; --mute: rgba(246, 242, 255, .62);
    --w: min(100%, clamp(250px, 44vh, 384px));
    width: var(--w); aspect-ratio: 1.586 / 1; container-type: inline-size; direction: ltr; position: relative;
    transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    transition-property: transform, --sc-a, --sc-b, --sc-glow; transition-duration: .22s, .6s, .6s, .6s; transition-timing-function: ease-out;
    animation: sc-in .8s cubic-bezier(.2, .8, .2, 1) both;
}
.sc-card[data-brand="visa"]       { --sc-a: #0b1f4d; --sc-b: #1d4fb8; --sc-glow: rgba(96, 165, 250, .5); }
.sc-card[data-brand="mastercard"] { --sc-a: #1d1226; --sc-b: #5b2a3c; --sc-glow: rgba(251, 146, 60, .38); }
.sc-card[data-brand="amex"]       { --sc-a: #0a3b44; --sc-b: #1b8a99; --sc-glow: rgba(94, 234, 212, .4); }
.sc-card[data-brand="discover"]   { --sc-a: #2b1708; --sc-b: #b4531a; --sc-glow: rgba(251, 191, 36, .4); }
.sc-card[data-brand="jcb"]        { --sc-a: #0b3b2a; --sc-b: #1a7a52; --sc-glow: rgba(74, 222, 128, .4); }
.sc-card[data-brand="unionpay"]   { --sc-a: #10263a; --sc-b: #8a1f33; --sc-glow: rgba(248, 113, 113, .4); }
.sc-card[data-brand="diners"]     { --sc-a: #1b2430; --sc-b: #4b5d78; --sc-glow: rgba(148, 163, 184, .45); }

@keyframes sc-in {
    from { opacity: 0; transform: translateY(16px) rotateX(16deg) scale(.96); }
    to   { opacity: 1; transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); }
}
@keyframes sc-sweep { from { --sc-sx: -25%; } to { --sc-sx: 125%; } }
@keyframes sc-shake {
    0%, 100% { translate: 0; } 20% { translate: -7px; } 40% { translate: 6px; } 60% { translate: -4px; } 80% { translate: 2px; }
}
.sc-card.is-shaking { animation: sc-shake .42s ease; }

.sc-flip { position: absolute; inset: 0; }
.sc-face {
    position: absolute; inset: 0; overflow: hidden; border-radius: 4.7cqw; color: var(--ink);
    background:
        radial-gradient(120% 95% at 0% 0%, var(--sc-glow) 0%, transparent 58%),
        repeating-radial-gradient(circle at 88% 118%, rgba(255, 255, 255, .055) 0 1px, transparent 1px 6px),
        linear-gradient(135deg, var(--sc-a), var(--sc-b));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .22), inset 0 -1px 0 rgba(0, 0, 0, .35),
        0 1px 2px rgba(20, 8, 44, .4), 0 14px 22px -10px rgba(20, 8, 44, .5), 0 34px 44px -22px rgba(20, 8, 44, .6);
    transition: opacity .12s ease;
}
.sc-back-face { opacity: 0; pointer-events: none; }
.sc-card.is-back .sc-front { opacity: 0; pointer-events: none; }
.sc-card.is-back .sc-back-face { opacity: 1; pointer-events: auto; }

/* light that follows the pointer + a single sweep when the card arrives */
.sc-sheen {
    position: absolute; inset: 0; pointer-events: none; mix-blend-mode: soft-light;
    background: linear-gradient(112deg, transparent calc(var(--sc-sx) - 22%), rgba(255, 255, 255, .5) var(--sc-sx), transparent calc(var(--sc-sx) + 22%));
    animation: sc-sweep 1.4s .25s cubic-bezier(.3, .6, .2, 1) both;
}

/* front */
.sc-front { padding: 6.2cqw 6.4cqw 5.6cqw; display: grid; grid-template-rows: auto 1fr auto; row-gap: 3cqw; }
.sc-chiprow { display: flex; align-items: center; justify-content: space-between; }
.sc-chip { width: 12.4cqw; height: auto; display: block; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.sc-nfc { width: 6.2cqw; height: auto; opacity: .8; }
.sc-lower { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; column-gap: 3.4cqw; }

.sc-slot {
    position: relative; display: flex; align-items: center; min-width: 0; border-radius: 2.4cqw;
    background: rgba(255, 255, 255, .075); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
    transition: box-shadow .18s ease, background .18s ease;
}
.sc-slot:hover { background: rgba(255, 255, 255, .1); }
.sc-slot.is-focus { background: rgba(255, 255, 255, .13); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .75), 0 0 0 3px rgba(255, 255, 255, .12); }
.sc-slot.is-invalid { box-shadow: inset 0 0 0 1.5px #ff9db0, 0 0 0 3px rgba(255, 120, 150, .18); }
.sc-slot > .StripeElement, .sc-slot > .sc-input { width: 100%; }
.sc-slot .StripeElement { padding: 0 3cqw; }
.sc-number { align-self: center; height: 11.4cqw; }
.sc-name { height: 9.4cqw; }
.sc-expiry { height: 9.4cqw; width: 30cqw; }
.sc-expiry .StripeElement { padding: 0 2cqw; }
.sc-cap {
    display: block; margin: 0 0 1cqw 1cqw; font-size: max(8.5px, 2.35cqw); font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
    color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;   /* a long translation must not push the row taller */
}
.sc-lower > div { min-width: 0; }
.sc-input {
    height: 100%; padding: 0 3cqw; background: transparent; border: 0; outline: 0; color: var(--ink);
    font: 500 max(12px, 3.7cqw)/1 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: .07em; text-transform: uppercase; text-overflow: ellipsis; text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
    caret-color: #fff;
}
.sc-input::placeholder { color: rgba(246, 242, 255, .34); }
.sc-net { display: flex; align-items: flex-end; justify-content: flex-end; width: 13cqw; height: 9.4cqw; opacity: 0; transition: opacity .3s ease; }
.sc-card:not([data-brand="unknown"]) .sc-net { opacity: 1; }
.sc-net svg { width: 100%; height: 100%; display: none; }
.sc-card[data-brand="visa"] .sc-net .n-visa,
.sc-card[data-brand="mastercard"] .sc-net .n-mc,
.sc-card[data-brand="amex"] .sc-net .n-amex,
.sc-card[data-brand="discover"] .sc-net .n-disc,
.sc-card[data-brand="jcb"] .sc-net .n-jcb,
.sc-card[data-brand="unionpay"] .sc-net .n-union,
.sc-card[data-brand="diners"] .sc-net .n-diners { display: block; }

/* the bank said yes: a quiet confirmation on the card itself while the account is being made */
.sc-ok {
    position: absolute; top: 5.6cqw; inset-inline-end: 6cqw; width: 8.6cqw; height: 8.6cqw; color: #86efac; pointer-events: none;
    opacity: 0; transform: scale(.5); transition: opacity .25s ease, transform .4s cubic-bezier(.2, 1.4, .4, 1);
}
.sc-card.is-accepted .sc-ok { opacity: 1; transform: scale(1); }
.sc-card.is-accepted .sc-nfc { opacity: 0; transition: opacity .2s ease; }
.sc-card.is-accepted .sc-slot { box-shadow: inset 0 0 0 1.5px rgba(134, 239, 172, .7); }
.sc-card.is-accepted .sc-chip { filter: drop-shadow(0 0 7px rgba(253, 224, 71, .55)); }

/* back */
.sc-band { position: absolute; inset-inline: 0; top: 11%; height: 19%; background: linear-gradient(#0c0617, #1a0f2b 60%, #0c0617); box-shadow: 0 1px 0 rgba(255, 255, 255, .08); }
.sc-sign { position: absolute; inset-inline: 6.4cqw; top: 40%; display: grid; grid-template-columns: 1fr 26cqw; align-items: center; column-gap: 2.4cqw; }
.sc-lines {
    height: 10.5cqw; border-radius: 1.4cqw; opacity: .92;
    background: repeating-linear-gradient(135deg, #efeaf7 0 1.6cqw, #ddd5ec 1.6cqw 3.2cqw);
}
.sc-cvc { height: 10.5cqw; background: rgba(255, 255, 255, .92); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .4); }
.sc-cvc.is-focus { box-shadow: inset 0 0 0 2px var(--px-purple, #7c3aed), 0 0 0 3px rgba(255, 255, 255, .25); background: #fff; }
.sc-cvc.is-invalid { box-shadow: inset 0 0 0 2px #e11d48; }
.sc-hint { position: absolute; inset-inline: 6.4cqw; top: 66%; margin: 0; font-size: max(10px, 2.9cqw); line-height: 1.4; color: var(--mute); }

/* ── below the card ────────────────────────────────────────────── */
.sc-error { min-height: 20px; margin: clamp(8px, 1.4vh, 14px) 0 clamp(2px, .6vh, 8px); font-size: 13px; line-height: 1.4; color: #be123c; text-align: center; }
.sc-error:empty { min-height: 0; margin: 0; }
.sc-due { margin: 0 0 clamp(8px, 1.4vh, 14px); padding: clamp(8px, 1.3vh, 12px) 14px; background: #f5f3ff; border: 1px solid #e9e2ff; border-radius: 12px; font-size: 13px; }
.sc-due > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sc-due > div + div { margin-top: 4px; color: #6b7280; }
.sc-due dt { margin: 0; font-weight: 500; }
.sc-due dd { margin: 0; font-weight: 700; color: #111827; white-space: nowrap; }
.sc-due > div + div dd { font-weight: 600; color: #4b5563; }
.sc-due .sc-today dt { font-weight: 700; color: #111827; }
.sc-due .sc-today dd { font-size: 15px; color: var(--px-dark, #4a12a0); }
.sc-submit[disabled] { opacity: .7; cursor: progress; }
.sc-submit svg { width: 16px; height: 16px; }
.sc-secure { display: flex; align-items: flex-start; gap: 8px; margin: clamp(8px, 1.2vh, 12px) 0 0; font-size: 12px; line-height: 1.45; color: #6b7280; }
.sc-secure svg { flex: 0 0 14px; width: 14px; height: 14px; margin-top: 1px; color: #16a34a; }

/* one quiet line under the step-1 button, so the card is never a surprise */
.sc-next { margin: 8px 0 0; font-size: 12px; line-height: 1.4; color: #6b7280; text-align: center; }

/* Scripts that must not be letter-spaced or upper-cased: Arabic and Persian letters JOIN (spacing breaks the joins), Indic / Thai /
   CJK / Georgian have no upper case worth forcing. The card caption and the name keep their natural shapes there. */
.sc:lang(ar) .sc-cap, .sc:lang(fa) .sc-cap, .sc:lang(hi) .sc-cap, .sc:lang(th) .sc-cap, .sc:lang(ja) .sc-cap, .sc:lang(ko) .sc-cap, .sc:lang(zh) .sc-cap, .sc:lang(ka) .sc-cap,
.sc:lang(ar) .sc-input, .sc:lang(fa) .sc-input, .sc:lang(hi) .sc-input, .sc:lang(th) .sc-input, .sc:lang(ja) .sc-input, .sc:lang(ko) .sc-input, .sc:lang(zh) .sc-input, .sc:lang(ka) .sc-input {
    letter-spacing: 0; text-transform: none;
}
.sc:lang(ar) .sc-cap, .sc:lang(fa) .sc-cap { font-size: max(10px, 2.9cqw); }

/* the page's other blocks are tagged .js-step1 and hidden while the card step is open */
.is-card-step .js-step1 { display: none !important; }

/* touch: iOS zooms into any input under 16px */
@media (pointer: coarse) { .sc-input { font-size: 16px; } }

@media (prefers-reduced-motion: reduce) {
    .sc-card { animation: none; transition: none; }
    .sc-sheen { animation: none; }
    .sc-card.is-shaking { animation: none; }
    .sc-face, .sc-slot, .sc-ok { transition: none; }
}

/* Right-to-left pages (Arabic, Persian). Around the card the page mirrors by itself; the card stays left to right. Two
   physical bits do not follow: the "Back" button's padding, and the captions ON the card, which must keep to the card's
   left instead of picking up the page's right alignment (Billing > Update card aligns its text right in RTL). */
[dir="rtl"] .sc-back { padding: 4px 2px 4px 8px; }
[dir="rtl"] .sc-card { text-align: left; }
