/* Login, signup and the handle pages — same cards, controls and type as Settings, on the site theme tokens */

.auth {
  --a-surface: color-mix(
    in srgb,
    var(--site-surface-2, #5e7594) 70%,
    rgba(0, 0, 0, 0.34)
  );
  --a-inset: color-mix(
    in srgb,
    var(--site-surface-3, #4a5f7a) 76%,
    rgba(0, 0, 0, 0.48)
  );
  --a-border: color-mix(
    in srgb,
    var(--site-border, #353d49) 70%,
    var(--site-muted, #b5cae0)
  );
  --a-control-border: var(--site-control-border, rgba(255, 255, 255, 0.24));
  --a-control-border-hover: var(
    --site-control-border-hover,
    rgba(255, 255, 255, 0.34)
  );
  --a-text: var(--site-text, #ffffff);
  --a-muted: var(--site-muted, #b5cae0);
  --a-accent: var(--site-accent, #f5b942);
  --a-accent-hover: var(--site-accent-hover, #f8cd6b);
  --a-on-accent: var(--site-accent-text, #484c51);
  --a-danger: #ff8a8e;
  --a-success: #6ee7a0;
  --a-radius: var(--site-radius-md, 14px);
  --a-radius-sm: var(--site-radius-sm, 10px);
  --a-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --a-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --a-fast: 120ms;
  --a-normal: 200ms;
  --a-slow: 360ms;
  --a-font: "Roboto", system-ui, -apple-system, sans-serif;

  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(420px, calc(100% - 32px));
  margin: 0 auto;
  padding: 52px 0 72px;
  font-family: var(--a-font);
  color: var(--a-text);
}

.auth *,
.auth *::before,
.auth *::after {
  box-sizing: border-box;
}

:root[data-theme="contrast"] .auth {
  --a-surface: #000000;
  --a-inset: #0a0a0a;
  --a-border: #ffffff;
  --a-control-border: #ffffff;
  --a-control-border-hover: #ffff00;
  --a-muted: #ffffff;
  --a-danger: #ff4d4d;
}

/* ---------- Entrance ---------- */

.auth > * {
  animation: a-rise var(--a-slow) var(--a-ease-out) both;
}
.auth > *:nth-child(2) {
  animation-delay: 50ms;
}
.auth > *:nth-child(n + 3) {
  animation-delay: 100ms;
}

@keyframes a-rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Header ---------- */

.auth-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin-bottom: 12px;
  text-align: center;
}

.auth-kicker {
  margin: 0 0 8px;
  color: var(--a-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-title {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.5rem);
  font-weight: 700;
  line-height: 1;
}

.auth-subtitle {
  margin: 12px 0 0;
  color: var(--a-muted);
  font-size: 1rem;
  line-height: 1.5;
}

/* The disc shows the first letter of the handle as it is typed */
.auth-avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid var(--a-control-border);
  background: var(--a-inset);
  color: var(--a-muted);
  font-size: 1.75rem;
  font-weight: 700;
  text-transform: uppercase;
  user-select: none;
  transition:
    color var(--a-normal) ease,
    background-color var(--a-normal) ease,
    border-color var(--a-normal) ease;
}

.auth-avatar svg {
  width: 28px;
  height: 28px;
}

.auth-avatar.has-initial {
  border-color: transparent;
  background: var(--a-accent);
  color: var(--a-on-accent);
}

.auth-avatar.is-popping {
  animation: a-pop var(--a-slow) var(--a-ease-spring);
}

@keyframes a-pop {
  from {
    transform: scale(0.88);
  }
  to {
    transform: none;
  }
}

/* ---------- Card and fields ---------- */

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
  background: var(--a-surface);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--a-text) 5%, transparent);
  text-align: left;
}

.auth-card h2 {
  margin: 0;
  font-size: 1.34rem;
  font-weight: 700;
  line-height: 1.12;
}

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

.auth-label {
  font-size: 0.92rem;
  font-weight: 700;
}

.auth-control {
  position: relative;
}

.auth-input {
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--a-control-border);
  border-radius: var(--a-radius-sm);
  background: var(--a-inset);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--a-text) 7%, transparent);
  color: var(--site-input-text, #ffffff);
  font-family: var(--a-font);
  font-size: 1rem;
  outline: none;
  transition:
    border-color var(--a-fast) ease,
    box-shadow var(--a-normal) ease;
}

.auth-input:hover {
  border-color: var(--a-control-border-hover);
}

.auth-input:focus-visible {
  border-color: var(--a-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--a-accent) 30%, transparent);
}

.auth-input[aria-invalid="true"] {
  border-color: var(--a-danger);
}

.auth-input[aria-invalid="true"]:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--a-danger) 28%, transparent);
}

.auth-control .auth-input {
  padding-right: 46px;
}

.auth-control.has-prefix .auth-input {
  padding-left: 32px;
  padding-right: 14px;
}

.auth-prefix {
  position: absolute;
  top: 0;
  left: 14px;
  display: grid;
  height: 44px;
  place-items: center;
  color: var(--a-accent);
  font-weight: 700;
  pointer-events: none;
}

.auth-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--a-muted);
  cursor: pointer;
  transition:
    background-color var(--a-fast) ease,
    color var(--a-fast) ease;
}

.auth-toggle:hover,
.auth-toggle:active {
  transform: none;
  background: color-mix(in srgb, var(--a-text) 10%, transparent);
  color: var(--a-text);
}

.auth-toggle svg {
  width: 18px;
  height: 18px;
}

.auth-toggle .auth-eye-off,
.auth-toggle[aria-pressed="true"] .auth-eye {
  display: none;
}

.auth-toggle[aria-pressed="true"] .auth-eye-off {
  display: block;
}

.auth-hint {
  margin: 0;
  color: var(--a-muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

.auth-hint.is-error {
  color: var(--a-danger);
}

/* Requirements that tick off as the field is typed in */
.auth-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  padding: 0;
  color: var(--a-muted);
  font-size: 0.875rem;
  line-height: 1.4;
  list-style: none;
}

.auth-rules li {
  display: flex;
  align-items: center;
  gap: 7px;
  transition: color var(--a-normal) ease;
}

.auth-rules li::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  margin: 0 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

.auth-rules li.is-met {
  color: var(--a-text);
}

.auth-rules li.is-met::before {
  width: 6px;
  height: 10px;
  margin: -3px 3px 0;
  border: solid var(--a-success);
  border-width: 0 2px 2px 0;
  border-radius: 0;
  background: none;
  opacity: 1;
  rotate: 45deg;
}

.auth-hint.is-ok {
  color: var(--a-success);
}

/* ---------- Captcha: a box that ticks itself ---------- */

.auth-captcha {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--a-control-border);
  border-radius: var(--a-radius-sm);
  background: var(--a-inset);
  color: var(--a-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--a-normal) ease,
    background-color var(--a-normal) ease;
}

/* style.css scales every button on hover; the captcha stays put. */
.auth-captcha:hover,
.auth-captcha:active {
  transform: none;
}

.auth-captcha:focus-visible {
  outline: 2px solid var(--a-accent);
  outline-offset: 2px;
}

.auth-captcha[data-state="working"] {
  cursor: progress;
}

.auth-captcha[data-state="done"] {
  border-color: color-mix(in srgb, var(--a-success) 55%, transparent);
  cursor: default;
}

.auth-captcha[data-state="error"] {
  border-color: color-mix(in srgb, var(--a-danger) 60%, transparent);
}

.auth-captcha-box {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--a-control-border-hover);
  border-radius: 7px;
  transition:
    border-color var(--a-normal) ease,
    border-radius var(--a-normal) var(--a-ease-out),
    background-color var(--a-normal) ease,
    scale var(--a-fast) ease;
}

.auth-captcha[data-state="idle"]:active .auth-captcha-box,
.auth-captcha[data-state="error"]:active .auth-captcha-box {
  scale: 0.9;
}

/* Working: the box rounds into a ring and spins */
.auth-captcha[data-state="working"] .auth-captcha-box {
  border-color: color-mix(in srgb, var(--a-accent) 28%, transparent);
  border-top-color: var(--a-accent);
  border-radius: 50%;
  animation: a-spin 0.7s linear infinite;
}

/* Done: it fills, pops, and the tick draws itself */
.auth-captcha[data-state="done"] .auth-captcha-box {
  border-color: var(--a-success);
  border-radius: 50%;
  background: var(--a-success);
  animation: a-captcha-pop var(--a-slow) var(--a-ease-spring);
}

.auth-captcha-check {
  width: 16px;
  height: 16px;
  color: #0b2b18;
}

.auth-captcha-check path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.auth-captcha[data-state="done"] .auth-captcha-check path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 320ms var(--a-ease-out) 120ms;
}

@keyframes a-captcha-pop {
  from {
    scale: 0.6;
  }
  to {
    scale: 1;
  }
}

.auth-captcha-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.auth-captcha-label {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.3;
}

.auth-captcha-note {
  color: var(--a-muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.auth-captcha[data-state="error"] .auth-captcha-note {
  color: var(--a-danger);
}

.auth-captcha-mark {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--a-muted);
  opacity: 0.7;
  transition:
    color var(--a-normal) ease,
    opacity var(--a-normal) ease;
}

.auth-captcha[data-state="done"] .auth-captcha-mark {
  color: var(--a-success);
  opacity: 1;
}

/* A field for form-filling scripts only: off screen, out of the tab order */
.auth-trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- Messages ---------- */

.auth-message {
  margin: 0;
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--a-tone) 55%, transparent);
  border-radius: var(--a-radius-sm);
  background: color-mix(in srgb, var(--a-tone) 12%, transparent);
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: left;
}

.auth-message[hidden] {
  display: none;
}

.auth-message[data-tone="error"] {
  --a-tone: var(--a-danger);
}

.auth-message[data-tone="success"] {
  --a-tone: var(--a-success);
}

.auth-message[data-tone="info"] {
  --a-tone: var(--a-muted);
}

/* ---------- Submit ---------- */

.auth-submit {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 46px;
  padding: 0 20px;
  border: none;
  border-radius: var(--a-radius-sm);
  background: var(--a-accent);
  color: var(--a-on-accent);
  font-family: var(--a-font);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color var(--a-fast) ease,
    transform var(--a-normal) var(--a-ease-spring);
}

.auth-submit:not(:disabled):hover {
  transform: translateY(-1px);
  background: var(--a-accent-hover);
}

.auth-submit:not(:disabled):active {
  transform: scale(0.98);
  transition-duration: 60ms;
}

.auth-submit:focus-visible,
.auth-toggle:focus-visible,
.auth-links a:focus-visible {
  outline: 2px solid var(--a-text);
  outline-offset: 2px;
}

.auth-submit:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* Loading state: label fades out, spinner fades in */
.auth-submit-label {
  transition:
    opacity var(--a-fast) ease,
    transform var(--a-normal) var(--a-ease-out);
}

.auth-spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  opacity: 0;
  transform: scale(0.6);
  transition:
    opacity var(--a-fast) ease,
    transform var(--a-normal) var(--a-ease-spring);
  animation: a-spin 0.7s linear infinite;
}

.auth-submit.is-loading .auth-submit-label {
  opacity: 0;
  transform: scale(0.9);
}

.auth-submit.is-loading .auth-spinner {
  opacity: 1;
  transform: scale(1);
}

@keyframes a-spin {
  to {
    rotate: 360deg;
  }
}

/* ---------- Links under the card ---------- */

.auth-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
  color: var(--a-muted);
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: center;
}

.auth-links p {
  margin: 0;
}

/* Links read as text; the accent is in the underline only */
.auth-links a {
  border-radius: 4px;
  color: var(--a-text);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--a-accent) 75%, transparent);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition:
    color var(--a-fast) ease,
    text-decoration-color var(--a-fast) ease;
}

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

/* ---------- Signup: pitch beside the form ---------- */

.auth-tag {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--a-border);
}

.auth-tag .auth-avatar {
  width: 52px;
  height: 52px;
  font-size: 1.35rem;
}

.auth-tag .auth-avatar svg {
  width: 22px;
  height: 22px;
}

.auth-tag-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.auth-tag-handle {
  overflow: hidden;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-tag-handle.is-empty {
  color: var(--a-muted);
}

.auth-tag-note {
  color: var(--a-muted);
  font-size: 0.875rem;
}

.auth-benefits {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.auth-benefits li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.auth-benefits i {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius-sm);
  background: var(--a-surface);
  font-size: 1rem;
}

.auth-benefits strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

.auth-benefits span {
  display: block;
  margin-top: 2px;
  color: var(--a-muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 900px) {
  .auth--split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    grid-template-rows: auto 1fr;
    gap: 32px 64px;
    align-items: start;
    width: min(940px, calc(100% - 64px));
    padding-top: 72px;
  }

  .auth--split .auth-header {
    grid-area: 1 / 1;
    align-items: flex-start;
    margin: 12px 0 0;
    text-align: left;
  }

  .auth--split .auth-title {
    font-size: 3.25rem;
    line-height: 0.95;
  }

  .auth--split .auth-benefits {
    grid-area: 2 / 1;
  }

  .auth--split .auth-panel {
    grid-area: 1 / 2 / span 2;
  }
}

/* ---------- Handles: lookup and explainer ---------- */

.auth--wide {
  width: min(760px, calc(100% - 32px));
}

.auth--wide .auth-header {
  align-items: flex-start;
  text-align: left;
}

.auth--wide .auth-title {
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 0.95;
}

.auth--wide .auth-links {
  text-align: left;
}

.auth-inline {
  display: flex;
  gap: 10px;
}

.auth-inline .auth-input {
  flex: 1;
  min-width: 0;
}

.auth-inline .auth-submit {
  width: auto;
  height: 44px;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.auth-grid .auth-card {
  gap: 10px;
}

.auth-card--wide {
  grid-column: 1 / -1;
}

.auth-prose p {
  margin: 0;
  color: var(--a-muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.auth-prose p[hidden] {
  display: none;
}

.auth-prose strong {
  color: var(--a-text);
  font-weight: 700;
}

.auth-prose ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 1.2em;
  color: var(--a-muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.auth-prose ul li::marker {
  color: var(--a-accent);
}

.auth-prose a {
  color: var(--a-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-prose a:hover {
  color: var(--a-accent-hover);
}

/* What each kind of old username turned into */
.auth-cases {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  margin: 4px 0 0;
  font-size: 0.98rem;
  line-height: 1.45;
}

.auth-cases dt,
.auth-cases dd {
  margin: 0;
  padding: 12px 0;
  border-top: 1px solid var(--a-border);
}

.auth-cases dt {
  padding-right: 20px;
  font-weight: 700;
}

.auth-cases dd {
  color: var(--a-muted);
}

.auth-cases dt:last-of-type,
.auth-cases dd:last-of-type {
  padding-bottom: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 620px) {
  .auth {
    padding-top: 28px;
  }

  .auth-card {
    padding: 18px;
  }

  .auth-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-cases {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-cases dt {
    padding: 12px 0 0;
  }

  .auth-cases dd {
    padding: 4px 0 12px;
    border-top: none;
  }

  .auth-cases dd:last-of-type {
    padding-bottom: 0;
  }

  .auth-inline {
    flex-direction: column;
  }

  .auth-inline .auth-input {
    flex: none;
  }

  .auth-inline .auth-submit {
    width: 100%;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .auth *,
  .auth > * {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }

  .auth-spinner,
  .auth-captcha[data-state="working"] .auth-captcha-box {
    animation: a-spin 1.4s linear infinite !important;
  }

  .auth-submit:not(:disabled):hover,
  .auth-submit:not(:disabled):active {
    transform: none;
  }
}
