/* ============================================================================
   ODX Admin — auth pages (login / verify / register) · KERNEL SKIN
   The showcase: centered stage with QR finder-pattern corner brackets,
   scan-beam sweep, panel-gradient card with acid hairline, acid CTA.
   Ported from Swift's kernel.css login. Loads after theme.css + ui.css.
   Templates: login.html, verify.html, register.html (all extend _auth.html).
   ========================================================================== */

/* ==================== Canvas / ambient stage ==================== */

.auth-wrapper {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(20px, 5vw, 48px) 18px;
  padding-top: max(clamp(20px, 5vw, 48px), env(safe-area-inset-top));
  padding-bottom: max(clamp(20px, 5vw, 48px), env(safe-area-inset-bottom));
  background: var(--bg-primary);
}

.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 18% -10%, rgba(45, 0, 244, 0.32), transparent 62%),
    radial-gradient(700px 520px at 108% 112%, rgba(45, 0, 244, 0.20), transparent 60%),
    radial-gradient(520px 380px at 88% -6%, rgba(255, 245, 130, 0.05), transparent 60%);
}

/* QR-module field, faded out of the centre so the card breathes */
.auth-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='112' height='112'%3E%3Cg fill='%236a4bff'%3E%3Crect x='0' y='0' width='8' height='8'/%3E%3Crect x='24' y='8' width='8' height='8'/%3E%3Crect x='56' y='0' width='8' height='8'/%3E%3Crect x='88' y='16' width='8' height='8'/%3E%3Crect x='8' y='40' width='8' height='8'/%3E%3Crect x='40' y='32' width='8' height='8'/%3E%3Crect x='72' y='48' width='8' height='8'/%3E%3Crect x='104' y='40' width='8' height='8'/%3E%3Crect x='16' y='72' width='8' height='8'/%3E%3Crect x='48' y='64' width='8' height='8'/%3E%3Crect x='80' y='80' width='8' height='8'/%3E%3Crect x='0' y='96' width='8' height='8'/%3E%3Crect x='32' y='104' width='8' height='8'/%3E%3Crect x='64' y='96' width='8' height='8'/%3E%3Crect x='96' y='104' width='8' height='8'/%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.06;
  -webkit-mask-image: radial-gradient(circle at 50% 44%, transparent 0 250px, #000 570px);
          mask-image: radial-gradient(circle at 50% 44%, transparent 0 250px, #000 570px);
}

/* vignette */
.auth-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

[data-theme="light"] .auth-bg {
  background:
    radial-gradient(900px 600px at 18% -10%, rgba(84, 53, 240, 0.10), transparent 62%),
    radial-gradient(700px 520px at 108% 112%, rgba(84, 53, 240, 0.06), transparent 60%);
}
[data-theme="light"] .auth-bg::before { opacity: 0.045; }
[data-theme="light"] .auth-bg::after { content: none; }

/* ==================== Stage (corners + beam live here) ==================== */

.auth-stage {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 436px;
  animation: rise 0.7s var(--ease) both;
}

/* QR finder-pattern corner brackets — the signature frame */
.corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 2px solid var(--acid);
  opacity: 0.9;
  pointer-events: none;
  z-index: 2;
  animation: cornerIn 0.9s var(--ease) both 0.15s;
}
.corner.tl { top: -12px; left: -12px; border-right: 0; border-bottom: 0; }
.corner.tr { top: -12px; right: -12px; border-left: 0; border-bottom: 0; }
.corner.bl { bottom: -12px; left: -12px; border-right: 0; border-top: 0; }
.corner.br { bottom: -12px; right: -12px; border-left: 0; border-top: 0; }
.corner::after { content: ''; position: absolute; width: 6px; height: 6px; background: var(--acid); }
.corner.tl::after { top: 3px; left: 3px; }
.corner.tr::after { top: 3px; right: 3px; }
.corner.bl::after { bottom: 3px; left: 3px; }
.corner.br::after { bottom: 3px; right: 3px; }

[data-theme="light"] .corner { border-color: var(--violet-soft); }
[data-theme="light"] .corner::after { background: var(--violet-soft); }

/* scan beam sweeping the card */
.beam {
  position: absolute;
  left: 6px;
  right: 6px;
  height: 2px;
  top: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 245, 130, 0.85), transparent);
  filter: drop-shadow(0 0 8px rgba(255, 245, 130, 0.55));
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  animation: scan 5.5s var(--ease) infinite 1.2s;
}

[data-theme="light"] .beam {
  background: linear-gradient(90deg, transparent, rgba(84, 53, 240, 0.55), transparent);
  filter: drop-shadow(0 0 8px rgba(84, 53, 240, 0.35));
}

/* ==================== Card ==================== */

.auth-card {
  position: relative;
  width: 100%;
  background: linear-gradient(180deg, var(--panel-2), var(--panel) 60%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow:
    0 0 0 1px rgba(45, 0, 244, 0.09),
    0 22px 60px -20px rgba(45, 0, 244, 0.36),
    0 46px 100px -36px rgba(0, 0, 0, 0.85);
  overflow: hidden;
}

/* hairline glow along the top edge — kernel signature */
.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 9%;
  right: 9%;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 245, 130, 0.45), transparent);
}

[data-theme="light"] .auth-card {
  background: var(--panel);
  box-shadow: var(--shadow-xl);
}
[data-theme="light"] .auth-card::before {
  background: linear-gradient(90deg, transparent, rgba(84, 53, 240, 0.25), transparent);
}

/* ==================== Card header ==================== */

.auth-hdr {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: clamp(22px, 5vw, 28px) clamp(20px, 5vw, 30px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

/* badge icon tile in acid */
.auth-badge {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  color: var(--acid);
  background: var(--acid-soft);
  border: 1px solid rgba(255, 245, 130, 0.22);
  box-shadow: 0 0 22px -6px rgba(255, 245, 130, 0.3);
}
.auth-badge svg { width: 22px; height: 22px; }

[data-theme="light"] .auth-badge {
  color: var(--violet-soft);
  background: var(--accent-light);
  border-color: rgba(84, 53, 240, 0.25);
  box-shadow: 0 0 22px -6px rgba(84, 53, 240, 0.3);
}

.auth-hdr-text { min-width: 0; }

.auth-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(18px, 3.6vw, 22px);
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: var(--text-primary);
  text-shadow: 0 0 26px rgba(106, 75, 255, 0.3);
}
[data-theme="light"] .auth-title { text-shadow: none; }

.auth-subtitle {
  margin: 5px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--text-secondary);
  word-break: break-word;
}

/* ==================== Card body / footer ==================== */

.auth-body { padding: clamp(20px, 5vw, 26px) clamp(20px, 5vw, 30px) clamp(22px, 5vw, 28px); }

.auth-copy {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.auth-ft {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 15px clamp(20px, 5vw, 30px) 18px;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  text-align: center;
}
.auth-ft > svg { flex: none; width: 14px; height: 14px; color: var(--accent-primary); opacity: 0.9; }

/* mono footnote — also used inline within register steps */
.auth-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  line-height: 1.5;
  color: var(--text-tertiary);
}
p.auth-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 20px 0 0;
}
.auth-meta svg { width: 14px; height: 14px; flex: none; color: var(--accent-primary); opacity: 0.9; }

/* ==================== Form ==================== */

.auth-form { display: flex; flex-direction: column; gap: 18px; }

/* hero-scale kernel inputs — taller than the app default, acid caret/focus
   come from ui.css tokens (--input-focus / --focus-ring) */
.auth-form .ui-input {
  height: 50px;
  padding: 0 16px;
  font-size: 15px;
  border-radius: var(--r-sm);
  background: rgba(5, 3, 12, 0.55);
}
.auth-form .ui-input:focus { background: rgba(5, 3, 12, 0.8); }
[data-theme="light"] .auth-form .ui-input,
[data-theme="light"] .auth-form .ui-input:focus { background: #ffffff; }

.auth-form .ui-input-icon > svg { left: 14px; }
.auth-form .ui-input-icon > .ui-input { padding-left: 42px; }
.auth-form .ui-input-icon.has-peek > .ui-input { padding-right: 48px; }

.auth-form .ui-label { letter-spacing: 0.18em; }

/* full-width acid CTA (display font + sheen come from .ui-btn-primary) */
.ui-btn.auth-submit {
  width: 100%;
  height: 52px;
  margin-top: 6px;
  border-radius: var(--r-sm);
  font-size: 13px;
  letter-spacing: 0.14em;
}

/* ---- password visibility toggle (kernel .ctrl-btn) ---- */

.auth-peek {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.auth-peek:hover { color: var(--acid); background: var(--acid-soft); }
.auth-peek[aria-pressed="true"] { color: var(--acid); }
[data-theme="light"] .auth-peek:hover,
[data-theme="light"] .auth-peek[aria-pressed="true"] { color: var(--violet-soft); }
[data-theme="light"] .auth-peek:hover { background: var(--accent-light); }
.auth-peek svg { width: 16px; height: 16px; }
.auth-peek .eye-off { display: none; }
.auth-peek[aria-pressed="true"] .eye { display: none; }
.auth-peek[aria-pressed="true"] .eye-off { display: block; }

/* ---- secondary links (back to sign in — kernel .backlink) ---- */

.auth-links { display: flex; justify-content: center; margin-top: 20px; }

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: color-mix(in srgb, var(--panel) 60%, transparent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.auth-back:hover { color: var(--acid); border-color: var(--line-hi); }
[data-theme="light"] .auth-back:hover { color: var(--violet-soft); }
.auth-back svg { width: 14px; height: 14px; flex: none; }

/* ==================== OTP input ==================== */

.otp-input {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.38em;
  text-indent: 0.38em; /* re-centers glyphs against the trailing letter-space */
  font-variant-numeric: tabular-nums;
}
.otp-input::placeholder { font-weight: 400; opacity: 0.4; letter-spacing: 0.38em; }

/* ==================== TOTP enrollment ==================== */

.totp-enroll {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

/* QR stays on a white tile in both themes so codes stay scannable */
.qr-surface {
  display: grid;
  place-items: center;
  background: #ffffff;
  border-radius: var(--r-md);
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 0 1px rgba(45, 0, 244, 0.15), 0 18px 44px -18px rgba(45, 0, 244, 0.5);
}
[data-theme="light"] .qr-surface {
  border-color: var(--line);
  box-shadow: 0 0 0 1px rgba(84, 53, 240, 0.10), 0 14px 34px -16px rgba(84, 53, 240, 0.30);
}
.totp-qr { display: block; width: 172px; height: 172px; }

.totp-manual {
  width: 100%;
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.totp-manual summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--r-xs);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.totp-manual summary::-webkit-details-marker { display: none; }
.totp-manual summary::marker { content: ''; }
.totp-manual summary:hover { background: var(--bg-hover); color: var(--acid); }
[data-theme="light"] .totp-manual summary:hover { color: var(--violet-soft); }
.totp-manual summary svg { width: 13px; height: 13px; flex-shrink: 0; transition: transform 0.15s var(--ease); }
.totp-manual[open] summary svg { transform: rotate(90deg); }

.totp-secret-pill {
  margin-top: 10px;
  max-width: 100%;
  padding: 7px 12px;
}
.totp-secret {
  font-family: inherit;
  letter-spacing: 0.06em;
  word-break: break-all;
  white-space: normal;
  text-align: left;
}

/* ==================== Register wizard ==================== */

.register-step { animation: rise 0.3s var(--ease); }
.register-step.hidden { display: none; }

#step-loading .ui-loading-block { padding: 64px 0; }

/* step headlines sit under the card header — smaller display type */
.auth-header { margin-bottom: 20px; }
.register-step .auth-title { font-size: 17px; }
.register-step .auth-subtitle {
  margin-top: 6px;
  font-family: var(--font-body);
  font-size: 13.5px;
  letter-spacing: 0;
  line-height: 1.55;
}

/* inline alert region (register.js showNotification renders here) */
.auth-alert-region { margin-bottom: 16px; }
.auth-alert-region:empty { display: none; margin: 0; }

.auth-notification {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  border-left: 3px solid currentColor;
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.5;
  animation: rise 0.25s var(--ease);
}
.auth-notification.success {
  background: var(--success-soft);
  border-color: rgba(74, 222, 128, 0.35);
  border-left-color: var(--success);
  color: var(--success-text);
}
.auth-notification.error {
  background: var(--error-soft);
  border-color: rgba(255, 92, 114, 0.35);
  border-left-color: var(--error);
  color: var(--error-text);
}
[data-theme="light"] .auth-notification.success { border-color: rgba(24, 165, 90, 0.35); border-left-color: var(--success); }
[data-theme="light"] .auth-notification.error { border-color: rgba(224, 53, 80, 0.32); border-left-color: var(--error); }
.auth-notification.fade-out { opacity: 0; transition: opacity 0.3s var(--ease); }

.auth-notification-icon { display: inline-flex; flex-shrink: 0; margin-top: 1px; }
.auth-notification-icon svg { width: 15px; height: 15px; }
.auth-notification-text { min-width: 0; overflow-wrap: break-word; }

/* terminal steps (invalid invite / account created) */
.register-status .auth-header { text-align: center; margin-bottom: 22px; }
.register-status .auth-title { font-size: 19px; }

.status-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
}
.status-icon svg { width: 28px; height: 28px; }
.success-icon { background: var(--success-soft); border-color: rgba(74, 222, 128, 0.35); color: var(--success); }
.error-icon { background: var(--error-soft); border-color: rgba(255, 92, 114, 0.35); color: var(--error); }
[data-theme="light"] .success-icon { border-color: rgba(24, 165, 90, 0.35); }
[data-theme="light"] .error-icon { border-color: rgba(224, 53, 80, 0.32); }

/* ==================== Motion ==================== */

@keyframes cornerIn {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 0.9; transform: scale(1); }
}
@keyframes scan {
  0% { top: 2%; opacity: 0; }
  8% { opacity: 0.55; }
  46% { top: 97%; opacity: 0.55; }
  54% { opacity: 0; top: 97%; }
  100% { opacity: 0; top: 97%; }
}

@media (prefers-reduced-motion: reduce) {
  .beam { display: none; }
  .auth-stage, .corner, .register-step { animation: none; opacity: 1; transform: none; }
}

/* ==================== Small screens ==================== */

@media (max-width: 420px) {
  .corner { width: 20px; height: 20px; }
  .corner.tl { top: -9px; left: -7px; }
  .corner.tr { top: -9px; right: -7px; }
  .corner.bl { bottom: -9px; left: -7px; }
  .corner.br { bottom: -9px; right: -7px; }

  .auth-wrapper { padding: 16px 12px 24px; }
  .totp-qr { width: 152px; height: 152px; }
  #step-loading .ui-loading-block { padding: 48px 0; }
}
