/* ═══════════════════════════════════════════════════════════
   APEX Terminal — login.css
   Космос на весь экран (глобус смещён вправо, Three.js),
   форма слева — матовое стекло (backdrop-filter).
   ═══════════════════════════════════════════════════════════ */

.auth-body {
  --glass-bg: rgba(8, 14, 30, 0.42);
  --glass-border: rgba(148, 197, 255, 0.16);
  --glass-hi: rgba(255, 255, 255, 0.22);
  --neon: #38bdf8;
  --neon-2: #e0f2fe;
  --neon-rgb: 56, 189, 248;
  --ink: #f8fafc;
  --ink-dim: rgba(226, 232, 240, 0.62);
  --field-bg: rgba(2, 6, 23, 0.46);

  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #02040a;
  color: var(--ink);
  overflow: hidden;
}

[data-theme="light"] .auth-body {
  --glass-bg: rgba(240, 247, 255, 0.62);
  --glass-border: rgba(255, 255, 255, 0.7);
  --glass-hi: rgba(255, 255, 255, 0.9);
  --ink: #0b1630;
  --ink-dim: rgba(20, 38, 74, 0.66);
  --field-bg: rgba(255, 255, 255, 0.66);
}

/* ─── Космос ─────────────────────────────────── */
.space-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.space-layer canvas { display: block; width: 100%; height: 100%; }

.space-vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(2, 4, 10, 0.78) 0%, rgba(2, 4, 10, 0.32) 34%, rgba(2, 4, 10, 0) 58%),
    radial-gradient(120% 90% at 70% 50%, rgba(2, 4, 10, 0) 55%, rgba(2, 4, 10, 0.7) 100%);
}

/* ─── Сцена и стеклянная карточка ────────────── */
.auth-stage {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 32px clamp(20px, 6vw, 96px);
  overflow-y: auto;
}

.glass-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: 30px 32px 24px;
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  backdrop-filter: blur(28px) saturate(170%);
  box-shadow:
    inset 0 1px 0 var(--glass-hi),
    inset 0 0 0 1px rgba(255, 255, 255, 0.02),
    0 30px 80px -20px rgba(0, 0, 0, 0.75),
    0 0 120px -40px rgba(var(--neon-rgb), 0.35);
  overflow: hidden;
  isolation: isolate;
}

/* медленный блик по стеклу */
.glass-card__sheen {
  position: absolute;
  inset: -40% -60%;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(115deg,
    transparent 40%, rgba(186, 230, 253, 0.07) 48%, rgba(186, 230, 253, 0.12) 50%, transparent 58%);
  animation: sheen 9s ease-in-out infinite;
}
@keyframes sheen {
  0%, 100% { transform: translateX(-30%); }
  50%      { transform: translateX(30%); }
}

/* неоновая обводка-градиент по краю */
.glass-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(140deg, rgba(var(--neon-rgb), 0.55), rgba(var(--neon-rgb), 0) 32%,
                                      rgba(var(--neon-rgb), 0) 68%, rgba(34, 211, 238, 0.4));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ─── Шапка карточки ─────────────────────────── */
.auth-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 26px;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-decoration: none;
}
.auth-logo span:last-child {
  font-weight: 300;
  letter-spacing: 0.22em;
  color: var(--ink-dim);
}
.auth-logo__mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: #1e3a8a;
  border: 1px solid rgba(148, 197, 255, 0.28);
  box-shadow: none;
  font-size: 14px;
}

.auth-controls { display: flex; gap: 6px; }

.auth-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  font: 700 11px/1 Inter, sans-serif;
  color: var(--ink-dim);
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, background-color 0.25s, box-shadow 0.25s;
}
.auth-icon-btn:hover {
  border-color: rgba(var(--neon-rgb), 0.55);
  background: rgba(var(--neon-rgb), 0.1);
  color: var(--neon);
  box-shadow: 0 0 18px rgba(var(--neon-rgb), 0.25);
}

/* ─── Заголовки ──────────────────────────────── */
.auth-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font: 500 10.5px/1 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--neon);
}
.auth-kicker__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--neon-2);
  box-shadow: 0 0 10px var(--neon-2);
  animation: pulse-dot 2.2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.7); }
}

.auth-title {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.12;
  background: linear-gradient(180deg, #ffffff 0%, #b9d4f5 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
[data-theme="light"] .auth-title {
  background: linear-gradient(180deg, #0b1630 0%, #1e3a8a 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.auth-sub {
  margin: 10px 0 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-dim);
}

/* ─── Табы со «скользящей» подложкой ─────────── */
.auth-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 24px 0 20px;
  padding: 4px;
  border: 1px solid var(--glass-border);
  border-radius: 13px;
  background: var(--field-bg);
}
.auth-tabs__glider {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 9px;
  background: rgba(30, 58, 138, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
.auth-tabs.is-register .auth-tabs__glider { transform: translateX(100%); }

.auth-tab {
  position: relative;
  z-index: 1;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font: 600 13.5px/1.2 Inter, sans-serif;
  color: var(--ink-dim);
  cursor: pointer;
  transition: color 0.3s;
}
.auth-tab:hover { color: var(--ink); }
.auth-tab.is-active { color: #fafaf9; }

/* ─── Поля ───────────────────────────────────── */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.auth-label {
  font: 500 10.5px/1 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.auth-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: var(--field-bg);
  font: 400 14px/1.3 Inter, sans-serif;
  color: var(--ink);
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, background-color 0.25s;
}
.auth-field input::placeholder { color: rgba(148, 170, 205, 0.45); }
.auth-field input:hover { border-color: rgba(var(--neon-rgb), 0.3); }
.auth-field input:focus {
  border-color: rgba(var(--neon-rgb), 0.75);
  background: rgba(2, 10, 28, 0.6);
  box-shadow: 0 0 0 4px rgba(var(--neon-rgb), 0.12), 0 0 26px -6px rgba(var(--neon-rgb), 0.55);
}
[data-theme="light"] .auth-field input:focus { background: #fff; }

.auth-password-wrap { position: relative; }
.auth-password-wrap input { padding-right: 46px; }

.auth-eye {
  position: absolute;
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}
.auth-eye:hover { color: var(--neon); background: rgba(var(--neon-rgb), 0.1); }

.auth-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-dim);
  cursor: pointer;
}
.auth-check input {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin-top: 2px;
  accent-color: var(--neon);
}

.auth-field[hidden],
.auth-check[hidden],
.auth-error[hidden],
#auth-2fa[hidden],
#auth-main[hidden],
.pwd-meter[hidden],
.pwd-meter-label[hidden],
.auth-extra[hidden] { display: none !important; }

.auth-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: 12px;
  background: rgba(127, 29, 29, 0.28);
  font-size: 12.5px;
  color: #fecaca;
}
.auth-error.is-info {
  border-color: rgba(var(--neon-rgb), 0.45);
  background: rgba(var(--neon-rgb), 0.1);
  color: #bae6fd;
}

/* ─── Главная кнопка: неон + бегущий блик ────── */
.auth-submit {
  position: relative;
  width: 100%;
  margin-top: 4px;
  padding: 14px 18px;
  border: 1px solid rgba(148, 197, 255, 0.28);
  border-radius: 13px;
  background: linear-gradient(180deg, #1e3a8a 0%, #172554 100%);
  font: 600 14.5px/1 Inter, sans-serif;
  letter-spacing: 0.02em;
  color: #fff;
  cursor: pointer;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s, filter 0.25s;
}
.auth-submit::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}
.auth-submit:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 12px 28px -10px rgba(30, 58, 138, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.auth-submit:hover::after { transform: translateX(120%); }
.auth-submit:active { transform: translateY(0) scale(0.99); }
.auth-submit:disabled { opacity: 0.6; cursor: progress; }

/* ─── Альтернативный вход ────────────────────── */
.auth-extra {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 500 10.5px/1 "JetBrains Mono", monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
}

.auth-alt-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-alt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  font: 600 13px/1 Inter, sans-serif;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.25s, background-color 0.25s, color 0.25s, box-shadow 0.25s;
}
.auth-alt-btn:hover {
  border-color: rgba(var(--neon-rgb), 0.5);
  background: rgba(var(--neon-rgb), 0.08);
  box-shadow: 0 0 20px -6px rgba(var(--neon-rgb), 0.6);
}
.auth-alt-btn--wide { width: 100%; margin-top: 10px; }
.auth-tg-btn { color: #7dd3fc; }

.auth-forgot {
  align-self: center;
  font-size: 12.5px;
  color: var(--ink-dim);
  text-decoration: none;
  transition: color 0.2s;
}
.auth-forgot:hover { color: var(--neon); }

/* ─── Подвал карточки ────────────────────────── */
.auth-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}
.auth-back {
  font-size: 12.5px;
  color: var(--ink-dim);
  text-decoration: none;
  transition: color 0.2s;
}
.auth-back:hover { color: var(--neon); }
.auth-secure {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 500 10px/1 "JetBrains Mono", monospace;
  letter-spacing: 0.12em;
  color: rgba(var(--neon-rgb), 0.75);
}

/* ─── Пароль: индикатор ──────────────────────── */
.pwd-meter {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 2px;
}
.pwd-meter span {
  height: 3px;
  border-radius: 999px;
  background: rgba(148, 170, 205, 0.2);
  transition: background-color 0.3s, box-shadow 0.3s;
}
.pwd-meter[data-level="1"] span:nth-child(1) { background: #f87171; box-shadow: 0 0 8px #f87171; }
.pwd-meter[data-level="2"] span:nth-child(1),
.pwd-meter[data-level="2"] span:nth-child(2) { background: #fbbf24; box-shadow: 0 0 8px #fbbf24; }
.pwd-meter[data-level="3"] span { background: var(--neon-2); box-shadow: 0 0 8px var(--neon-2); }
.pwd-meter-label { font-size: 11.5px; color: var(--ink-dim); }

/* ─── 2FA ────────────────────────────────────── */
.otp-digits {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 24px 0 16px;
}
.otp-digit {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: var(--field-bg);
  font: 600 22px/1 "JetBrains Mono", monospace;
  text-align: center;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.otp-digit:focus {
  border-color: rgba(var(--neon-rgb), 0.8);
  box-shadow: 0 0 0 4px rgba(var(--neon-rgb), 0.12), 0 0 22px -4px rgba(var(--neon-rgb), 0.6);
}

/* ─── HUD телеметрии (правый нижний угол) ────── */
.space-hud {
  position: fixed;
  right: clamp(16px, 3vw, 40px);
  bottom: clamp(16px, 3vh, 36px);
  z-index: 2;
  display: grid;
  gap: 6px;
  min-width: 190px;
  padding: 12px 14px;
  border: 1px solid rgba(var(--neon-rgb), 0.18);
  border-radius: 14px;
  background: rgba(2, 8, 22, 0.35);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font: 500 10.5px/1 "JetBrains Mono", monospace;
  letter-spacing: 0.12em;
  color: rgba(203, 221, 245, 0.55);
}
.space-hud__row { display: flex; justify-content: space-between; gap: 18px; }
.space-hud__row b { font-weight: 500; color: #7dd3fc; }

/* ─── Появление (Motion управляет, CSS — исходное состояние) ─── */
.js-motion .glass-card { opacity: 0; transform: translateY(18px) scale(0.985); }
.js-motion [data-reveal] { opacity: 0; transform: translateY(12px); }

@media (prefers-reduced-motion: reduce) {
  .glass-card__sheen, .auth-kicker__dot { animation: none; }
  .js-motion .glass-card, .js-motion [data-reveal] { opacity: 1; transform: none; }
}

@media (max-width: 900px) {
  .auth-body { overflow-y: auto; }
  .space-vignette { background: rgba(2, 4, 10, 0.45); }
  .auth-stage { justify-content: center; padding: 24px 16px; }
  .glass-card { padding: 24px 20px 20px; border-radius: 20px; }
  .auth-title { font-size: 25px; }
  .space-hud { display: none; }
}
