/* Buyer-auth modal — Phase 5a.
 * Hand-written CSS, .bauth-* prefix per the buyer-auth-prompt.md
 * stack constraints. Visual baseline matches the admin sign-in modal
 * (blue gradient backdrop, white card, scrypt trust footer) but is a
 * separate stylesheet — admin modal lives in apps/portals (React) and
 * is not reusable from /landing.
 */

.bauth-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, rgba(11, 31, 63, 0.84) 0%, rgba(26, 59, 122, 0.84) 60%, rgba(36, 87, 197, 0.84) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  animation: bauth-fade-in 160ms ease-out forwards;
}
@keyframes bauth-fade-in { to { opacity: 1; } }

.bauth-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border-radius: 18px;
  padding: 32px 32px 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.32);
  font-family: var(--font-body);
  color: #0c1424;
  transform: translateY(8px);
  animation: bauth-slide-in 220ms cubic-bezier(.2,.8,.2,1) forwards;
}
@keyframes bauth-slide-in { to { transform: translateY(0); } }

.bauth-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.bauth-head .bauth-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #475069;
  font-size: 13px;
  font-weight: 500;
}
.bauth-head .bauth-brand-mark {
  width: 28px;
  height: 28px;
  background: var(--ss-navy, #0D2B55);
  border-radius: 8px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.bauth-x {
  background: transparent;
  border: none;
  width: var(--ss-tap, 44px);
  height: var(--ss-tap, 44px);
  margin: -6px -8px -6px 0;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ss-ink-3, #5B6B84);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms;
}
.bauth-x:hover { background: #f6f7fb; color: #0c1424; }
.bauth-x svg { width: 18px; height: 18px; }

.bauth-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 14px 0 6px;
}
.bauth-sub {
  font-size: 13px;
  color: #475069;
  margin: 0 0 22px;
  line-height: 1.5;
}

/* Tabs (Phone | Email) at the top of signin / signup_step1 */
.bauth-tabs {
  display: flex;
  background: #f6f7fb;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 22px;
}
.bauth-tab {
  flex: 1;
  padding: 9px 8px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ss-ink-3, #5B6B84);
  min-height: var(--ss-tap, 44px);
  cursor: pointer;
  font-family: inherit;
  transition: background 150ms, color 150ms, box-shadow 150ms;
}
.bauth-tab.is-active {
  background: #ffffff;
  color: #0c1424;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(12, 20, 36, 0.06);
}

/* Country chip for the phone input (locked +63 / 🇵🇭) */
.bauth-phone-row {
  display: flex;
  gap: 8px;
}
.bauth-cc {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  background: #f6f7fb;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #0c1424;
  user-select: none;
}
.bauth-cc .bauth-flag { font-size: 16px; line-height: 1; }
.bauth-phone-row input.bauth-phone-input { flex: 1 1 auto; }

/* Secondary CTA: "Sign in with SMS code instead" — dashed border, blue text */
.bauth-secondary {
  width: 100%;
  margin-top: 10px;
  padding: 11px 16px;
  background: transparent;
  color: var(--ss-navy, #0D2B55);
  border: 1.5px dashed var(--ss-line-2, #CBD4E1);
  min-height: var(--ss-tap, 44px);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 150ms, border-color 150ms;
}
.bauth-secondary:hover:not(:disabled) {
  background: var(--ss-cyan-tint, #E8F4FC);
  border-color: var(--ss-navy, #0D2B55);
}
.bauth-secondary:disabled { opacity: 0.55; cursor: not-allowed; }

/* OTP digit entry — six 1-character boxes */
.bauth-otp-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  justify-content: space-between;
}
.bauth-otp-row input {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  padding: 14px 0;
  background: #f6f7fb;
  border: none;
  border-radius: 10px;
  color: #0c1424;
  outline: none;
  transition: box-shadow 150ms;
}
.bauth-otp-row input:focus {
  box-shadow: inset 0 0 0 1.5px #3b78ff;
}

.bauth-field {
  margin-bottom: 14px;
}
.bauth-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #0c1424;
}
.bauth-field input {
  width: 100%;
  min-height: var(--ss-tap, 44px);
  padding: 11px 12px;
  background: #f6f7fb;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  color: #0c1424;
  font-family: inherit;
  outline: none;
  transition: box-shadow 150ms;
}
.bauth-field input:focus {
  box-shadow: inset 0 0 0 1.5px #3b78ff;
}
.bauth-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.bauth-label-row label {
  margin-bottom: 0;
}
.bauth-generate {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ss-navy, #0D2B55);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}
.bauth-generate::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: max(100%, var(--ss-tap, 44px)); height: max(100%, var(--ss-tap, 44px));
  translate: -50% -50%;
}
.bauth-generate:hover { text-decoration: underline; }
.bauth-generate.is-copied { color: var(--success, #107A4D); }
.bauth-field .bauth-input-wrap {
  position: relative;
}
.bauth-field .bauth-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--ss-tap, 44px);
  min-height: var(--ss-tap, 44px);
  background: transparent;
  border: none;
  font-size: 12px;
  color: #475069;
  cursor: pointer;
  padding: 0 12px;
  border-radius: 6px;
}
.bauth-field .bauth-toggle:hover { color: var(--ss-navy, #0D2B55); }
/* The Show button is 44px wide now, so typed text stops short of it. */
.bauth-field .bauth-input-wrap input { padding-right: 64px; }

.bauth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -10px 0 8px;
  font-size: 13px;
}
.bauth-row a {
  display: inline-flex;
  align-items: center;
  min-height: var(--ss-tap, 44px);
  color: var(--ss-navy, #0D2B55);
  text-decoration: none;
  font-weight: 600;
}
.bauth-row a:hover { text-decoration: underline; }
.bauth-row label {
  display: flex;
  align-items: center;
  min-height: var(--ss-tap, 44px);
  gap: 6px;
  color: #475069;
  cursor: pointer;
}

.bauth-primary {
  width: 100%;
  min-height: var(--ss-tap, 44px);
  padding: 12px 16px;
  background: var(--ss-action, #0D2B55);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter 150ms, transform 80ms;
}
.bauth-primary:hover:not(:disabled) { background: var(--ss-action-hover, #143A6B); }
.bauth-primary:active:not(:disabled) { transform: translateY(1px); }
.bauth-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.bauth-primary .bauth-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: bauth-spin 700ms linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}
@keyframes bauth-spin { to { transform: rotate(360deg); } }

/* AUTH-01: a flex row, so the rules always stop at the label whatever its
 * width (the old calc(50% - 36px) rules assumed a label under 72px and ran
 * through "or continue with"). */
.bauth-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  font-size: 12px;
  color: var(--ss-ink-3, #5B6B84);
  white-space: nowrap;
  text-transform: lowercase;
}
.bauth-or::before, .bauth-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ss-line, #E3E8EF);
}

.bauth-oauth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
/* AUTH-02: only live providers render, so a lone button takes the full row. */
.bauth-oauth-grid > :only-child { grid-column: 1 / -1; }
.bauth-oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--ss-tap, 44px);
  padding: 10px 12px;
  background: #fff;
  border: 1.5px solid #e6e9f2;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #0c1424;
  font-family: inherit;
  cursor: not-allowed;
  opacity: 0.55;
  position: relative;
}
/* #1877F2 gives white text 4.23:1; Facebook's own hover blue passes (4.73:1). */
.bauth-oauth-btn[data-provider="facebook"] {
  background: #166FE5;
  color: #fff;
  border-color: #166FE5;
}
/* Phase 4: active state — buttons go solid + clickable when the
 * provider is configured server-side. Disabled "Soon" state stays
 * for unconfigured providers. */
.bauth-oauth-btn.is-active {
  cursor: pointer;
  opacity: 1;
}
.bauth-oauth-btn.is-active:hover {
  filter: brightness(0.97);
}
.bauth-oauth-btn.is-active[data-provider="google"]:hover {
  border-color: var(--ss-navy, #0D2B55);
  background: var(--ss-cyan-tint, #E8F4FC);
}
.bauth-oauth-btn.is-active[data-provider="facebook"]:hover {
  background: #1466D2;
}
.bauth-oauth-btn .bauth-soon {
  font-size: var(--ss-t-12, .75rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ss-ink-3, #5B6B84);
  margin-left: 4px;
}
.bauth-oauth-btn[data-provider="facebook"] .bauth-soon { color: #fff; }

.bauth-foot {
  text-align: center;
  font-size: 13px;
  color: #475069;
  margin: 0 0 8px;
}
.bauth-foot a {
  color: var(--ss-navy, #0D2B55);
  text-decoration: none;
  font-weight: 600;
}
.bauth-foot a:hover { text-decoration: underline; }

/* New-buyer CTA — "Create account" used to be footer small print under the
 * OAuth row and first-timers missed it. It now gets its own separated block
 * with a full-width outlined button: clearly secondary to the blue "Sign in"
 * primary, but unmistakably a button. */
.bauth-newuser {
  margin-top: 2px;
  padding-top: 18px;
  border-top: 1px solid #f0f1f6;
  text-align: center;
}
.bauth-newuser-label {
  font-size: 13px;
  font-weight: 600;
  color: #475069;
  margin-bottom: 10px;
}
.bauth-create {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--ss-tap, 44px);
  padding: 12px 16px;
  background: var(--ss-surface, #fff);
  color: var(--ss-navy, #0D2B55);
  border: 1.5px solid var(--ss-navy, #0D2B55);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 150ms, border-color 150ms, transform 80ms;
}
.bauth-create:hover { background: var(--ss-cyan-tint, #E8F4FC); border-color: var(--ss-navy, #0D2B55); }
.bauth-create:active { transform: translateY(1px); }
.bauth-create:focus-visible { outline: 2px solid var(--ss-cyan, #1B9BDB); outline-offset: 2px; }
.bauth-create svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  transition: transform 150ms;
}
.bauth-create:hover svg { transform: translateX(2px); }
.bauth-newuser-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--ss-ink-3, #5B6B84);
}

.bauth-trust {
  text-align: center;
  font-size: var(--ss-t-12, .75rem);
  color: var(--ss-ink-3, #5B6B84);
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f0f1f6;
}
/* LEG-009: keep the Privacy Policy link legible against the muted footer. */
.bauth-trust a {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}
/* The new-buyer block already draws a separator — don't stack two hairlines. */
.bauth-newuser + .bauth-trust {
  border-top: none;
  padding-top: 0;
  margin-top: 16px;
}

.bauth-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.4;
}
.bauth-success {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.4;
}

.bauth-back {
  background: transparent;
  border: none;
  color: #475069;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  min-height: var(--ss-tap, 44px);
  padding: 4px 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.bauth-back:hover { color: var(--ss-navy, #0D2B55); }
.bauth-back svg { width: 14px; height: 14px; }

/* --- Phase 5c: signup wizard chrome ----------------------------------- */

.bauth-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 10px;
}
.bauth-progress-bar {
  flex: 1 1 0;
  height: 4px;
  border-radius: 2px;
  background: #e6e9f2;
  overflow: hidden;
}
.bauth-progress-bar.is-on {
  background: linear-gradient(90deg, #3b78ff 0%, #2457c5 100%);
}
.bauth-progress-label {
  font-size: var(--ss-t-12, .75rem);
  font-weight: 600;
  color: var(--ss-ink-3, #5B6B84);
  letter-spacing: 0.04em;
  margin: 0 0 16px;
  text-transform: uppercase;
}

/* Green verified-phone pill on step 3 */
.bauth-verified-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 14px;
}
.bauth-verified-pill::before {
  content: "✓";
  font-size: 12px;
  font-weight: 700;
}

/* Terms checkbox row */
.bauth-terms {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: #475069;
  line-height: 1.5;
  min-height: var(--ss-tap, 44px);
  margin: 4px 0 18px;
}
.bauth-terms input[type="checkbox"] {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 0;
}
.bauth-terms a { color: var(--ss-navy, #0D2B55); text-decoration: underline; font-weight: 600; }
.bauth-terms a:hover { text-decoration: underline; }

/* Captcha slot (Turnstile injects its widget here when configured) */
.bauth-captcha {
  margin: 8px 0 14px;
  min-height: 0;
}
.bauth-captcha:empty { margin: 0; }

/* Password strength meter (lightweight; 4 segments) */
.bauth-strength {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.bauth-strength-seg {
  flex: 1 1 0;
  height: 4px;
  border-radius: 2px;
  background: #e6e9f2;
}
.bauth-strength-seg.is-on-1 { background: #ef4444; }
.bauth-strength-seg.is-on-2 { background: #9A5700; }
.bauth-strength-seg.is-on-3 { background: #10b981; }
.bauth-strength-seg.is-on-4 { background: #047857; }
.bauth-strength-label {
  font-size: var(--ss-t-12, .75rem);
  color: var(--ss-ink-3, #5B6B84);
  margin-top: 6px;
}

/* Locked-down body when modal is open */
body.bauth-open {
  overflow: hidden;
}

/* --- Pass 4 closeout: account-management state ---------------------- */
.bauth-account-section {
  margin: 18px 0;
  padding: 16px;
  background: #f6f7fb;
  border-radius: 12px;
}
.bauth-account-section h3 {
  font-size: var(--ss-t-12, .75rem);
  font-weight: 700;
  color: #475069;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 10px;
}
.bauth-account-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--ss-tap, 44px);
  font-size: 14px;
  font-weight: 600;
  color: var(--ss-navy, #0D2B55);
  text-decoration: none;
}
.bauth-account-link:hover { text-decoration: underline; }
.bauth-identity-row,
.bauth-session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  font-size: 13px;
}
.bauth-identity-row + .bauth-identity-row,
.bauth-session-row + .bauth-session-row {
  border-top: 1px solid #e6e9f2;
}
.bauth-identity-row .bauth-id-kind {
  font-weight: 600;
  color: #1a3b7a;
  min-width: 70px;
  font-size: var(--ss-t-12, .75rem);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bauth-identity-row .bauth-id-value {
  flex: 1 1 auto;
  color: #0c1424;
  word-break: break-all;
}
.bauth-id-pill {
  font-size: var(--ss-t-12, .75rem);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}
.bauth-id-pill.is-pending {
  background: #fef9c3;
  color: #854d0e;
  border-color: #fde68a;
}
.bauth-session-row .bauth-sess-meta {
  flex: 1 1 auto;
  font-size: 12px;
  color: #475069;
  line-height: 1.4;
}
.bauth-session-row .bauth-sess-meta strong { color: #0c1424; font-size: 13px; }

.bauth-account-greeting {
  text-align: center;
  margin-bottom: 4px;
  font-size: 14px;
  color: #475069;
}
.bauth-account-greeting strong { color: #0c1424; font-weight: 700; font-size: 15px; }

.bauth-danger {
  width: 100%;
  margin-top: 10px;
  min-height: var(--ss-tap, 44px);
  padding: 11px 16px;
  background: transparent;
  color: #b91c1c;
  border: 1.5px solid #fecaca;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.bauth-danger:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #ef4444;
}

/* --- Phase 5e: mobile page shell -------------------------------------
 * At <768px the modal becomes a full-bleed page: no backdrop padding,
 * no rounded card outline, larger touch targets and text size to match
 * the buyer-auth-prompt.md spec ("Larger inputs (48px height vs 36px),
 * larger text (15px vs 14px), larger tap targets (52px primary buttons)").
 * Same JS module renders into this shell — no redirect.
 */
/* On short viewports (e.g. a landscape tablet at 768/1024), the centred card
   could be taller than the screen and was clipped top and bottom, with no way
   to scroll to the Back/close control or the submit button (REGT1-97). Cap it
   to the viewport height and let it scroll internally. Phones (<=767px) are a
   full-screen sheet handled below and are unaffected. */
@media (min-width: 768px) {
  .bauth-card {
    /* border-box so the cap includes the card's padding (every host page sets
       this globally, but state it here so the cap is correct regardless). */
    box-sizing: border-box;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
  }
}

@media (max-width: 767px) {
  .bauth-modal {
    padding: 0;
    background: #ffffff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .bauth-card {
    max-width: none;
    width: 100%;
    height: 100dvh;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    padding: 20px 20px 32px;
    overflow-y: auto;
    transform: none;
    animation: none;
  }
  /* Status-bar-ish spacer; harmless on Android, leaves breathing room
   * above the close/back nav on iOS even without viewport-fit=cover. */
  .bauth-card::before {
    content: "";
    display: block;
    height: env(safe-area-inset-top, 12px);
  }
  .bauth-head {
    margin-bottom: 12px;
  }
  .bauth-title {
    font-size: 26px;
    margin-top: 18px;
  }
  .bauth-sub {
    font-size: 14px;
    margin-bottom: 24px;
  }
  .bauth-field input {
    padding: 14px 14px;
    font-size: 16px;
    border-radius: 12px;
  }
  .bauth-cc {
    padding: 0 14px;
    font-size: 15px;
  }
  .bauth-primary {
    padding: 16px 20px;
    font-size: 15px;
    border-radius: 12px;
  }
  .bauth-secondary {
    padding: 14px 20px;
    font-size: 14px;
    border-radius: 12px;
  }
  .bauth-create {
    padding: 15px 20px;
    font-size: 15px;
    border-radius: 12px;
  }
  .bauth-newuser-label { font-size: 14px; }
  .bauth-tab {
    padding: 12px 8px;
    font-size: 14px;
  }
  .bauth-otp-row input {
    font-size: 26px;
    padding: 18px 0;
    border-radius: 12px;
  }
  .bauth-oauth-btn {
    padding: 14px 12px;
    font-size: 14px;
    border-radius: 12px;
  }
  .bauth-x, .bauth-back {
    width: 44px;
    height: 44px;
    border-radius: 10px;
  }
  .bauth-back {
    width: auto;
    padding: 8px 12px;
  }
  /* Bottom safe-area inset so the primary CTA isn't trapped under the
   * iOS home indicator. */
  .bauth-card > form:last-of-type ~ .bauth-trust,
  .bauth-card > .bauth-trust {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

/* In-modal navigation links. buyer-auth.js writes one of them with an inline
   color:#3b78ff (3.94:1 on white), so this needs !important to reach AA. */
.bauth-card a[data-bauth-go] { color: var(--ss-navy, #0D2B55) !important; }
