/* ═══════════════════════════════════════════════════════════════════
   Auth page (frontend/auth.html): sign in, register, email verification
   and password reset. Colours come from the shared --ui-* tokens in
   theme.css, so the page follows the dark / light switch on its own.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --au-input-bg: rgba(15, 23, 42, 0.72);
  --au-input-bg-focus: rgba(15, 23, 42, 0.95);
  --au-input-border: rgba(148, 163, 184, 0.18);
  --au-input-text: #f1f5f9;
  --au-placeholder: #64748b;
  --au-label: #cbd5e1;
  --au-card: rgba(11, 17, 32, 0.78);
  --au-card-border: rgba(148, 163, 184, 0.14);
  --au-seg-bg: rgba(15, 23, 42, 0.8);
  --au-seg-thumb: rgba(59, 130, 246, 0.16);
  --au-seg-thumb-border: rgba(59, 130, 246, 0.35);
  --au-danger: #f87171;
  --au-danger-bg: rgba(239, 68, 68, 0.1);
  --au-danger-border: rgba(239, 68, 68, 0.3);
  --au-success: #34d399;
  --au-success-bg: rgba(16, 185, 129, 0.1);
  --au-success-border: rgba(16, 185, 129, 0.3);
  --au-warn: #fbbf24;
  --au-info-bg: rgba(59, 130, 246, 0.1);
  --au-info-border: rgba(59, 130, 246, 0.3);
  --au-info: #93c5fd;
  --au-meter-empty: rgba(148, 163, 184, 0.16);
}

:root[data-theme="light"] {
  --au-input-bg: #ffffff;
  --au-input-bg-focus: #ffffff;
  --au-input-border: #d3d8e2;
  --au-input-text: #0f172a;
  --au-placeholder: #94a3b8;
  --au-label: #334155;
  --au-card: rgba(255, 255, 255, 0.92);
  --au-card-border: #e4e7ee;
  --au-seg-bg: #eef1f6;
  --au-seg-thumb: #ffffff;
  --au-seg-thumb-border: #d3d8e2;
  --au-danger: #dc2626;
  --au-danger-bg: #fef2f2;
  --au-danger-border: #fecaca;
  --au-success: #059669;
  --au-success-bg: #ecfdf5;
  --au-success-border: #a7f3d0;
  --au-warn: #b45309;
  --au-info-bg: #eff6ff;
  --au-info-border: #bfdbfe;
  --au-info: #1d4ed8;
  --au-meter-empty: #e2e8f0;
}

/* ── Page ────────────────────────────────────────────────────────── */
.au-body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--ui-bg);
  color: var(--ui-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.au-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 8% 0%, rgba(59, 130, 246, 0.16), transparent 60%),
    radial-gradient(800px 520px at 100% 100%, rgba(139, 92, 246, 0.14), transparent 60%),
    var(--ui-bg);
}
.au-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
          mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
}
:root[data-theme="light"] .au-bg {
  background:
    radial-gradient(900px 520px at 8% 0%, rgba(37, 99, 235, 0.09), transparent 60%),
    radial-gradient(800px 520px at 100% 100%, rgba(124, 58, 237, 0.08), transparent 60%),
    var(--ui-bg);
}

.au-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 96px 16px 40px;
}

.au-shell {
  width: 100%;
  max-width: 1080px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 48px;
  align-items: center;
}
@media (min-width: 1024px) {
  .au-shell { grid-template-columns: 1.05fr 1fr; gap: 72px; }
}

/* ── Brand / pitch panel ────────────────────────────────────────── */
.au-pitch { display: none; }
@media (min-width: 1024px) { .au-pitch { display: block; } }

.au-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--au-info);
  background: var(--au-info-bg);
  border: 1px solid var(--au-info-border);
}
.au-badge-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.au-pitch h1 {
  margin-top: 20px;
  font-size: clamp(32px, 3.4vw, 44px);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--ui-text);
}
.au-gradient {
  background: linear-gradient(120deg, #60a5fa 0%, #a78bfa 55%, #22d3ee 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}
:root[data-theme="light"] .au-gradient {
  background-image: linear-gradient(120deg, #2563eb 0%, #7c3aed 60%, #0891b2 100%);
}

.au-pitch-lead {
  margin-top: 16px;
  font-size: 17px;
  line-height: 1.6;
  color: var(--ui-text-muted);
  max-width: 30em;
}

.au-features { margin-top: 32px; display: grid; gap: 14px; }
.au-feature {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
}
.au-feature-icon {
  flex: none;
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--ui-accent), var(--ui-accent-2));
}
.au-feature-icon svg { width: 19px; height: 19px; }
.au-feature b { display: block; font-size: 15px; font-weight: 600; color: var(--ui-text); }
.au-feature span { display: block; margin-top: 2px; font-size: 13.5px; color: var(--ui-text-muted); line-height: 1.5; }

.au-trust {
  margin-top: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ui-text-muted);
}
.au-trust svg { width: 16px; height: 16px; color: var(--au-success); }

/* ── Card ────────────────────────────────────────────────────────── */
.au-card-wrap { width: 100%; max-width: 448px; margin: 0 auto; }

.au-card {
  position: relative;
  padding: 32px;
  border-radius: 20px;
  background: var(--au-card);
  border: 1px solid var(--au-card-border);
  box-shadow: var(--ui-shadow-pop);
  -webkit-backdrop-filter: blur(18px);
          backdrop-filter: blur(18px);
}
@media (max-width: 480px) {
  .au-card { padding: 24px 20px; border-radius: 16px; }
}

.au-head { margin-bottom: 24px; }
.au-head h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ui-text);
}
.au-head p {
  margin-top: 6px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ui-text-muted);
}
.au-head p strong { color: var(--ui-text); font-weight: 600; word-break: break-all; }

.au-icon-badge {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: grid; place-items: center;
  margin-bottom: 16px;
  color: var(--ui-accent);
  background: var(--au-info-bg);
  border: 1px solid var(--au-info-border);
}
.au-icon-badge svg { width: 24px; height: 24px; }

/* Segmented tabs */
.au-seg {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  margin-bottom: 24px;
  border-radius: 12px;
  background: var(--au-seg-bg);
  border: 1px solid var(--ui-border);
}
.au-seg-thumb {
  position: absolute;
  top: 4px; bottom: 4px; left: 4px;
  width: calc(50% - 4px);
  border-radius: 9px;
  background: var(--au-seg-thumb);
  border: 1px solid var(--au-seg-thumb-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform 0.28s cubic-bezier(0.3, 0.7, 0.2, 1);
}
.au-seg[hidden], [data-strength-for][hidden] { display: none; }
.au-seg[data-active="signup"] .au-seg-thumb { transform: translateX(100%); }
.au-seg button {
  position: relative;
  z-index: 1;
  padding: 9px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ui-text-muted);
  border-radius: 9px;
  transition: color 0.2s;
}
.au-seg button[aria-selected="true"] { color: var(--ui-text); }
.au-seg button:focus-visible { outline: 2px solid var(--ui-ring); outline-offset: 2px; }

/* Views */
.au-view { display: none; }
.au-view.is-active { display: block; animation: au-in 0.32s ease-out; }
@keyframes au-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ── Form controls ───────────────────────────────────────────────── */
.au-form { display: grid; gap: 18px; }

.au-field label,
.au-label {
  display: block;
  margin-bottom: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--au-label);
}
.au-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.au-label-row .au-link { font-size: 13px; }

.au-control { position: relative; }
.au-control > svg.au-lead {
  position: absolute;
  left: 14px; top: 50%;
  width: 18px; height: 18px;
  transform: translateY(-50%);
  color: var(--au-placeholder);
  pointer-events: none;
  transition: color 0.15s;
}
.au-control:focus-within > svg.au-lead { color: var(--ui-accent); }

.au-input {
  width: 100%;
  height: 48px;
  padding: 0 14px 0 42px;
  font-size: 15px;
  color: var(--au-input-text);
  background: var(--au-input-bg);
  border: 1px solid var(--au-input-border);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.au-input.has-action { padding-right: 48px; }
.au-input::placeholder { color: var(--au-placeholder); }
.au-input:hover { border-color: var(--ui-border-strong); }
.au-input:focus {
  background: var(--au-input-bg-focus);
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 4px var(--ui-ring);
}
.au-input[aria-invalid="true"] { border-color: var(--au-danger); }
.au-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.25); }
/* Chrome autofill keeps our colours */
.au-input:-webkit-autofill {
  -webkit-text-fill-color: var(--au-input-text);
  -webkit-box-shadow: 0 0 0 1000px var(--au-input-bg-focus) inset;
  caret-color: var(--au-input-text);
}

.au-eye {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--au-placeholder);
  transition: color 0.15s, background-color 0.15s;
}
.au-eye:hover { color: var(--ui-text); background: rgba(148, 163, 184, 0.12); }
.au-eye:focus-visible { outline: 2px solid var(--ui-ring); outline-offset: 0; }
.au-eye svg { width: 19px; height: 19px; }
.au-eye .au-eye-off { display: none; }
.au-eye[aria-pressed="true"] .au-eye-on { display: none; }
.au-eye[aria-pressed="true"] .au-eye-off { display: block; }

.au-error {
  display: none;
  align-items: flex-start;
  gap: 6px;
  margin-top: 7px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--au-danger);
}
.au-error.is-visible { display: flex; }
.au-error svg { flex: none; width: 15px; height: 15px; margin-top: 1px; }

.au-hint { margin-top: 7px; font-size: 12.5px; color: var(--ui-text-muted); }
.au-caps {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--au-warn);
}
.au-caps.is-visible { display: flex; }
.au-caps svg { width: 14px; height: 14px; }

/* Strength meter + checklist */
.au-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.au-meter i {
  height: 4px;
  border-radius: 4px;
  background: var(--au-meter-empty);
  transition: background-color 0.25s;
}
.au-meter[data-score="1"] i:nth-child(-n+1) { background: #ef4444; }
.au-meter[data-score="2"] i:nth-child(-n+2) { background: #f59e0b; }
.au-meter[data-score="3"] i:nth-child(-n+3) { background: #3b82f6; }
.au-meter[data-score="4"] i { background: #10b981; }
.au-meter-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ui-text-muted);
}
.au-meter-label { font-weight: 600; }

.au-rules { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.au-rule {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ui-text-muted);
  transition: color 0.2s;
}
.au-rule::before {
  content: '';
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  opacity: 0.6;
  flex: none;
}
.au-rule.is-met { color: var(--au-success); }
.au-rule.is-met::before {
  opacity: 1;
  border-color: var(--au-success);
  background: var(--au-success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5'/%3E%3C/svg%3E") center / 11px no-repeat;
}

.au-match { display: none; align-items: center; gap: 6px; margin-top: 7px; font-size: 12.5px; font-weight: 500; }
.au-match.is-visible { display: flex; }
.au-match[data-ok="true"] { color: var(--au-success); }
.au-match[data-ok="false"] { color: var(--au-danger); }
.au-match svg { width: 14px; height: 14px; }
.au-match[data-ok="true"] [data-match-icon="bad"],
.au-match[data-ok="true"] [data-match-text="bad"],
.au-match[data-ok="false"] [data-match-icon="ok"],
.au-match[data-ok="false"] [data-match-text="ok"] { display: none; }

/* Checkbox */
.au-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ui-text-muted);
  cursor: pointer;
  user-select: none;
}
.au-check input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 18px; height: 18px;
  margin-top: 1px;
  border-radius: 5px;
  border: 1.5px solid var(--ui-border-strong);
  background: var(--au-input-bg);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.au-check input:checked {
  border-color: var(--ui-accent);
  background: var(--ui-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5'/%3E%3C/svg%3E") center / 13px no-repeat;
}
.au-check input:focus-visible { outline: 2px solid var(--ui-ring); outline-offset: 2px; }
.au-check input[aria-invalid="true"] { border-color: var(--au-danger); }

.au-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.au-link {
  color: var(--ui-accent);
  font-weight: 600;
  text-decoration: none;
  border-radius: 4px;
  transition: color 0.15s;
}
.au-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.au-link:focus-visible { outline: 2px solid var(--ui-ring); outline-offset: 2px; }
button.au-link:disabled { color: var(--ui-text-muted); cursor: default; text-decoration: none; }

/* Buttons */
.au-btn {
  position: relative;
  width: 100%;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 55%, #8b5cf6 100%);
  box-shadow: 0 8px 24px -10px rgba(99, 102, 241, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s, opacity 0.2s;
}
.au-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 12px 30px -10px rgba(99, 102, 241, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.au-btn:active:not(:disabled) { transform: translateY(1px); }
.au-btn:focus-visible { outline: 3px solid var(--ui-ring); outline-offset: 2px; }
.au-btn:disabled { cursor: not-allowed; opacity: 0.7; }
.au-btn .au-spinner { display: none; }
.au-btn[aria-busy="true"] .au-spinner { display: block; }
.au-btn[aria-busy="true"] .au-btn-arrow { display: none; }
.au-btn-arrow { width: 18px; height: 18px; transition: transform 0.2s; }
.au-btn:hover:not(:disabled) .au-btn-arrow { transform: translateX(3px); }

.au-spinner {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: au-spin 0.7s linear infinite;
}
@keyframes au-spin { to { transform: rotate(360deg); } }

.au-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ui-text-muted);
  border-radius: 6px;
  transition: color 0.15s;
}
.au-back:hover { color: var(--ui-text); }
.au-back:focus-visible { outline: 2px solid var(--ui-ring); outline-offset: 2px; }
.au-back svg { width: 16px; height: 16px; }

.au-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 14px;
  color: var(--ui-text-muted);
}
.au-fine { margin-top: 14px; text-align: center; font-size: 12.5px; color: var(--ui-text-muted); }

/* Alert banner */
.au-alert {
  display: none;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 20px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid;
}
.au-alert.is-visible { display: flex; animation: au-in 0.25s ease-out; }
.au-alert svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.au-alert[data-type="error"] { color: var(--au-danger); background: var(--au-danger-bg); border-color: var(--au-danger-border); }
.au-alert[data-type="success"] { color: var(--au-success); background: var(--au-success-bg); border-color: var(--au-success-border); }
.au-alert[data-type="info"] { color: var(--au-info); background: var(--au-info-bg); border-color: var(--au-info-border); }
.au-alert .au-alert-icon { display: none; }
.au-alert[data-type="error"] .au-alert-icon[data-for="error"],
.au-alert[data-type="success"] .au-alert-icon[data-for="success"],
.au-alert[data-type="info"] .au-alert-icon[data-for="info"] { display: block; }
.au-alert-text a { color: inherit; font-weight: 700; text-decoration: underline; }

/* OTP cells */
.au-otp {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.au-otp input {
  width: 100%;
  min-width: 0;
  height: 56px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--au-input-text);
  background: var(--au-input-bg);
  border: 1px solid var(--au-input-border);
  border-radius: 12px;
  outline: none;
  caret-color: var(--ui-accent);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.au-otp input:focus { border-color: var(--ui-accent); box-shadow: 0 0 0 4px var(--ui-ring); }
.au-otp input.is-filled { border-color: var(--ui-border-strong); }
.au-otp[aria-invalid="true"] input { border-color: var(--au-danger); }
.au-otp.is-shaking { animation: au-shake 0.4s; }
@keyframes au-shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
@media (max-width: 380px) {
  .au-otp { gap: 6px; }
  .au-otp input { height: 48px; font-size: 19px; }
}

.au-resend {
  margin-top: 18px;
  text-align: center;
  font-size: 13.5px;
  color: var(--ui-text-muted);
}

/* Success state */
.au-done { text-align: center; padding: 8px 0; }
.au-done .au-icon-badge {
  margin: 0 auto 16px;
  color: var(--au-success);
  background: var(--au-success-bg);
  border-color: var(--au-success-border);
}

/* Footer */
.au-footer {
  padding: 20px 16px;
  border-top: 1px solid var(--ui-border);
  font-size: 13px;
  color: var(--ui-text-muted);
}
.au-footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
}
.au-footer nav { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.au-footer a { color: var(--ui-text-muted); transition: color 0.15s; }
.au-footer a:hover { color: var(--ui-accent); }

.au-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .au-view.is-active,
  .au-alert.is-visible,
  .au-otp.is-shaking { animation: none; }
  .au-seg-thumb { transition: none; }
}
