/* ═══════════════════════════════════════════════════════════════
   Auth / Welcome shared styling
   Used by app/templates/welcome.html and app/templates/auth/login.html
   so the landing → login flow feels like one surface.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #fafaf9;
  --card: rgba(255, 255, 255, 0.78);
  --card-border: rgba(255, 255, 255, 0.55);
  --card-shadow: 0 1px 2px rgba(17, 24, 39, 0.03),
                 0 18px 44px -18px rgba(17, 24, 39, 0.18),
                 0 1px 0 rgba(255, 255, 255, 0.6) inset;

  --text: #111827;
  --muted: #6b7280;
  --soft: #9ca3af;

  --accent: #111827;
  --accent-hover: #1f2937;

  --border: #e7e5e4;

  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-text: #991b1b;

  --env-dev: #3b82f6;
  --env-stage: #f59e0b;
  --env-prod: #10b981;
  --env-local: #6b7280;

  /* Blob palette — saturated enough to sit behind 80px blur */
  --blob-amber: #f59e0b;
  --blob-teal: #10b981;
  --blob-indigo: #6366f1;
  --blob-rose: #f472b6;

  /* Tokens for values that used to be hardcoded, so the dark theme
     below can override them in one place. */
  --on-accent: #fff;
  --surface: #fff;
  --surface-soft: rgba(255, 255, 255, 0.85);
  --shadow-rgb: 17, 24, 39;
  --ring: rgba(17, 24, 39, 0.08);
  --dot: rgba(17, 24, 39, 0.09);
  --dot-blend: multiply;
  --logo-bg: linear-gradient(135deg, #111827, #1f2937);
  --logo-fg: #fff;
  --pill-bg: rgba(255, 255, 255, 0.7);
  --pill-border: rgba(17, 24, 39, 0.08);
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --success-text: #065f46;
  --shape-opacity: 1;
}

/* ─── Dark theme ──────────────────────────────────────────────────
   Mirrors cpa.css "Ledger" (zinc surfaces, warm-gold accent). Set by
   the pre-paint script in each auth template from localStorage
   `cpa-theme` — the same key the app's theme toggle writes — so the
   sign-in pages match what the user sees once inside. */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --card: rgba(17, 17, 19, 0.72);
  --card-border: rgba(255, 255, 255, 0.06);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.3),
                 0 24px 60px -20px rgba(0, 0, 0, 0.7),
                 0 1px 0 rgba(255, 255, 255, 0.04) inset;

  --text: #fafafa;
  --muted: #a1a1aa;
  --soft: #71717a;

  --accent: #c9a96e;
  --accent-hover: #dbbf8a;
  --on-accent: #111113;

  --border: #27272a;

  --error-bg: rgba(248, 113, 113, 0.08);
  --error-border: rgba(248, 113, 113, 0.28);
  --error-text: #fca5a5;

  --surface: #111113;
  --surface-soft: rgba(24, 24, 27, 0.8);
  --shadow-rgb: 0, 0, 0;
  --ring: rgba(201, 169, 110, 0.18);
  --dot: rgba(255, 255, 255, 0.06);
  --dot-blend: normal;
  --logo-bg: linear-gradient(135deg, #dbbf8a, #96783a);
  --logo-fg: #111113;
  --pill-bg: rgba(24, 24, 27, 0.7);
  --pill-border: rgba(255, 255, 255, 0.08);
  --success-bg: rgba(74, 222, 128, 0.08);
  --success-border: rgba(74, 222, 128, 0.25);
  --success-text: #86efac;
  --shape-opacity: 0.45;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-x: hidden;
  position: relative;
}

/* ─── Abstract background shapes ───────────────────────────────
   Three blurred color blobs that float behind the content, plus a
   fine dot grid for texture. Purely decorative — pointer-events off
   and tucked to z-index:0 with content at z-index:1.
   ─────────────────────────────────────────────────────────────── */
.bg-shapes {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: calc(0.45 * var(--shape-opacity));
  will-change: transform;
}

.shape-1 {
  width: 520px; height: 520px;
  background: var(--blob-amber);
  top: -180px; left: -160px;
  animation: drift-a 18s ease-in-out infinite;
}

.shape-2 {
  width: 620px; height: 620px;
  background: var(--blob-teal);
  bottom: -220px; right: -180px;
  animation: drift-b 22s ease-in-out infinite;
}

.shape-3 {
  width: 340px; height: 340px;
  background: var(--blob-indigo);
  top: 55%; left: 55%;
  opacity: calc(0.32 * var(--shape-opacity));
  animation: drift-a 15s ease-in-out infinite reverse;
}

.shape-4 {
  width: 220px; height: 220px;
  background: var(--blob-rose);
  top: 12%; right: 18%;
  opacity: calc(0.28 * var(--shape-opacity));
  animation: drift-b 17s ease-in-out infinite 2s;
}

/* Thin SVG-pattern overlay of dots — gives the abstract feel a bit
   of rhythm without fighting the blobs. */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(circle at center, var(--dot) 1px, transparent 1.4px);
  background-size: 26px 26px;
  background-position: 0 0;
  opacity: 0.55;
  mix-blend-mode: var(--dot-blend);
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 80%);
}

@keyframes drift-a {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(24px, -28px) scale(1.06); }
}
@keyframes drift-b {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-30px, 22px) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .shape { animation: none !important; }
}

/* ─── Centered content shell ───────────────────────────────────── */
.shell {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

.header {
  text-align: center;
  margin-bottom: 28px;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  border-radius: 18px;
  background: var(--logo-bg);
  color: var(--logo-fg);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.5px;
  margin-bottom: 18px;
  box-shadow: 0 10px 24px -10px rgba(var(--shadow-rgb), 0.5),
              0 1px 0 rgba(255, 255, 255, 0.15) inset;
}

.title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.env-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 5px 12px;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.env-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--env-color, var(--env-prod));
}
.env-dev   { --env-color: var(--env-dev); }
.env-stage { --env-color: var(--env-stage); }
.env-prod  { --env-color: var(--env-prod); }
.env-local { --env-color: var(--env-local); }

/* ─── Card (frosted) ───────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
}

.card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 24px;
  text-align: center;
}

/* ─── Button (primary) ─────────────────────────────────────────── */
.btn,
button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 18px;
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background 140ms, transform 140ms, box-shadow 140ms;
  box-shadow: 0 6px 16px -8px rgba(var(--shadow-rgb), 0.4);
}
.btn:hover,
button[type="submit"]:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -10px rgba(var(--shadow-rgb), 0.45);
}
.btn:active,
button[type="submit"]:active { transform: translateY(0); }
button[type="submit"]:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ─── Form fields ──────────────────────────────────────────────── */
.alert {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.field { margin-bottom: 16px; }

label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
  letter-spacing: 0.01em;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 120ms, box-shadow 120ms;
}
input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

/* ─── Footer ───────────────────────────────────────────────────── */
.footer {
  margin-top: 22px;
  text-align: center;
  color: var(--soft);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

/* ─── Alert variants (used by /auth/2fa for the "code sent" notice) ── */
.alert.alert-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

/* ─── Secondary button — for "Verify my location" and similar ──── */
button.btn-secondary {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  text-transform: uppercase;
}
button.btn-secondary:hover {
  background: var(--surface);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -10px rgba(var(--shadow-rgb), 0.18);
}

/* ─── Link button — inline text with a form submit underneath ──── */
button.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  padding: 0;
  background: transparent;
  color: var(--muted);
  border: 0;
  box-shadow: none;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 120ms;
}
button.btn-link:hover {
  color: var(--text);
  background: transparent;
  transform: none;
  box-shadow: none;
}
a.btn-link {
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 120ms;
}
a.btn-link:hover { color: var(--text); }

/* ─── OTP / verification code input ────────────────────────────── */
input.otp-input {
  font-family: "SF Mono", "Menlo", "Consolas", "Roboto Mono", monospace;
  text-align: center;
  letter-spacing: 0.55em;
  font-size: 24px;
  font-weight: 600;
  padding: 16px 14px;
  padding-right: calc(14px - 0.55em); /* keep the centered look — letter-spacing shifts right */
}

/* ─── Divider with "or" between primary/secondary actions ─────── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--soft);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Custom checkbox row ──────────────────────────────────────── */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.checkbox-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-grid;
  place-content: center;
  transition: background 120ms, border-color 120ms;
  margin: 0;
}
.checkbox-row input[type="checkbox"]::before {
  content: "";
  width: 10px;
  height: 10px;
  transform: scale(0);
  transition: transform 100ms;
  clip-path: polygon(14% 44%, 0% 65%, 45% 100%, 100% 16%, 80% 0%, 43% 62%);
  background: var(--on-accent);
}
.checkbox-row input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox-row input[type="checkbox"]:checked::before {
  transform: scale(1);
}
.checkbox-row label {
  margin: 0;
  cursor: pointer;
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
}

/* ─── Row of small utility links under the primary CTA ─────────── */
.link-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}
.link-row form { margin: 0; }

/* ─── Compact on short screens ─────────────────────────────────── */
@media (max-height: 640px) {
  .header { margin-bottom: 18px; }
  .logo-mark { width: 52px; height: 52px; font-size: 18px; margin-bottom: 12px; }
  .title { font-size: 22px; }
  input.otp-input { font-size: 20px; padding: 12px 10px; }
}

/* ── Passkey sign-in on the login page ─────────────────────────────── */
/* Secondary to the password submit: same size/shape/type treatment so the
   two read as a pair, but frosted white instead of solid ink. */
.passkey-panel { margin-top: 4px; }
.passkey-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 18px;
  background: var(--surface-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase;
  cursor: pointer;
  transition: background 140ms, border-color 140ms, transform 140ms, box-shadow 140ms;
}
.passkey-btn:hover:not(:disabled) {
  background: var(--surface); border-color: var(--soft);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -12px rgba(var(--shadow-rgb), 0.25);
}
.passkey-btn:active:not(:disabled) { transform: translateY(0); }
.passkey-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.passkey-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.passkey-btn-icon {
  width: 24px; height: 24px; flex-shrink: 0;
  display: inline-grid; place-content: center;
  border-radius: 7px; background: var(--accent); color: var(--on-accent); font-size: 12px;
}
.passkey-hint {
  margin-top: 8px; text-align: center;
  color: var(--soft); font-size: 11.5px; letter-spacing: 0.01em;
}
.passkey-msg[hidden] { display: none; }
.passkey-msg { margin: 12px 0 0; }
.passkey-msg .fa-circle-notch { margin-top: 2px; }

/* ── Theme toggle (auth pages) ─────────────────────────────────────── */
.theme-toggle {
  position: fixed; top: 16px; right: 16px; z-index: 2;
  width: 38px; height: 38px; display: inline-grid; place-content: center;
  border-radius: 10px; border: 1px solid var(--pill-border);
  background: var(--pill-bg); color: var(--muted);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  cursor: pointer; font-size: 14px;
  transition: color 140ms, border-color 140ms;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border); }
.theme-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
