/* ============================================================
   BetBuilderAI - auth surfaces (login / signup / account)
   Depends on design-system.css tokens (load it first).
   ============================================================ */

/* Centered stage above the ambient body glow (design-system body::before/after). */
.auth-viewport {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 24px;
}

/* The card ("pop up"): elevated, brand-lit, one deliberate entrance. */
.auth-card {
  position: relative;
  width: 100%;
  max-width: 404px;
  padding: 40px 36px 30px;
  background: var(--gradient-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  box-shadow:
    var(--shadow-xl),
    var(--glow-red),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
  animation: authIn 560ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Hairline sheen along the top edge. */
.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 22px;
  right: 22px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
}

/* Soft brand aura behind the header. */
.auth-card::after {
  content: '';
  position: absolute;
  top: -120px;
  left: 50%;
  width: 340px;
  height: 240px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(255, 0, 0, 0.12), transparent 68%);
  pointer-events: none;
}

.auth-card > * {
  position: relative;
  z-index: 1;
}

@keyframes authIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.auth-logo {
  display: block;
  height: 34px;
  width: auto;
  margin: 0 auto 22px;
}

.auth-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 23px;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-align: center;
  color: var(--text-primary);
}

.auth-sub {
  margin: 6px 0 26px;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Banner (error / info). Text is set via JS; the ::before dot survives that. */
.auth-banner {
  display: none;
  position: relative;
  margin-bottom: 22px;
  padding: 11px 14px 11px 34px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 13.5px;
  line-height: 1.45;
}
.auth-banner::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
}
.auth-banner.is-error {
  display: block;
  background: rgba(255, 43, 43, 0.08);
  border-color: rgba(255, 43, 43, 0.30);
  color: #ffb0b0;
}
.auth-banner.is-error::before { background: var(--red-400); box-shadow: 0 0 8px rgba(255, 43, 43, 0.6); }
.auth-banner.is-info {
  display: block;
  background: rgba(2, 87, 255, 0.10);
  border-color: rgba(2, 87, 255, 0.32);
  color: #c3d6ff;
}
.auth-banner.is-info::before { background: var(--blue-400); box-shadow: 0 0 8px rgba(55, 120, 255, 0.6); }

/* Fields */
.auth-field { margin-bottom: 16px; }

/* Two fields side by side (first / last name) */
.auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.auth-row > .auth-field { margin-bottom: 0; }
@media (max-width: 380px) {
  .auth-row { grid-template-columns: 1fr; gap: 0; }
  .auth-row > .auth-field { margin-bottom: 16px; }
  .auth-row > .auth-field:last-child { margin-bottom: 0; }
}

.auth-label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-icon {
  position: absolute;
  left: 13px;
  width: 17px;
  height: 17px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.18s ease;
}

.auth-input {
  width: 100%;
  height: 46px;
  padding: 0 14px 0 40px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.auth-input::placeholder { color: var(--text-disabled); }
.auth-input:hover { border-color: var(--border-strong); }
.auth-input:focus {
  outline: none;
  border-color: var(--red-500);
  background: var(--surface-default);
  box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.10);
}
.auth-input-wrap:focus-within .auth-icon { color: var(--red-400); }
.auth-input.has-toggle { padding-right: 46px; }

/* Kill the jarring white autofill box on dark. */
.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:hover,
.auth-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-primary);
  -webkit-box-shadow: 0 0 0 1000px var(--surface-sunken) inset;
  caret-color: var(--text-primary);
  transition: background-color 9999s ease-out 0s;
}

/* Show / hide password */
.auth-toggle {
  position: absolute;
  right: 6px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.auth-toggle:hover { color: var(--text-secondary); background: var(--surface-hover); }
.auth-toggle:focus-visible { outline: 2px solid var(--red-500); outline-offset: 2px; }
.auth-toggle svg { width: 18px; height: 18px; }
.auth-toggle .icon-hide { display: none; }
.auth-toggle[aria-pressed="true"] .icon-show { display: none; }
.auth-toggle[aria-pressed="true"] .icon-hide { display: block; }

.auth-hint {
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Primary submit with loading state */
.auth-submit {
  position: relative;
  width: 100%;
  height: 48px;
  margin-top: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--gradient-primary);
  color: #fff;
  border: 0;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--glow-red);
  transition: box-shadow 0.2s ease, transform 0.12s ease, filter 0.2s ease;
}
.auth-submit:hover { box-shadow: var(--glow-red-strong); transform: translateY(-1px); }
.auth-submit:active { transform: translateY(0); }
.auth-submit:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.auth-submit:disabled { cursor: default; }
.auth-submit.is-loading { filter: saturate(0.85) brightness(0.95); transform: none; box-shadow: none; }
.auth-submit .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  display: none;
  animation: authSpin 0.7s linear infinite;
}
.auth-submit.is-loading .spinner { display: block; }

@keyframes authSpin { to { transform: rotate(360deg); } }

/* Secondary / ghost action (e.g. log out) */
.auth-secondary {
  width: 100%;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.auth-secondary:hover { border-color: var(--border-strong); color: var(--text-primary); background: rgba(255, 255, 255, 0.02); }
.auth-secondary:focus-visible { outline: 2px solid var(--red-500); outline-offset: 2px; }

/* Alternate action line */
.auth-alt {
  margin-top: 20px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-muted);
}
.auth-alt a {
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.auth-alt a:hover { color: var(--red-400); border-color: var(--red-400); }

/* Footer: quiet compliance line (this is a gambling product) */
.auth-foot {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--text-disabled);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.auth-foot .age {
  font-weight: 800;
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border-default);
  border-radius: var(--r-full);
  padding: 2px 7px;
  letter-spacing: 0.04em;
}

/* Account page specifics */
.auth-avatar {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  background: var(--gradient-primary);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  box-shadow: var(--glow-red);
}
.auth-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 auto 18px;
  padding: 5px 12px;
  border-radius: var(--r-full);
  background: rgba(52, 211, 153, 0.10);
  border: 1px solid rgba(52, 211, 153, 0.28);
  color: var(--color-success);
  font-size: 12px;
  font-weight: 600;
}
.auth-status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.7);
}
.auth-detail {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
}
.auth-detail .k {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.auth-detail .v {
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--text-primary);
  word-break: break-all;
}
.auth-actions { margin-top: 24px; display: grid; gap: 10px; }
.auth-loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 0 4px;
}
.is-hidden { display: none !important; }

/* ---- Detailed signup: two-panel wide card ---- */
.auth-card-wide { max-width: 880px; padding: 0; }
.auth-card-wide::after { display: none; } /* brand panel supplies its own aura */

/* Fit the wide split card to tall viewports: cap it at the screen height and let
   EACH panel scroll internally, so a long form (signup's 7 fields) never pushes
   the card off-frame. Guarded to >=640px tall so short / landscape screens keep
   their natural full-page scroll instead of a cramped double scroll (and so the
   brand panel's benefits + "18+" line are never clipped). Below 560px wide the
   card is a single column and the page scrolls. */
@media (min-width: 561px) and (min-height: 640px) {
  .auth-card-wide { max-height: calc(100dvh - 64px); display: flex; flex-direction: column; }
  .auth-card-wide .auth-split { flex: 1 1 auto; min-height: 0; }
  .auth-card-wide .auth-brandpanel,
  .auth-card-wide .auth-formpanel { min-height: 0; overflow-y: auto; }
}

.auth-split { display: grid; grid-template-columns: 1.02fr 1fr; }

.auth-brandpanel {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 40px 34px;
  border-right: 1px solid var(--border-subtle);
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(255, 0, 0, 0.13), transparent 55%),
    var(--surface-sunken);
}
.auth-brandpanel .auth-logo { margin: 0 0 26px; height: 30px; } /* left-align in panel */
.auth-brand-h {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 27px;
  letter-spacing: -0.02em;
  line-height: 1.12;
  color: var(--text-primary);
}
.auth-brand-p {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.auth-benefits {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-benefits li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--text-secondary);
}
.auth-benefits .bcheck {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 0, 0, 0.12);
  color: var(--red-300);
}
.auth-benefits .bcheck svg { width: 12px; height: 12px; }
.auth-brand-foot {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-disabled);
  font-size: 12px;
  letter-spacing: 0.02em;
}

/* BetBuilderAI + gambling.com logo lockup at the top of each auth page. The
   gambling.com wordmark is gdc.svg (same asset the nav "back to gambling.com"
   button uses). Divider between the two: BETBUILDERAI | GAMBLING.COM */
.auth-lockup { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 0 auto 24px; }
.auth-lockup .auth-logo { height: 32px; margin: 0; }
.auth-lockup-sep { flex: 0 0 auto; width: 1px; height: 28px; background: var(--border-default); }
.auth-lockup .auth-gdc { height: 30px; width: auto; display: block; opacity: 0.95; }
.auth-brandpanel .auth-lockup { margin: 0 0 26px; justify-content: flex-start; }

.auth-formpanel { padding: 40px 36px 30px; }
.auth-formpanel .auth-title { text-align: left; font-size: 22px; }
.auth-formpanel .auth-sub { text-align: left; margin-bottom: 22px; }

/* Password strength meter */
.auth-strength { margin-top: 9px; display: flex; align-items: center; gap: 10px; }
.auth-strength-track {
  flex: 1;
  height: 5px;
  border-radius: var(--r-full);
  background: var(--surface-active);
  overflow: hidden;
}
.auth-strength-fill {
  height: 100%;
  width: 0;
  border-radius: var(--r-full);
  background: var(--red-400);
  transition: width 0.25s ease, background 0.25s ease;
}
.auth-strength-label {
  min-width: 54px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Terms checkbox (styled real checkbox: focusable, native required works) */
.auth-check {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: 20px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  cursor: pointer;
}
.auth-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  position: relative;
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-sunken);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.auth-check input[type="checkbox"]:checked {
  background: var(--gradient-primary);
  border-color: transparent;
}
.auth-check input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2.5px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.auth-check input[type="checkbox"]:focus-visible { outline: 2px solid var(--red-500); outline-offset: 2px; }
.auth-check a { color: var(--text-primary); text-decoration: underline; text-underline-offset: 2px; }
.auth-check a:hover { color: var(--red-400); }

@media (max-width: 720px) {
  .auth-card-wide { max-width: 404px; }
  .auth-split { grid-template-columns: 1fr; }
  /* On a phone the brand panel is a slim strip above the form: logos on the
     left, the 18+ badge on the right. The pitch (heading, paragraph,
     benefits) is dropped: stacked above the form it filled a third of the
     screen and pushed the first field below the fold. */
  .auth-brandpanel {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-right: 0;
    border-bottom: 1px solid var(--border-subtle);
  }
  .auth-brandpanel .auth-lockup { margin: 0; gap: 12px; }
  .auth-brandpanel .auth-lockup .auth-logo,
  .auth-brandpanel .auth-lockup .auth-gdc { height: 24px; }
  .auth-brandpanel .auth-lockup-sep { height: 22px; }
  .auth-brand-h,
  .auth-brand-p,
  .auth-benefits { display: none; }
  .auth-brand-foot { margin: 0; padding: 0; flex: none; } /* 18+ stays visible */
  .auth-formpanel { padding: 24px 22px; }
}
/* Too narrow for the logos AND "Play responsibly": keep the 18+ badge. */
@media (max-width: 420px) {
  .auth-brand-foot span:not(.age) { display: none; }
}

@media (max-width: 480px) {
  .auth-viewport { padding: 16px; }
  .auth-card { border-radius: var(--r-lg); }
  .auth-card:not(.auth-card-wide) { padding: 32px 22px 24px; }
}

/* ============================================================
   Social sign-in ("Continue with Google"), leagues/social-auth.js.
   Google's branding rules fix the button's look: its own four-colour G
   on the left, "Continue with Google", and one of their three themes.
   This is the DARK theme (#131314 fill, #8E918F border, #E3E3E3 text),
   which is the one that sits on our cards. Do not recolour it. X's
   button shares the style with its own logo in white, which X's
   guidelines allow (black or white, the logo unaltered).
   ============================================================ */
.auth-social {
  width: 100%;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #131314;
  color: #e3e3e3;
  border: 1px solid #8e918f;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.auth-social + .auth-social { margin-top: 10px; }
.auth-social:hover { background: #1f1f21; border-color: #a4a7a5; }
.auth-social:focus-visible { outline: 2px solid var(--red-500); outline-offset: 2px; }
.auth-social:disabled { opacity: 0.6; cursor: progress; }
.auth-social svg { width: 20px; height: 20px; flex: none; }

/* "or" between the social buttons and the email form. */
.auth-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.auth-or::before,
.auth-or::after { content: ''; flex: 1; height: 1px; background: var(--border-subtle); }

/* Signup's "One last step" mode (?step=complete) after a social sign-in:
   only the username, the age/terms tick and the marketing opt-in remain. */
[data-complete-only] { display: none; }
.is-complete [data-complete-only] { display: block; }
.is-complete [data-signup-only] { display: none; }

/* ============================================================
   Inside the site-wide pop-up (?embed=1, set by leagues/auth-embed.js).
   The frame IS the card: the parent dialog in shared.js supplies the
   backdrop, rounded corners, shadow, entrance and the close button, so
   here the card just fills the frame edge to edge at its natural height.
   The parent sizes the frame to the card and scrolls it when taller than
   the screen, so the per-panel scrolling above is switched off.
   ============================================================ */
.is-embed body::before,
.is-embed body::after { display: none; }
.is-embed .auth-viewport { min-height: 0; padding: 0; display: block; }
.is-embed .auth-card {
  max-width: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  animation: none;
}
.is-embed .auth-card-wide { max-height: none; display: block; }
.is-embed .auth-card-wide .auth-brandpanel,
.is-embed .auth-card-wide .auth-formpanel { overflow: visible; }

/* Phone: the pop-up is full screen (shared.js, <=560px), so the card fills
   the frame instead of ending in a band of bare page below the form, and the
   brand strip leaves room for the pop-up's close button on the right. Kept to
   the same 560px as the parent: above it the frame is sized FROM the card,
   and a card at least as tall as the frame could only ever grow. */
@media (max-width: 560px) {
  .is-embed .auth-card { min-height: 100dvh; }
  .is-embed .auth-card-wide .auth-split { min-height: 100dvh; grid-template-rows: auto 1fr; }
  .is-embed .auth-brandpanel { padding-right: 64px; }
}
