/* ==========================================================================
   login.css — futuristic BUILDER-workbench sign-in / invite-acceptance
   screens for the admin console. Loaded LAST, after css/console.css,
   css/kits.css and css/builder.css, so it inherits every kit token
   (--accent, --accent-2, --accent-strong, --glow-rgb, --bg, --panel,
   --border, --text, --text-muted, --font-mono, --radius-*, --shadow-*) and
   builder.css's own workbench tokens (--bw-graphite-0/1/2, --bw-hair,
   --bw-hair-dim, --bw-tick, --bw-grid-major/minor, --bw-radius). No colour
   is hard-coded here. Structural only — every id/name console.js reads
   (#signin-form, #si-email, #si-password, #si-totp, #si-error,
   #accept-form, #ac-name, #ac-password, #ac-password2, #accept-error,
   #accept-step-1/2/done, #accept-otpauth-uri, #accept-qr,
   #accept-totp-form, #ac-totp, #accept-totp-error) is untouched. The six
   digit boxes and the step indicator are purely decorative additions kept
   in sync with the real (now hidden) #si-totp / #ac-totp inputs by
   js/login-fx.js — console.js still reads those same ids' .value exactly
   as before. No external requests, no web fonts, no build step.
   Phone-first: correct at 375x812 and 1280x800, 44px targets, safe-area
   insets, AA contrast, visible focus rings, prefers-reduced-motion static.
   ========================================================================== */

/* ---------- page backdrop: blueprint grid, terminal-dark ---------- */

.view-login {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.login-bp-grid {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--bw-grid-major, rgba(var(--glow-rgb), 0.07)) 1px, transparent 1px) 0 0 / 64px 64px,
    linear-gradient(90deg, var(--bw-grid-major, rgba(var(--glow-rgb), 0.07)) 1px, transparent 1px) 0 0 / 64px 64px,
    linear-gradient(var(--bw-grid-minor, rgba(var(--glow-rgb), 0.035)) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(90deg, var(--bw-grid-minor, rgba(var(--glow-rgb), 0.035)) 1px, transparent 1px) 0 0 / 16px 16px;
}

/* corner ticks framing the whole screen: retired (26 Sep 2026) — not drawn */
.login-corner-ticks { display: none !important; }
.login-corner-ticks-retired {
  position: absolute;
  inset: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
  z-index: 0;
  pointer-events: none;
}
.lct {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--bw-tick, rgba(var(--glow-rgb), 0.55));
  opacity: 0.75;
}
.lct.tl { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.lct.tr { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.lct.bl { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.lct.br { bottom: 0; right: 0; border-left: 0; border-top: 0; }

/* ---------- the sign-in card: terminal-like panel ---------- */

.login-card {
  z-index: 1;
  background: var(--bw-graphite-2, var(--panel));
  border: 1px solid var(--border);
  box-shadow:
    0 0 0 1px rgba(var(--glow-rgb), 0.05),
    0 20px 60px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

/* the card's corner tick: retired — not drawn */
.login-card::before {
  content: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 9px;
  height: 9px;
  border-top: 1.5px solid var(--bw-tick, var(--accent));
  border-left: 1.5px solid var(--bw-tick, var(--accent));
  opacity: 0.85;
  pointer-events: none;
}

.login-card .brand-word,
.login-card .brand-word-full,
.login-card .brand-word-short {
  font-family: var(--font-mono);
  letter-spacing: 0;
}

/* ---------- three-step indicator: email -> password -> code ---------- */

.login-steps {
  list-style: none;
  display: flex;
  gap: 4px;
  margin: 4px 0 18px;
  padding: 0;
  font-family: var(--font-mono);
}
.login-step {
  flex: 1;
  text-align: center;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 6px 2px;
  border-bottom: 2px solid var(--border);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.login-step.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.login-step.is-done {
  color: var(--text-muted);
  border-bottom-color: rgba(var(--glow-rgb), 0.4);
}

/* ---------- fields: workbench style, square, monospace ---------- */

.login-card .field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.login-card .field-input {
  border-radius: var(--bw-radius-sm, 2px);
  background: var(--bw-graphite-1, var(--bg));
  border: 1px solid var(--border);
  font-family: var(--font-mono);
}
.login-card .field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.35);
  outline: none;
}
.login-card .field-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- remember this device: a 44 px hand, the box and its words ---------- */

.login-remember {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 6px 0 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  user-select: none;
}
.login-remember input[type="checkbox"] {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.login-remember input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.login-remember-sub {
  color: var(--text-muted);
  font-size: 12px;
}
.login-note {
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px solid rgba(var(--glow-rgb), 0.45);
  border-radius: var(--bw-radius-sm, 2px);
  font-size: 12.5px;
  color: var(--text);
  background: rgba(var(--glow-rgb), 0.08);
}

/* ---------- 6-digit code boxes: auto-advance, paste-friendly ---------- */

.totp-boxes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-top: 2px;
}
.totp-box {
  min-height: 48px;
  width: 100%;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--bw-radius-sm, 2px);
  background: var(--bw-graphite-1, var(--bg));
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  -moz-appearance: textfield;
}
.totp-box::-webkit-outer-spin-button,
.totp-box::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.totp-box:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.4), 0 0 10px 0 rgba(var(--glow-rgb), 0.35);
  outline: none;
}
.totp-box:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.totp-box.is-filled {
  border-color: rgba(var(--glow-rgb), 0.45);
  color: var(--accent-strong);
}

/* ---------- invite-only note ---------- */

.preview-note {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  position: relative;
  padding-left: 16px;
}
.preview-note::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 6px;
  height: 6px;
  transform: translateY(-50%);
  background: var(--accent);
  box-shadow: 0 0 6px 1px rgba(var(--glow-rgb), 0.6);
}

/* ---------- primary button: flat, square, workbench ---------- */

.login-card .btn-primary {
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
  border-radius: var(--bw-radius-sm, 2px);
}

/* ---------- QR / invite acceptance ---------- */

.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: var(--bw-graphite-1, var(--bg));
  border: 1px solid var(--border);
  border-radius: var(--bw-radius, 3px);
  margin: 10px 0;
}
.qr-wrap canvas {
  max-width: 100%;
  height: auto;
}
.otpauth-uri {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  word-break: break-all;
  text-align: center;
  margin: 0 0 12px;
}
.accept-done-msg {
  font-family: var(--font-mono);
  font-size: 13.5px;
  text-align: center;
}
.accept-done-msg a {
  color: var(--accent);
}

/* ---------- focus rings — always visible, AA ---------- */

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

/* ---------- reduced motion: everything static ---------- */

@media (prefers-reduced-motion: reduce) {
  .login-step,
  .totp-box {
    transition: none !important;
  }
}

/* ---------- phone-first sizing (375x812 measured) ---------- */

@media (max-width: 480px) {
  .login-card { padding: 24px 16px 20px; }
  .totp-boxes { gap: 5px; }
  .totp-box { min-height: 46px; font-size: 18px; }
  .login-step { font-size: 8.5px; padding: 5px 1px; }
}

/* ---------- desktop (1280x800 measured) ---------- */

@media (min-width: 900px) {
  .login-card { max-width: 460px; padding: 34px 30px 28px; }
}
