/* Sign in / sign up (V3) — see pages/auth.js.
   The cover is the daftar itself: teal, ruled lines like the logo, a big faint mark. Each step's question is
   written ON the cover's lines (its line-height is the rule height); the sheet below holds the answer.
   Colors come from tokens only; the cover has its own derived set so dark mode stays a deep, calm teal. */

.auth {
  --rule: 36px;            /* distance between the ruled lines = line-height of the cover titles */
  --rule-shift: -9px;      /* puts each line right under the letters (Vazirmatn baseline sits 25px into a 36px line) */
  --gutter: 20px;
  --overlap: 26px;         /* how far the sheet rides up over the cover */
  --cover-a: var(--brand);
  --cover-b: var(--brand-strong);
  --cover-ink: #fff;
  --cover-ink-2: color-mix(in srgb, #fff 80%, transparent);
  --cover-mark: #fff;
  --cover-deep: var(--brand-strong);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .auth {
    --cover-a: var(--brand-soft);
    --cover-b: var(--brand-softer);
    --cover-ink: var(--text);
    --cover-ink-2: var(--text-2);
    --cover-mark: var(--brand);
    --cover-deep: var(--brand-softer);
  }
}
:root[data-theme='dark'] .auth {
  --cover-a: var(--brand-soft);
  --cover-b: var(--brand-softer);
  --cover-ink: var(--text);
  --cover-ink-2: var(--text-2);
  --cover-mark: var(--brand);
  --cover-deep: var(--brand-softer);
}

/* Phones: whatever shows below the sheet (browser bars coming and going) is the sheet's color, never a seam. */
@media (max-width: 720px) { html:has(.auth) { background: var(--surface); } }

/* ---------- cover ---------- */
.auth-cover {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  color: var(--cover-ink);
  padding: var(--safe-t) var(--gutter) calc(var(--overlap) + var(--rule));
  background-color: var(--cover-b);
  background-image:
    linear-gradient(to bottom, transparent calc(var(--rule) - 1px), color-mix(in srgb, var(--cover-ink) 10%, transparent) calc(var(--rule) - 1px)),
    linear-gradient(165deg, var(--cover-a) 10%, var(--cover-b) 100%);
  background-size: 100% var(--rule), 100% 100%;
  background-position: 0 calc(var(--safe-t) + var(--rule-shift)), 0 0;
  background-repeat: repeat-y, no-repeat;
}
.auth-cover-in { position: relative; max-width: 440px; margin: 0 auto; }
/* V5: the decorative watermark must not widen the page (2 px sideways scroll on phones) */
.auth-cover, .auth { overflow-x: clip; }
.auth-cover :focus-visible { outline-color: var(--cover-ink); }

.auth-wm { position: absolute; z-index: -1; top: calc(var(--rule) * 2); inset-inline-end: -78px; width: 290px; height: 290px; pointer-events: none; }
.auth-wm path { fill: color-mix(in srgb, var(--cover-ink) 6%, transparent); }

.auth-bar { display: flex; align-items: center; gap: 12px; height: calc(var(--rule) * 2); }
.auth-bar .lang-picker { margin-inline-start: auto; }
.auth-back {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 44px; height: 44px; border-radius: 50%;
  color: var(--cover-ink); background: color-mix(in srgb, var(--cover-ink) 12%, transparent);
  transition: background var(--dur);
}
.auth-back:hover { background: color-mix(in srgb, var(--cover-ink) 20%, transparent); }

.auth-hero { padding-top: calc(var(--rule) * 2); }
@media (max-height: 700px) { .auth-hero { padding-top: var(--rule); } }
.auth-lockup { display: flex; align-items: center; gap: 12px; height: calc(var(--rule) * 2); }
.auth-mark { flex: 0 0 auto; }
.auth-wordmark { font-size: 32px; font-weight: 900; letter-spacing: -0.015em; line-height: 1; }
:lang(en) .auth-wordmark { font-weight: 800; letter-spacing: -0.03em; }

.auth-title {
  max-width: 16em;
  font-size: clamp(23px, 6.6vw, 28px);
  font-weight: 800;
  line-height: var(--rule);
  letter-spacing: -0.01em;
  color: var(--cover-ink);
  text-wrap: balance;
  animation: auth-fade 320ms var(--ease) both;
}
.auth-promise { font-size: clamp(25px, 7.2vw, 30px); }

/* ---------- sheet ---------- */
.auth-sheet {
  position: relative; z-index: 1;
  flex: 1 0 auto;
  margin-top: calc(-1 * var(--overlap));
  padding: 26px var(--gutter) calc(32px + var(--safe-b));
  background: var(--surface);
  border-radius: 26px 26px 0 0;
}
.auth-step { --auth-flip: 1; max-width: 440px; margin: 0 auto; animation: auth-step-in 300ms var(--ease) both; }
.auth-step.is-back { --auth-flip: -1; }
[dir='rtl'] .auth-step { --auth-flip: -1; }
[dir='rtl'] .auth-step.is-back { --auth-flip: 1; }
.auth-step.is-first { animation-name: auth-fade; }

@keyframes auth-step-in { from { opacity: 0; transform: translateX(calc(var(--auth-flip) * 22px)); } to { opacity: 1; transform: none; } }
@keyframes auth-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-lead { color: var(--text-2); font-size: var(--fs-md); line-height: 1.6; }
.auth-hint { color: var(--text-3); font-size: var(--fs-xs); line-height: 1.6; text-align: center; }
.auth-field-main .field-label { font-size: var(--fs-md); font-weight: 800; color: var(--text); }

.auth-form .input { min-height: 52px; border-radius: 14px; }
/* PasswordInput's field is dir="auto" (LTR for dots/Latin) while its eye button sits at the page's inline end:
   on RTL pages keep the text clear of the button (left) and next to the label (right). */
[dir='rtl'] .auth-form .input-wrap .input { padding-left: 50px; padding-right: 14px; text-align: right; }
.auth-form .phone-input {
  min-height: 62px; padding-inline: 18px;
  border-width: 2px; border-radius: 16px;
  font-size: 23px; font-weight: 700; letter-spacing: .05em;
  font-variant-numeric: tabular-nums;
}
.auth-form .phone-input::placeholder { font-weight: 600; }
.auth-form .otp-input { min-height: 70px; font-size: 32px; border-width: 2px; border-radius: 18px; }
.auth-form .btn-lg { min-height: 56px; border-radius: 16px; font-weight: 800; }

/* the two promise lines under the phone button */
.auth-notes { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.auth-note { display: flex; align-items: flex-start; gap: 10px; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.55; }
.auth-note > .icon { flex: 0 0 auto; margin-top: 1px; color: var(--brand); }
.auth-ribbon { flex: 0 0 auto; width: 12px; height: 18px; margin-inline: 3px; color: var(--gold); }
/* V5: launch offer tag (amber) and the "a friend invited you" line */
.auth-launch { display: inline-flex; padding: 2px 12px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-ink); font-weight: 800; line-height: 1.6; }
.auth-ref { color: var(--text); font-weight: 700; }
.auth-ref > .icon { color: var(--accent-strong); }

/* the number this flow is about */
.auth-number {
  display: flex; align-items: center; gap: 12px;
  min-height: 58px; padding-block: 7px; padding-inline: 8px 6px;
  border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border);
}
.auth-number-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm);
}
.auth-number-icon.ok { background: var(--brand); color: var(--brand-ink); box-shadow: none; }
.auth-number-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; color: var(--text); font-size: var(--fs-lg); font-weight: 800; line-height: 1.3; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
.auth-number-ok { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0; color: var(--brand-strong); }
.auth-number-change {
  margin-inline-start: auto; flex: 0 0 auto;
  min-height: 44px; padding: 0 12px; border-radius: 12px;
  font-size: var(--fs-sm); font-weight: 800; color: var(--brand); white-space: nowrap;
}
.auth-number-change:hover { background: var(--brand-softer); }

/* quiet text actions */
.auth-link {
  align-self: center; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 14px; border-radius: 12px;
  font-weight: 800; color: var(--brand);
}
.auth-link:hover { background: var(--brand-softer); text-decoration: none; }
.auth-link:disabled { opacity: .6; cursor: default; }
.auth-resend { display: flex; align-items: center; justify-content: center; min-height: 44px; margin-top: -6px; }
.auth-resend:empty { display: none; }
.auth-timer { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: var(--fs-sm); font-weight: 600; }
.auth-timer b { color: var(--text-2); font-weight: 800; }
.auth-help { align-self: center; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 10px; border-radius: 10px; color: var(--text-3); font-size: var(--fs-sm); font-weight: 600; }
.auth-help:hover { color: var(--brand); text-decoration: none; }
/* V5.0.1: «ما وصلك على واتساب؟ أرسل برسالة SMS» — quieter than the resend link */
.auth-sms { margin-top: -10px; color: var(--text-2); font-size: var(--fs-sm); font-weight: 700; white-space: normal; text-align: center; }
.auth-sms:hover { color: var(--brand); }
.auth-dev { align-items: center; }
.auth-dev-code { font-size: var(--fs-lg); letter-spacing: .14em; }

/* ---------- language picker (also usable outside the auth page) ---------- */
.lang-picker { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.lang-btn {
  min-height: 48px; padding: 0 20px; border-radius: var(--r-pill);
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font-size: var(--fs-md); font-weight: 700;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.lang-btn:hover { background: var(--surface-2); color: var(--text); }
.lang-btn.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.lang-picker.compact { flex-wrap: nowrap; gap: 2px; padding: 3px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--border); }
.lang-picker.compact .lang-btn { min-height: 38px; padding: 0 12px; border: 0; background: transparent; font-size: var(--fs-sm); }
.lang-picker.compact .lang-btn.active { background: var(--surface); color: var(--brand-strong); box-shadow: var(--shadow-sm); }
.auth-cover .lang-picker.compact { background: color-mix(in srgb, var(--cover-ink) 12%, transparent); border-color: color-mix(in srgb, var(--cover-ink) 18%, transparent); }
.auth-cover .lang-picker.compact .lang-btn { color: var(--cover-ink-2); }
.auth-cover .lang-picker.compact .lang-btn:hover { color: var(--cover-ink); background: color-mix(in srgb, var(--cover-ink) 10%, transparent); }
.auth-cover .lang-picker.compact .lang-btn.active { background: var(--cover-ink); color: var(--cover-deep); box-shadow: none; }

/* ---------- wide screens: a teal band with the sheet as a card on it ---------- */
@media (min-width: 721px) {
  .auth { --overlap: 104px; background: var(--bg); }
  .auth-cover { padding-inline: 24px; padding-bottom: calc(var(--overlap) + var(--rule) * 2); }
  /* the mark sits in the free space beside the column (positioned against the whole band) */
  .auth-cover-in { position: static; max-width: 480px; padding-inline: 32px; }
  .auth-wm { width: 360px; height: 360px; top: calc(var(--rule) + 6px); inset-inline-end: calc((100% - 480px) / 4 - 180px); }
  .auth-sheet {
    flex: 0 0 auto;
    width: calc(100% - 48px); max-width: 480px;
    margin: calc(-1 * var(--overlap)) auto 56px;
    padding: 32px;
    border-radius: 28px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
}
