/* P11 · passkey-first auth screens (Figma 67:19197). Tokens only; loads after tokens.css and player.css. */

/* Fixed so it escapes the legacy .app grid that wraps #app in player.css. */
.auth-page {
  --radius-card: 20px; /* player.css sets the panel to 16; the auth card is 20 in Figma */
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  overflow-x: hidden;
  overflow-y: auto;
}

/* Auth / Background (Figma 71:19249): glow + 1px grid at 5% + vignette + edge pixels. Mobile frame below 768px. */
.auth-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
/* Vignette: transparent to 45% of the half-frame, then bg darkened to 60% (Figma rgba(5,5,6,.6)). */
.auth-bg__vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: radial-gradient(ellipse 50% 50% at 50% 50%, transparent 45%, color-mix(in srgb, color-mix(in srgb, var(--color-bg) 36%, var(--color-shadow)) 60%, transparent) 100%);
}
/* Glow: r 260 circle, blur 91, 40% accent; desktop swaps to r 450 / blur 157.5 below. */
.auth-bg__glow {
  position: absolute;
  left: -200px;
  top: -140px;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: var(--color-accent);
  opacity: 0.4;
  filter: blur(91px);
}
/* 1px lines, first at 28px (mobile) / 40px (desktop), 5% of the text color. */
.auth-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0.05;
  background-image:
    linear-gradient(to right, transparent calc(100% - 1px), var(--color-text) 0),
    linear-gradient(to bottom, transparent calc(100% - 1px), var(--color-text) 0);
  background-size: 28px 28px;
  background-position: 1px 1px;
}

.auth-logo {
  position: absolute;
  z-index: 1;
  top: 20px;
  left: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.auth-logo img { display: block; }
.auth-logo__btn { display: flex; align-items: center; gap: var(--space-3); padding: 0; background: none; border: 0; color: inherit; cursor: pointer; }
.auth-logo__btn:focus-visible { outline: 3px solid var(--color-accent-2); outline-offset: 4px; }
.auth-btn.is-busy { display: inline-flex; align-items: center; justify-content: center; gap: 10px; cursor: wait; opacity: 1; }
.auth-btn[aria-disabled="true"] { opacity: 0.85; cursor: not-allowed; }

/* Card is vertically centred like the Figma frames; 56px keeps it clear of the logo. */
.auth-main {
  position: relative;
  box-sizing: border-box;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Mobile frames center the card on y=438 of 844 (16px below the viewport middle, clear of the logo). */
  padding: 72px var(--space-4) 48px;
}

.auth-glyph {
  display: block;
  width: 32px;
  height: 32px;
  flex: none;
  background: var(--glyph-color, var(--color-accent));
  -webkit-mask: var(--glyph) center / contain no-repeat;
  mask: var(--glyph) center / contain no-repeat;
}
.auth-glyph--28 { width: 28px; height: 28px; }
.auth-glyph--wordmark { width: 86.25px; height: 23px; --glyph-color: var(--color-text); }

.auth-card {
  --auth-shadow: var(--color-accent);
  box-sizing: border-box;
  width: 100%;
  max-width: 358px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  /* Figma lays 318 / 496 px of content in the 358 / 560 card (content box is 6px wider than a symmetric padding would give). */
  padding: 20px 14px 20px 20px;
  background: var(--color-surface);
  border: 3px solid var(--color-outline);
  border-radius: var(--radius-card);
  box-shadow: 6px 6px 0 var(--auth-shadow);
}
.auth-card--error { --auth-shadow: var(--color-danger); }
.auth-card--violet { --auth-shadow: var(--color-accent-2); }

.auth-card__hd { display: flex; align-items: center; gap: 14px; }
.auth-card__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: none;
  background: var(--color-bg);
  border: 3px solid var(--color-accent);
  border-radius: var(--radius-button);
  box-shadow: 4px 4px 0 var(--color-shadow);
}
.auth-card--error .auth-card__icon { border-color: var(--color-danger); }

.auth-chip {
  padding: 6px 12px;
  background: var(--color-surface-2);
  border: 2px solid var(--color-outline);
  border-radius: 999px;
  font: 400 10px/1.4 var(--font-mono);
  letter-spacing: 0;
  white-space: nowrap;
  color: var(--color-text);
}
.auth-chip--error { background: var(--color-danger); color: var(--color-on-accent); }

.auth-card__title {
  margin: 0;
  font: 400 20px/30px "Press Start 2P", ui-monospace, monospace;
  overflow-wrap: anywhere;
  color: var(--color-text);
}
.auth-card--error .auth-card__title { color: var(--color-danger); }
/* The title takes programmatic focus on each step (screen readers announce it); it is not a control, so no ring. */
.auth-card__title:focus { outline: none; }

.auth-card__sub { margin: 0; font: 400 16px/1.5 var(--font-sans); color: var(--color-muted); }

.auth-micro { font: 400 10px/1.4 var(--font-mono); letter-spacing: 0; color: var(--color-muted-2); }
.auth-micro--label { font-size: 12px; letter-spacing: 0; }
.auth-micro--text { color: var(--color-text); }

.auth-list {
  list-style: none;
  margin: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--color-surface-2);
  border: 2px solid var(--color-outline);
  border-radius: var(--radius-button);
  font: 400 14px/1.5 var(--font-sans);
  color: var(--color-text);
}
.auth-list li { display: flex; gap: 10px; }
.auth-list li::before { content: "■"; flex: none; font: 400 10px/1.4 var(--font-mono); color: var(--color-accent); }

.auth-field { display: flex; flex-direction: column; gap: 8px; }
.auth-input {
  box-sizing: border-box;
  width: 100%;
  padding: 16px;
  background: var(--color-bg);
  color: var(--color-text);
  border: 3px solid var(--color-accent);
  border-radius: var(--radius-button);
  font: 400 16px/1.5 var(--font-sans);
}
.auth-input:focus-visible { outline: 3px solid var(--color-accent-2); outline-offset: 2px; }
.auth-input[aria-invalid="true"] { border-color: var(--color-danger); }
.auth-field__error { font: 400 14px/1.5 var(--font-sans); color: var(--color-text); }
.auth-field__error::before { content: "× "; color: var(--color-danger); font-family: var(--font-mono); }
.auth-field__status { font: 400 14px/1.5 var(--font-sans); color: var(--color-text); }
.auth-field__status:empty { display: none; }

/* B1 name choice: Discord name or a custom one (radio cards in the input style of Figma 67:19371). */
.auth-choices { display: flex; flex-direction: column; gap: 12px; }
.auth-choice {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: var(--color-bg);
  color: var(--color-text);
  border: 3px solid var(--color-line);
  border-radius: var(--radius-button);
  font: 400 16px/1.5 var(--font-sans);
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
  cursor: pointer;
}
.auth-choice.is-on { border-color: var(--color-accent); }
.auth-choice:focus-visible { outline: 3px solid var(--color-accent-2); outline-offset: 2px; }
.auth-choice:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-choice__dot { flex: none; width: 14px; height: 14px; border: 2px solid var(--color-muted); border-radius: 3px; }
.auth-choice.is-on .auth-choice__dot { background: var(--color-accent); border-color: var(--color-accent); }
.auth-choice__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.auth-handle { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.auth-handle__value { font: 400 16px/1.5 var(--font-mono); color: var(--color-accent); overflow-wrap: anywhere; }

.auth-wallet, .auth-rank, .auth-server { display: flex; align-items: center; gap: 12px; }
.auth-wallet {
  padding: 14px;
  background: var(--color-surface-2);
  border: 2px solid var(--color-outline);
  border-radius: var(--radius-button);
}
.auth-wallet__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.auth-wallet__addr { font: 400 12px/1.4 var(--font-mono); letter-spacing: 0.06em; color: var(--color-text); overflow-wrap: anywhere; }

.auth-servers {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--color-surface-2);
  border: 2px solid var(--color-outline);
  border-radius: var(--radius-button);
}
.auth-server__av { width: 32px; height: 32px; flex: none; background: var(--color-accent-2); border: 2px solid var(--color-outline); border-radius: 8px; }
.auth-server__text { display: flex; flex-direction: column; gap: 2px; font: 400 14px/1.5 var(--font-sans); min-width: 0; }
.auth-servers .auth-rank { padding-top: 8px; }
.auth-rank img { width: 29px; height: 32px; image-rendering: pixelated; }

.auth-actions { display: flex; flex-direction: column; gap: 12px; }

.auth-btn {
  box-sizing: border-box;
  width: 100%;
  min-height: 56px;
  padding: 20px 4px;
  border: 3px solid var(--color-outline);
  border-radius: var(--radius-button);
  font: 500 14px/16px var(--font-mono);
  letter-spacing: 0;
  text-align: center;
  box-shadow: none;
  cursor: pointer;
}
.auth-btn--sm { font-size: 12px; letter-spacing: 0; }
.auth-btn--primary { background: var(--color-accent); color: var(--color-on-accent); box-shadow: 4px 4px 0 var(--color-shadow); }
.auth-btn--outline { background: transparent; color: var(--color-text); border-color: var(--color-muted); }
.auth-btn:focus-visible, .auth-link:focus-visible { outline: 3px solid var(--color-accent-2); outline-offset: 3px; }
.auth-btn:disabled, .auth-link:disabled { opacity: 0.6; cursor: progress; }
.auth-btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--color-shadow); }

.auth-link {
  min-height: 24px;
  padding: 4px;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--color-text);
  font: 500 14px/16px var(--font-mono);
  letter-spacing: 0;
  text-decoration: underline;
  cursor: pointer;
}

/* Touch screens keep the 44px target; the Figma 24px row is for pointer devices (WCAG 2.5.8 minimum). */
@media (pointer: coarse) {
  .auth-link { min-height: 44px; }
}

/* Recover: a quiet secondary link, sentence case, never a button. */
.auth-recover { margin: 4px 0 0; text-align: center; }
/* A · «¿Qué es una passkey?»: same quiet sentence-case link as Recover, under the bullets. */
.auth-what { margin: 0; }
.auth-what .link { font: 400 13px/1.5 var(--font-sans); letter-spacing: 0; text-transform: none; }
.auth-recover .auth-link {
  font: 400 13px/1.5 var(--font-sans);
  letter-spacing: 0;
  text-transform: none;
  color: var(--color-muted-2);
}

@media (max-width: 420px) {
  .auth-btn { letter-spacing: 0; }
  .auth-logo { top: 14px; }
}
@media (max-width: 380px) {
  .auth-card__title { font-size: 16px; line-height: 26px; }
  .auth-btn { font-size: 12px; letter-spacing: 0; }
}

/* Desktop frames (Figma 67:19198): 560 card, 32px padding, 32/44 title, logo at 48/32. */
@media (min-width: 768px) {
  .auth-main { padding: 56px var(--space-4); }
  .auth-flow { margin-top: -48px; }
  .auth-card { max-width: 560px; padding: 32px 26px 32px 32px; }
  .auth-card__title { font-size: var(--fs-h2); line-height: 44px; }
  .auth-logo { top: 32px; left: 48px; }
  .auth-bg__glow { left: -260px; top: -320px; width: 900px; height: 900px; filter: blur(157.5px); }
  .auth-bg::before { background-size: 40px 40px; }
  .auth-px--m { display: none; }
}
@media (max-width: 767px) {
  .auth-px--d { display: none; }
}

/* Edge pixels from Figma 72:16493, placed in % of the page so they scale with the frame. */
.auth-px { position: absolute; z-index: 3; background: var(--px, var(--color-surface-2)); }
.auth-px--line { --px: var(--color-line); }
.auth-px--muted { --px: var(--color-muted); }
.auth-px--accent { --px: var(--color-accent); }

/* Light theme: same layers bound to the light tokens; the glow is softer and the dark vignette is dropped so the cream page stays clean. */
[data-theme="light"] .auth-bg__glow { opacity: 0.18; }
[data-theme="light"] .auth-bg__vignette { display: none; }

/* Flow overview (Figma 78:27186): the last child of the page, in flow. Its summary sits in the card's bottom padding, so the card stays centered and nothing overlaps it. */
.auth-flow { position: relative; z-index: 2; box-sizing: border-box; width: 100%; max-width: 1100px; margin: -40px auto 0; padding: 0 var(--space-4) var(--space-3); }
.auth-flow > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  min-height: 32px;
  margin: 0 auto;
  padding: 4px 8px;
  cursor: pointer;
  list-style: none;
  color: var(--color-muted-2);
  font: 400 13px/1.5 var(--font-sans);
  text-decoration: underline;
}
.auth-flow > summary::-webkit-details-marker { display: none; }
.auth-flow > summary::after { content: "▾" / ""; display: inline-block; text-decoration: none; font: 400 12px/1 var(--font-mono); }
.auth-flow[open] > summary::after { transform: rotate(180deg); }
.auth-flow > summary:focus-visible { outline: 3px solid var(--color-accent-2); outline-offset: 3px; }
.auth-flow__panel {
  box-sizing: border-box;
  width: 100%;
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background: var(--color-surface);
  border: 3px solid var(--color-outline);
  border-radius: var(--radius-card);
  box-shadow: 6px 6px 0 var(--color-accent);
  text-align: left;
}
.auth-flow__title { margin: 0; font: 400 16px/26px "Press Start 2P", ui-monospace, monospace; color: var(--color-text); }
.auth-flow__lead { margin: 0; font: 400 14px/1.5 var(--font-sans); color: var(--color-muted); }
.auth-flow__group { display: flex; flex-direction: column; gap: 8px; }
.auth-flow__group-title { margin: 0; font: 400 12px/1.4 var(--font-mono); letter-spacing: 0; color: var(--color-muted-2); }
.auth-flow__steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 12px 28px; }
.auth-flow__step {
  position: relative;
  box-sizing: border-box;
  flex: 1 1 200px;
  max-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--color-surface-2);
  border: 2px solid var(--color-outline);
  border-radius: var(--radius-button);
  box-shadow: 3px 3px 0 var(--color-shadow);
}
.auth-flow__step--ok { border-color: var(--color-accent); }
.auth-flow__step--err { border-color: var(--color-danger); }
.auth-flow__step:not(:last-child)::after { content: "→" / ""; position: absolute; right: -22px; top: 50%; transform: translateY(-50%); font: 400 14px/1 var(--font-mono); color: var(--color-muted); }
.auth-flow__name { font: 400 10px/1.4 var(--font-mono); letter-spacing: 0; color: var(--color-text); }
.auth-flow__text { font: 400 14px/1.5 var(--font-sans); color: var(--color-muted); }
@media (max-width: 767px) {
  .auth-flow__steps { flex-direction: column; flex-wrap: nowrap; gap: 20px; }
  .auth-flow__step { flex: none; max-width: none; }
  .auth-flow__step:not(:last-child)::after { content: "↓" / ""; right: auto; left: 50%; top: auto; bottom: -19px; transform: translateX(-50%); }
}

/* Loading states (passkey prompt, server verify, Discord round trip): waiting cat + status line (role=status). */
.auth-loading { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); text-align: center; }
.auth-loading__cat { display: block; overflow: hidden; padding: 0 20px; }
.auth-loading.is-busy .pose-img { animation: auth-cat-pace 1.05s ease-in-out infinite alternate; }
.auth-status { margin: 0; font: 400 14px/1.5 var(--font-sans); color: var(--color-text); }
.auth-loading.is-busy .auth-status::after { content: ""; }
@keyframes auth-cat-pace {
  from { transform: translateX(-14px); }
  to { transform: translateX(14px); }
}
/* Reduced motion: the cat stands still and the ring spinner (player.css) is already static; the text carries the state. */
@media (prefers-reduced-motion: reduce) {
  .auth-loading.is-busy .pose-img { animation: none; }
}
