/** Monochrome onboarding and sign-in layout for the tracer, in a dark and a light scheme.
 *
 * The sign-in pages stay black and white on purpose (the app's own themes are coloured). The scheme
 * is dark unless auth-scheme.ts sets data-auth-scheme="light" on the root: the system is light, or the
 * saved theme is a light one. Every colour below is a token; nothing else in this file may use a
 * literal black or white, so the light scheme cannot miss a spot. */
.auth-screen:not(.flow-layer) {
  --fg: #f4f4f5;
  --fg-2: #a1a1aa;
  --fg-3: #63636b;
  --on-fg: #000;
  --line: rgb(255 255 255 / 0.09);
  --edge: rgb(255 255 255 / 0.28);
  --strong: rgb(255 255 255 / 0.4);
  --ring: rgb(255 255 255 / 0.55);
  /* One material: the card and the fields are the same tint, the fields a touch denser. */
  --tint-a: 0.05;
  --halo: rgb(0 0 0 / 0.9);
  --card: rgb(0 0 0 / var(--tint-a));
  --field: rgb(0 0 0 / calc(var(--tint-a) + 0.14));
  --field-focus: rgb(0 0 0 / calc(var(--tint-a) + 0.26));
  --hover: rgb(255 255 255 / 0.06);
  --wash: rgb(255 255 255 / 0.03);
  --shade: rgb(0 0 0 / 0.9);
  --ui-on-fg: var(--on-fg);
}
:root[data-auth-scheme="light"] .auth-screen:not(.flow-layer) {
  --fg: #18181b;
  --fg-2: #52525b;
  --fg-3: #6b6b74;
  --on-fg: #fff;
  --line: rgb(0 0 0 / 0.1);
  --edge: rgb(0 0 0 / 0.32);
  --strong: rgb(0 0 0 / 0.4);
  --ring: rgb(0 0 0 / 0.55);
  --tint-a: 0.1;
  --halo: rgb(255 255 255 / 0.9);
  --card: rgb(255 255 255 / var(--tint-a));
  --field: rgb(255 255 255 / calc(var(--tint-a) + 0.14));
  --field-focus: rgb(255 255 255 / calc(var(--tint-a) + 0.26));
  --hover: rgb(0 0 0 / 0.05);
  --wash: rgb(0 0 0 / 0.03);
  --shade: rgb(0 0 0 / 0.28);
}
:root[data-auth-scheme="light"] { color-scheme: light; background: #f6f6f4; color: #18181b; }
/* The shared tick and counter assume a dark card: ink on the fill, a white hairline. */
.auth-screen:not(.flow-layer) .tick { color: var(--on-fg); box-shadow: inset 0 0 0 1.5px var(--edge); }
.auth-screen:not(.flow-layer) .busy-count { color: var(--on-fg); opacity: 0.6; }
.auth-screen {
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  position: fixed;
  z-index: 1;
  inset: 0;
  display: grid;
  place-items: safe center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  color: var(--fg);
  background: transparent;
  font: var(--fw-body) 14px/1.55 var(--font-face);
  letter-spacing: -0.01em;
}

#faulty-field {
  position: fixed;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  transition: opacity 240ms ease-out;
}

.auth-card {
  min-width: 0;
  width: min(440px, 100%);
  --auth-pad: 36px;
  padding: var(--auth-pad) 32px var(--auth-pad);
  border-radius: 22px;
  animation: auth-card-in 240ms var(--ease) both;
}
/* The card is the shared translucent overlay material (.ui-overlay-surface, packages/ui), tuned for
   this page through its instance properties: a black tint on dark (0.05), a white tint on light (0.10) and a
   4 px blur. The backdrop is low contrast, so a thin tint and a small blur are what make its drifting glyphs
   show through. No top-edge highlight. */
.auth-card.ui-overlay-surface {
  --ui-overlay-background: var(--card);
  --ui-overlay-border: var(--line);
  --ui-overlay-color: var(--fg);
  --ui-overlay-shadow: 0 30px 80px -30px var(--shade);
  --ui-overlay-blur: 4px;
  --ui-overlay-saturation: 100%;
}
/* Cards that are not glass stay solid. */
.auth-card:not(.ui-overlay-surface) { border: 1px solid var(--line); background: var(--card); box-shadow: 0 30px 80px -30px rgb(0 0 0 / 0.9); }
/* Where the tint is thin a glyph can sit directly behind a letter, so the text carries a soft halo in
   the card's own tint colour (--halo) instead of the card getting more tint. */
.auth-card.ui-overlay-surface { text-shadow: 0 0 6px var(--halo, transparent); }
.auth-card.ui-overlay-surface .auth-primary { text-shadow: none; }
@keyframes auth-card-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } }
.auth-mark { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; font-weight: var(--fw-title); line-height: 1; }
.auth-mark svg { width: 22px; height: 22px; flex: none; }
.auth-card h1 { margin: 0 0 10px; color: var(--fg); font: var(--fw-title) 21px/1.25 var(--font-face); letter-spacing: -0.03em; }
.auth-eyebrow { margin: 0 0 6px; color: var(--fg-3); font: var(--fw-label) 12px/1 var(--font-face); letter-spacing: 0.02em; }
.auth-lede { margin: 0 0 24px; color: var(--fg-2); }
.auth-label { display: block; margin: 0 0 8px; color: var(--fg-2); font-size: 13px; }
.auth-input {
  display: block;
  width: 100%;
  height: 48px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: var(--field);
  color: var(--fg);
  font: var(--fw-body) 16px/1 var(--font-face);
}
.auth-input:focus { border-color: var(--edge); background: var(--field-focus); }
.auth-mono { font-size: 16px; letter-spacing: 0.01em; }
.auth-command {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 4px 5px 4px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--wash);
  color: var(--fg-2);
  font-size: 12.5px;
}
.auth-command code { flex: 1; overflow-x: auto; white-space: nowrap; }
.auth-hint { min-height: 1em; margin: 6px 0 14px; color: var(--fg-3); font-size: 12px; }
.recovery-word-label { margin-top: 18px; }
.auth-word-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; list-style: none; margin: 0; padding: 0; }
.auth-word-inputs li { display: flex; align-items: center; min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--field); }
.auth-word-inputs li > span { flex: none; width: 22px; text-align: center; color: var(--fg-3); font-size: 10px; }
.auth-word-inputs input { min-width: 0; width: 100%; height: 44px; padding: 0 4px 0 0; border: 0; border-radius: 9px; outline: none; color: var(--fg); background: transparent; font: var(--fw-body) 16px/1 var(--font-face); }
.auth-word-inputs li:focus-within { border-color: var(--fg-2); background: var(--field-focus); }
.auth-word-inputs li:has([aria-invalid="true"]) { border-color: var(--fg); }
.auth-error-line { margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--hover); color: var(--fg); font-size: 13.5px; }
.auth-message { min-height: 1.4em; margin: 12px 0 0; color: var(--fg-2); font-size: 12px; line-height: 1.5; }

.auth-steps { display: flex; align-items: center; gap: 0; margin: 0 0 30px; padding: 0; list-style: none; }
.auth-steps li { display: flex; flex: 1; align-items: center; }
.auth-steps li:last-child { flex: none; }
.auth-dot {
  display: grid;
  width: 24px;
  height: 24px;
  flex: none;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--fg-3);
  font: var(--fw-label) 11.5px/1 var(--font-face);
  cursor: pointer;
}
.auth-dot:disabled { cursor: default; }
.auth-steps .is-current .auth-dot { border-color: var(--fg); background: var(--fg); color: var(--on-fg); }
.auth-steps .is-done .auth-dot { border-color: var(--edge); color: var(--fg); }
.auth-step-bar { position: relative; height: 1px; flex: 1; overflow: hidden; margin: 0 8px; background: var(--line); }
.auth-step-bar::after { position: absolute; inset: 0; transform: scaleX(0); transform-origin: left; background: var(--strong); content: ""; transition: transform 240ms var(--ease); }
.auth-steps .is-done .auth-step-bar::after { transform: scaleX(1); }
.auth-steps .tick { width: 24px; height: 24px; border-radius: 50%; box-shadow: none; }
.auth-steps .tick-fill { background: var(--fg); }

.auth-viewport { position: relative; overflow: hidden; margin: 0 -6px; padding: 0 6px; transition: height 240ms var(--ease); }
.auth-pane { min-width: 0; transition: opacity 240ms var(--ease), transform 240ms var(--ease); }
.auth-pane[data-direction="forward"] { animation: auth-pane-forward 240ms var(--ease) both; }
.auth-pane[data-direction="back"] { animation: auth-pane-back 240ms var(--ease) both; }
.auth-pane[data-direction="none"] { animation: none; }
.auth-card[data-no-motion] .auth-input,
.auth-card[data-no-motion] .auth-dot,
.auth-card[data-no-motion] .auth-step-bar::after,
.auth-card[data-no-motion] .auth-viewport,
.auth-card[data-no-motion] .auth-pane,
.auth-card[data-no-motion] .auth-primary { transition: none; }
.auth-card[data-no-motion] .auth-pane { animation: none; }
.auth-card[data-no-motion] .auth-primary:active { transform: none; }
@keyframes auth-pane-forward { from { opacity: 0; transform: translateX(24px); } }
@keyframes auth-pane-back { from { opacity: 0; transform: translateX(-24px); } }
.auth-footer { display: flex; min-height: 42px; justify-content: space-between; align-items: center; gap: 12px; margin-top: 26px; }
.auth-primary {
  display: inline-flex;
  min-width: 140px;
  height: 42px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 0 auto; /* Keep the primary button at the content edge when the hidden back control is removed. */
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--fg);
  color: var(--on-fg);
  font: var(--fw-title) 13.5px/1 var(--font-face);
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 140ms var(--ease), opacity 160ms ease;
}
.auth-primary:active { transform: scale(var(--ui-press-scale-soft)); }
.auth-primary[disabled] { transform: none; opacity: 0.35; cursor: default; }
.auth-primary svg { width: 18px; height: 18px; flex: none; }
.auth-footer .auth-primary { min-width: 140px; }
.auth-back, .auth-text-button {
  border: 0;
  background: none;
  color: var(--fg-2);
  font: var(--fw-label) 13.5px/1 var(--font-face);
  cursor: pointer;
}
.auth-back { padding: 10px 8px; margin-left: -8px; }
.auth-back[hidden] { display: inline; visibility: hidden; }
.auth-back:hover { color: var(--fg); }
/* The sign-in card hugs their content. Top and bottom padding are one value
   (--auth-pad), measured to the ink: when the last thing is a quiet text action, its own empty inset
   (--auth-tail, half the 44 px button's height minus its text) is taken off the bottom so the visible gap
   under the text equals the gap above the mark. */
#use-recovery, #recovery-card .auth-primary, #recovery-card .auth-back, #recovery-card .icon-action { min-width: 44px; min-height: 44px; }
.auth-signin { --auth-pad: 36px; --auth-tail: 15px; padding: var(--auth-pad) 32px var(--auth-pad); }
.auth-signin:has(.auth-text-button) { padding-bottom: calc(var(--auth-pad) - var(--auth-tail)); }
.auth-signin .auth-lede { margin-bottom: 28px; }
.auth-login { width: 100%; height: 48px; border-radius: 12px; font-size: 15px; }
.auth-loading { min-height: 1em; margin: 14px 0 0; text-align: center; }
/* A line that exists only while it has something to say (the passkey wait counter, an error): the
   row is 0fr while empty, so the card hugs its content, and eases open when text arrives. */
.auth-note { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 240ms var(--ease); }
.auth-note > div { min-height: 0; overflow: hidden; }
.auth-note:has(.auth-message:not(:empty), .busy-count:not([hidden])) { grid-template-rows: 1fr; }
@media (prefers-reduced-motion: reduce) { .auth-note { transition: none; } }
/* A failure of the primary action sits in the notice row directly above it, centred, never below the quiet action. */
.auth-signin .auth-message { margin: 0 0 12px; text-align: center; }
.auth-signin .auth-message:empty { min-height: 0; margin: 0; }
.auth-check { position: relative; display: flex; min-height: 44px; align-items: center; gap: 10px; margin-top: 18px; color: var(--fg-2); font-size: 14px; cursor: pointer; }
.auth-check input { width: 18px; height: 18px; accent-color: var(--fg); }
[data-focus-ring="on"] .auth-check input:focus-visible + .tick { outline: 2px solid var(--ring); outline-offset: 2px; }
.auth-check[data-pressed] { transform: scale(0.98); }
.auth-check .tick { width: 20px; height: 20px; }
.auth-words { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; margin: 4px 0 0; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgb(255 255 255 / 0.03); counter-reset: recovery; list-style: none; }
.auth-words li { display: flex; min-width: 0; align-items: baseline; gap: 5px; color: var(--fg); font: var(--fw-body) 13px/1.9 var(--font-face); }
.auth-word-number { width: 19px; flex: none; color: var(--fg-3); font-size: 10.5px; text-align: right; }
.auth-actions { display: flex; justify-content: flex-end; gap: 4px; margin: 10px -8px -4px 0; }
.icon-action { display: inline-grid; width: 40px; height: 40px; place-items: center; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--fg-2); cursor: pointer; }
.icon-action:hover { background: var(--hover); color: var(--fg); }
.auth-recovery-message { min-height: 1em; margin: 2px 0 0; color: var(--fg-3); font-size: 11px; }
.auth-welcome { text-align: center; }
.welcome-copy { max-width: 100%; text-align: center; }
.welcome-copy h1 { margin: 0 0 14px; font-size: clamp(20px, 6vw, 64px); font-weight: var(--fw-title); letter-spacing: -0.04em; line-height: 1.05; }
.welcome-copy p { margin: 0; color: var(--fg-2); animation: auth-welcome-caption 240ms 900ms var(--ease) both; }
.auth-welcome[data-no-motion] .welcome-copy p { animation: none; }
@keyframes auth-welcome-caption { from { opacity: 0; transform: translateX(10px); } }

.auth-screen button:focus { outline: none; }
[data-focus-ring="on"] .auth-screen button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
@media (max-width: 480px) {
  .auth-card { --auth-pad: 28px; padding: var(--auth-pad) 22px var(--auth-pad); border-radius: 20px; }
  .auth-signin { --auth-pad: 28px; padding-inline: 22px; padding-bottom: var(--auth-pad); }
  .auth-card h1 { font-size: 23px; }
  .auth-words { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .auth-card, .auth-pane, .auth-welcome p { animation: none; }
  .auth-pane { transition: opacity 200ms var(--ease); }
  .auth-viewport { transition: none; }
  .auth-primary:active { transform: none; transition: none; }
  .auth-check[data-pressed] { transform: none; }
}
