/* Avenzo authentication - components for the sign-in, sign-up and reset pages.
   Tokens, the brand lockup, the theme toggle and theme behaviour come from the shared
   design system (/assets/ui/); this file only styles what is specific to the auth forms. */

/* ---------- base ---------- */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body.az {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--font-ui); font-size: 16px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
.az *, .az *::before, .az *::after { box-sizing: border-box; }
.az [hidden] { display: none !important; }
.az a { color: var(--brand-ink); text-decoration: none; font-weight: 600; }
.az a:hover { text-decoration: underline; text-underline-offset: 3px; }
.az :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.az-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.az-skip {
  position: absolute; left: 12px; top: -60px; z-index: 20; padding: 10px 14px; border-radius: 10px;
  background: var(--text); color: var(--bg) !important;
}
.az-skip:focus { top: 12px; }

/* ---------- text ---------- */

.az-title { margin: 0; font-family: var(--font-display); font-size: clamp(28px, 7.4vw, 34px); font-weight: 600; line-height: 1.12; letter-spacing: -0.02em; }
.az-lead { margin: 8px 0 0; font-size: 16px; color: var(--text-2); }
.az-meta { margin: 0; font-size: 15px; color: var(--text-2); }
.az-meta a { display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- fields ---------- */

.az-form { display: flex; flex-direction: column; gap: 18px; }
.az-field { display: flex; flex-direction: column; gap: 8px; }
.az-label { font-size: 14px; font-weight: 600; color: var(--text); }
.az-optional { font-weight: 500; color: var(--text-3); }
.az-input {
  width: 100%; height: var(--control); padding: 0 16px;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--field); border: 1px solid var(--border-strong); border-radius: var(--r);
  -webkit-appearance: none; appearance: none; outline: none;
  transition: border-color var(--fast) ease, box-shadow var(--fast) ease, background var(--fast) ease;
}
.az-input:hover { border-color: rgba(127, 127, 127, 0.45); }
.az-input:focus, .az-input:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); background: var(--surface); outline: none; border-radius: var(--r); }
.az-input[aria-invalid="true"] { border-color: var(--danger); }
.az-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.az-input::placeholder { color: var(--text-3); }
/* Keep autofilled fields on-theme (Chrome otherwise paints its own fill). */
.az-input:-webkit-autofill, .az-input:-webkit-autofill:hover, .az-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text); caret-color: var(--text);
  -webkit-box-shadow: 0 0 0 100px var(--field) inset; transition: background-color 600000s 0s;
}
.az-input:-webkit-autofill:focus { -webkit-box-shadow: 0 0 0 100px var(--surface) inset, 0 0 0 3px var(--ring); }

.az-pw { position: relative; }
.az-pw .az-input { padding-right: 52px; }
.az-pw-toggle {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: var(--text-2); cursor: pointer;
}
.az-pw-toggle:hover { color: var(--text); }
.az-pw-toggle svg { width: 20px; height: 20px; }
.az-pw-toggle .az-eye-off, .az-pw-toggle[aria-pressed="true"] .az-eye { display: none; }
.az-pw-toggle[aria-pressed="true"] .az-eye-off { display: block; }

.az-affix { position: relative; display: flex; }
.az-prefix { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-2); font-size: 16px; pointer-events: none; }
.az-affix .az-prefix ~ .az-input { padding-left: 52px; }

.az-hint { margin: 0; font-size: 13px; color: var(--text-2); }
.az-hint[data-met="true"] { color: var(--success); }
.az-error { margin: 0; font-size: 13.5px; font-weight: 500; color: var(--danger); }
.az-error:empty { display: none; }

.az-row { display: flex; justify-content: flex-end; margin-top: -8px; }
.az-link-sm { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; }

.az-check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--text-2); }
.az-check input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand-fill); }
.az-check label { line-height: 1.45; }

/* Form message: one compact line, announced (role="alert"). Empty = gone. */
.az-alert {
  display: flex; gap: 8px; padding: 10px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 500; line-height: 1.45;
  color: var(--danger); background: var(--danger-soft);
}
.az-alert:empty { display: none; }
.az-alert a { color: inherit; text-decoration: underline; }
.az-alert[data-tone="info"] { color: var(--text); background: var(--surface-subtle); }
.az-alert[data-tone="success"] { color: var(--success); background: var(--success-soft); }

/* ---------- buttons ---------- */

.az-btn {
  position: relative; width: 100%; min-height: var(--control); padding: 0 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font: inherit; font-size: 16px; font-weight: 600; letter-spacing: -0.005em;
  border: 1px solid transparent; border-radius: var(--r); cursor: pointer;
  text-decoration: none !important;
  transition: background var(--fast) ease, border-color var(--fast) ease, transform var(--fast) ease, box-shadow var(--fast) ease;
  -webkit-tap-highlight-color: transparent;
}
.az-btn:active:not(:disabled) { transform: scale(0.985); }
.az-btn-primary { color: #fff !important; background: var(--brand-fill); box-shadow: var(--shadow-1); }
.az-btn-primary:hover:not(:disabled) { background: var(--brand-fill-hover); }
.az-btn-secondary { color: var(--text) !important; background: var(--surface); border-color: var(--border-strong); }
.az-btn-secondary:hover:not(:disabled) { background: var(--surface-subtle); }
.az-btn-quiet { min-height: 44px; width: auto; padding: 0 10px; color: var(--text-2); background: transparent; font-size: 15px; }
.az-btn-quiet:hover:not(:disabled) { color: var(--text); background: var(--surface-subtle); }
.az-btn:disabled { cursor: not-allowed; opacity: 0.55; }
.az-btn[aria-busy="true"] { cursor: progress; opacity: 1; }
.az-g-icon { width: 20px; height: 20px; flex: none; }
/* The arrow and the progress ring share one slot at the right, so loading never moves the label. */
.az-btn-end { position: absolute; right: 16px; top: 50%; width: 18px; height: 18px; margin-top: -9px; }
.az-arrow { width: 18px; height: 18px; display: block; transition: transform var(--fast) ease; }
@media (hover: hover) { .az-btn-primary:hover .az-arrow { transform: translateX(2px); } }
.az-spinner {
  display: none; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: az-spin 0.7s linear infinite;
}
.az-btn[aria-busy="true"] .az-spinner { display: block; }
.az-btn[aria-busy="true"] .az-arrow { display: none; }
@keyframes az-spin { to { transform: rotate(360deg); } }

.az-divider { display: flex; align-items: center; gap: 12px; margin: 2px 0; font-size: 13px; color: var(--text-3); }
.az-divider::before, .az-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- one-time code ---------- */

.az-otp { position: relative; }
.az-otp-input {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.001;
  font-size: 16px; letter-spacing: 1em; color: transparent; caret-color: transparent;
  border: 0; background: transparent; outline: none;
}
.az-otp-cells { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; pointer-events: none; }
.az-otp-cells span {
  height: 56px; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--text);
  background: var(--field); border: 1px solid var(--border-strong); border-radius: 12px;
  transition: border-color var(--fast) ease, box-shadow var(--fast) ease;
}
.az-otp[data-focused="true"] .az-otp-cells span[data-active="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.az-otp[data-invalid="true"] .az-otp-cells span { border-color: var(--danger); }
.az-resend { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-size: 14px; color: var(--text-2); }

/* ---------- motion ---------- */


@media (prefers-reduced-motion: reduce) {
  .az *, .az *::before, .az *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
  .az-spinner { animation: az-spin 1.4s linear infinite !important; }
}
@media (forced-colors: active) {
  .az-btn, .az-input, .az-otp-cells span { border: 1px solid CanvasText; }
}
