/* ============================================================
   Routes - Sign in / create account (class prefix .ra-)

   One flow, two shells:
     • .ra-root      global modal (desktop) / full-screen sheet (phones)
     • .ra-page      the /login and /register routes

   Steps: email → (password | create) → verify code → done.
   ============================================================ */

:root {
  --ra-ink: #0e1116;
  --ra-ink-soft: #3d4452;
  --ra-muted: #6b7280;
  --ra-faint: #9aa1ae;
  --ra-line: rgba(16, 24, 40, 0.1);
  --ra-line-strong: rgba(16, 24, 40, 0.18);
  --ra-navy: #132a8e;
  --ra-navy-deep: #0f2170;
  --ra-orange: #ff7a1a;
  --ra-save: #0e9f6e;
  --ra-danger: #d92d20;
  --ra-surface: #f7f8fb;
  --ra-display: "Plus Jakarta Sans", "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --ra-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ------------------------------------------------------------ shell */
.ra-root {
  position: fixed;
  inset: 0;
  z-index: 1300; /* above the vehicle showcase (1000) and savings nudge (1200) */
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--ra-ink);
  -webkit-font-smoothing: antialiased;
}
.ra-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 16, 0.62);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}
.ra-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(452px, 100%);
  max-height: calc(100dvh - 40px);
  overflow: hidden;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 50px 110px -34px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* The floating currency pill must not sit over the dialog. */
body:has(.ra-root) .rcy-fab {
  opacity: 0;
  pointer-events: none;
}

.ra-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(16, 24, 40, 0.06);
  color: var(--ra-ink-soft);
  cursor: pointer;
  transition: background 0.2s var(--ra-ease), transform 0.2s var(--ra-ease);
}
.ra-close:hover {
  background: rgba(16, 24, 40, 0.12);
  transform: rotate(90deg);
}
.ra-back {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(16, 24, 40, 0.06);
  color: var(--ra-ink-soft);
  cursor: pointer;
  transition: background 0.2s var(--ra-ease), transform 0.2s var(--ra-ease);
}
.ra-back:hover {
  background: rgba(16, 24, 40, 0.12);
  transform: translateX(-2px);
}

/* ------------------------------------------------------------ body */
.ra-body {
  padding: 34px 30px 26px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.ra-step { position: relative; }

.ra-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: linear-gradient(135deg, #1c3aa9 0%, var(--ra-navy) 55%, var(--ra-navy-deep) 100%);
  color: #fff;
  box-shadow: 0 16px 30px -14px rgba(19, 42, 142, 0.8);
}
.ra-mark--save {
  background: linear-gradient(135deg, #17c27f 0%, var(--ra-save) 100%);
  box-shadow: 0 16px 30px -14px rgba(14, 159, 110, 0.85);
}
.ra-title {
  margin: 16px 0 0;
  font-family: var(--ra-display);
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.ra-sub {
  margin: 8px 0 0;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ra-muted);
}
.ra-sub b { color: var(--ra-ink); font-weight: 700; }

/* why the dialog opened - set by the caller (e.g. member rate) */
.ra-reason {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 13px;
  background: #eef1fb;
  color: var(--ra-navy);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}
.ra-reason svg { flex: none; }

/* ------------------------------------------------------------ fields */
.ra-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}
.ra-field { position: relative; }
.ra-input {
  width: 100%;
  height: 58px;
  padding: 22px 14px 8px 44px;
  border: 1px solid var(--ra-line-strong);
  border-radius: 15px;
  background: #fff;
  color: var(--ra-ink);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.18s var(--ra-ease), box-shadow 0.18s var(--ra-ease), background 0.18s;
  /* iOS must not zoom the page when a field takes focus */
  -webkit-text-size-adjust: 100%;
}
.ra-input::placeholder { color: transparent; }
.ra-input:hover { border-color: rgba(16, 24, 40, 0.28); }
.ra-input:focus {
  border-color: var(--ra-navy);
  box-shadow: 0 0 0 4px rgba(19, 42, 142, 0.12);
}
.ra-label {
  position: absolute;
  top: 50%;
  left: 44px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ra-faint);
  transform: translateY(-50%);
  transform-origin: left center;
  pointer-events: none;
  transition: transform 0.18s var(--ra-ease), color 0.18s var(--ra-ease);
}
.ra-input:focus + .ra-label,
.ra-input:not(:placeholder-shown) + .ra-label {
  transform: translateY(-138%) scale(0.74);
  color: var(--ra-muted);
}
.ra-input:focus + .ra-label { color: var(--ra-navy); }
.ra-field-ic {
  position: absolute;
  top: 50%;
  left: 15px;
  display: grid;
  place-items: center;
  color: var(--ra-faint);
  transform: translateY(-50%);
  pointer-events: none;
  transition: color 0.18s var(--ra-ease);
}
.ra-input:focus ~ .ra-field-ic { color: var(--ra-navy); }
.ra-field.is-bad .ra-input {
  border-color: var(--ra-danger);
  background: #fff7f6;
}
.ra-field.is-bad .ra-field-ic { color: var(--ra-danger); }
.ra-field.is-ok .ra-input { border-color: rgba(14, 159, 110, 0.55); }
.ra-peek {
  position: absolute;
  top: 50%;
  right: 10px;
  padding: 6px 8px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ra-muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transform: translateY(-50%);
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}
.ra-peek:hover { background: rgba(16, 24, 40, 0.05); color: var(--ra-ink); }
.ra-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 6px 2px 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ra-muted);
}
.ra-hint--bad { color: var(--ra-danger); }

/* password strength */
.ra-strength {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 2px 0;
}
.ra-strength-bars {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.ra-strength-bars i {
  height: 4px;
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.1);
  transition: background 0.3s var(--ra-ease);
}
.ra-strength[data-score="1"] .ra-strength-bars i:nth-child(-n + 1) { background: #e0483e; }
.ra-strength[data-score="2"] .ra-strength-bars i:nth-child(-n + 2) { background: #f2994a; }
.ra-strength[data-score="3"] .ra-strength-bars i:nth-child(-n + 3) { background: #f2c94c; }
.ra-strength[data-score="4"] .ra-strength-bars i { background: var(--ra-save); }
.ra-strength-lbl {
  min-width: 5.5em;
  font-size: 0.7rem;
  font-weight: 800;
  text-align: right;
  color: var(--ra-muted);
}

/* ------------------------------------------------------------ buttons */
.ra-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 54px;
  margin-top: 4px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(135deg, #1c3aa9 0%, var(--ra-navy) 55%, var(--ra-navy-deep) 100%);
  color: #fff;
  font-family: var(--ra-display);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 20px 36px -18px rgba(19, 42, 142, 0.9);
  transition: transform 0.2s var(--ra-ease), box-shadow 0.2s var(--ra-ease), filter 0.2s;
}
.ra-cta:hover:not(:disabled) { transform: translateY(-1px); filter: saturate(1.06); }
.ra-cta:active:not(:disabled) { transform: translateY(0) scale(0.99); }
.ra-cta:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.ra-cta--orange {
  background: linear-gradient(135deg, #ff8f33 0%, var(--ra-orange) 55%, #e56a0f 100%);
  box-shadow: 0 20px 36px -18px rgba(255, 122, 26, 0.9);
}
.ra-textbtn {
  padding: 6px 4px;
  border: 0;
  background: none;
  color: var(--ra-muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.2s;
}
.ra-textbtn:hover { color: var(--ra-ink); }
.ra-textbtn:disabled { opacity: 0.5; cursor: not-allowed; text-decoration: none; }

/* ------------------------------------------------------------ alternate sign-in */
.ra-alt {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--ra-line);
}
.ra-alt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  height: 50px;
  border: 1px solid var(--ra-line-strong);
  border-radius: 15px;
  background: #fff;
  color: var(--ra-ink);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.18s var(--ra-ease), background 0.18s var(--ra-ease), transform 0.18s var(--ra-ease);
}
.ra-alt-btn:hover:not(:disabled) {
  border-color: rgba(19, 42, 142, 0.4);
  background: #f7f9ff;
  transform: translateY(-1px);
}
.ra-alt-btn:active:not(:disabled) { transform: translateY(0) scale(0.99); }
.ra-alt-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.ra-alt-btn svg { color: var(--ra-navy); }

/* ------------------------------------------------------------ social */
.ra-social {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}
.ra-soc {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid var(--ra-line-strong);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.18s var(--ra-ease), background 0.18s var(--ra-ease),
    transform 0.18s var(--ra-ease), box-shadow 0.18s var(--ra-ease);
}
.ra-soc:hover {
  border-color: rgba(16, 24, 40, 0.3);
  background: #fbfbfd;
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -12px rgba(16, 24, 40, 0.5);
}
.ra-soc:active { transform: translateY(0) scale(0.96); }
.ra-soc:disabled { opacity: 0.55; cursor: wait; }
.ra-soc svg { flex: none; }

.ra-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 2px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ra-faint);
}
.ra-or::before,
.ra-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ra-line);
}

/* ------------------------------------------------------------ email chip */
.ra-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin-top: 14px;
  padding: 7px 8px 7px 12px;
  border: 1px solid var(--ra-line);
  border-radius: 999px;
  background: var(--ra-surface);
  font-size: 0.82rem;
  font-weight: 700;
}
.ra-chip-mail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ra-chip-edit {
  flex: none;
  padding: 3px 9px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--ra-navy);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--ra-line);
  transition: background 0.18s, color 0.18s;
}
.ra-chip-edit:hover { background: var(--ra-navy); color: #fff; }

/* ------------------------------------------------------------ OTP */
.ra-otp {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
}
.ra-otp input {
  width: 100%;
  height: 62px;
  padding: 0;
  border: 1px solid var(--ra-line-strong);
  border-radius: 14px;
  background: #fff;
  color: var(--ra-ink);
  font-family: var(--ra-display);
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  outline: none;
  transition: border-color 0.18s var(--ra-ease), box-shadow 0.18s var(--ra-ease), transform 0.18s var(--ra-ease);
  font-variant-numeric: tabular-nums;
}
.ra-otp input:focus {
  border-color: var(--ra-navy);
  box-shadow: 0 0 0 4px rgba(19, 42, 142, 0.12);
  transform: translateY(-1px);
}
.ra-otp input:not(:placeholder-shown) {
  border-color: rgba(19, 42, 142, 0.4);
  background: #f7f9ff;
}
.ra-otp.is-bad input {
  border-color: var(--ra-danger);
  background: #fff7f6;
}
.ra-otp.is-bad { animation: ra-shake 0.4s var(--ra-ease); }
@keyframes ra-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}
.ra-resend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ra-muted);
}

/* ------------------------------------------------------------ messages */
.ra-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 13px;
  background: #fff1f0;
  color: #a92419;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.4;
}
.ra-alert svg { flex: none; margin-top: 1px; }
.ra-alert--info { background: #eef1fb; color: var(--ra-navy); }
.ra-alert--good { background: #e7f8f0; color: #067a54; }

.ra-legal {
  margin: 16px 0 0;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  color: var(--ra-faint);
}
.ra-legal a { color: var(--ra-muted); text-decoration: underline; text-underline-offset: 2px; }
.ra-switch {
  margin: 16px 0 0;
  font-size: 0.83rem;
  font-weight: 600;
  text-align: center;
  color: var(--ra-muted);
}
.ra-switch button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ra-navy);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.ra-switch button:hover { text-decoration: underline; text-underline-offset: 3px; }

/* perks strip under the email step */
.ra-perks {
  display: grid;
  gap: 7px;
  margin: 18px 0 0;
  padding: 14px 14px;
  border-radius: 15px;
  background: var(--ra-surface);
  list-style: none;
}
.ra-perks li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ra-ink-soft);
}
.ra-perks svg { flex: none; color: var(--ra-save); }

/* ------------------------------------------------------------ done */
.ra-done {
  display: grid;
  place-items: center;
  padding: 42px 30px 46px;
  text-align: center;
}
.ra-done-ring {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: linear-gradient(135deg, #17c27f 0%, var(--ra-save) 100%);
  color: #fff;
  box-shadow: 0 22px 42px -18px rgba(14, 159, 110, 0.9);
}

/* ------------------------------------------------------------ phones: full-screen sheet */
@media (max-width: 599px) {
  .ra-root { padding: 0; place-items: stretch; }
  .ra-card {
    width: 100%;
    max-height: none;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .ra-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: calc(60px + env(safe-area-inset-top)) 20px calc(26px + env(safe-area-inset-bottom));
  }
  /* centre short steps, stay scrollable from the top when they're tall */
  .ra-body > .ra-step { margin-block: auto; }
  .ra-close,
  .ra-back { top: calc(14px + env(safe-area-inset-top)); }
  .ra-title { font-size: 1.5rem; }
  .ra-otp { gap: 6px; }
  .ra-otp input { height: 56px; font-size: 1.32rem; }
}

/* very small phones - keep everything on one screen */
@media (max-width: 599px) and (max-height: 700px) {
  .ra-body { padding-top: calc(52px + env(safe-area-inset-top)); }
  .ra-mark { width: 40px; height: 40px; border-radius: 13px; }
  .ra-title { margin-top: 12px; font-size: 1.35rem; }
  .ra-form { gap: 10px; margin-top: 16px; }
  .ra-input { height: 54px; }
  .ra-cta { height: 50px; }
  .ra-soc { width: 48px; height: 48px; }
  .ra-perks { display: none; }
  .ra-otp input { height: 52px; }
}

/* ------------------------------------------------------------ /login and /register pages */
.ra-page {
  width: 100%;
  color: var(--ra-ink);
}
.ra-page .ra-body { padding: 0; overflow: visible; }
.ra-page .ra-card {
  width: 100%;
  max-height: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
.ra-page .ra-close,
.ra-page .ra-back { display: none; }
.ra-page .ra-step-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ra-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.ra-page .ra-step-back:hover { color: var(--ra-ink); }
.ra-card .ra-step-back { display: none; }

@media (prefers-reduced-motion: reduce) {
  .ra-otp.is-bad { animation: none; }
  .ra-cta,
  .ra-soc,
  .ra-close,
  .ra-back { transition: none; }
}
