/* closely — entry flow. Same tokens as the app (app.css :root, and the
   html.dark overrides on #app), so sign-in is the same product, not a portal
   bolted onto the front of one. */

html.auth-open #screen,
html.auth-open #nav { display: none; }

#auth {
  position: absolute;
  inset: 0;
  background: var(--bg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.auth-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* Centred as one block. Pinning the actions to the bottom with margin-top:auto
     opened a dead gap in the middle of every short step. */
  justify-content: center;
  padding: 30px 24px calc(30px + env(safe-area-inset-bottom));
  animation: authIn .24s ease;
}
@keyframes authIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-inner { animation: none; }
}

/* ---------- welcome ---------- */
.auth-hero { text-align: center; }
.auth-mark {
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  color: var(--accent);
  background: var(--accent-soft-2);
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
}
.auth-mark svg { width: 44px; height: 44px; }
.auth-wordmark {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -.02em;
  margin: 0;
  color: var(--text);
}
.auth-tagline {
  margin: 6px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted-2);
}
.auth-body {
  margin: 22px auto 0;
  max-width: 30ch;
  text-align: center;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-2);
}

/* ---------- step heads ---------- */
.auth-head { margin: 0 0 22px; }
.auth-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -.01em;
  margin: 0 0 6px;
  color: var(--text);
}
.auth-sub {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--muted-2);
}

/* ---------- fields ---------- */
#auth .field { margin-top: 4px; }
#auth .field label {
  display: block;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}
#auth .field input {
  width: 100%;
  font-family: inherit;
  font-size: 16px; /* 16px keeps iOS from zooming the page on focus */
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
}
#auth .field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft-2);
}
#auth .field input::placeholder { color: var(--faint); }

.code-input {
  text-align: center;
  letter-spacing: .3em;
  font-weight: 900 !important;
  font-size: 20px !important;
  text-transform: uppercase;
}

/* ---------- otp ---------- */
.otp-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 4px 0 2px;
}
.otp-box {
  width: 100%;
  aspect-ratio: 3 / 4;
  text-align: center;
  font-family: inherit;
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  padding: 0;
}
.otp-box:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft-2);
}
.auth-dev {
  margin: 12px 0 0;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  background: var(--soft);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}

/* ---------- pair choice ---------- */
.auth-pair {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}
.pair-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.pair-card:hover { border-color: var(--accent); }
.pair-ico {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--soft);
  display: grid;
  place-items: center;
  font-size: 20px;
}
.pair-label {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

/* ---------- invite code ---------- */
.code-display {
  margin: 10px 0 16px;
  text-align: center;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: .22em;
  color: var(--accent-text);
  background: var(--surface);
  border: 1px dashed var(--accent);
  border-radius: 18px;
  padding: 22px 12px;
}
.auth-wait {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  padding: 16px;
  background: var(--soft-2);
  border-radius: 16px;
}
.auth-wait b { font-size: 13.5px; color: var(--text); }
.auth-wait .sub { margin: 2px 0 0; }
.auth-spin {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: var(--radius-pill);
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: authSpin .9s linear infinite;
}
@keyframes authSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .auth-spin { animation-duration: 3s; }
}

/* ---------- shared ---------- */
.auth-actions {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.auth-actions .btn { font-size: 15px; padding: 15px 20px; }
.auth-err {
  margin: 14px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--on-accent);
  background: var(--accent-press);
  border-radius: 12px;
  padding: 10px 13px;
}
.auth-foot {
  margin: 20px 0 0;
  text-align: center;
  font-size: 12px;
  line-height: 2;
  color: var(--muted-2);
}
.auth-lang {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  background: var(--soft);
  border-radius: 18px;
  padding: 4px;
}
.auth-lang button {
  background: none;
  border: 0;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.auth-lang button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

#auth :focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

[dir="rtl"] #auth { font-family: var(--font-arabic); }
html:lang(ko) #auth,
html:lang(ja) #auth,
html:lang(zh-Hans) #auth,
html:lang(zh-Hant) #auth { font-family: var(--font-cjk); }
