/*
 * Shell chrome for the branded auth threshold: compact wordmark spine, one
 * bordered consequence panel with a fine ink top rule, restrained supporting
 * copy. No decorative courts/nets, no gradients, no oversized rounded cards.
 */

.bbai-auth-body {
  display: flex;
  min-height: 100vh;
}

.bbai-policy-review { margin-block: 12px 20px; }
.bbai-policy-link {
  display: block;
  background: transparent;
  border: none;
  color: var(--bbai-brand-readable);
  text-decoration: underline;
  min-height: 44px;
}
.bbai-policy-dialog {
  box-sizing: border-box;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--bbai-line);
  border-radius: 4px;
  background: var(--bbai-panel);
  color: var(--bbai-ink);
}
.bbai-policy-dialog::backdrop { background: rgb(0 0 0 / 45%); }
.bbai-policy-scroll {
  max-height: 48dvh;
  overflow-y: auto;
  padding: 0 16px 12px 0;
  line-height: 1.8;
  border-block: 1px solid var(--bbai-line);
}
.bbai-policy-item { padding-inline-start: 16px; }
.bbai-policy-placeholder {
  background: var(--bbai-line);
  border-bottom: 1px dashed var(--bbai-muted);
  color: inherit;
  padding-inline: 2px;
}
.bbai-policy-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin-block: 8px;
}
.bbai-policy-checkbox input { width: 18px; height: 18px; flex: 0 0 18px; }
.bbai-policy-dialog button { min-height: 44px; }
.bbai-policy-scroll:focus-visible { outline: 2px solid var(--bbai-brand); outline-offset: 2px; }

.bbai-auth-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100%;
  min-height: 100vh;
}

.bbai-auth-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--bbai-line);
}

.bbai-auth-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bbai-auth-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bbai-wordmark {
  display: inline-flex;
  align-items: center;
  color: var(--bbai-ink);
}

/* Type-only wordmark, exactly like the product shell: identity comes from the
   face and the blue accent, never a decorative mark. */
.bbai-wordmark-text {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

/* The settings page's way back to the product: a visible control beside the
   language and theme toggles, not a muted text link. */
.bbai-back-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--bbai-ink);
  text-decoration: none;
  border: 1px solid var(--bbai-line);
  border-radius: 4px;
}

.bbai-back-link:hover {
  color: var(--bbai-brand-readable);
  border-color: var(--bbai-brand);
}

.bbai-theme-toggle,
.bbai-language-toggle {
  background: transparent;
  color: var(--bbai-ink);
  border: 1px solid var(--bbai-line);
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
}

.bbai-theme-toggle:hover,
.bbai-language-toggle:hover {
  border-color: var(--bbai-brand);
}

/* 524px leaves the 492px the sign-in panel takes inside the 16px gutters, so the panel no
   longer overhangs the column and sits on the tagline and footer axis (U33). */
.bbai-auth-main {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 12px;
  width: 100%;
  max-width: 524px;
  margin: 0 auto;
  padding: clamp(24px, 6vh, 64px) 16px 40px;
}

.bbai-settings-main {
  max-width: 640px;
}

.bbai-auth-panel {
  width: 100%;
  max-width: 100%;
  background: var(--bbai-panel);
  border: 1px solid var(--bbai-line);
  border-top: 2px solid var(--bbai-ink);
  border-radius: 4px;
  padding: clamp(20px, 4vw, 28px);
  animation: bbai-auth-panel-arrive 220ms ease-out;
}

.bbai-settings-panel {
  padding: clamp(20px, 3vw, 32px);
}

/* Ory Elements' settings screen ships a 37px title, 4px grey divider stubs
   after every settings section (empty ones included) and stacked 32px gaps.
   Bring it to the same rhythm as the other account cards: one title, a muted
   lead, one full-width rule, then the form. */
.bbai-settings-panel [class*="typography_size_headline37"] {
  margin: 0 0 6px;
  font-size: 1.25rem !important;
  font-weight: 800 !important;
  line-height: 1.25 !important;
  color: var(--bbai-ink) !important;
}

.bbai-settings-panel [class*="typography_size_headline37"] + [class*="typography"] {
  margin-bottom: 16px;
  color: var(--bbai-muted) !important;
  font-size: 0.85rem !important;
  line-height: 1.5 !important;
}

.bbai-settings-panel hr {
  display: none !important;
}

.bbai-settings-panel hr.divider-left {
  display: block !important;
  width: 100% !important;
  height: 1px;
  margin: 20px 0 !important;
  border: 0 !important;
  background: var(--bbai-line);
}

.bbai-settings-panel h3 {
  margin: 0 !important;
  font-size: 1rem !important;
  font-weight: 800 !important;
  line-height: 1.3 !important;
  color: var(--bbai-ink) !important;
}

.bbai-settings-panel [class*="grid_gap_32"] {
  gap: 16px !important;
}

@keyframes bbai-auth-panel-arrive {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bbai-auth-panel {
    animation: none;
  }
}

.bbai-auth-panel h1,
.bbai-auth-panel h2 {
  margin: 0 0 6px;
  font-size: 1.25rem !important;
  font-weight: 800 !important;
  line-height: 1.25 !important;
  color: var(--bbai-ink) !important;
}

.bbai-auth-context {
  width: 100%;
  margin: 0;
  max-width: 46ch;
  text-align: center;
  color: var(--bbai-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.bbai-auth-footer {
  padding: 16px clamp(16px, 4vw, 40px) 20px;
  text-align: center;
}

.bbai-auth-footer-line {
  margin: 0;
  color: var(--bbai-muted);
  font-size: 0.72rem;
}

@media (max-width: 820px) {
  .bbai-auth-topbar {
    padding: 14px 16px;
  }

  .bbai-auth-main {
    padding-top: clamp(20px, 5vh, 40px);
  }
}

@media (max-width: 390px) {
  .bbai-auth-topbar {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .bbai-wordmark-text {
    font-size: 0.85rem;
  }

  .bbai-theme-toggle,
  .bbai-language-toggle,
  .bbai-back-link {
    font-size: 0.72rem;
    padding: 0 8px;
  }
}

.bbai-legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  margin-bottom: 8px;
}

.bbai-legal-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  color: var(--bbai-ink);
  font-size: 0.8rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.bbai-legal-new-tab {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The account journey rail: the same four steps the product draws above /auth
   (frontend/src/components/account/JourneyRail.module.css), so the hop to this
   host reads as one journey. Done steps take the filled accent with a check,
   the current one an accent ring; under 560px the labels give way to
   "Step 1 of 4 · Account". */
.bbai-journey {
  width: 100%;
  margin-bottom: 4px;
}

.bbai-journey[hidden] {
  display: none;
}

.bbai-journey-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

.bbai-journey-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--bbai-muted);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}

.bbai-journey-step + .bbai-journey-step::before {
  position: absolute;
  top: 11px;
  right: 50%;
  left: -50%;
  height: 2px;
  background: var(--bbai-line);
  content: "";
}

.bbai-journey-step[data-state="done"] + .bbai-journey-step::before {
  background: var(--bbai-brand);
}

.bbai-journey-marker {
  position: relative;
  z-index: 1;
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  width: 24px;
  height: 24px;
  border: 2px solid var(--bbai-line);
  border-radius: 999px;
  background: var(--bbai-panel);
  color: var(--bbai-muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.bbai-journey-step[data-state="done"] .bbai-journey-marker {
  border-color: var(--bbai-brand);
  background: var(--bbai-brand);
  color: #ffffff;
}

.bbai-journey-step[data-state="current"] {
  color: var(--bbai-ink);
}

.bbai-journey-step[data-state="current"] .bbai-journey-marker {
  border-color: var(--bbai-brand-readable);
  color: var(--bbai-brand-readable);
  box-shadow: 0 0 0 3px var(--bbai-brand-bg);
}

.bbai-journey-label {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.bbai-journey-compact {
  display: none;
  margin: 8px 0 0;
  color: var(--bbai-muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.bbai-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .bbai-journey-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .bbai-journey-compact {
    display: block;
  }
}

@media (forced-colors: active) {
  .bbai-journey-marker {
    border-color: CanvasText;
  }

  .bbai-journey-step[data-state="current"] .bbai-journey-marker {
    outline: 2px solid Highlight;
  }
}

/* "Email verified": the state after a correct code. Ory's own card heading and
   its one-line message give way to this block; the Continue link stays Ory's,
   restyled as the panel's one primary action and relabelled by destination. */
.bbai-auth-panel[data-bbai-state="verified"] {
  text-align: center;
}

.bbai-auth-panel[data-bbai-state="verified"] h2:not(.bbai-verified-title),
.bbai-auth-panel[data-bbai-state="verified"] [data-testid="ui/message/1080002"] {
  display: none !important;
}

.bbai-verified {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 18px;
}

.bbai-verified-mark {
  margin-bottom: 4px;
  color: var(--bbai-brand-readable);
}

.bbai-verified-circle {
  stroke-dasharray: 160;
  animation: bbai-verified-draw-circle 320ms cubic-bezier(0.2, 0, 0, 1) backwards;
}

.bbai-verified-tick {
  stroke-dasharray: 48;
  animation: bbai-verified-draw-tick 200ms cubic-bezier(0.2, 0, 0, 1) 190ms backwards;
}

/* Drawn from nothing; at rest (and wherever animation is frozen) the mark is whole. */
@keyframes bbai-verified-draw-circle {
  from {
    stroke-dashoffset: 160;
  }
}

@keyframes bbai-verified-draw-tick {
  from {
    stroke-dashoffset: 48;
  }
}

.bbai-auth-panel .bbai-verified-title {
  margin: 0 !important;
  font-size: 1.5rem !important;
  letter-spacing: -0.02em;
}

.bbai-verified-body {
  margin: 0;
  max-width: 38ch;
  color: var(--bbai-muted);
  line-height: 1.55;
}

a.bbai-verified-action {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid var(--bbai-brand);
  border-radius: 4px;
  background: var(--bbai-brand);
  color: #ffffff !important;
  font-weight: 800;
  text-decoration: none;
}

a.bbai-verified-action:hover {
  filter: brightness(0.94);
}

@media (prefers-reduced-motion: reduce) {
  .bbai-verified-circle,
  .bbai-verified-tick {
    animation: none;
  }
}
