/* ============================================================================
   Auth UI — Design System (Linear / Minimal style)
   Variables → Reset → Layout → Card → Brand → Form →
   Input → Button → OTP → Banner → Social → Legal → Animations
   ============================================================================ */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --primary:            #6c47ff;
  --primary-foreground: #ffffff;
  --primary-hover:      color-mix(in srgb, var(--primary) 85%, #000);
  --primary-subtle:     color-mix(in srgb, var(--primary) 10%, transparent);

  --bg:          #f7f7f6;
  --surface:     #ffffff;
  --border:      #e8e8e4;
  --border-focus: var(--primary);

  --text:        #0f0f0e;
  --text-muted:  #6b6b6b;
  --text-subtle: #9b9b9b;

  --err:         #dc2626;
  --err-subtle:  color-mix(in srgb, #dc2626 10%, transparent);
  --ok:          #16a34a;
  --ok-subtle:   color-mix(in srgb, #16a34a 12%, transparent);

  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   16px;
  --radius-full: 9999px;

  /* Button: always near-black on light theme */
  --btn-bg:  #141414;
  --btn-fg:  #ffffff;
  --btn-bg-hover: #2d2d2d;

  /* Input background (borderless style) */
  --input-bg: color-mix(in srgb, var(--bg) 60%, var(--surface));

  --shadow-card:  0 1px 4px 0 rgb(0 0 0 / .05), 0 6px 24px -4px rgb(0 0 0 / .09);
  --shadow-input: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);

  --transition: 150ms ease;
  --font: system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-auth-theme="light"]) {
    --bg:      #0c0c10;
    --surface: #17171e;
    --border:  #2a2a35;
    --text:    #f0f0f5;
    --text-muted:  #9ca3af;
    --text-subtle: #6b7280;
    --shadow-card: 0 1px 4px 0 rgb(0 0 0 / .3), 0 6px 24px -4px rgb(0 0 0 / .3);
    --input-bg: color-mix(in srgb, var(--bg) 60%, var(--surface));
    /* Button inverts in dark mode for visibility */
    --btn-bg:       #e8e8e6;
    --btn-fg:       #0f0f0e;
    --btn-bg-hover: #d0d0ce;
  }
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { cursor: pointer; font: inherit; border: none; background: none; }
a { color: inherit; text-decoration: none; }
input { font: inherit; }
svg { display: block; }
/* Prevents display:flex/block rules from overriding [hidden]'s display:none */
[hidden] { display: none !important; }

/* Screen-reader only */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Page layout ────────────────────────────────────────────────────────────── */
.auth-body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.auth-root {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 40px;
}

.auth-main-shell {
  width: 100%;
  max-width: 420px;
}

/* ── Card ───────────────────────────────────────────────────────────────────── */
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px 36px 36px;
  width: 100%;
  animation: auth-card-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@media (max-width: 480px) {
  .auth-card { padding: 24px 20px 28px; border-radius: var(--radius-md); }
}

/* ── Brand header (logo + name row) ────────────────────────────────────────── */
.auth-brand {
  margin-bottom: 20px;
}

.auth-brand--row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Logo shown when branded */
.auth-logo {
  height: 28px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  display: none;
  flex-shrink: 0;
}

.auth-logo.is-visible { display: block; }

/* Brand name text */
.auth-brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1;
}

/* Badge — hidden in this design */
.auth-badge { display: none !important; }

/* Step badge (e.g. "Step 1 of 2") */
.auth-step-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--input-bg);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  margin-bottom: 10px;
}

/* ── Title + subtitle ───────────────────────────────────────────────────────── */
.auth-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.15;
  margin-bottom: 4px;
}

.auth-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.auth-sub.auth-status--error {
  color: var(--err);
  font-weight: 500;
}

/* ── Navigation ─────────────────────────────────────────────────────────────── */
.auth-nav {
  margin-bottom: 12px;
}

.auth-nav-back__a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
  transition: color var(--transition);
}

.auth-nav-back__a:hover { color: var(--text); }

.auth-links-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13.5px;
}

.auth-links-row--center {
  justify-content: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.auth-footer__muted { color: var(--text-muted); }

.auth-link-muted {
  color: var(--text-muted);
  font-weight: 600;
  transition: color var(--transition);
}

.auth-link-muted:hover { color: var(--text); }

/* ── Form ───────────────────────────────────────────────────────────────────── */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.field__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field__aux-action {
  font-size: 12.5px;
  color: var(--text-muted);
  transition: color var(--transition);
}

.field__aux-action:hover { color: var(--primary); }

/* Forgot password link row (below password input) */
.auth-forgot-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
  margin-bottom: 4px;
}

.auth-forgot-row a {
  font-size: 12.5px;
  color: var(--text-muted);
  transition: color var(--transition);
}

.auth-forgot-row a:hover { color: var(--primary); }

.field__error {
  font-size: 12.5px;
  color: var(--err);
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 5px;
}

.field__error::before {
  content: '';
  display: inline-block;
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  margin-top: 1px;
  background-color: var(--err);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Ccircle cx='8' cy='8' r='7' stroke='currentColor' stroke-width='1.5'/%3E%3Cpath d='M8 5v3.5' stroke='currentColor' stroke-width='1.5' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='11' r='.75' fill='currentColor'/%3E%3C/svg%3E");
  mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Ccircle cx='8' cy='8' r='7' stroke='currentColor' stroke-width='1.5'/%3E%3Cpath d='M8 5v3.5' stroke='currentColor' stroke-width='1.5' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='11' r='.75' fill='currentColor'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
}

.field-hint {
  font-size: 12.5px;
  color: var(--text-subtle);
}

/* Password strength bar */
.auth-pw-strength {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.auth-pw-strength__seg {
  height: 3px;
  flex: 1;
  border-radius: var(--radius-full);
  background: var(--border);
  transition: background 0.25s ease;
}

.auth-pw-strength__seg.is-weak   { background: #ef4444; }
.auth-pw-strength__seg.is-fair   { background: #f59e0b; }
.auth-pw-strength__seg.is-strong { background: #16a34a; }

.field--error .input { border-color: var(--err) !important; }
.field--error .auth-otp-digit { border-color: var(--err) !important; }

/* ── Input ──────────────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  /* Transparent border reserves space so focus ring doesn't shift layout */
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  appearance: none;
}

.input::placeholder { color: var(--text-subtle); }

.input:hover:not(:disabled) {
  background: color-mix(in srgb, var(--input-bg) 80%, var(--surface));
}

.input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-input);
  background: var(--surface);
}

.input:disabled { opacity: 0.5; cursor: not-allowed; }

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

.input-wrap .input { padding-right: 46px; }

/* ── Password toggle ────────────────────────────────────────────────────────── */
.btn-toggle-password {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  transition: color var(--transition);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.btn-toggle-password:hover { color: var(--text-muted); }

.btn-toggle-password__eye-off { display: none; }
.btn-toggle-password.is-active .btn-toggle-password__eye { display: none; }
.btn-toggle-password.is-active .btn-toggle-password__eye-off { display: block; }

/* ── Button ─────────────────────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  background: var(--btn-bg);
  color: var(--btn-fg);
  transition: background var(--transition), opacity var(--transition), transform 80ms ease;
  user-select: none;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { background: var(--btn-bg-hover); }
.btn:active:not(:disabled) { transform: scale(0.985); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn--secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  font-weight: 500;
}

.btn--secondary:hover:not(:disabled) {
  background: var(--input-bg);
  color: var(--text);
  border-color: color-mix(in srgb, var(--border) 60%, var(--text));
}

/* Button loading — animated dots overlay */
.btn.is-loading {
  pointer-events: none;
  position: relative;
  color: transparent !important;
  opacity: 1 !important; /* keep full opacity; :disabled normally dims to 0.4 */
}

/* Overlay fills the button, flex-centres the dots — no transform needed */
.btn.is-loading::before {
  content: '• • •';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.9);
  font-size: 11px;
  letter-spacing: 3px;
  animation: btn-loading-dots 1.1s ease-in-out infinite;
}

.btn--secondary.is-loading::before {
  color: var(--text-muted);
}

@keyframes btn-loading-dots {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 1;   }
}

/* ── Secondary action (e.g. Resend button below form) ───────────────────────── */
.auth-secondary-action {
  margin-top: 8px;
}

/* ── Action hint (e.g. "not verified" nudge below login error) ──────────────── */
.auth-action-hint {
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.auth-action-hint a {
  color: var(--primary);
  font-weight: 500;
  margin-left: 4px;
}

/* ── Form summary error ─────────────────────────────────────────────────────── */
.auth-form-summary {
  font-size: 13px;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  line-height: 1.5;
  animation: field-err-in 0.2s ease both;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.auth-form-summary--error {
  color: var(--err);
  background: var(--err-subtle);
  border-left: 3px solid var(--err);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.auth-form-summary--error::before {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-top: 1px;
  background-color: var(--err);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Ccircle cx='8' cy='8' r='7' stroke='currentColor' stroke-width='1.5'/%3E%3Cpath d='M8 5v3.5' stroke='currentColor' stroke-width='1.5' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='11' r='.75' fill='currentColor'/%3E%3C/svg%3E");
  mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Ccircle cx='8' cy='8' r='7' stroke='currentColor' stroke-width='1.5'/%3E%3Cpath d='M8 5v3.5' stroke='currentColor' stroke-width='1.5' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='11' r='.75' fill='currentColor'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
}

/* ── OTP ─────────────────────────────────────────────────────────────────────── */
.auth-otp-wrap { width: 100%; }

.auth-otp-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-otp-digit {
  width: 48px;
  height: 56px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  outline: none;
  caret-color: var(--primary);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.auth-otp-digit:hover:not(:disabled) {
  background: color-mix(in srgb, var(--input-bg) 80%, var(--surface));
}

.auth-otp-digit:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-input);
  background: var(--surface);
}

.auth-otp-sep {
  font-size: 20px;
  color: var(--text-subtle);
  user-select: none;
  padding: 0 2px;
}

@media (max-width: 380px) {
  .auth-otp-digit { width: 38px; height: 46px; font-size: 18px; }
  .auth-otp-row { gap: 5px; }
}

/* Verify-email resend row */
.auth-verify-resend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  justify-content: center;
}

.auth-text-link {
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  transition: opacity var(--transition);
  display: inline;
}

.auth-text-link:hover { opacity: 0.75; }
.auth-text-link:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Banner ──────────────────────────────────────────────────────────────────── */
.banner {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  font-size: 13px;
  font-weight: 500;
  transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease, margin 0.3s ease;
  margin-bottom: 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.banner.is-visible {
  max-height: 80px;
  opacity: 1;
  padding: 10px 13px;
  margin-bottom: 12px;
}

.banner--success {
  color: var(--ok);
  background: var(--ok-subtle);
  border-left: 3px solid var(--ok);
}

.banner--success::before {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-top: 1px;
  background-color: var(--ok);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Ccircle cx='8' cy='8' r='7' stroke='currentColor' stroke-width='1.5'/%3E%3Cpath d='M5 8l2 2 4-4' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Ccircle cx='8' cy='8' r='7' stroke='currentColor' stroke-width='1.5'/%3E%3Cpath d='M5 8l2 2 4-4' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
}

/* ── Spinner ─────────────────────────────────────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 16px auto;
}

/* ── Social / Google ─────────────────────────────────────────────────────────── */
.auth-social { margin-top: 16px; }

.auth-divider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--text-subtle);
}

.auth-divider-row::before,
.auth-divider-row::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 42px;
  padding: 0 20px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition);
}

.btn-google:hover { background: var(--input-bg); }

.btn-google-icon {
  width: 18px;
  height: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%234285F4' d='M23.49 12.27c0-.87-.07-1.7-.2-2.5H12v4.73h6.47c-.28 1.52-1.12 2.8-2.38 3.66v3.04h3.85c2.25-2.07 3.55-5.13 3.55-8.93z'/%3E%3Cpath fill='%2334A853' d='M12 24c3.24 0 5.95-1.07 7.93-2.9l-3.85-3.04c-1.07.72-2.44 1.14-4.08 1.14-3.14 0-5.79-2.12-6.74-4.97H1.28v3.14C3.25 21.44 7.31 24 12 24z'/%3E%3Cpath fill='%23FBBC05' d='M5.26 14.23A7.2 7.2 0 0 1 4.82 12c0-.77.13-1.52.44-2.23V6.63H1.28A12 12 0 0 0 0 12c0 1.94.46 3.77 1.28 5.37l3.98-3.14z'/%3E%3Cpath fill='%23EA4335' d='M12 4.75c1.77 0 3.35.61 4.6 1.8l3.44-3.44C17.94 1.19 15.23 0 12 0 7.31 0 3.25 2.56 1.28 6.63l3.98 3.14C6.21 6.87 8.86 4.75 12 4.75z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
}

/* ── Legal ───────────────────────────────────────────────────────────────────── */
.auth-legal {
  font-size: 12px;
  color: var(--text-subtle);
  text-align: center;
  line-height: 1.6;
  margin-top: 20px;
}

.auth-legal a {
  color: var(--text-muted);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color var(--transition), color var(--transition);
}

.auth-legal a:hover {
  color: var(--text);
  text-decoration-color: currentColor;
}

/* ── Field error animation ───────────────────────────────────────────────────── */
.field__error:not([hidden]) {
  animation: field-err-in 0.2s ease both;
}

/* ── Step transitions (signup multi-step) ────────────────────────────────────── */
@keyframes step-enter-forward {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes step-enter-back {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: translateX(0); }
}

.auth-step--enter-forward { animation: step-enter-forward 0.28s cubic-bezier(0.22, 1, 0.36, 1) both; }
.auth-step--enter-back    { animation: step-enter-back    0.28s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* Progressive field reveal (OTP → password) */
.auth-reveal {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.28s ease;
}
.auth-reveal.is-visible {
  max-height: 120px;
  opacity: 1;
}

/* ── Animations ──────────────────────────────────────────────────────────────── */
@keyframes auth-card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes field-err-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes auth-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.auth-shake { animation: auth-shake 0.38s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Print ───────────────────────────────────────────────────────────────────── */
@media print {
  .auth-root { background: white; }
  .btn, .auth-social, .auth-nav, .auth-links-row, .auth-forgot-row { display: none; }
  .auth-card { box-shadow: none; border: 1px solid #ddd; }
}
