/* The customer login journey — Fix Prompt 16 (design-reference/login-journey/login-journey.html). Tokens only
   (tokens.css): every colour, radius and shadow is an existing token. The split coin is the only decoration; it
   tells the state. Motion: transform, opacity and the ring's stroke-dashoffset only. */

html:has(.lj-shell), body:has(.lj-shell) { background: var(--bg); }
.app-shell.lj-shell {
  max-width: none; margin: 0; min-height: 100dvh; background: var(--bg); box-shadow: none; overflow: visible;
  align-items: center; gap: 14px; padding: max(24px, 6vh) 16px 40px;
}

.auth {
  --g: 0;
  --spring: cubic-bezier(.3, 1.45, .5, 1);
  --ease: cubic-bezier(.2, .7, .2, 1);
  position: relative; width: min(100%, 400px); background: var(--surface); border-radius: var(--radius-card);
  box-shadow: var(--shadow); padding: 24px 22px 22px; display: flex; flex-direction: column; align-items: center;
  text-align: center; color: var(--text); font-size: 14px; line-height: 1.8;
}
.auth .num { direction: ltr; unicode-bidi: isolate; display: inline-block; font-variant-numeric: tabular-nums; }

/* ===== the mark ===== */
.mark { position: relative; width: 148px; height: 148px; display: grid; place-items: center; perspective: 520px; margin-bottom: 4px; }
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); opacity: 0; transition: opacity .35s; }
.ring circle { fill: none; stroke-width: 3; stroke-linecap: round; }
.ring .track { stroke: var(--ink-tint); transition: stroke .3s; }
.ring .prog { stroke: var(--ink); stroke-dasharray: 427.26; stroke-dashoffset: 427.26; transition: stroke .3s; }
.auth[data-step=code] .ring, .auth[data-step=welcome] .ring { opacity: 1; }
.auth[data-state=locked] .ring { opacity: .45; }
.auth[data-state=err] .ring .prog { stroke: var(--danger); }
.auth[data-state=ok] .ring .prog, .auth[data-step=welcome] .ring .prog { stroke: var(--emerald); }
.auth[data-state=ok] .ring .track, .auth[data-step=welcome] .ring .track { stroke: var(--emerald-bg); }

.coin-wrap { display: block; width: 92px; height: 92px; transform-style: preserve-3d; position: relative; z-index: 1; }
.coin { width: 100%; height: 100%; display: block; overflow: visible; }
/* --g = how far apart the two halves stand (SVG units); 0 = the logo as it is */
.coin .ha { transform: translate(calc(var(--g) * -1px), calc(var(--g) * -1px)); }
.coin .hb { transform: translate(calc(var(--g) * 1px), calc(var(--g) * 1px)); }
.coin .ha, .coin .hb { transition: transform .5s var(--spring); }
.auth.no-tr .ha, .auth.no-tr .hb { transition: none !important; }
.auth.assemble .ha, .auth.assemble .hb { transition: transform .95s cubic-bezier(.3, 1.3, .45, 1); }
.auth.assemble .hin { animation: lj-fadein .35s ease-out both; }
@keyframes lj-fadein { from { opacity: 0; } }
.coin .hin { transform-box: fill-box; transform-origin: 50% 50%; }

.auth[data-step=code][data-state=wait] .ha .hin { animation: lj-breatheA 2.8s ease-in-out infinite; }
.auth[data-step=code][data-state=wait] .hb .hin { animation: lj-breatheB 2.8s ease-in-out infinite; }
@keyframes lj-breatheA { 50% { transform: translate(-3px, -3px); } }
@keyframes lj-breatheB { 50% { transform: translate(3px, 3px); } }
.auth[data-state=err] .ha .hin { animation: lj-crackA .7s var(--ease); }
.auth[data-state=err] .hb .hin { animation: lj-crackB .7s var(--ease); }
@keyframes lj-crackA { 22% { transform: translate(-10px, -10px) rotate(-14deg); } 60% { transform: translate(-2px, -2px) rotate(3deg); } }
@keyframes lj-crackB { 22% { transform: translate(10px, 10px) rotate(14deg); } 60% { transform: translate(2px, 2px) rotate(-3deg); } }
.auth[data-state=sending] .coin-wrap { animation: lj-charge .9s ease-in-out infinite; }
@keyframes lj-charge { 50% { transform: scale(.93); } }
.mark.tossing .coin-wrap { animation: lj-toss .8s cubic-bezier(.45, 0, .55, 1) infinite; }
@keyframes lj-toss { 0% { transform: translateY(0) rotateY(0); } 45% { transform: translateY(-18px) rotateY(380deg); } 100% { transform: translateY(0) rotateY(720deg); } }
.shadow { position: absolute; left: 50%; top: calc(50% + 50px); width: 58px; height: 10px; margin-left: -29px; border-radius: 50%;
  background: radial-gradient(closest-side, var(--ink-tint), transparent); opacity: 0; pointer-events: none; }
.mark.tossing .shadow { animation: lj-shadow .8s cubic-bezier(.45, 0, .55, 1) infinite; }
@keyframes lj-shadow { 0%, 100% { opacity: .9; transform: scaleX(1); } 45% { opacity: .3; transform: scaleX(.55); } }
.sheen-move { transform: translate(-170px, -170px); }
.auth.shine .sheen-move { animation: lj-sheen 1s cubic-bezier(.35, .6, .3, 1) both; }
@keyframes lj-sheen { from { transform: translate(-170px, -170px); } to { transform: translate(170px, 170px); } }

/* the SMS chip and the success badge */
.chip { position: absolute; top: 12px; inset-inline-start: 12px; width: 32px; height: 32px; border-radius: 50%; background: var(--ink);
  color: var(--surface); display: grid; place-items: center; border: 3px solid var(--surface); opacity: 0; pointer-events: none; z-index: 2; }
.chip .ping { position: absolute; inset: -3px; border-radius: 50%; border: 2px solid var(--ink); opacity: 0; }
.badge { position: absolute; inset-inline-end: 16px; bottom: 16px; width: 34px; height: 34px; border-radius: 50%; background: var(--emerald);
  color: var(--surface); display: grid; place-items: center; border: 3px solid var(--surface); transform: scale(0); opacity: 0; z-index: 2;
  transition: transform .45s var(--spring), opacity .2s; }
.badge svg path { stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .35s ease-out; }
.auth[data-state=ok] .badge, .auth[data-step=welcome] .badge { transform: scale(1); opacity: 1; transition-delay: .18s; }
.auth[data-state=ok] .badge svg path, .auth[data-step=welcome] .badge svg path { stroke-dashoffset: 0; transition-delay: .45s; }
.dust { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; z-index: 3; }
.dust i { position: absolute; left: 0; top: 0; border-radius: 50%; }
.fly { position: absolute; left: 0; top: 0; font-size: 24px; font-weight: 800; line-height: 1; color: var(--ink-2); pointer-events: none; z-index: 6; will-change: transform; }

/* ===== steps ===== */
.stage { width: 100%; }
.step, .step-form { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; margin: 0; }
.step[hidden] { display: none; }
.step h1 { margin: 2px 0 0; font-size: 20px; font-weight: 800; line-height: 1.5; }
.auth .sub { margin: -6px 0 4px; color: var(--text-soft); font-size: 13.5px; line-height: 1.9; max-width: 320px; }
.fld { width: 100%; max-width: 336px; display: flex; flex-direction: column; gap: 6px; text-align: start; }
.fld label { font-size: 12.5px; font-weight: 700; color: var(--text-soft); }
.inp { width: 100%; height: 52px; border-radius: var(--radius-card); border: 1.5px solid var(--border); background: var(--surface-2); padding: 0 14px;
  font: inherit; font-size: 16px; color: var(--text); transition: border-color .2s, box-shadow .2s, background-color .2s; }
.inp:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px var(--ink-tint); background: var(--surface); }
.inp.phone { font-size: 20px; font-weight: 700; letter-spacing: .06em; text-align: center; direction: ltr; }
.inp.phone::placeholder { color: var(--muted); font-weight: 500; }
.inp[aria-invalid=true] { border-color: var(--danger); background: var(--danger-bg); }
.inp[aria-invalid=true]:focus { box-shadow: 0 0 0 4px var(--danger-bg); }
.ferr { font-size: 12px; color: var(--danger-text); font-weight: 700; }
.ferr:empty { display: none; }

/* the six cells — one real input lies on top of them, so every autofill works */
.otp-field { position: relative; width: 100%; max-width: 336px; }
.cells { display: flex; gap: 8px; direction: ltr; justify-content: center; }
.cell { flex: 1 1 0; max-width: 50px; height: 58px; border-radius: var(--radius-card); background: var(--surface-2); border: 1.5px solid var(--border);
  display: grid; place-items: center; font-size: 24px; font-weight: 800; line-height: 1; position: relative; overflow: hidden; color: var(--text);
  transition: border-color .2s, background-color .2s, box-shadow .2s, opacity .2s; }
.cell .d { display: block; }
.cell.filled { background: var(--surface); border-color: var(--ink); }
.cell.filled .d { animation: lj-land .42s var(--spring); }
@keyframes lj-land { 0% { transform: translateY(-10px) scale(.4); opacity: 0; } 100% { transform: none; opacity: 1; } }
.cell.filled::after { content: ""; position: absolute; inset: 0; background: var(--gold-tint); opacity: 0; animation: lj-flash .6s ease-out; }
@keyframes lj-flash { 0% { opacity: .95; } 100% { opacity: 0; } }
.cell.active { border-color: var(--ink); box-shadow: 0 0 0 4px var(--ink-tint); }
.cell.active:not(.filled)::before { content: ""; width: 2px; height: 24px; background: var(--ink); border-radius: 2px; animation: lj-caret 1s steps(1) infinite; }
@keyframes lj-caret { 50% { opacity: 0; } }
.otp-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; background: transparent; font-size: 16px;
  color: transparent; caret-color: transparent; direction: ltr; cursor: text; }
/* without JavaScript the real field is shown (no script draws the cells) */
html:not(.lj-js) .cells { display: none; }
html:not(.lj-js) .otp-input { position: static; opacity: 1; height: 52px; border-radius: var(--radius-card); border: 1.5px solid var(--border);
  background: var(--surface-2); color: var(--text); caret-color: auto; text-align: center; font-size: 22px; letter-spacing: .3em; }
.auth[data-state=verifying] .cell { border-color: var(--ink); background: var(--ink-tint); }
.auth[data-state=ok] .cell { border-color: var(--emerald); background: var(--emerald-bg); animation: lj-wave .55s var(--spring) both; animation-delay: calc(var(--i) * 60ms); }
@keyframes lj-wave { 40% { transform: translateY(-8px); } }
.auth[data-state=err] .cell { border-color: var(--danger); background: var(--danger-bg); animation: lj-shake .5s cubic-bezier(.36, .07, .19, .97); }
@keyframes lj-shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }
.auth[data-state=locked] .cell { background: var(--neutral-tint); border-color: var(--border); opacity: .6; }

.auth .status { min-height: 24px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--text-soft); margin: -2px 0; }
.auth .status.bad { color: var(--danger-text); }
.auth .status.good { color: var(--emerald-text); }
.auth .status.info { color: var(--ink-2); }
.auth .status:empty { min-height: 0; margin: 0; }
#codeStatus.status:empty { min-height: 24px; margin: -2px 0; }
@media (max-width: 360px) { #codeStatus.status, #codeStatus.status:empty { min-height: 44px; } }   /* two lines on a narrow phone: no shift when it clears */

/* buttons */
.auth .btn { font: inherit; font-weight: 700; font-size: 14.5px; border-radius: var(--radius-card); padding: 8px 16px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; white-space: nowrap; text-decoration: none; }
.auth .btn.primary { background: var(--ink); color: var(--surface); width: 100%; max-width: 336px; transition: background-color .2s, opacity .2s; }
.auth .btn.primary:hover:not([disabled]) { background: var(--ink-2); }
.auth .btn.primary[disabled] { opacity: .45; cursor: not-allowed; }
.auth .btn.primary.busy[disabled] { opacity: .9; cursor: progress; }
.auth[data-state=ok] .btn.primary { background: var(--emerald); opacity: 1; }
.auth .btn.link { background: none; color: var(--ink-2); min-height: 44px; padding: 4px 8px; font-size: 13px; }
.auth .btn.inline { min-height: 0; padding: 0 4px; display: inline; font-size: 13px; vertical-align: baseline; }
.auth .btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-top-color: transparent; animation: lj-rot .7s linear infinite; display: none; }
.btn.busy .spin { display: inline-block; }
.mini-spin { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink-tint); border-top-color: var(--ink); animation: lj-rot .7s linear infinite; vertical-align: -2px; }
@keyframes lj-rot { to { transform: rotate(360deg); } }
.resend { color: var(--text-soft); font-size: 13px; min-height: 44px; display: flex; align-items: center; gap: 6px; justify-content: center; margin: -6px 0 -8px; }
.resend form { margin: 0; }
.staff { color: var(--text-soft); font-size: 13px; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; padding: 0 10px; }
.staff:hover { color: var(--ink-2); }
.staff:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 8px; }

/* short screens (the keyboard open on a small phone) */
@media (max-height: 700px) {
  .mark { width: 116px; height: 116px; }
  .coin-wrap { width: 72px; height: 72px; }
  .chip { top: 6px; inset-inline-start: 6px; }
  .badge { inset-inline-end: 10px; bottom: 10px; }
  .shadow { top: calc(50% + 40px); }
}

@media (prefers-reduced-motion: reduce) {
  .coin .ha, .coin .hb, .badge, .badge svg path, .ring, .ring .prog, .cell, .inp { transition: none !important; }
  .hin, .coin-wrap, .shadow, .cell, .cell .d, .cell::after, .cell::before, .sheen-move, .spin, .mini-spin { animation: none !important; }
  .badge svg path { stroke-dashoffset: 0; }
}

/* Fix Prompt 43 — «راهنما» under the phone field (/help#login) */
.auth .lj-help { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
