/* =========================================================
   onboarding.css — conversational onboarding + "Welcome back"
   sign-in for the INSTALLED APP (html.app-mode) only.
   Rendered by js/onboarding.js into #obRoot on landing.html.
   Inherits the landing palette (--lp-* custom properties) so
   light/dark theming follows body.dark-theme automatically.
   ========================================================= */

#obRoot {
  position: fixed;
  inset: 0;
  z-index: 900; /* above the landing page, below the splash (2147483000) */
  display: flex;
  flex-direction: column;
  background: var(--lp-bg, #fbfaf7);
  color: var(--lp-ink, #0a2540);
  font-family: var(--lp-font, "Inter", -apple-system, system-ui, sans-serif);
  padding-top: calc(env(safe-area-inset-top) + 10px);
  padding-bottom: calc(env(safe-area-inset-bottom) + 18px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#obRoot.hidden { display: none; }

/* Soft brand glow, same spirit as the landing page background. */
#obRoot::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(70% 42% at 50% -6%, rgba(37, 99, 235, 0.07), transparent 70%);
}
body.dark-theme #obRoot::before {
  background:
    radial-gradient(70% 42% at 50% -6%, rgba(64, 110, 183, 0.16), transparent 70%);
}

/* ---------- Top bar: back + progress ---------- */
.ob-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px 4px;
  min-height: 44px;
}
.ob-back {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--lp-line, #eae8e1);
  background: var(--lp-bg-card, #fff);
  color: var(--lp-ink, #0a2540);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.ob-back:active { transform: scale(0.94); }
.ob-back svg { width: 18px; height: 18px; }
.ob-back.ob-back-hidden { visibility: hidden; }
.ob-back:focus-visible,
.ob-option:focus-visible,
.ob-chip:focus-visible,
.ob-link:focus-visible {
  outline: 2px solid var(--lp-blue, #2563eb);
  outline-offset: 2px;
}

.ob-progress {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.ob-progress-track {
  flex: 1 1 auto;
  height: 3px;
  border-radius: 99px;
  background: var(--lp-line, #eae8e1);
  overflow: hidden;
}
.ob-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--lp-ink, #0a2540);
  transition: width 0.4s var(--lp-ease, ease);
}
.ob-progress-count {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--lp-ink-mute, #8394a7);
  font-variant-numeric: tabular-nums;
}
.ob-progress.ob-progress-hidden { visibility: hidden; }

/* ---------- Step body ---------- */
.ob-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  padding: 12px 24px 8px;
}

.ob-step { width: 100%; }

/* Enter/leave motion: fade + slight vertical drift + blur. */
.ob-step-enter {
  animation: obEnter 0.32s var(--lp-ease, cubic-bezier(0.22, 1, 0.36, 1)) both;
}
.ob-step-leave {
  animation: obLeave 0.18s ease both;
  pointer-events: none;
}
@keyframes obEnter {
  from { opacity: 0; transform: translateY(16px); filter: blur(4px); }
  to   { opacity: 1; transform: translateY(0);    filter: blur(0); }
}
@keyframes obLeave {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-12px); }
}

/* ---------- Typography ---------- */
.ob-kicker {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--lp-ink-mute, #8394a7);
  margin: 0 0 14px;
}
.ob-h1 {
  font-size: clamp(27px, 7.2vw, 36px);
  line-height: 1.16;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  outline: none; /* focus target on step change; visible focus not needed on a heading */
}
.ob-h1 em {
  font-family: var(--lp-serif, Georgia, serif);
  font-style: italic;
  font-weight: 400;
}
.ob-sub {
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--lp-ink-soft, #46586d);
  margin: 0 0 26px;
}

/* ---------- Text inputs ---------- */
.ob-field { display: block; margin: 0 0 14px; }
.ob-input {
  width: 100%;
  padding: 15px 16px;
  border-radius: 14px;
  border: 1px solid var(--lp-line-strong, #d9d6cc);
  background: var(--lp-bg-card, #fff);
  color: var(--lp-ink, #0a2540);
  font-family: inherit;
  font-size: 17px; /* ≥16px so iOS doesn't zoom the viewport on focus */
  font-weight: 500;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ob-input::placeholder { color: var(--lp-ink-mute, #8394a7); font-weight: 400; }
.ob-input:focus {
  outline: none;
  border-color: var(--lp-ink, #0a2540);
  box-shadow: 0 0 0 3px rgba(10, 37, 64, 0.08);
}
body.dark-theme .ob-input:focus {
  border-color: var(--lp-ink, #f5f7fb);
  box-shadow: 0 0 0 3px rgba(245, 247, 251, 0.12);
}

/* Gentle inline validation — quiet text, no banners, no shake. */
.ob-error {
  display: none;
  font-size: 13.5px;
  line-height: 1.4;
  color: #b4231f;
  margin: 8px 2px 0;
}
body.dark-theme .ob-error { color: #f0a9a5; }
.ob-error.visible { display: block; }

/* Neutral (non-error) helper line, e.g. "check your email". */
.ob-note {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--lp-ink-soft, #46586d);
  background: var(--lp-accent-soft, #eef3f9);
  border: 1px solid var(--lp-line, #eae8e1);
  border-radius: 12px;
  padding: 11px 14px;
  margin: 0 0 14px;
}

/* ---------- Large selectable options ---------- */
.ob-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 8px;
}
.ob-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--lp-line-strong, #d9d6cc);
  background: var(--lp-bg-card, #fff);
  color: var(--lp-ink, #0a2540);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.18s var(--lp-ease, ease);
}
.ob-option:active { transform: scale(0.985); }
.ob-option .ob-option-check {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--lp-line-strong, #d9d6cc);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.15s ease;
}
.ob-option .ob-option-check svg { width: 12px; height: 12px; }
.ob-option.selected {
  border-color: var(--lp-ink, #0a2540);
  background: var(--lp-accent-soft, #eef3f9);
  animation: obConfirm 0.28s var(--lp-ease, ease);
}
.ob-option.selected .ob-option-check {
  border-color: var(--lp-ink, #0a2540);
  background: var(--lp-ink, #0a2540);
  color: var(--lp-bg-card, #fff);
}
@keyframes obConfirm {
  0% { transform: scale(1); }
  45% { transform: scale(0.975); }
  100% { transform: scale(1); }
}

/* ---------- University chip bank ---------- */
.ob-uni-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 0 0 18px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 2px; /* keep focus rings from clipping */
}
.ob-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 99px;
  border: 1px solid var(--lp-line-strong, #d9d6cc);
  background: var(--lp-bg-card, #fff);
  color: var(--lp-ink, #0a2540);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.ob-chip:active { transform: scale(0.96); }
.ob-chip .ob-chip-tick { display: none; width: 13px; height: 13px; }
.ob-chip.selected {
  border-color: var(--lp-ink, #0a2540);
  background: var(--lp-ink, #0a2540);
  color: var(--lp-bg-card, #fff);
}
body.dark-theme .ob-chip.selected {
  background: var(--lp-ink, #f5f7fb);
  color: #0b1020;
}
.ob-chip.selected .ob-chip-tick { display: inline-block; }
.ob-uni-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--lp-ink-mute, #8394a7);
  margin: 0 0 14px;
}

/* ---------- Buttons & links ---------- */
.ob-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}
.ob-actions .landing-btn { width: 100%; }
.ob-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}
.ob-link {
  background: none;
  border: none;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--lp-ink-soft, #46586d);
  text-decoration: underline;
  text-decoration-color: var(--lp-line-strong, #d9d6cc);
  text-underline-offset: 3px;
  cursor: pointer;
}
.ob-link:hover { color: var(--lp-ink, #0a2540); }
.ob-link-quiet {
  font-weight: 500;
  font-size: 13.5px;
  color: var(--lp-ink-mute, #8394a7);
}

/* Secondary (soft) button reuse from landing.css already; give the
   passkey note some air. */
.ob-auth-note {
  font-size: 13px;
  line-height: 1.5;
  color: var(--lp-ink-mute, #8394a7);
  text-align: center;
  margin: 2px 0 0;
}

/* ---------- Google sign-in button ----------
   Google's brand guidelines: white surface, neutral border, unmodified
   multi-colour "G". Kept identical in dark mode (the mark must not be
   recoloured), with a slightly softer border so it doesn't glare. */
.ob-google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #ffffff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
  font-weight: 600;
}
.ob-google-btn:hover { background: #f7f8f8; border-color: #d2d5d9; }
.ob-google-btn:active { transform: scale(0.99); }
.ob-google-g { width: 18px; height: 18px; flex: 0 0 auto; }
body.dark-theme .ob-google-btn {
  background: #ffffff;
  color: #1f1f1f;
  border-color: rgba(255, 255, 255, 0.22);
}

/* Error shown directly under the auth buttons (outside any form). */
.ob-error-standalone { margin: 10px 2px 0; text-align: center; }

/* ---------- Greeting interstitial ("Nice to meet you, Leo.") ---------- */
.ob-greet {
  text-align: center;
  padding: 40px 0;
  cursor: pointer;
}
.ob-greet .ob-h1 { font-size: clamp(26px, 7vw, 34px); }
.ob-greet .ob-sub { margin-bottom: 0; }

/* ---------- Completion ---------- */
.ob-done-mark {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--lp-ink, #0a2540);
  color: var(--lp-bg-card, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 20px;
  animation: obDoneIn 0.45s var(--lp-ease, ease) both;
}
body.dark-theme .ob-done-mark { color: #0b1020; }
.ob-done-mark svg { width: 24px; height: 24px; }
@keyframes obDoneIn {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

/* Collapsible inline email form on the account/sign-in screens. */
.ob-email-form { display: none; margin-top: 18px; }
.ob-email-form.open { display: block; animation: obEnter 0.26s var(--lp-ease, ease) both; }

/* ---------- Reduced motion: fades only, no drift/blur/scale ---------- */
@media (prefers-reduced-motion: reduce) {
  .ob-step-enter { animation: obFadeOnly 0.15s ease both; }
  .ob-step-leave { animation: none; opacity: 0; }
  .ob-email-form.open { animation: obFadeOnly 0.15s ease both; }
  .ob-done-mark { animation: obFadeOnly 0.2s ease both; }
  .ob-option.selected { animation: none; }
  .ob-option:active, .ob-chip:active, .ob-back:active { transform: none; }
  .ob-progress-fill { transition: none; }
  @keyframes obFadeOnly { from { opacity: 0; } to { opacity: 1; } }
}

/* Tiny screens: keep the step comfortably above the keyboard. */
@media (max-height: 640px) {
  .ob-body { justify-content: flex-start; padding-top: 6vh; }
  .ob-h1 { font-size: clamp(24px, 6.4vw, 30px); }
}
