/* =====================================================================
   LARA — AUTH MODAL  (شماره موبایل → کد تأیید → ورود)
   Loads after css/styles.css (+ css/hero-v2.css on the landing page).
   Same language as the hero: cream/white surfaces, one green accent,
   hairline borders, r24 cards, soft warm shadows. No dark fills.
   ===================================================================== */

/* ---------- 0. scrim ---------- */
.auth{
  position:fixed; inset:0; z-index:400;
  display:grid; place-items:center;
  padding:clamp(16px,4vw,32px);
  background:rgba(24,35,31,.34);
  -webkit-backdrop-filter:blur(10px) saturate(1.2);
  backdrop-filter:blur(10px) saturate(1.2);
  opacity:0; visibility:hidden;
  transition:opacity .28s var(--ease), visibility .28s;
}
.auth.is-open{ opacity:1; visibility:visible; }
body.auth-lock{ overflow:hidden; }

/* ---------- 1. card ---------- */
.auth__card{
  position:relative; width:min(452px,100%);
  background:var(--paper); border:1px solid rgba(30,40,36,.075);
  border-radius:26px; box-shadow:var(--sh-lg), 0 40px 90px -50px rgba(var(--green-rgb),.4);
  padding:clamp(24px,4vw,34px) clamp(20px,4vw,32px) clamp(20px,3vw,26px);
  transform:translateY(16px) scale(.985); opacity:0;
  transition:transform .4s var(--ease), opacity .3s var(--ease);
  max-height:calc(100dvh - 32px); overflow-y:auto; overscroll-behavior:contain;
}
.auth.is-open .auth__card{ transform:none; opacity:1; }
.auth__card::before{                       /* faint green bloom, like the hero card */
  content:""; position:absolute; inset:0; border-radius:inherit; pointer-events:none;
  background:radial-gradient(120% 70% at 50% -20%, rgba(var(--green-rgb),.07), transparent 62%);
}

.auth__close{
  position:absolute; inset-block-start:14px; inset-inline-end:14px;
  width:38px; height:38px; border-radius:var(--r-pill);
  display:grid; place-items:center; color:var(--ink-3);
  transition:background .22s, color .22s;
}
.auth__close:hover{ background:rgba(30,40,36,.05); color:var(--ink); }
.auth__close svg{ width:18px; height:18px; }

/* ---------- 2. head ---------- */
.auth__mark{
  width:44px; height:44px; border-radius:15px; display:grid; place-items:center;
  color:var(--green-700); background:var(--green-tint);
  border:1px solid var(--green-line); margin-bottom:16px;
}
.auth__mark svg{ width:24px; height:24px; }
.auth__title{
  font-size:clamp(21px,3.4vw,24px); font-weight:800; font-variation-settings:"wght" 800;
  letter-spacing:normal; line-height:1.4; color:var(--ink); text-wrap:balance;
}
.auth__sub{ margin-top:7px; font-size:14.5px; line-height:1.85; color:var(--ink-3); }
.auth__sub b{ color:var(--ink); font-weight:600; direction:ltr; unicode-bidi:isolate; }

/* the question the visitor asked, carried into the modal */
.auth__carry{
  display:flex; gap:10px; align-items:flex-start;
  margin-top:18px; padding:12px 14px;
  background:var(--green-tint-2); border:1px solid var(--green-line);
  border-radius:16px;
}
.auth__carry svg{ width:16px; height:16px; flex:none; margin-top:4px; color:var(--green-600); }
.auth__carry p{ font-size:13.5px; line-height:1.8; color:var(--ink-2);
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.auth__carry[hidden]{ display:none; }

/* ---------- 3. steps ---------- */
.auth__step{ display:none; }
.auth__step.is-active{ display:block; animation:authIn .38s var(--ease) both; }
@keyframes authIn{ from{ opacity:0; transform:translateY(10px); } to{ opacity:1; transform:none; } }

/* ---------- 4. fields ---------- */
.auth__label{
  display:block; margin:20px 0 8px;
  font-size:13.5px; font-weight:600; color:var(--ink-2);
}
.auth__field{
  display:flex; align-items:center; gap:10px;
  height:54px; padding-inline:14px;
  background:var(--paper-warm); border:1.5px solid var(--line-2); border-radius:16px;
  transition:border-color .22s, box-shadow .22s, background .22s;
}
.auth__field:focus-within{
  background:var(--paper); border-color:var(--green-600);
  box-shadow:0 0 0 4px rgba(var(--green-rgb),.10);
}
.auth__field.is-error{ border-color:var(--coral); box-shadow:0 0 0 4px rgba(var(--coral-rgb),.10); }
.auth__prefix{
  font-size:14px; color:var(--ink-4); font-weight:600;
  padding-inline-end:10px; border-inline-end:1px solid var(--line-2); line-height:1;
}
.auth__field svg{ width:19px; height:19px; color:var(--ink-4); flex:none; }
.auth__input{
  flex:1; min-width:0; height:100%; border:none; background:none; outline:none;
  font-size:17px; font-weight:600; color:var(--ink);
  direction:ltr; text-align:left; letter-spacing:.06em;
  font-feature-settings:"tnum"; font-variant-numeric:tabular-nums;
}
.auth__input::placeholder{ color:var(--ink-4); font-weight:400; letter-spacing:normal; }

/* inline validation / status message */
.auth__msg{
  display:flex; align-items:center; gap:7px;
  margin-top:9px; min-height:19px; font-size:13px; line-height:1.6; color:var(--coral);
}
.auth__msg svg{ width:15px; height:15px; flex:none; }
.auth__msg:empty{ display:none; }

/* ---------- 5. OTP boxes ---------- */
.auth__otp{
  display:flex; gap:10px; direction:ltr; justify-content:center; margin-top:20px;
}
.auth__otp input{
  width:56px; height:64px; flex:1 1 0; max-width:62px;
  border:1.5px solid var(--line-2); border-radius:16px; background:var(--paper-warm);
  text-align:center; font-size:24px; font-weight:700; color:var(--ink);
  font-feature-settings:"tnum"; font-variant-numeric:tabular-nums;
  outline:none; transition:border-color .2s, box-shadow .2s, background .2s, transform .2s;
}
.auth__otp input:focus{
  background:var(--paper); border-color:var(--green-600);
  box-shadow:0 0 0 4px rgba(var(--green-rgb),.10); transform:translateY(-2px);
}
.auth__otp input:not(:placeholder-shown){ border-color:var(--green-line); background:var(--green-tint-2); }
.auth__otp.is-error input{ border-color:var(--coral); background:#FDF5F3; }
.auth__otp.is-error{ animation:authShake .42s var(--ease); }
@keyframes authShake{ 0%,100%{transform:none} 22%{transform:translateX(-6px)} 55%{transform:translateX(5px)} 80%{transform:translateX(-2px)} }
.auth__otp.is-done input{ border-color:var(--green-600); background:var(--green-tint); }

/* ---------- 6. resend ---------- */
.auth__resend{
  display:flex; align-items:center; justify-content:center; gap:6px;
  margin-top:18px; font-size:13.5px; color:var(--ink-3);
}
.auth__timer{ font-feature-settings:"tnum"; color:var(--ink-2); font-weight:600; }
.auth__again{
  color:var(--green-600); font-weight:600; border-radius:var(--r-pill);
  padding:4px 8px; transition:background .2s, color .2s;
}
.auth__again[disabled]{ color:var(--ink-4); cursor:default; }
.auth__again:not([disabled]):hover{ background:var(--green-tint); color:var(--green-800); }

/* ---------- 7. buttons ---------- */
.auth__submit{
  width:100%; height:54px; margin-top:20px;
  display:inline-flex; align-items:center; justify-content:center; gap:9px;
  border-radius:var(--r-pill); background:var(--green-700); color:#F6FAF6;
  font-size:15.5px; font-weight:600; letter-spacing:normal;
  box-shadow:0 12px 28px -16px rgba(var(--green-rgb),.75), inset 0 1px 0 rgba(255,255,255,.14);
  transition:background .25s, transform .22s, box-shadow .25s, opacity .25s;
}
.auth__submit:hover:not([disabled]){ background:var(--green-900); transform:translateY(-1px); }
.auth__submit[disabled]{ opacity:.45; cursor:not-allowed; transform:none; box-shadow:none; }
.auth__submit svg{ width:18px; height:18px; }
.auth__submit .auth__spin{ display:none; }
.auth__submit.is-busy .auth__lbl, .auth__submit.is-busy > svg{ display:none; }
.auth__submit.is-busy .auth__spin{ display:block; }
.auth__spin{
  width:19px; height:19px; border-radius:50%;
  border:2px solid rgba(255,255,255,.3); border-top-color:#fff;
  animation:authSpin .8s linear infinite;
}
@keyframes authSpin{ to{ transform:rotate(360deg); } }

.auth__back{
  display:inline-flex; align-items:center; gap:6px; margin-top:16px;
  font-size:13.5px; font-weight:500; color:var(--ink-3);
  padding:6px 10px; border-radius:var(--r-pill); transition:background .2s, color .2s;
}
.auth__back:hover{ background:rgba(30,40,36,.045); color:var(--ink); }
.auth__back svg{ width:15px; height:15px; transform:scaleX(-1); }

.auth__legal{
  margin-top:18px; padding-top:16px; border-top:1px solid var(--line);
  font-size:12.5px; line-height:1.9; color:var(--ink-4); text-align:center;
}
.auth__legal a{ color:var(--green-600); font-weight:500; }
.auth__legal a:hover{ text-decoration:underline; }

/* ---------- 8. success ---------- */
.auth__done{ text-align:center; padding-block:22px 6px; }
.auth__tick{
  width:74px; height:74px; margin:0 auto 20px; border-radius:50%;
  display:grid; place-items:center; color:#fff; background:var(--green-700);
  box-shadow:0 0 0 10px var(--green-tint);
  animation:authPop .5s var(--ease) both;
}
@keyframes authPop{ from{ transform:scale(.6); opacity:0; } to{ transform:none; opacity:1; } }
.auth__tick svg{ width:34px; height:34px; }
.auth__tick path{ stroke-dasharray:28; stroke-dashoffset:28; animation:authDraw .5s var(--ease) .22s forwards; }
@keyframes authDraw{ to{ stroke-dashoffset:0; } }

/* ---------- 9. mobile ---------- */
@media (max-width:480px){
  .auth{ padding:0; place-items:end stretch; }
  .auth__card{
    width:100%; border-radius:26px 26px 0 0; border-block-end:none;
    padding-bottom:max(24px, env(safe-area-inset-bottom));
    transform:translateY(100%); max-height:92dvh;
  }
  .auth.is-open .auth__card{ transform:none; }
  .auth__otp input{ width:auto; height:58px; font-size:21px; }
}

/* ---------- 10. reduced motion ---------- */
@media (prefers-reduced-motion:reduce){
  .auth, .auth__card, .auth__step, .auth__tick, .auth__tick path, .auth__otp.is-error{
    animation:none !important; transition:opacity .01s !important; transform:none !important;
  }
}

/* ---------- 11. sign-in required (the chat page): no way to dismiss ---------- */
.auth--required .auth__close{ display:none; }
.auth__tabs{display:grid;grid-template-columns:1fr 1fr;gap:4px;margin-top:20px;padding:4px;border:1px solid var(--line-2);border-radius:14px;background:var(--paper-warm)}
.auth__tabs button{padding:10px 8px;border-radius:10px;color:var(--ink-3);font-size:13.5px;font-weight:600;transition:background .2s,color .2s,box-shadow .2s}
.auth__tabs button[aria-selected="true"]{background:var(--paper);color:var(--green-700);box-shadow:0 2px 8px rgba(30,40,36,.08)}
.auth__tabs button:focus-visible{outline:2px solid var(--green-700);outline-offset:2px}
.auth__step form[hidden]{display:none!important}
.auth__tabs + form .auth__label,.auth__tabs ~ form .auth__label{margin-top:16px}
