/* auth.css - login, join, reset, step-up and the passkey fragment (design Y, after its
   login page). Every value comes from tokens.css. One detail carries the page: hairlines that
   extend the frame of the card to the edge of the screen, with a tick on each corner. Nothing
   moves on load; what moves is an answer (the fingerprint while the browser waits for the
   passkey, the check mark of a free username). */

/* --- Page: one card on black, no topbar ------------------------------------------------- */

.shell.bare:has(.login-wrap) .topbar { display: none; }
.content:has(> .login-wrap) { max-width: none; padding: 0; }

.login-wrap {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center;
  min-height: 100dvh; padding: 24px 16px 72px; overflow: hidden;
}
/* Brand above, frame below: in the flow, so a long form (join at 390 px) scrolls with it. */
.login-stack { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 28px; width: 100%; }
.login-frame { position: relative; width: 100%; max-width: 448px; padding: 24px; }
.login-frame::before, .login-frame::after { content: ""; position: absolute; pointer-events: none; }
.login-frame::before { left: -100vw; right: -100vw; top: 0; bottom: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.login-frame::after { top: -200vh; bottom: -200vh; left: 0; right: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.tick { position: absolute; z-index: 1; width: 11px; height: 11px; }
.tick::before, .tick::after { content: ""; position: absolute; background: var(--fg-3); }
.tick::before { left: 5px; top: 0; width: 1px; height: 11px; }
.tick::after { top: 5px; left: 0; height: 1px; width: 11px; }
.tick.tl { left: -5px; top: -5px; }
.tick.tr { right: -6px; top: -5px; }
.tick.bl { left: -5px; bottom: -6px; }
.tick.br { right: -6px; bottom: -6px; }

.login-card {
  position: relative; z-index: 2; display: flex; flex-direction: column; gap: 16px; padding: 32px;
  background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-card);
}
.login-brand {
  position: relative; z-index: 2; display: flex; align-items: center; justify-content: center; gap: 12px;
  font-size: var(--t-lg); font-weight: 500; letter-spacing: -.01em; line-height: 1;
}
.login-brand .brand-mark { height: 28px; }
.login-card h1 { font-size: var(--t-h1); font-weight: 500; letter-spacing: -.02em; line-height: 1.25; }
.login-card h1 + p { margin-top: -12px; margin-bottom: 8px; color: var(--fg-2); }
.login-card .input { height: 40px; background: var(--bg); }
.login-card .btn { height: 40px; }
.login-card .btn .kbd { margin-left: 4px; background: var(--on-accent-tint); border-color: transparent; color: var(--on-accent); }

/* Password with its eye: the field keeps room for the button on the right. */
.pw { position: relative; }
.pw > .input { width: 100%; padding-right: 40px; }
.login-card .pw > .btn, .pw > .btn { position: absolute; top: 6px; right: 6px; height: 28px; }
.pw .pw-off, .pw [aria-pressed="true"] .pw-on { display: none; }
.pw [aria-pressed="true"] .pw-off { display: block; }

.auth-alt, .auth-panel, .join-part { display: flex; flex-direction: column; gap: 16px; }
.or { display: flex; align-items: center; gap: 12px; font-size: var(--t-xs); color: var(--fg-3); }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-note { margin-top: 4px; font-size: var(--t-xs); color: var(--fg-3); text-align: center; }
.login-note a { color: var(--fg-2); }
.login-foot {
  position: absolute; left: var(--pad); right: var(--pad); bottom: 24px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  font-size: var(--t-xs); color: var(--fg-3);
}
.login-foot > span { display: inline-flex; align-items: center; gap: 8px; }
.login-foot > :last-child { margin-left: auto; }
.auth-panel .dlg-head:not(:has(.dlg-close)) { padding-right: 0; }

/* --- Passkey mark: the fingerprint draws stroke by stroke, then a quiet spinner ---------- */

.pk-ic { position: relative; display: inline-flex; width: 16px; height: 16px; flex: none; }
.pk-ic > .ic { position: absolute; inset: 0; }
.pk-spin { opacity: 0; }
[data-waiting] .pk-print { animation: pk-out var(--d1) var(--ease) calc(var(--d1) * 6) both; }
[data-waiting] .pk-print > path {
  stroke-dasharray: 40; stroke-dashoffset: 40;
  animation: pk-draw var(--d1) var(--ease) both;
}
[data-waiting] .pk-print > path:nth-child(2) { animation-delay: var(--d1); }
[data-waiting] .pk-print > path:nth-child(3) { animation-delay: calc(var(--d1) * 2); }
[data-waiting] .pk-print > path:nth-child(4) { animation-delay: calc(var(--d1) * 3); }
[data-waiting] .pk-print > path:nth-child(5) { animation-delay: calc(var(--d1) * 4); }
[data-waiting] .pk-spin {
  animation: pk-in var(--d1) var(--ease) calc(var(--d1) * 7) both,
    pk-turn calc(var(--d1) * 8) linear calc(var(--d1) * 7) infinite;
}
@keyframes pk-draw { to { stroke-dashoffset: 0; } }
@keyframes pk-out { to { opacity: 0; } }
@keyframes pk-in { to { opacity: 1; } }
@keyframes pk-turn { to { transform: rotate(360deg); } }

/* --- Join and reset: the invite as a line, the name check inside the field, 12 ticks ------ */

.join-invite { display: flex; flex-direction: column; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.join-line { font-size: var(--t-sm); color: var(--fg-2); overflow-wrap: anywhere; }

.join-name { position: relative; }
.join-name > .input { width: 100%; padding-right: 96px; }
.join-name-status {
  position: absolute; top: 0; bottom: 0; right: 12px;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--t-xs); color: var(--fg-3);
  pointer-events: none; opacity: 0;
  transition: opacity var(--d1) var(--ease), color var(--d1) var(--ease);
}
.join-name-status[data-state] { opacity: 1; }
.join-name-status[data-state="free"] { color: var(--ok); }
.join-name-status[data-state="taken"] { color: var(--err-fg); }
.name-check { display: none; }
[data-state="free"] > .name-check { display: block; }
[data-state="free"] > .name-check > path {
  stroke-dasharray: 24; stroke-dashoffset: 24;
  animation: pk-draw var(--d2) var(--ease) forwards;
}

.strength { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.strength-ticks { display: flex; gap: 4px; flex: none; }
.strength-tick {
  width: 3px; height: 12px; border-radius: 1px; background: var(--s4);
  transition: background-color var(--d1) var(--ease);
}
.strength-tick.on { background: var(--fg-2); }
.strength[data-level="ok"] .strength-tick.on { background: var(--accent); }
.strength-text { font-size: var(--t-xs); color: var(--fg-3); text-align: right; }

/* --- WQHD and small screens --------------------------------------------------------------- */

@media (min-width: 2200px) {
  .login-stack { gap: 32px; }
  .login-brand .brand-mark { height: 32px; }
  .login-frame { max-width: 512px; padding: 32px; }
  .login-card { padding: 40px; gap: 20px; }
  .login-card .input, .login-card .btn { height: 44px; }
  .login-card .pw > .btn { top: 8px; right: 8px; height: 28px; }
}
@media (max-width: 760px) {
  .login-wrap { padding-bottom: 88px; }
  .login-stack { gap: 20px; }
  .login-frame { padding: 16px 0; }
  .login-frame::after, .tick { display: none; }
  .login-card { padding: 24px 20px; }
  .login-foot { flex-direction: column; gap: 6px; bottom: 16px; }
  .login-foot > :last-child { margin-left: 0; }
}

/* --- Reduced motion: everything stands in its end state ---------------------------------- */

:root[data-motion="reduced"] [data-waiting] .pk-print,
:root[data-motion="reduced"] [data-waiting] .pk-print > path,
:root[data-motion="reduced"] [data-waiting] .pk-spin,
:root[data-motion="reduced"] [data-state="free"] > .name-check > path {
  animation: none; stroke-dashoffset: 0;
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) [data-waiting] .pk-print,
  :root:not([data-motion="full"]) [data-waiting] .pk-print > path,
  :root:not([data-motion="full"]) [data-waiting] .pk-spin,
  :root:not([data-motion="full"]) [data-state="free"] > .name-check > path {
    animation: none; stroke-dashoffset: 0;
  }
}
