/* Login — brand stage (left) + form panel (right)
   Motion timeline (ms):
     0     glows "dawn" (scale .86 → 1, 2.4s)
     150   grid sweeps in left→right via mask
     350   light beam travels across the horizon line (1.5s), leaves a hairline
     500   logo wipes in (clip-path)  ·  600 panel slides in
     750+  title lines rise from masks, 110ms apart
     900+  form elements stagger in (translate + blur), 70ms apart
     then  ambient drift (24–30s loops) + pointer parallax on [data-depth] layers */

.login-page { overflow: hidden; }
.login { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(420px, 1fr); min-height: 100vh; }

/* ---------- Stage ---------- */
.stage { position: relative; overflow: hidden; background: #06141B; color: #E8ECEB; isolation: isolate; }
[data-theme="light"] .stage { background: #E7EAE9; color: #111; }

.stage__bg { position: absolute; inset: 0; z-index: -1; }
.layer { position: absolute; inset: -6%; translate: var(--px, 0) var(--py, 0); will-change: translate; }

.glow { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0; }
.glow--red {
  width: 62vw; height: 62vw; left: -8%; bottom: -38%;
  background: radial-gradient(closest-side, rgba(223,23,61,.55), rgba(223,23,61,.12) 55%, transparent 72%);
  animation: dawn 2.4s var(--ease-out) .05s forwards, drift-a 28s ease-in-out 2.4s infinite alternate;
}
.glow--cyan {
  width: 40vw; height: 40vw; right: -6%; top: -18%;
  background: radial-gradient(closest-side, rgba(0,231,255,.16), rgba(37,55,69,.35) 50%, transparent 72%);
  animation: dawn 2.8s var(--ease-out) .2s forwards, drift-b 24s ease-in-out 2.8s infinite alternate;
}
[data-theme="light"] .glow--red { background: radial-gradient(closest-side, rgba(223,23,61,.22), rgba(223,23,61,.06) 55%, transparent 72%); }
[data-theme="light"] .glow--cyan { background: radial-gradient(closest-side, rgba(0,231,255,.18), rgba(155,168,171,.25) 50%, transparent 72%); }

.grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, rgba(155,168,171,.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(155,168,171,.07) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: linear-gradient(100deg, #000 0%, #000 var(--m, 0%), transparent calc(var(--m, 0%) + 18%)), radial-gradient(ellipse 80% 70% at 40% 60%, #000 30%, transparent 75%);
  -webkit-mask-composite: source-in; mask-composite: intersect;
  animation: grid-sweep 1.8s var(--ease-inout) .15s forwards;
}
[data-theme="light"] .grid {
  background-image:
    linear-gradient(to right, rgba(17,33,45,.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(17,33,45,.07) 1px, transparent 1px);
}
@property --m { syntax: "<percentage>"; inherits: false; initial-value: 0%; }

.horizon { position: absolute; left: 0; right: 0; top: 64%; height: 1px; }
.horizon::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(155,168,171,.22) 20%, rgba(155,168,171,.22) 80%, transparent);
  transform: scaleX(0); transform-origin: left; animation: line-draw 1.5s var(--ease-out) .35s forwards;
}
.beam {
  position: absolute; top: -40px; left: 0; width: 260px; height: 81px; opacity: 0;
  background:
    linear-gradient(90deg, transparent, rgba(255,255,255,.9) 70%, #df173d 100%) center / 100% 1px no-repeat,
    radial-gradient(closest-side, rgba(223,23,61,.35), transparent) center / 100% 100% no-repeat;
  animation: beam 1.5s var(--ease-inout) .35s forwards;
}
[data-theme="light"] .beam { background: linear-gradient(90deg, transparent, rgba(17,17,17,.7) 70%, #df173d 100%) center / 100% 1px no-repeat, radial-gradient(closest-side, rgba(223,23,61,.18), transparent) center / 100% 100% no-repeat; }

.vignette { position: absolute; inset: 0; background: radial-gradient(ellipse 120% 90% at 30% 50%, transparent 50%, rgba(6,20,27,.7)); }
[data-theme="light"] .vignette { background: radial-gradient(ellipse 120% 90% at 30% 50%, transparent 55%, rgba(204,208,207,.6)); }

.stage__content {
  position: relative; height: 100%; min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto;
  padding: 44px clamp(40px, 5vw, 80px);
}
.stage__brand { display: flex; align-items: center; gap: 16px; }
.logo-reveal { clip-path: inset(0 100% 0 0); animation: wipe 1s var(--ease-out) .5s forwards; }
.logo-reveal .logo { height: 72px; width: auto; }
.auth__mark { display: block; margin-bottom: 20px; }
.auth__mark .logo { height: 56px; width: auto; }
.stage__divider { width: 1px; height: 22px; background: currentColor; opacity: .2; transform: scaleY(0); animation: grow-y .6s var(--ease-out) 1.1s forwards; }
.stage__product {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .32em; text-transform: uppercase; opacity: 0;
  animation: fade-track 1s var(--ease-out) 1.2s forwards;
}

.stage__hero { align-self: center; max-width: 640px; padding-bottom: 6vh; }
.stage__eyebrow { color: #9BA8AB; margin-bottom: 24px; opacity: 0; animation: rise .8s var(--ease-out) .65s forwards; }
[data-theme="light"] .stage__eyebrow { color: #4A5C6A; }
.stage__title { font-weight: 500; font-size: clamp(44px, 5.2vw, 76px); line-height: 1.02; letter-spacing: -.035em; }
.stage__title .line { display: block; overflow: hidden; padding-bottom: .06em; }
.stage__title .line > span { display: inline-block; transform: translateY(110%); animation: line-up 1.1s var(--ease-out) forwards; }
.stage__title .line:nth-child(1) > span { animation-delay: .75s; }
.stage__title .line:nth-child(2) > span { animation-delay: .86s; }
.stage__title .line:nth-child(3) > span { animation-delay: .97s; }
.stage__title em { font-style: normal; color: #df173d; }
.stage__lede {
  margin-top: 28px; max-width: 440px; font-size: 16px; line-height: 1.6; color: #9BA8AB; text-wrap: pretty;
  opacity: 0; filter: blur(6px); animation: focus-in 1s var(--ease-out) 1.25s forwards;
}
[data-theme="light"] .stage__lede { color: #4A5C6A; }

.stage__foot {
  display: flex; justify-content: space-between; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: #6F8089; opacity: 0; animation: rise .8s var(--ease-out) 1.5s forwards;
}
[data-theme="light"] .stage__foot { color: #4A5C6A; }

/* ---------- Panel ---------- */
.panel {
  position: relative; display: grid; grid-template-rows: auto 1fr auto; padding: 32px clamp(32px, 4vw, 64px);
  background: var(--bg); border-left: 1px solid var(--border);
  opacity: 0; transform: translateX(24px); animation: panel-in 1s var(--ease-out) .6s forwards;
}
.panel__top { display: flex; align-items: center; justify-content: space-between; }
.panel__secure { display: inline-flex; align-items: center; gap: 8px; }
.panel__tools { display: flex; align-items: center; gap: 8px; }
.panel__foot { display: grid; gap: 6px; }
.panel__demo { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
button.field__link { font-size: var(--fs-12); color: var(--text-3); }
button.field__link:hover { color: var(--accent-ink); }

.auth { align-self: center; justify-self: center; width: 100%; max-width: 380px; display: grid; gap: 20px; }
.auth__head { margin-bottom: 8px; }
.auth__head h2 { font-size: var(--fs-28); font-weight: 500; letter-spacing: -.02em; }
.auth__head p { margin-top: 6px; color: var(--text-2); }

.field { display: grid; gap: 8px; }
.field label { font-size: var(--fs-13); font-weight: 500; color: var(--text-2); }
.field__row { display: flex; justify-content: space-between; align-items: baseline; }
.field__link { font-size: var(--fs-12); color: var(--text-3); }
.input__action {
  display: grid; place-items: center; width: 32px; height: 32px; margin-right: -8px; border-radius: var(--r-sm); color: var(--text-3);
}
.input__action:hover { color: var(--text); background: var(--surface-3); }

.auth__row { display: flex; align-items: center; justify-content: space-between; }
.auth__caps { font-size: 11px; color: var(--accent-ink); }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-13); color: var(--text-2); cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check__box {
  display: grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; color: transparent;
  box-shadow: inset 0 0 0 1px var(--border-strong); background: var(--surface-2); transition: all var(--dur) var(--ease-out);
}
.check__box .ico { stroke-width: 2.5; transform: scale(.6); transition: transform var(--dur) var(--ease-out); }
.check input:checked + .check__box { background: var(--accent); box-shadow: none; color: #fff; }
.check input:checked + .check__box .ico { transform: scale(1); }
.check input:focus-visible + .check__box { box-shadow: 0 0 0 3px var(--accent-ring); }

.auth__error { font-size: var(--fs-13); color: var(--accent-ink); display: flex; gap: 8px; align-items: center; }
.auth__error.is-ok { color: var(--positive-ink); }

.auth__submit { position: relative; overflow: hidden; margin-top: 4px; }
.auth__submit::after { /* sheen */
  content: ""; position: absolute; inset: 0; transform: translateX(-120%);
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.22) 50%, transparent 70%);
}
.auth__submit:hover::after { transition: transform .9s var(--ease-out); transform: translateX(120%); }
.auth__arrow { transition: transform var(--dur) var(--ease-out); }
.auth__submit:hover .auth__arrow { transform: translateX(3px); }
.auth__spinner { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .7s linear infinite; }
.is-loading .auth__spinner { display: block; }
.is-loading .auth__arrow { display: none; }

.panel__foot { font-size: var(--fs-12); color: var(--text-3); text-align: center; }
.panel__foot a { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-strong); }

.reveal { opacity: 0; transform: translateY(12px); filter: blur(4px); animation: focus-in .9s var(--ease-out) forwards; }
.auth > .reveal:nth-child(1) { animation-delay: .9s; }
.auth > .reveal:nth-child(2) { animation-delay: .97s; }
.auth > .reveal:nth-child(3) { animation-delay: 1.04s; }
.auth > .reveal:nth-child(4) { animation-delay: 1.11s; }
.auth > .reveal:nth-child(6) { animation-delay: 1.18s; }
.panel__foot.reveal { animation-delay: 1.4s; }

.shake { animation: shake .4s var(--ease-out); }

/* Exit transition → dashboard */
.login.is-leaving .panel { transition: opacity .5s var(--ease-out), transform .5s var(--ease-out); opacity: 0; transform: translateX(-12px); }
.login.is-leaving .stage__content { transition: opacity .45s var(--ease-out); opacity: 0; }
.login.is-leaving .glow--red { transition: filter .6s; filter: blur(40px) brightness(1.4); }

/* ---------- MFA vault step ---------- */
.auth[hidden] { display: none; }
.auth.is-out { transition: opacity .3s var(--ease-out), transform .3s var(--ease-out), filter .3s; opacity: 0; transform: translateY(-8px); filter: blur(4px); }
.mfa { gap: 18px; }
.mfa .auth__head { margin-bottom: 0; }
.mfa__step { display: block; margin-bottom: 10px; color: var(--text-3); }
.mfa.is-in > * { opacity: 0; transform: translateY(12px); filter: blur(4px); animation: focus-in .8s var(--ease-out) forwards; }
.mfa.is-in > :nth-child(2) { animation-delay: .08s; }
.mfa.is-in > :nth-child(3) { animation-delay: .16s; }
.mfa.is-in > :nth-child(4) { animation-delay: .22s; }
.mfa.is-in > :nth-child(5) { animation-delay: .28s; }
.vault { position: relative; width: min(300px, 100%, 40vh); aspect-ratio: 1; justify-self: center; perspective: 1100px; }
.vault canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.vault__door { will-change: transform; }
.vault-fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 1000; }
.otp { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; perspective: 800px; }
.otp__cell {
  width: 100%; height: 56px; padding: 0; text-align: center; font-family: var(--font-mono); font-size: 22px; font-weight: 500; color: var(--text);
  background: var(--surface-2); border: 0; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--border-strong); caret-color: var(--accent);
  transition: box-shadow var(--dur) var(--ease-out), background var(--dur), color var(--dur);
}
.otp__cell:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-ring); }
.otp__cell.has-val { box-shadow: inset 0 0 0 1px var(--text-3); }
.otp.is-ok .otp__cell { box-shadow: inset 0 0 0 1px var(--positive); color: var(--positive-ink); background: var(--positive-soft); }
.otp.is-error .otp__cell { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.otp__done {
  position: absolute; left: 50%; top: 0; width: 56px; height: 56px; margin-left: -28px; display: grid; place-items: center; opacity: 0; pointer-events: none;
  border-radius: var(--r-md); background: var(--positive-soft); color: var(--positive-ink); box-shadow: inset 0 0 0 1px var(--positive), 0 0 36px -6px var(--positive);
}
.otp__done path { stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .45s var(--ease-out); }
.otp__done.is-drawn path { stroke-dashoffset: 0; }
.mfa__status { min-height: 18px; font-size: 12px; text-align: center; color: var(--text-3); }
.mfa__status.is-error { color: var(--accent-ink); }
.mfa__status.is-ok { color: var(--positive-ink); }
.mfa__foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Keyframes ---------- */
.stage__foot { gap: 24px; align-items: baseline; }
.stage__copy { text-transform: none; letter-spacing: 0; line-height: 1.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-size: clamp(9px, .72vw, 11px); }
.stage__foot > span:last-child { flex: none; }
.stage__copy strong { font-weight: 600; color: #9BA8AB; }
[data-theme="light"] .stage__copy strong { color: #253745; }
.stage__copy a { color: inherit; }
.stage__copy a:hover strong { color: #df173d; }
.stage__copy .sep { opacity: .45; margin: 0 2px; }
@keyframes dawn { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: scale(1); } }
@keyframes drift-a { to { transform: translate(4%, -3%) scale(1.06); } }
@keyframes drift-b { to { transform: translate(-5%, 4%) scale(.94); } }
@keyframes grid-sweep { to { --m: 100%; } }
@keyframes line-draw { to { transform: scaleX(1); } }
@keyframes beam { 0% { opacity: 0; transform: translateX(-260px); } 15% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; transform: translateX(calc(57vw)); } }
@keyframes wipe { to { clip-path: inset(0 0 0 0); } }
@keyframes grow-y { to { transform: scaleY(1); } }
@keyframes fade-track { from { opacity: 0; letter-spacing: .6em; } to { opacity: .8; letter-spacing: .32em; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes line-up { to { transform: translateY(0); } }
@keyframes focus-in { to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes panel-in { to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

@media (max-width: 960px) {
  .login-page { overflow: auto; }
  .login { grid-template-columns: 1fr; }
  .stage { min-height: 46vh; }
  .stage__content { min-height: 46vh; padding: 28px; }
  .stage__hero { padding: 32px 0; }
  .panel { border-left: 0; border-top: 1px solid var(--border); min-height: 70vh; }
}
/* Mobile login: compact brand header, form first-class, safe areas, 16px inputs (no iOS zoom). */
@media (max-width: 600px) {
  .stage, .stage__content { min-height: 0; }
  .stage__content { padding: calc(20px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 18px max(20px, env(safe-area-inset-left)); gap: 18px; }
  .logo-reveal .logo { height: 54px; }
  .auth__mark .logo { height: 48px; }
  .stage__hero { padding: 4px 0 0; }
  .stage__eyebrow { margin-bottom: 10px; }
  .stage__title { font-size: clamp(30px, 9vw, 38px); }
  .stage__lede { display: none; }
  .stage__foot { flex-direction: column; gap: 4px; font-size: 9.5px; letter-spacing: .04em; line-height: 1.6; }
  .stage__copy, .stage__foot > * { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; }
  .panel__top { flex-wrap: wrap; gap: 10px; }
  .panel { min-height: 0; padding: 18px max(20px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); gap: 28px; }
  .auth { max-width: none; }
  .input { height: 52px; }
  .input input { font-size: 16px; }
  .input__action { width: 44px; height: 44px; margin-right: -12px; }
  .check { min-height: 44px; }
  .vault { width: min(260px, 72vw); }
  .otp__cell { height: 52px; font-size: 20px; }
}

/* ---------- Account activation (invitation → password → TOTP → recovery codes) ---------- */
.act { display: grid; gap: 18px; }
.act form { display: grid; gap: 18px; }
.act__load { color: var(--text-3); font-size: var(--fs-13); text-align: center; padding: 40px 0; }
.act__steps { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.act__steps li { display: grid; justify-items: start; gap: 6px; padding-top: 10px; border-top: 2px solid var(--border-strong); color: var(--text-3); }
.act__steps li.is-now { border-top-color: var(--accent); color: var(--text); }
.act__steps li.is-done { border-top-color: var(--positive); color: var(--positive-ink); }
.act__steps span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-family: var(--font-mono); font-size: 11px; box-shadow: inset 0 0 0 1px currentColor; }
.act__steps em { font-style: normal; font-size: var(--fs-12); }
.act__hint { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-12); color: var(--text-3); line-height: 1.5; }
.act__state { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; color: var(--accent-ink); background: var(--accent-soft); }
.act__state--ok { color: var(--positive-ink); background: var(--positive-soft); }
.act .ico--lg { width: 26px; height: 26px; }
.act__qr { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 18px; align-items: center; }
.act__qrbox { width: 168px; height: 168px; padding: 10px; border-radius: var(--r-md); background: #fff; color: #000; box-shadow: inset 0 0 0 1px var(--border-strong); } /* QR needs a light quiet zone in both themes */
.act__qrbox svg { display: block; width: 100%; height: 100%; }
.act__sec { display: grid; gap: 8px; min-width: 0; }
.act__lbl { font-size: var(--fs-12); color: var(--text-3); }
.act__secret { display: block; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); font-family: var(--font-mono); font-size: 13px; letter-spacing: .08em; overflow-wrap: anywhere; user-select: all; }
.act__row { display: flex; gap: 8px; flex-wrap: wrap; }
.act__codes { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.act__codes li { padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); text-align: center; }
.act__codes code { font-family: var(--font-mono); font-size: 14px; letter-spacing: .06em; user-select: all; overflow-wrap: anywhere; }
.act__warn { display: flex; gap: 10px; align-items: flex-start; }
@media (max-width: 600px) { .act__qr { grid-template-columns: minmax(0, 1fr); justify-items: center; } .act__sec { justify-items: stretch; width: 100%; } .act__codes { grid-template-columns: minmax(0, 1fr); } }
.otp[hidden], .field[hidden] { display: none; }
body.login-page { overflow-x: clip; }
.login { overflow-x: clip; max-width: 100vw; } /* decorative glow/beam layers (animated, full motion) must not widen the document */
