/* auth.css
 * Shared stylesheet for all auth/account-flow pages.
 * Loaded by: login, login-verify, register, forgot-password, reset-password,
 *            activate, setup, confirm-email (and their state variants).
 *
 * Sections:
 *   1. Fonts + design-token re-imports we rely on
 *   2. Reset / base
 *   3. Background shell (.auth-bg, watermark, dotted texture)
 *   4. Card (.auth-card, header, title, subtitle)
 *   5. Form elements (label, input, password toggle, checkbox, disabled)
 *   6. Buttons (primary, secondary, loading)
 *   7. Alerts (error / success / info / warning)
 *   8. Specialized: password strength meter, match indicator,
 *                   6-digit code input, rate-limit banner, expired-token empty
 *   9. Footer links + responsive
 */

/* ─── 1. Fonts + tokens ─────────────────────────────────────────────── */
/* Fonts (self-hosted woff2) and core design tokens come from design-tokens.css,
   loaded ahead of this file by each auth page. The block below adds only the
   tokens auth pages need that aren't in the platform set. */
:root {
  --gold-dk:        #a07840;
  --border-strong:  #cfd6e0;

  --red-50:         #fdecec;
  --red-200:        #f4b4b4;
  --red-700:        #b3261e;
  --green-50:       #e8f4ec;
  --green-200:      #a9d4b8;
  --green-700:      #1f7a3a;
  --amber-50:       #fdf3e2;
  --amber-200:      #f0d28a;
  --amber-700:      #8a5a0e;

  --radius-xl:      22px;
  /* Deeper drop-shadow than the platform default — cards sit on a dark bg. */
  --shadow-lg:      0 24px 60px rgba(5, 18, 38, .35), 0 4px 14px rgba(5, 18, 38, .25);
}

/* ─── 2. Reset / base ───────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-900);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; }
a { color: var(--blue-700); text-decoration: none; }
a:hover { color: var(--blue-900); text-decoration: underline; }

/* ─── 3. Background shell ───────────────────────────────────────────── */
.auth-bg {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(184, 146, 74, .22), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(38, 114, 184, .35), transparent 55%),
    linear-gradient(180deg, #0a2240 0%, #0d2e52 55%, #14406f 100%);
  isolation: isolate;
  display: flex;
  flex-direction: column;
}

/* Dotted texture overlay */
.auth-bg::before {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .06) 1px, transparent 0);
  background-size: 4px 4px;
  opacity: .35;
  z-index: 0;
  pointer-events: none;
}

/* Logo watermark — large, faint, off-center */
.auth-watermark {
  position: absolute;
  right: 200px;
  top: 50%;
  transform: translateY(-50%);
  width: 720px;
  height: 720px;
  opacity: 0.06;
  z-index: 0;
  pointer-events: none;
  filter: brightness(0) invert(1);
  user-select: none;
}
@media (max-width: 900px) {
  .auth-watermark { width: 480px; height: 480px; right: -80px; opacity: .05; }
}

/* Page layout: centers card vertically; small top brand bar above it */
.auth-shell {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px 48px;
}
.auth-topbar {
  width: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}
.auth-topbar .auth-topbar-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, .85);
  font-family: 'Lora', Georgia, serif;
  font-size: 1.05rem;
  letter-spacing: .01em;
  text-decoration: none;
}
.auth-topbar .auth-topbar-mark img {
  height: 28px; width: auto;
  filter: brightness(0) invert(1);
  opacity: .9;
}
.auth-topbar .auth-topbar-mark:hover { color: #fff; text-decoration: none; }

.auth-main {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex: 1 1 auto;
}

.auth-bottombar {
  position: relative;
  z-index: 1;
  width: 100%;
  text-align: center;
  padding: 24px 20px 28px;
  color: rgba(255, 255, 255, .55);
  font-size: .82rem;
}
.auth-bottombar a { color: rgba(255, 255, 255, .75); }
.auth-bottombar a:hover { color: #fff; }
.auth-bottombar .sep { margin: 0 10px; opacity: .5; }

/* ─── 4. Card ───────────────────────────────────────────────────────── */
.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text-900);
  padding: 44px 44px 36px;
  position: relative;
}
.auth-card--wide { max-width: 540px; }
.auth-card--narrow { max-width: 420px; }

@media (max-width: 600px) {
  .auth-card { padding: 28px 22px 26px; border-radius: var(--radius); }
}

.auth-card-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--blue-50);
  color: var(--blue-700);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.auth-card-icon--gold { background: var(--gold-lt); color: var(--gold-dk); }
.auth-card-icon--green { background: var(--green-50); color: var(--green-700); }
.auth-card-icon--red { background: var(--red-50); color: var(--red-700); }
.auth-card-icon--amber { background: var(--amber-50); color: var(--amber-700); }
.auth-card-icon svg { width: 28px; height: 28px; }

.auth-card-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--blue-900);
  text-align: center;
  margin: 0 0 8px;
  line-height: 1.2;
  letter-spacing: -.005em;
}
.auth-card-subtitle {
  text-align: center;
  color: var(--text-500);
  font-size: .98rem;
  margin: 0 0 28px;
  line-height: 1.5;
  text-wrap: pretty;
}
.auth-card-subtitle strong { color: var(--text-900); font-weight: 600; }

/* Optional small wordmark above title (used when no icon) */
.auth-card-mark {
  text-align: center;
  margin-bottom: 18px;
}
.auth-card-mark img {
  height: 36px;
  width: auto;
  display: inline-block;
  opacity: .95;
}

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

.field { display: flex; flex-direction: column; gap: 6px; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 480px) {
  .field-row { grid-template-columns: 1fr; gap: 18px; }
}

.field-label {
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-700);
}
.field-label .req { color: var(--red-700); margin-left: 2px; font-weight: 700; }
.field-help {
  font-size: .82rem;
  color: var(--text-500);
  margin-top: 2px;
  line-height: 1.4;
}
.field-help--note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-style: italic;
}

.input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--text-900);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 11px 14px;
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--text-300); }
.input:hover { border-color: #b6bfcc; }
.input:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(38, 114, 184, .18);
}
.input:disabled,
.input[readonly] {
  background: #f4f6fa;
  color: var(--text-700);
  cursor: not-allowed;
  border-color: var(--border);
}
.input.is-invalid {
  border-color: var(--red-700);
  box-shadow: 0 0 0 3px rgba(179, 38, 30, .12);
}
.input.is-valid {
  border-color: var(--green-700);
}

/* Password input with show/hide toggle */
.input-pw {
  position: relative;
}
.input-pw .input { padding-right: 44px; }
.input-pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  border: 0;
  background: transparent;
  color: var(--text-500);
  cursor: pointer;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.input-pw-toggle:hover { color: var(--blue-700); background: var(--blue-50); }
.input-pw-toggle:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 1px; }
.input-pw-toggle svg { width: 18px; height: 18px; }

/* Checkbox */
.check {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: .94rem;
  color: var(--text-700);
  line-height: 1.4;
  user-select: none;
}
.check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  position: relative;
  transition: background .15s, border-color .15s;
  margin-top: 2px;
}
.check input[type="checkbox"]:hover { border-color: var(--blue-600); }
.check input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 2px;
}
.check input[type="checkbox"]:checked {
  background: var(--blue-700);
  border-color: var(--blue-700);
}
.check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px; top: 1px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.check a { font-weight: 500; }

/* Row holding "Remember me" + "Forgot password" */
.field-inline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: .94rem;
}
.field-inline-row a { font-weight: 500; }

/* ─── 6. Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: .01em;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
  min-height: 46px;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(184, 146, 74, .35);
}
.btn:active { transform: translateY(1px); }
.btn--block { width: 100%; }

.btn-primary {
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
}
.btn-primary:hover { background: var(--gold-dk); border-color: var(--gold-dk); color: #fff; text-decoration: none; }
.btn-primary:disabled,
.btn-primary.is-loading {
  cursor: not-allowed;
  opacity: .85;
}

.btn-secondary {
  background: #fff;
  color: var(--blue-900);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--blue-50); color: var(--blue-900); border-color: var(--blue-600); text-decoration: none; }

/* Loading spinner */
.btn .spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── 7. Alerts ─────────────────────────────────────────────────────── */
.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: .94rem;
  line-height: 1.5;
}
.alert-icon {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  margin-top: 1px;
}
.alert-body { flex: 1 1 auto; }
.alert-title { font-weight: 600; margin: 0 0 2px; }
.alert-body p { margin: 0; }
.alert-body p + p { margin-top: 4px; }

.alert-error   { background: var(--red-50);   border-color: var(--red-200);   color: var(--red-700); }
.alert-success { background: var(--green-50); border-color: var(--green-200); color: var(--green-700); }
.alert-info    { background: var(--blue-50);  border-color: var(--blue-100);  color: var(--blue-700); }
.alert-warning { background: var(--amber-50); border-color: var(--amber-200); color: var(--amber-700); }

.alert a {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}

/* ─── 8. Specialized pieces ─────────────────────────────────────────── */

/* Password strength meter (3-tier) */
.pw-strength {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pw-strength-bars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.pw-strength-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  transition: background .2s;
}
.pw-strength[data-level="1"] .pw-strength-bar:nth-child(1) { background: var(--red-700); }
.pw-strength[data-level="2"] .pw-strength-bar:nth-child(-n+2) { background: var(--amber-700); }
.pw-strength[data-level="3"] .pw-strength-bar { background: var(--green-700); }

.pw-strength-label {
  font-size: .82rem;
  color: var(--text-500);
  display: flex;
  justify-content: space-between;
}
.pw-strength[data-level="1"] .pw-strength-label .level { color: var(--red-700); font-weight: 600; }
.pw-strength[data-level="2"] .pw-strength-label .level { color: var(--amber-700); font-weight: 600; }
.pw-strength[data-level="3"] .pw-strength-label .level { color: var(--green-700); font-weight: 600; }

/* Password requirements checklist */
.pw-reqs {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .86rem;
  color: var(--text-500);
}
.pw-reqs li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pw-reqs li::before {
  content: "";
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: #fff;
  flex: 0 0 auto;
}
.pw-reqs li.met { color: var(--green-700); }
.pw-reqs li.met::before {
  background: var(--green-700);
  border-color: var(--green-700);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M3 6.5l2 2 4-4.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
}

/* Password match indicator */
.pw-match {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .86rem;
  color: var(--text-500);
  margin-top: 2px;
}
.pw-match.is-match { color: var(--green-700); }
.pw-match.is-mismatch { color: var(--red-700); }
.pw-match svg { width: 14px; height: 14px; }

/* 6-digit numeric code input */
.code-input {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 6px 0 4px;
}
.code-input input {
  width: 48px;
  height: 60px;
  text-align: center;
  font-family: 'SFMono-Regular', 'Menlo', 'Consolas', monospace;
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--blue-900);
  background: #fff;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  -moz-appearance: textfield;
  appearance: textfield;
  transition: border-color .15s, box-shadow .15s;
}
.code-input input::-webkit-outer-spin-button,
.code-input input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.code-input input:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(38, 114, 184, .18);
}
.code-input input.has-value {
  border-color: var(--blue-700);
  background: var(--blue-50);
}
@media (max-width: 480px) {
  .code-input { gap: 6px; }
  .code-input input { width: 40px; height: 52px; font-size: 1.3rem; }
}

/* Rate-limit "locked out" banner — bigger / more prominent than .alert */
.lockout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 18px 18px;
  border-radius: var(--radius);
  background: var(--amber-50);
  border: 1px solid var(--amber-200);
  color: var(--amber-700);
}
.lockout-icon {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #fff;
  color: var(--amber-700);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--amber-200);
}
.lockout-icon svg { width: 20px; height: 20px; }
.lockout-body { flex: 1 1 auto; }
.lockout-title { font-weight: 700; margin: 0 0 2px; color: var(--amber-700); }
.lockout-body p { margin: 0; color: var(--text-700); font-size: .92rem; }
.lockout-countdown {
  font-family: 'SFMono-Regular', 'Menlo', 'Consolas', monospace;
  font-weight: 600;
  color: var(--amber-700);
}

/* Token-expired empty state (no form) */
.empty-state {
  text-align: center;
  padding: 4px 0;
}
.empty-state .auth-card-icon { margin-bottom: 18px; }
.empty-state p {
  color: var(--text-500);
  margin: 0 0 22px;
  font-size: .98rem;
  line-height: 1.55;
  text-wrap: pretty;
}

/* ─── 9. Footer links / divider / responsive ───────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-500);
  font-size: .82rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin: 24px 0 4px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--border);
}

.auth-card-foot {
  text-align: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-500);
  font-size: .94rem;
}
.auth-card-foot a { font-weight: 600; }
.auth-card-foot--noborder { border-top: 0; padding-top: 0; }

.auth-help-link {
  text-align: center;
  margin-top: 20px;
  font-size: .92rem;
}
.auth-help-link a {
  color: rgba(255, 255, 255, .85);
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, .3);
  text-underline-offset: 3px;
}
.auth-help-link a:hover { color: #fff; text-decoration-color: #fff; }

/* Visually-hidden label (used when label is decorative on top of code input etc.) */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
