/* Login page - staged KDS alignment */
.page {
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 480px at 15% -10%, rgba(229, 170, 23, 0.24), transparent 60%),
    radial-gradient(900px 420px at 100% 0%, rgba(255, 255, 255, 0.68), transparent 55%),
    radial-gradient(900px 520px at -10% 100%, rgba(247, 205, 79, 0.22), transparent 60%),
    linear-gradient(180deg, var(--color-surface-base) 0%, var(--color-neutral-100) 100%);
}

.page::before {
  content: "";
  position: absolute;
  inset: -10% -5% auto -5%;
  height: 60%;
  pointer-events: none;
  background:
    radial-gradient(220px 220px at 20% 40%, rgba(255, 255, 255, 0.74), transparent 70%),
    radial-gradient(260px 260px at 80% 20%, rgba(229, 170, 23, 0.18), transparent 70%);
  filter: blur(6px);
  opacity: 0.82;
  animation: pageGlowDrift 18s ease-in-out infinite;
}

.page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(42, 38, 33, 0.08) 1px, transparent 0);
  background-size: 3px 3px;
  opacity: 0.045;
  animation: pageGlowPulse 22s ease-in-out infinite;
}

.page .container {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 28px);
  position: relative;
  z-index: 1;
}

.page .container > .auth {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth {
  min-height: auto;
  padding: 0;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  position: relative;
  background: var(--glass-bg);
  border-radius: var(--radius-2xl);
  padding: 28px 22px 30px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-3);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
  overflow: hidden;
  z-index: 1;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.74),
    rgba(255, 255, 255, 0.16) 55%,
    rgba(255, 255, 255, 0)
  );
  opacity: 0.64;
}

.auth-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.58),
    inset 0 -1px 0 rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.36);
  opacity: 0.7;
}

.auth-card > * {
  position: relative;
  z-index: 1;
}

@keyframes pageGlowDrift {
  0% {
    transform: translate3d(-1%, -1%, 0) scale(1);
    opacity: 0.75;
  }

  50% {
    transform: translate3d(2%, 1%, 0) scale(1.03);
    opacity: 0.9;
  }

  100% {
    transform: translate3d(-1%, -1%, 0) scale(1);
    opacity: 0.75;
  }
}

@keyframes pageGlowPulse {
  0% {
    opacity: 0.04;
  }

  50% {
    opacity: 0.085;
  }

  100% {
    opacity: 0.04;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page::before,
  .page::after {
    animation: none;
  }
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-1);
}

.auth-logo img {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  box-shadow:
    0 2px 8px rgba(42, 38, 33, 0.14),
    0 0 0 1px rgba(42, 38, 33, 0.06);
}

.auth-header {
  text-align: center;
}

.auth-header .h1 {
  margin-bottom: var(--space-2);
  font-size: var(--fs-6);
  font-weight: var(--fw-bold);
  color: var(--text-main);
}

.auth-header .muted {
  font-size: var(--fs-2);
  color: var(--text-muted);
}

.auth-step {
  /* انیمیشن از طریق کلاس JS مدیریت می‌شود */
}

.auth-step[hidden] {
  display: none;
}

/* exit: فید اوت + کمی بالا */
@keyframes stepExit {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-10px) scale(0.97); }
}

/* enter: فید این + از پایین */
@keyframes stepEnter {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.auth-step--exit {
  animation: stepExit 220ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

.auth-step--enter {
  animation: stepEnter 280ms cubic-bezier(0.34, 1.3, 0.64, 1) forwards;
}

/* card — ارتفاع نرم */
.auth-card {
  transition: min-height 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
  .auth-step--exit,
  .auth-step--enter { animation: none; }
  .auth-card { transition: none; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-label {
  font-size: var(--fs-2);
  color: var(--text-muted);
}

/* prefix +98 */
.input-tel-wrap {
  display: flex;
  align-items: center;
  direction: ltr;           /* prefix همیشه سمت چپ */
  height: var(--control-h);
  border-radius: var(--control-radius);
  background: var(--surface-1);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.input-tel-wrap:focus-within {
  border-color: var(--color-line-focus);
  box-shadow: var(--focus-ring), var(--shadow-1);
}

.input-tel-prefix {
  padding: 0 10px;
  font-size: 0.9375rem;
  font-weight: var(--fw-medium);
  color: var(--text-3);
  height: 100%;
  display: flex;
  align-items: center;
  user-select: none;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

.input--mobile {
  border: none;
  box-shadow: none;
  background: transparent;
  border-radius: 0;
  height: 100%;
  flex: 1;
  padding: 0 12px;
  letter-spacing: 0.1em;
  font-size: 1rem;
  min-width: 0;
  text-align: center;       /* وسط‌چین */
  direction: ltr;
}

.input--mobile:focus-visible {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

/* spinner روی دکمه */
.btn-spinner {
  display: none;
  width: 20px;
  height: 20px;
  animation: spinnerRotate 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes spinnerRotate {
  to { transform: rotate(360deg); }
}

.btn--primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn--primary.is-loading .btn-label { opacity: 0.5; }
.btn--primary.is-loading .btn-spinner { display: block; }

@media (prefers-reduced-motion: reduce) {
  .btn-spinner { animation: none; }
}

.auth .input {
  height: var(--control-h);
  padding: 0 var(--control-pad-x);
  border-radius: var(--control-radius);
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-main);
  box-shadow: var(--shadow-1);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.auth .input::placeholder {
  color: var(--color-ink-300);
  opacity: 1;
}

.auth .input:hover {
  border-color: var(--border-soft);
}

.auth .input:focus-visible {
  border-color: var(--color-line-focus);
  box-shadow:
    var(--focus-ring),
    var(--shadow-1);
}

.input--center {
  text-align: center;
  font-size: 18px;
  letter-spacing: 0.8px;
}

.form-msg {
  font-size: var(--fs-2);
  line-height: 1.7;
  min-height: 1em;
}

.btn--block {
  width: 100%;
}

#otpSendForm .btn--block,
#otpVerifyForm .btn--block {
  margin-top: var(--space-5);
}

.auth .btn--primary {
  height: var(--control-h);
  border-radius: var(--control-radius);
  background: linear-gradient(180deg, var(--color-brand-200) 0%, var(--color-brand-500) 100%);
  color: var(--color-brand-900);
  border: 1px solid rgba(157, 112, 14, 0.32);
  box-shadow:
    0 10px 20px rgba(229, 170, 23, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

.auth .btn--primary:active {
  transform: translateY(1px);
}

.auth .btn--primary:focus-visible {
  box-shadow:
    0 10px 20px rgba(229, 170, 23, 0.24),
    0 0 0 3px rgba(229, 170, 23, 0.24);
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-4);
  gap: var(--space-3);
}

.link-muted {
  font-size: var(--fs-2);
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.link-muted:hover {
  text-decoration: underline;
}

.form-note {
  margin-top: var(--space-1);
  font-size: var(--fs-1);
  text-align: center;
}

@media (max-width: 480px) {
  .auth-card {
    border-radius: var(--radius-xl);
    padding: 22px 16px 24px;
  }
}

/* Resend circular timer */
.resend-circle {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--color-line-200);
  background: rgba(255, 255, 255, 0.72);
  border-radius: var(--radius-pill);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: not-allowed;
  box-shadow: var(--shadow-1);
}

.resend-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.resend-bg {
  fill: none;
  stroke: rgba(42, 38, 33, 0.12);
  stroke-width: 3;
}

.resend-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.9s linear;
}

.resend-circle.is-active {
  cursor: pointer;
}

.resend-circle.is-active .resend-progress {
  stroke-dashoffset: 0;
}

#step-code .field {
  margin-bottom: var(--space-2);
}

/* OTP 6-box */
.otp-boxes {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.otp-box {
  width: 44px;
  height: 52px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface-1);
  text-align: center;
  font-size: 1.375rem;
  font-weight: var(--fw-bold);
  color: var(--text-main);
  caret-color: var(--accent);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
  -webkit-appearance: none;
  appearance: none;
}

.otp-box:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229, 170, 23, 0.18);
  background: var(--color-surface-base);
}

.otp-box--filled {
  border-color: var(--accent);
  background: rgba(229, 170, 23, 0.06);
}

@media (max-width: 360px) {
  .otp-box {
    width: 38px;
    height: 46px;
    font-size: 1.125rem;
  }
  .otp-boxes { gap: 6px; }
}

.resend-circle svg {
  opacity: 0.84;
}

.resend-circle:not([disabled]) svg {
  opacity: 1;
}
