/* The login page. It uses the auth-* class names auth.js expects, but is
   styled here on its own: auth.css still styles signup and the handle pages. */

.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)
  );
  /* The hairline above the panel's closing strip */
  --a-line: color-mix(in srgb, var(--site-text, #ffffff) 12%, transparent);
  --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);
  /* Secondary text; mixed toward the text colour so it holds up on the page
     background as well as on the panel */
  --a-muted: color-mix(
    in srgb,
    var(--site-muted, #b5cae0) 55%,
    var(--site-text, #ffffff)
  );
  --a-accent: var(--site-accent, #f5b942);
  --a-accent-hover: var(--site-accent-hover, #f8cd6b);
  --a-on-accent: var(--site-accent-text, #484c51);
  --a-danger: #ff9a9d;
  --a-success: #6ee7a0;
  --a-radius: 12px;
  --a-radius-sm: 8px;
  --a-pad: 24px;
  --a-fast: 120ms;
  --a-font: "Geist", "Roboto", system-ui, -apple-system, sans-serif;

  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: min(384px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(32px, 9vh, 96px) 0 72px;
  font-family: var(--a-font);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--a-text);
  text-align: left;
  -webkit-font-smoothing: antialiased;
}

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

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

/* style.css scales every button on hover; nothing here moves. */
.auth button:hover,
.auth button:active {
  transform: none;
}

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

.auth-title {
  margin: 0;
  font-size: 1.625rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  margin: 6px 0 0;
  color: var(--a-muted);
  font-size: 0.9375rem;
  line-height: 1.5;
  text-wrap: pretty;
}

/* ---------- Panel and fields ---------- */

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: var(--a-pad);
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
  background: var(--a-surface);
}

/* The strip closing the panel: where to go instead */
.auth-card-foot {
  margin: 4px calc(var(--a-pad) * -1) calc(var(--a-pad) * -1);
  padding: 14px var(--a-pad);
  border-top: 1px solid var(--a-line);
  border-radius: 0 0 calc(var(--a-radius) - 1px) calc(var(--a-radius) - 1px);
  background: var(--a-inset);
  color: var(--a-muted);
  font-size: 0.875rem;
}

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

.auth-label {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
}

.auth-control {
  position: relative;
}

.auth-input {
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--a-control-border);
  border-radius: var(--a-radius-sm);
  background: var(--a-inset);
  color: var(--site-input-text, #ffffff);
  font-family: var(--a-font);
  font-size: 0.9375rem;
  outline: none;
  transition:
    border-color var(--a-fast) ease,
    box-shadow var(--a-fast) 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) 28%, 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: 42px;
}

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

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

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

.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.8125rem;
  line-height: 1.45;
}

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

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

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

.auth-message {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--a-tone) 50%, transparent);
  border-radius: var(--a-radius-sm);
  background: color-mix(in srgb, var(--a-tone) 10%, transparent);
  font-size: 0.875rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.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: 40px;
  padding: 0 16px;
  border: none;
  border-radius: var(--a-radius-sm);
  background: var(--a-accent);
  color: var(--a-on-accent);
  font-family: var(--a-font);
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--a-fast) ease;
}

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

.auth-submit:not(:disabled):active {
  background: color-mix(in srgb, var(--a-accent) 86%, #000000);
}

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

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

/* Loading state: the label gives way to a spinner, the width stays */
.auth-submit-label {
  transition: opacity var(--a-fast) ease;
}

.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;
  transition: opacity var(--a-fast) ease;
  animation: a-spin 0.7s linear infinite;
}

.auth-submit.is-loading .auth-submit-label {
  opacity: 0;
}

.auth-submit.is-loading .auth-spinner {
  opacity: 1;
}

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

/* ---------- Links ---------- */

.auth-links {
  color: var(--a-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.auth-links p,
.auth-card-foot p {
  margin: 0;
}

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

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

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

@media (max-width: 620px) {
  .auth {
    --a-pad: 20px;
    padding-top: 28px;
    padding-bottom: 48px;
  }

  /* 16px keeps iOS from zooming the page when a field takes focus */
  .auth-input {
    font-size: 1rem;
  }
}

@media (max-width: 360px) {
  .auth {
    --a-pad: 16px;
    width: calc(100% - 24px);
  }
}

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

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

  .auth-spinner {
    animation-duration: 1.4s;
  }
}
