/* ============================================================
   Nexus — Auth (Login / Sign-up)
   Metrics from Telegram-iOS research:
   input inset 16 · field height ~48 · font 17 · primary button
   height ~48 · error shake amplitude 3 / duration .3 / count 4
   ============================================================ */

:root {
  --auth-max: 400px;
  --auth-radius: var(--r-card);
  --auth-field-h: 48px;
  --auth-fs: 1rem;      /* ~17 */
  --auth-fs-sub: .9rem;
  --auth-placeholder: var(--nb-text-mute);
}

/* ---------- layout ---------- */
.auth-wrap { display: flex; align-items: center; justify-content: center; padding: 52px 16px 40px; padding-top: calc(52px + env(safe-area-inset-top, 0px)); padding-bottom: calc(40px + var(--tabbar-h) + var(--tabbar-offset) + env(safe-area-inset-bottom, 0px)); }

/* The auth card: a real surface, like any professional sign-in screen. */
.auth-card {
  width: 100%; max-width: var(--auth-max);
  text-align: center;
  padding: 30px 24px 22px;
  background: var(--nb-surface);
  border: 1px solid color-mix(in srgb, var(--nb-text) 12%, transparent);
  border-radius: var(--r-card);
  box-shadow: 0 22px 60px -30px rgba(2, 6, 23, .3), 0 2px 10px -2px rgba(2, 6, 23, .08);
}
[data-theme="dark"] .auth-card { box-shadow: 0 22px 60px -30px rgba(0, 0, 0, .8), 0 2px 10px -2px rgba(0, 0, 0, .6); }

/* Login screen: no header, no tabbar — center the card in the viewport. */
.app-body--auth main#main { display: flex; padding-bottom: 0; }
.app-body--auth .ios-page { flex: 1; display: flex; max-width: none; padding: 0; }
.app-body--auth .auth-wrap { flex: 1; padding: 24px 16px; padding-top: calc(24px + env(safe-area-inset-top, 0px)); padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }

.auth-logo { width: 76px; height: 76px; border-radius: var(--r-avatar-square); margin: 0 auto 14px; display: grid; place-items: center; background: var(--nb-surface-hi); color: var(--nb-text-mute); font-size: 1.9rem; font-weight: 900; box-shadow: none; }
.auth-title { font-size: 1.45rem; font-weight: 800; }
.auth-sub { color: var(--nb-text-mute); font-size: var(--auth-fs-sub); margin-top: 3px; margin-bottom: 24px; }

/* ---------- grouped input card (rows + separators) ---------- */
.auth-group { background: var(--nb-surface); border: 1px solid var(--nb-line); border-radius: var(--auth-radius); overflow: hidden; text-align: start; }
[data-theme="dark"] .auth-group { background: var(--nb-surface-hi); }
.auth-field { position: relative; display: flex; align-items: center; min-height: var(--auth-field-h); padding: 0 16px; }
.auth-field:not(:last-child)::after { content: ''; position: absolute; bottom: 0; inset-inline: 0; height: 1px; background: var(--nb-line); }
.auth-field input {
  flex: 1 1 auto; width: 100%; min-width: 0;
  border: 0; background: none; font: inherit; font-size: var(--auth-fs);
  color: var(--nb-text); padding: 12px 0;
  outline: none; box-shadow: none; appearance: none; -webkit-appearance: none;
}
/* no default focus box anywhere — the row separator is the only focus cue */
.auth-field input:focus,
.auth-field input:focus-visible { outline: none; box-shadow: none; }
/* one placeholder colour for every input */
.auth-field input::placeholder { color: var(--auth-placeholder); opacity: 1; }
/* every empty input shows its (Persian) placeholder right-aligned */
.auth-field input:placeholder-shown { text-align: right; }
/* only the English username switches to LTR while typing */
.auth-field input[dir="ltr"]:not(:placeholder-shown) { direction: ltr; text-align: left; }
.auth-field.is-focused::after { background: var(--brand); }

.auth-eye { flex: none; width: 24px; height: 40px; display: grid; place-items: center; border: 0; background: none; color: var(--nb-text-mute); cursor: pointer; padding: 0; margin-inline-end: -2px; border-radius: var(--r-control); }
.auth-eye:hover { color: var(--brand); }
.auth-eye.is-on { color: var(--brand); }

/* ---------- primary button ---------- */
.auth-btn { width: 100%; height: var(--auth-field-h); border: 0; border-radius: var(--r-control); background: var(--grad); color: #fff; font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; margin-top: 24px; display: grid; place-items: center; transition: transform .15s ease, opacity .15s ease; }
.auth-btn:active { transform: scale(.98); }
.auth-btn.is-loading { opacity: .65; pointer-events: none; }
.auth-spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: auth-spin .7s linear infinite; }
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* ---------- captcha ---------- */
.auth-field-cap { gap: 10px; }
.auth-cap-img { flex: none; width: 96px; height: 34px; border-radius: 8px; border: 1px solid var(--nb-line); cursor: pointer; background: var(--nb-surface); }
.auth-cap-refresh { flex: none; width: 30px; height: 34px; border: 0; background: none; color: var(--nb-text-mute); cursor: pointer; display: grid; place-items: center; border-radius: var(--r-control); }
.auth-cap-refresh:hover { color: var(--brand); background: var(--sunk); }

/* ---------- inline error + shake ---------- */
.auth-error { color: var(--err); font-size: .82rem; margin-top: 8px; text-align: start; min-height: 0; }
.auth-group.shake { animation: auth-shake .3s ease; }
@keyframes auth-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(3px); }
  40% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
  80% { transform: translateX(-3px); }
}

/* ---------- mode switch (text link below the primary button) ---------- */
.auth-switch { margin-top: 16px; font-size: .86rem; color: var(--nb-text-mute); }
.auth-switch a { color: var(--brand); font-weight: 700; text-decoration: none; padding: 2px 4px; }
.auth-switch a:hover { text-decoration: underline; }

/* ---------- settings profile card ---------- */
.set-profile { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--nb-surface); border-radius: var(--auth-radius); margin-bottom: var(--ui-section-gap); }
.set-profile-avatar { flex: none; width: 64px; height: 64px; border-radius: var(--r-avatar-square); display: grid; place-items: center; background: var(--grad); color: #fff; font-size: 1.6rem; font-weight: 900; }
.set-profile-main { flex: 1; min-width: 0; }
.set-profile-name { font-size: 1.2rem; font-weight: 800; }
.set-profile-user { color: var(--nb-text-mute); font-size: .86rem; }
.set-profile-meta { color: var(--nb-text-mute); font-size: .74rem; margin-top: 2px; }
