/* The sign-in pages (worker/infra/auth/better-auth-pages.ts), in the app's design: warm paper,
   blue-black ink, one ballpoint-blue accent, red only for errors. Newsreader for words, IBM Plex Mono for labels and
   buttons, Source Serif 4 for italic running text. Ruled lines, no cards. Tokens match src/styles.css. */

:root {
  --paper: #f6f1e7;
  --paper-2: #eee7d8;
  --card: #fbf8f1;
  --ink: #16171d;
  --ink-2: #44454d;
  --muted: #6c685f;
  --rule: rgba(22, 23, 29, 0.12);
  --rule-strong: rgba(22, 23, 29, 0.32);
  --accent: #2443c9;
  --accent-ink: #ffffff;
  --accent-soft: rgba(36, 67, 201, 0.09);
  --red: #c93a25;

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --italic: "Source Serif 4", var(--serif);
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121318;
    --paper-2: #1a1b21;
    --card: #1b1c22;
    --ink: #ece7dc;
    --ink-2: #bdb8ad;
    --muted: #8a877f;
    --rule: rgba(236, 231, 220, 0.11);
    --rule-strong: rgba(236, 231, 220, 0.3);
    --accent: #8fa3ff;
    --accent-ink: #0f1226;
    --accent-soft: rgba(143, 163, 255, 0.12);
    --red: #ff7b66;
    color-scheme: dark;
  }
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.45;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

button:disabled {
  cursor: default;
}

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

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

h1 {
  margin: 0;
  font-weight: 400;
}

/* ---------- Page ---------- */
.auth {
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 20px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.auth-top {
  padding: 18px 0 6px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  font-size: 25px;
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
}

/* The deployment's mark (BRAND) draws in currentColor and var(--accent). */
.logo {
  color: var(--ink);
}

/* Hung near the top, like the app's dialogs, so the steps grow downward instead of jumping. */
.auth-main {
  margin-top: clamp(28px, 8vh, 80px);
  display: flex;
  flex-direction: column;
}

.auth-title {
  font-size: 46px;
  line-height: 1.02;
  letter-spacing: -0.025em;
}

.auth-lede {
  margin: 12px 0 0;
  font-family: var(--italic);
  font-style: italic;
  color: var(--ink-2);
}

.auth-lede b {
  font-family: var(--serif);
  font-style: normal;
  font-weight: 500;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.form-error {
  margin: 14px 0 0;
  color: var(--red);
  font-family: var(--mono);
  font-size: 13px;
}

.form-error.form-note {
  color: var(--muted);
}

/* Each step starts under a ruled line. */
.auth-step {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-main > .btn {
  margin-top: 28px;
}

.auth-or {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.auth-or::before,
.auth-or::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--rule);
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
}

.auth-turnstile {
  margin-top: 18px;
}

.auth-foot {
  margin-top: auto;
  padding-top: 48px;
  display: flex;
  gap: 20px;
}

.auth-foot a {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}

.auth-foot a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ---------- Fields and buttons (as in the app) ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.input {
  width: 100%;
  border: 1px solid var(--rule-strong);
  background: var(--card);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 17px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input::placeholder {
  color: var(--muted);
  font-family: var(--italic);
  font-style: italic;
  opacity: 1;
}

.input-code {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  letter-spacing: 0.35em;
  text-align: center;
  padding: 10px 14px 10px calc(14px + 0.35em);
}

.input-code::placeholder {
  font-family: var(--mono);
  font-style: normal;
  color: var(--rule-strong);
}

.btn {
  height: 52px;
  padding: 0 20px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.12s, background 0.15s, color 0.15s;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Not ready yet: an outline rather than a greyed-out slab. A button busy with a spinner stays solid. */
.btn-primary:disabled:not(:has(.spinner)) {
  background: transparent;
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--rule-strong);
}

.btn-outline {
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--rule-strong);
}

.btn-outline:hover:not(:disabled) {
  background: var(--paper-2);
}

.btn-outline:disabled {
  color: var(--muted);
}

.btn .g {
  flex: none;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 6px 2px;
}

.link-btn:hover:not(:disabled) {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.link-btn:disabled {
  color: var(--muted);
}

.link-btn-muted {
  color: var(--muted);
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 22%, transparent);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  /* Waiting still has to look like waiting: the spinner keeps turning. */
  .spinner {
    animation-duration: 1s !important;
    animation-iteration-count: infinite !important;
  }
}
