/* Split-screen authentication layout (login, MFA, onboarding) */

.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  background: var(--bg-app);
}

.auth-split-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.auth-split-form-wrap {
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 55% at 0% 0%, color-mix(in srgb, var(--color-secondary) 10%, transparent), transparent 58%),
    radial-gradient(ellipse 55% 45% at 100% 100%, color-mix(in srgb, var(--color-accent) 8%, transparent), transparent 55%),
    var(--bg-app);
  padding-bottom: calc(var(--sp-8) + 2.5rem);
}

.auth-split-form-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(color-mix(in srgb, var(--border-subtle) 35%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--border-subtle) 35%, transparent) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 85% 75% at 50% 45%, #000 20%, transparent 72%);
  opacity: 0.45;
}

.auth-split-form {
  position: relative;
  z-index: 1;
  padding: clamp(var(--sp-6), 6vw, var(--sp-8));
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  animation: authFadeIn 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: clamp(var(--sp-5), 4vw, var(--sp-6));
}

.auth-brand .logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--bg-elev-1);
  color: var(--text-link);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid color-mix(in srgb, var(--border-subtle) 80%, transparent);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 8px 24px color-mix(in srgb, var(--color-primary) 12%, transparent);
}

.auth-brand .logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
}

.auth-brand--wordmark .logo {
  width: auto;
  max-width: var(--brand-logo-max-width-auth);
  height: var(--brand-logo-height);
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}

.auth-brand--wordmark .logo img {
  width: auto;
  max-width: var(--brand-logo-max-width-auth);
  height: var(--brand-logo-height);
  padding: 0;
  object-fit: contain;
  object-position: left center;
}

.auth-brand--wordmark .name {
  display: none;
}

.brand-logo-img {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.auth-brand .name {
  font-size: clamp(1.125rem, 2vw, 1.375rem);
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.auth-intro {
  margin-bottom: var(--sp-5);
}

.auth-heading {
  margin: 0 0 8px;
  font-size: clamp(1.875rem, 3.2vw, 2.375rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: var(--text-1);
}

.auth-subtitle {
  color: var(--text-3);
  font-size: var(--fz-15, 15px);
  line-height: 1.55;
  margin: 0;
  max-width: 34ch;
}

.auth-form-card {
  background: color-mix(in srgb, var(--bg-elev-1) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--border-subtle) 90%, transparent);
  border-radius: var(--r-2xl);
  padding: clamp(var(--sp-5), 3vw, var(--sp-6));
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.03),
    0 12px 40px rgba(15, 23, 42, 0.07);
  backdrop-filter: blur(16px);
}

.auth-form-card .field label {
  font-size: var(--fz-13);
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}

.auth-form-card .field input[type="text"],
.auth-form-card .field input[type="email"],
.auth-form-card .field input[type="password"] {
  min-height: 46px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elev-2);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}

.auth-form-card .field input:focus {
  border-color: color-mix(in srgb, var(--color-primary) 45%, var(--border-subtle));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 12%, transparent);
  background: var(--bg-elev-1);
}

.auth-form-card .flex.items-center {
  margin: var(--sp-4) 0 var(--sp-2);
  font-size: var(--fz-13);
  color: var(--text-2);
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.auth-actions .btn.primary {
  width: 100%;
  min-height: 48px;
  border-radius: var(--r-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--color-primary) 28%, transparent);
}

.auth-actions .btn.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--color-primary) 34%, transparent);
}

.auth-form-card .field + .field {
  margin-top: var(--sp-4);
}

.auth-forgot-row {
  display: flex;
  justify-content: center;
}

.auth-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}

.auth-field-row .btn.primary {
  flex: 1;
}

.auth-split-carousel {
  position: relative;
  overflow: hidden;
  background: color-mix(in srgb, var(--color-primary) 88%, #2a1450);
  min-height: 280px;
  color-scheme: dark;
  --auth-panel-heading: #ffffff;
  --auth-panel-body: rgba(255, 255, 255, 0.9);
  --auth-panel-link: rgba(255, 255, 255, 0.95);
  --auth-panel-link-hover: #ffffff;
}

.auth-link {
  color: var(--text-link);
  font-size: var(--fz-13);
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.auth-link:hover {
  opacity: 0.85;
  text-decoration: underline;
}

.auth-password-wrap {
  position: relative;
}

.auth-password-wrap input {
  padding-right: 42px;
}

.auth-password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: color 0.15s;
}

.auth-password-toggle:hover {
  color: var(--text-1);
}

.auth-forgot-help {
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent, #5B6CFF) 10%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--accent, #5B6CFF) 22%, var(--border-subtle));
}

.auth-forgot-help-text {
  margin: 0;
  font-size: var(--fz-13);
  line-height: var(--lh-normal, 1.5);
  color: var(--text-2);
}

.auth-forgot-help a {
  color: var(--text-link);
  font-weight: var(--fw-medium, 500);
  text-decoration: none;
}

.auth-forgot-help a:hover {
  text-decoration: underline;
}

.auth-footer {
  position: absolute;
  left: clamp(var(--sp-6), 6vw, var(--sp-8));
  bottom: var(--sp-4);
  z-index: 1;
  margin: 0;
  font-size: var(--fz-12);
  line-height: 1.55;
  color: var(--text-3);
}

.auth-footer p {
  margin: 0;
}

.auth-footer-version {
  color: var(--text-3);
}

.auth-footer-copy {
  color: var(--text-3);
}

/* MFA code input */
.mfa-code-inputs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: var(--sp-4) 0;
}

.mfa-code-inputs input {
  width: 44px;
  height: 52px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-input);
  color: var(--text-1);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.mfa-code-inputs input:focus {
  outline: none;
  border-color: var(--text-link);
  box-shadow: var(--focus-ring);
}

.mfa-code-inputs.error input {
  border-color: var(--color-danger);
  animation: mfaShake 0.35s ease;
}

.mfa-countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: var(--fz-12);
  color: var(--text-3);
  margin-bottom: var(--sp-3);
}

.mfa-countdown-ring {
  width: 18px;
  height: 18px;
  transform: rotate(-90deg);
}

.mfa-countdown-ring circle {
  fill: none;
  stroke: var(--border);
  stroke-width: 2;
}

.mfa-countdown-ring .progress {
  stroke: var(--accent);
  stroke-dasharray: 50.27;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

/* Login panel quote carousel */
.auth-carousel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.auth-carousel-deco {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.auth-carousel-deco-svg {
  position: absolute;
  top: 0;
  right: 0;
  width: min(62%, 520px);
  height: 100%;
}

.auth-quote-stage {
  flex: 1;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  padding: clamp(var(--sp-6), 5vw, var(--sp-10));
}

.auth-quote-block {
  width: 100%;
  max-width: 520px;
  align-self: flex-start;
}

.auth-quote-slides {
  position: relative;
  width: 100%;
}

.auth-quote-slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  color: var(--auth-panel-body);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.auth-quote-slide.active {
  position: relative;
  inset: auto;
  opacity: 1;
  pointer-events: auto;
}

.auth-quote-title {
  margin: 0 0 12px;
  font-size: clamp(1.5rem, 2.8vw, 2.125rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--auth-panel-heading);
}

.auth-quote-subtitle {
  margin: 0 0 var(--sp-4);
  font-size: clamp(var(--fz-14), 1.6vw, var(--fz-16));
  font-weight: 400;
  line-height: 1.55;
  color: var(--auth-panel-body);
  max-width: 36ch;
}

.auth-carousel.transition-slide .auth-quote-slide {
  transform: translateX(24px);
}

.auth-carousel.transition-slide .auth-quote-slide.active {
  transform: translateX(0);
}

.auth-carousel.transition-slide .auth-quote-slide.leaving {
  transform: translateX(-24px);
  opacity: 0;
}

.auth-carousel.transition-zoom .auth-quote-slide {
  transform: scale(0.96);
}

.auth-carousel.transition-zoom .auth-quote-slide.active {
  transform: scale(1);
}

.auth-carousel.transition-zoom .auth-quote-slide.leaving {
  transform: scale(1.02);
  opacity: 0;
}

.auth-carousel-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--auth-panel-link);
  font-weight: 500;
  font-size: var(--fz-14);
  text-decoration: none;
  transition: color 0.15s, transform 0.15s;
}

.auth-carousel-cta:hover {
  color: var(--auth-panel-link-hover);
  transform: translateX(4px);
}

.auth-carousel-dots {
  display: flex;
  justify-content: center;
  width: 100%;
  gap: 8px;
  margin-top: var(--sp-5);
  z-index: 3;
}

.auth-carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s, background 0.2s;
}

.auth-carousel-dot.active {
  background: #ffffff;
  transform: scale(1.25);
}

/* Override global heading/link tokens inside the purple auth panel */
.auth-split-carousel h2,
.auth-split-carousel .auth-quote-title {
  color: var(--auth-panel-heading);
}

.auth-split-carousel p,
.auth-split-carousel .auth-quote-subtitle {
  color: var(--auth-panel-body);
}

.auth-split-carousel a,
.auth-split-carousel .auth-carousel-cta {
  color: var(--auth-panel-link);
}

.auth-split-carousel a:hover,
.auth-split-carousel .auth-carousel-cta:hover {
  color: var(--auth-panel-link-hover);
}

/* Tablet */
@media (max-width: 1024px) {
  .auth-split {
    grid-template-columns: 3fr 2fr;
  }
}

@media (min-width: 640px) {
  .auth-brand--wordmark .logo {
    max-width: min(var(--brand-logo-max-width-lg), 88vw);
    height: var(--brand-logo-height-lg);
  }

  .auth-brand--wordmark .logo img {
    max-width: min(var(--brand-logo-max-width-lg), 88vw);
    height: var(--brand-logo-height-lg);
  }
}

@media (min-width: 769px) {
  .auth-brand .logo {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    font-size: 24px;
  }

  .auth-brand .logo img {
    padding: 8px;
  }

  .auth-brand--wordmark .logo {
    width: auto;
    max-width: min(var(--brand-logo-max-width-lg), 88vw);
    height: var(--brand-logo-height-lg);
    border-radius: 0;
  }

  .auth-brand--wordmark .logo img {
    max-width: min(var(--brand-logo-max-width-lg), 88vw);
    height: var(--brand-logo-height-lg);
    padding: 0;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .auth-split {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .auth-split-carousel {
    order: -1;
    min-height: 200px;
    max-height: min(42vh, 320px);
  }

  .auth-quote-stage {
    padding: var(--sp-5) var(--sp-4);
  }

  .auth-carousel-dots {
    margin-top: var(--sp-4);
  }

  .auth-quote-title {
    font-size: clamp(1.25rem, 5vw, 1.5rem);
  }

  .auth-quote-subtitle {
    font-size: var(--fz-13);
  }

  .auth-split-form {
    padding: var(--sp-5) var(--sp-4) var(--sp-6);
  }

  .auth-footer {
    left: var(--sp-4);
    bottom: var(--sp-3);
    font-size: var(--fz-11);
  }

  .auth-form-card {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }

  .mfa-code-inputs input {
    width: 38px;
    height: 46px;
    font-size: 18px;
  }

  .mfa-qr img,
  .mfa-qr canvas,
  .auth-qr img,
  #mfaQr img,
  #mfaQr canvas {
    display: block;
    max-width: min(280px, 72vw);
    width: 100%;
    height: auto;
    margin: 0 auto;
  }

  .auth-split-form-wrap {
    padding-bottom: max(var(--sp-6), env(safe-area-inset-bottom, 0px));
  }

}

@media (prefers-reduced-motion: reduce) {
  .auth-quote-slide,
  .auth-split-form {
    transition: none;
    animation: none;
  }
}

@keyframes authFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes mfaShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
