/* login.css — the control-panel origin's login page (login.html, login.js).

   A page of its own, not the SPA's TOTP gate card over a blurred panel: the
   visitor has no panel behind it yet. One card, centred, on the panel's own
   background; the agent's mark alone on top, its host on the line under it,
   both centred, so the owner sees at once whose panel this is; then exactly
   one step at a time -- the spinner while a link is being spent, the
   second-factor code, or the ways in (no heading over them: the buttons say
   what they are; Mart, 2026-10-20). Colours
   and type come from base.css's tokens, so light and dark follow the
   panel's own theme (theme_boot.js) and a template overlay (theme.css)
   restyles this page with the rest. */

html.login-root, body.login-body {
  overflow: auto;               /* base.css hides overflow for the shell */
}
body.login-body {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.login {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1rem;
  /* A soft glow of the accent behind the card, nothing a template overlay
     cannot repaint through --accent. */
  background:
    radial-gradient(60rem 30rem at 50% -10rem, var(--accent-softer), transparent 70%),
    var(--bg);
}

.login-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 18px;
  padding: 1.6rem 1.5rem 1.5rem;
  box-shadow: 0 20px 60px -24px rgba(0, 0, 0, .45);
}

/* ── Brand: the mark, and the agent's host under it, centred ─────────────── */

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .7rem;
  margin: .2rem 0 1.4rem;
  text-align: center;
}
.login-mark {
  width: 64px;
  height: 64px;
  flex: none;
}
.login-host {
  font-size: 1.02rem;
  font-weight: 600;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* ── Steps ───────────────────────────────────────────────────────────────── */

.login-step { display: flex; flex-direction: column; }
.login-step[hidden] { display: none; }

.login-title {
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -.01em;
  margin: 0 0 .45rem;
}
/* A title with no lead line under it keeps the lead's gap to what follows. */
.login-title-spaced { margin-bottom: 1rem; }
.login-lead {
  margin: 0 0 1rem;
  font-size: .92rem;
  line-height: 1.5;
  color: var(--muted);
}
.login-hint {
  margin: .8rem 0 0;
  font-size: .8rem;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}
.login-error {
  margin: 0 0 .9rem;
  padding: .6rem .75rem;
  border-radius: 10px;
  font-size: .86rem;
  line-height: 1.45;
  color: var(--danger-action);
  background: color-mix(in srgb, var(--err) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--err) 30%, transparent);
}
.login-error[hidden] { display: none; }

/* Signing in: the spinner and one line, centred, the height of the card
   the ways-in step would need so the swap from one to the other barely
   moves. */
.login-busy {
  align-items: center;
  justify-content: center;
  min-height: 9rem;
  text-align: center;
}
.login-busy .login-lead { margin: .9rem 0 0; }
.login-spinner {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: login-spin .8s linear infinite;
}
.login-spinner-small {
  width: 1.1rem;
  height: 1.1rem;
  border-width: 2px;
  flex: none;
}
@keyframes login-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .login-spinner { animation-duration: 2s; }
}

/* The second-factor code: large, spaced digits, the panel's monospace. */
.login-code {
  width: 100%;
  font-size: 1.6rem;
  letter-spacing: .25em;
  text-align: center;
  padding: .6rem .6rem;
  border-radius: 12px;
  border: 1px solid var(--border2);
  background: var(--surface-control);
  color: inherit;
  font-family: var(--mono);
}
.login-code:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-code + .login-error { margin: .7rem 0 0; }

/* ── Actions: one shape for every way in ─────────────────────────────────── */

.login-actions {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.login-actions[hidden] { display: none; }
.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  width: 100%;
  min-height: 2.75rem;
  padding: .6rem .9rem;
  border-radius: 12px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-text);
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.login-btn:hover {
  background: var(--btn-hover-bg);
  border-color: var(--btn-hover-border);
  color: var(--btn-hover-text);
  text-decoration: none;
}
.login-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.login-btn:active { transform: translateY(1px); }
.login-btn:disabled { opacity: .5; cursor: progress; transform: none; }
.login-btn[hidden] { display: none; }
.login-btn-icon { width: 1.15rem; height: 1.15rem; flex: none; }
/* Telegram's doors: the computer/phone icons, or on a phone this device/QR. */
.login-icon-touch, .login-doors-touch .login-icon-desk { display: none; }
.login-doors-touch .login-icon-touch { display: block; }

.login-actions [data-method][hidden] { display: none; }

/* The one solid action: the passkey when the browser has them, else the
   code's Verify or the retry. */
.login-btn-primary {
  background: var(--accent-solid, var(--accent));
  border-color: var(--accent-solid, var(--accent));
  color: var(--on-accent-solid);
}
.login-btn-primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: var(--on-accent-solid);
}
.login-step > .login-btn-primary { margin-top: .4rem; }

/* Telegram keeps its own blue. "Sign in with Telegram" swaps the list for
   its two doors (#loginTelegramDoors): the bot on this computer, or the
   same request as a QR code for the phone. While the bot holds the sign-in
   request the line under the door says so, with the request's link for a
   tab the browser refused to open. */
.login-btn-telegram {
  background: #229ed9;
  border-color: #229ed9;
  color: #fff;
}
.login-btn-telegram:hover { background: #2aabee; border-color: #2aabee; color: #fff; }
.login-wait {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .25rem .6rem;
  margin: -.1rem 0 .15rem;
  padding: .55rem .75rem;
  border-radius: 10px;
  background: var(--surface-row);
  border: 1px solid var(--border);
}
.login-wait[hidden] { display: none; }
.login-wait .login-hint { margin: 0; flex: 1 1 12rem; text-align: left; }
.login-wait-link { flex: 1 1 100%; font-size: .8rem; text-align: center; }

/* The QR hand-off, under the buttons once asked for. */
.login-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: .1rem 0 .3rem;
  padding: .9rem;
  border-radius: 12px;
  background: var(--surface-row);
  border: 1px solid var(--border);
}
.login-qr[hidden] { display: none; }
.login-qr-title {
  margin: 0 0 .7rem;
  font-size: .95rem;
  font-weight: 650;
  text-align: center;
}
/* 256px: a signed code is denser (qr_image.py), and at this width a module
   is as large as it was at 200px unsigned. A narrow phone shrinks it. */
.login-qr img {
  display: block;
  width: 256px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #fff;
}
.login-qr .login-hint { margin-top: .6rem; }

/* Back from the two doors to the other ways in: a line of text, not a
   fourth button. Hidden when Telegram is the only way the owner keeps on. */
.login-link {
  align-self: center;
  margin-top: .2rem;
  padding: .35rem .5rem;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: .18em;
}
.login-link:hover { color: var(--accent); }
.login-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.login-link[hidden] { display: none; }

/* No method on: the one line in place of the buttons. */
#loginNone { margin-top: .2rem; }
#loginNone[hidden] { display: none; }

/* ── A sign-in link: the panel's boot veil (shell.css .boot-veil) ──────────
   Under <html data-login-link> (theme_boot.js) the page is the mark alone,
   still on the background, the same size and place as the panel's own first
   seconds: the link opens the panel under one unbroken mark, with no card
   and no "Signing you in" in between. Nothing on it moves (Mart, 2026-12-03:
   a breath restarted by the panel's document jolted the mark at the
   handoff), and the page keeps no scrollbar meanwhile, as the panel keeps
   none, so the centre the mark sits on is the same on both sides. A step
   the link leads to (the code, the ways in) lifts it and the card fades in
   (login.js _show). */
html.login-root[data-login-link],
html.login-root[data-login-link] body.login-body { overflow: hidden; }
.login-veil {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .32s ease, visibility 0s linear .32s;
}
:root[data-login-link] .login-veil {
  opacity: 1;
  visibility: visible;
  transition: none;
}
.login-veil-mark {
  width: 44px;
  height: 44px;
}
@media (prefers-reduced-motion: reduce) {
  .login-veil { transition: none; }
}

@media (max-width: 440px) {
  .login { padding: 1rem .75rem; justify-content: flex-start; }
  .login-card { padding: 1.3rem 1.1rem 1.2rem; border-radius: 16px; }
  .login-mark { width: 56px; height: 56px; }
}
