/* Email code screen in the sign-in sheet (stage/email-code.js).
   Shared UX-pack motion values: 160ms small, 240ms default, 300ms max for
   anything frequent; enter cubic-bezier(.2,.7,.3,1), exit cubic-bezier(.4,0,1,1).
   Errors reuse the Studio's wizNope shake. Reduce Motion turns all of it off. */
#emailGate{--ec-fast:160ms;--ec-base:240ms;--ec-max:300ms;--ec-in:cubic-bezier(.2,.7,.3,1);--ec-out:cubic-bezier(.4,0,1,1);--ec-ok:#067647;--ec-err:#B42318}

/* While the code is asked for, the sheet shows only the code. */
#emailGate .gen-card.ec-on .auth-mode-tabs,
#emailGate .gen-card.ec-on #authTitle,
#emailGate .gen-card.ec-on #authSub,
#emailGate .gen-card.ec-on #authNoCard,
#emailGate .gen-card.ec-on #emailForm,
#emailGate .gen-card.ec-on .authswitch,
#emailGate .gen-card.ec-on #authConfirm,
#emailGate .gen-card.ec-on #authMsg,
#emailGate .gen-card.ec-on .authsep,
#emailGate .gen-card.ec-on #googleBtn,
#emailGate .gen-card.ec-on #appleBtn,
#emailGate .gen-card.ec-on .guest-before-create,
#emailGate .gen-card.ec-on #authTermsLine{display:none!important}

.ec[hidden]{display:none!important}
.ec{margin-top:6px;text-align:center}
.ec h3{font:700 20px/1.25 'Inter',sans-serif;margin:4px 0 6px;color:var(--ink)}
.ec h3:focus{outline:none}
.ec-sub{margin:0;font-size:13.5px;line-height:1.5;color:var(--muted)}
.ec-addr{margin:2px 0 14px;font-size:14px;overflow-wrap:anywhere}
.ec-preview{margin:-6px 0 12px;padding:7px 10px;border-radius:9px;background:#fff6e0;color:#7a4b00;font-size:12px;line-height:1.4}

/* One real input on top of the boxes: autofill, paste and the keyboard all land here. */
.ec-field{position:relative;margin:0 auto;max-width:calc(var(--n,6) * 50px + 24px)}
/* The id beats the Studio's own sheet-input rule (.approved-studio #emailGate input[type=text]). */
#emailGate .ec-field input#authCodeInput{position:absolute;inset:0;width:100%;height:100%;min-height:0;z-index:2;margin:0;padding:0;border:0;border-radius:0;box-shadow:none;outline:none;background:transparent;color:transparent;caret-color:transparent;font-size:16px;letter-spacing:0;text-align:left;-webkit-text-fill-color:transparent;-webkit-appearance:none;appearance:none;cursor:text}
#emailGate .ec-field input#authCodeInput::selection{background:transparent}
.ec-boxes{display:grid;grid-template-columns:repeat(var(--n,6),minmax(0,1fr));gap:6px;direction:ltr}
.ec-box{position:relative;display:grid;place-items:center;height:50px;border:1.5px solid var(--hair);border-radius:11px;background:#fff;font:700 22px/1 'Inter',ui-monospace,monospace;color:var(--ink);font-variant-numeric:tabular-nums;transition:border-color var(--ec-fast) var(--ec-in),background-color var(--ec-fast) var(--ec-in),box-shadow var(--ec-fast) var(--ec-in)}
/* A 6-digit code reads as 123 456: the halves step apart with `translate`,
   which composes with the transform the animations use. */
.ec-box.lh{translate:-3px 0}.ec-box.rh{translate:3px 0}
.ec-box.filled{border-color:var(--ink)}
.ec-box.active{border-color:var(--cobalt);box-shadow:0 0 0 3px rgba(29,78,216,.16)}
.ec-box.active:not(.filled)::after{content:"";width:2px;height:22px;background:var(--cobalt);border-radius:1px;animation:ecCaret 1s steps(1) infinite}
.ec-d{display:block}
@media (max-width:380px){.ec-box{height:46px;font-size:19px;border-radius:9px}.ec-boxes{gap:5px}.ec-box.lh{translate:-2px 0}.ec-box.rh{translate:2px 0}}

/* Boxes slide in one after another when the screen opens. */
.ec-boxes.enter .ec-box{animation:ecIn var(--ec-base) var(--ec-in) both;animation-delay:calc(var(--i) * 30ms)}
/* Each digit pops as it lands; a paste or autofill runs left to right. */
.ec-box.pop .ec-d{animation:ecPop var(--ec-fast) var(--ec-in) both;animation-delay:var(--d,0ms)}
/* Right code: the boxes turn green in a wave, then a check mark. */
.ec-boxes.ok .ec-box{animation:ecOk var(--ec-base) var(--ec-in) both;animation-delay:calc(var(--i) * 40ms)}
.ec-field.ok::after{content:"";position:absolute;inset-inline-start:50%;top:100%;width:30px;height:30px;margin:10px 0 0 -15px;border-radius:50%;background:var(--ec-ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/18px no-repeat;animation:ecCheck var(--ec-max) var(--ec-in) both;animation-delay:calc(var(--n,6) * 40ms + 120ms)}
[dir="rtl"] .ec-field.ok::after{margin:10px -15px 0 0}
.ec-field.ok{margin-bottom:44px}
.ec-field.ok input{pointer-events:none}
/* Wrong code: the Studio's shake, then the boxes clear. */
.ec-field.nope .ec-boxes{animation:wizNope .22s ease-in-out 2}
.ec-field.nope .ec-box{border-color:var(--ec-err);background:#fff5f4}

.ec-hint{margin:10px 0 0;font-size:12px;color:var(--muted)}
.ec .authmsg{margin-top:8px}

/* Send again: a ring empties until the button unlocks. */
.ec-resend .ec-timer{display:none;position:relative;width:24px;height:24px;flex:none}
.ec-resend.counting .ec-timer{display:inline-block}
.ec-timer svg{position:absolute;inset:0;transform:rotate(-90deg)}
.ec-timer circle{fill:none;stroke-width:2.5}
.ec-timer .ec-ring-bg{stroke:var(--hair)}
.ec-timer .ec-ring-fg{stroke:var(--cobalt);stroke-dasharray:62.83;stroke-dashoffset:0;stroke-linecap:round}
.ec-resend.counting .ec-ring-fg{animation:ecRing var(--wait,60000ms) linear both}
.ec-timer b{position:absolute;inset:0;display:grid;place-items:center;font:700 9.5px/1 'Inter',sans-serif;color:var(--muted);font-variant-numeric:tabular-nums}

/* The new password step after a reset code. */
#authNewPasswordForm{display:grid;gap:8px;margin-top:10px}
#authNewPasswordForm input:not([hidden]){width:100%;padding:11px 13px;border:1.5px solid var(--hair);border-radius:11px;font-size:16px}
.ec .authbtn{transition:transform var(--ec-fast) var(--ec-in)}
.ec .authbtn:active:not([disabled]){transform:scale(.98)}

@keyframes ecIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
@keyframes ecPop{0%{opacity:0;transform:scale(.55)}65%{opacity:1;transform:scale(1.14)}100%{transform:scale(1)}}
@keyframes ecOk{0%{transform:scale(1)}45%{transform:scale(1.07);background:var(--ec-ok);border-color:var(--ec-ok);color:#fff}100%{transform:scale(1);background:var(--ec-ok);border-color:var(--ec-ok);color:#fff}}
@keyframes ecCheck{from{opacity:0;transform:scale(.4)}to{opacity:1;transform:scale(1)}}
@keyframes ecRing{from{stroke-dashoffset:0}to{stroke-dashoffset:62.83}}
@keyframes ecCaret{50%{opacity:0}}

@media (prefers-reduced-motion:reduce){
  .ec *,.ec *::before,.ec *::after,.ec-field.ok::after{animation:none!important;transition:none!important}
  /* The end states still show: green boxes and the check mark, with no movement. */
  .ec-boxes.ok .ec-box{background:var(--ec-ok);border-color:var(--ec-ok);color:#fff}
  .ec-resend.counting .ec-ring-fg{stroke-dashoffset:0}
}
