/* ═════════ LOCK ═════════
   Three rows — bar / scene / gate — so text can never sit on top of the character. */
.lock {
  position: fixed; inset: 0; z-index: 30; overflow: clip; isolation: isolate;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100vh; height: 100dvh;
  background: var(--lock-bg); --px: 0; --py: 0; --charge: 0;
  transition: opacity .8s var(--ease-io);
}
.lock.is-leaving { opacity: 0; pointer-events: none; }
.lock__dust { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.lock__grain { position: absolute; inset: 0; z-index: 9; pointer-events: none; opacity: var(--grain-op); mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }

/* Top bar */
.lock__top { position: relative; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  padding: clamp(14px, 2.4vw, 28px) clamp(16px, 3.4vw, 44px); animation: lock-fade 1s var(--ease-out) both 1.1s; }
.lock__top-r { display: flex; align-items: center; gap: 18px; }
@keyframes lock-fade { from { opacity: 0; } }
.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark { width: 24px; height: 24px; }
.brand .mono { font-weight: 700; letter-spacing: .3em; }
.lock__status { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.lock__status i { width: 7px; height: 7px; background: var(--hit); animation: lock-blink 1.6s steps(2) infinite; }
[data-theme='light'] .lock__status i { background: var(--blue); }
@keyframes lock-blink { 50% { opacity: .2; } }

/* Scene */
.lock__scene { position: relative; z-index: 2; min-height: 0; container-type: size; overflow-x: clip; }
.lock__floor { position: absolute; left: -20%; right: -20%; bottom: -30%; height: 70%; pointer-events: none; opacity: .28;
  background: linear-gradient(var(--numeral-stroke) 1px, transparent 1px) 0 0 / 100% 54px, linear-gradient(90deg, var(--numeral-stroke) 1px, transparent 1px) 0 0 / 86px 100%;
  transform: perspective(520px) rotateX(64deg); transform-origin: 50% 0;
  -webkit-mask-image: linear-gradient(#000, transparent 80%); mask-image: linear-gradient(#000, transparent 80%); animation: lock-fade 2s var(--ease-out) both .4s; }
[data-theme='light'] .lock__floor { opacity: .14; }

.lock__num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;
  font: 900 min(36cqw, 82cqh)/.8 var(--font-display); letter-spacing: -.045em;
  transform: translate3d(calc(var(--px) * -12px), calc(var(--py) * -8px), 0); }
.lock__num span { color: transparent; -webkit-text-stroke: 2px var(--numeral-stroke); animation: num-in 1.5s var(--ease-out) both; }
.lock__num span:nth-child(2) { animation-delay: .12s; } .lock__num span:nth-child(3) { animation-delay: .24s; }
.lock__num .z { -webkit-text-stroke-width: 0; background: var(--numeral-zero); -webkit-background-clip: text; background-clip: text; }
[data-theme='light'] .lock__num .z { -webkit-text-stroke: 2px var(--ink); background: none; color: var(--hit); }
@keyframes num-in { from { transform: translateY(14%); opacity: 0; filter: blur(14px); } }

/* Ghost — figure spans ~4%–96% of the scene; the glow pool lands just above the gate */
.lock__ghost { position: absolute; left: 50%; bottom: -10%; height: 112%; aspect-ratio: 1; pointer-events: none;
  transform: translate3d(calc(-50% + var(--px) * 22px), calc(var(--py) * 12px), 0); }
.lock__ghost-in { width: 100%; animation: ghost-in 2s var(--ease-out) both .35s, float 8s ease-in-out infinite 2.4s; transition: transform 1.1s var(--ease-io), filter 1s; }
@keyframes ghost-in { from { opacity: 0; filter: blur(16px); transform: translateY(3%) scale(.97); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1.8%); } }
.lock .ghost__core { animation: core 3.6s ease-in-out infinite 2.4s; }
@keyframes core { 0%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(.85); } 50% { opacity: .6; transform: translate(-50%, -50%) scale(1.4); } }
.lock .ghost__visor { animation: visor 5s ease-in-out infinite 2s; }
@keyframes visor { 0%, 100% { opacity: .3; } 50% { opacity: .7; } }

.lock__flare { position: fixed; z-index: 6; left: 0; right: 0; top: 24%; height: 2px; pointer-events: none; opacity: 0; transform: scaleX(0);
  background: linear-gradient(90deg, transparent, var(--blue-hot) 25%, #fff 50%, var(--blue-hot) 75%, transparent); box-shadow: var(--glow); }
[data-theme='light'] .lock__flare { background: var(--blue); height: 3px; box-shadow: none; }

/* Gate */
.gate { position: relative; z-index: 10; justify-self: center; width: min(520px, calc(100% - 40px));
  padding-bottom: max(clamp(20px, 5vh, 52px), env(safe-area-inset-bottom)); display: grid; gap: 10px; animation: lock-rise 1.1s var(--ease-out) both 1.3s; }
@keyframes lock-rise { from { opacity: 0; transform: translateY(18px); } }
.gate__label { color: var(--ink-2); letter-spacing: .42em; transition: color var(--dur-1); }
.gate:focus-within .gate__label { color: var(--ink); }
.gate__row { display: flex; align-items: stretch; gap: 12px; }
.gate input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--ink); caret-color: var(--hit);
  font: 500 clamp(22px, 5.4vw, 28px)/1.5 var(--font-mono); letter-spacing: .42em; padding: 4px 0; }
[data-theme='light'] .gate input { caret-color: var(--blue); }
.gate input::placeholder { color: var(--ink-3); opacity: .7; }
.gate__go { flex: none; width: 48px; display: grid; place-items: center; background: var(--hit); color: var(--on-hit); font: 700 20px var(--font-mono);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px); transition: transform .2s var(--ease-out), filter .2s; }
.gate__go:hover { transform: translateX(3px); } .gate__go:active { transform: scale(.94); }
.gate__go span { transition: transform .3s var(--ease-out); } .gate__go:hover span { transform: translateX(3px); }
.gate__line { position: relative; height: 2px; background: var(--line-strong); }
.gate__line i { position: absolute; left: 0; top: -1px; bottom: -1px; width: 100%; background: var(--blue-hot); transform-origin: 0 50%;
  transform: scaleX(calc(.04 + var(--charge) * .96)); transition: transform .4s var(--ease-out), background .25s; }
[data-theme='light'] .gate__line { background: var(--ink); } [data-theme='light'] .gate__line i { background: var(--blue); top: -1.5px; bottom: -1.5px; }
.gate:focus-within .gate__line i { min-width: 12%; }
.gate__row--email { margin-bottom: 4px; } .gate__row--email input { font-size: clamp(15px, 2.2vw, 20px); letter-spacing: .02em; } .gate__line--email { margin-bottom: 14px; }
.gate__meta { display: flex; justify-content: space-between; gap: 16px; min-height: 22px; }
.gate__msg { color: var(--ink-2); transition: color var(--dur-1); }
.gate__eye { color: var(--ink-3); padding: 2px 0; flex: none; } .gate__eye:hover { color: var(--ink); }

/* Denied: one honest shake, red line, quiet glitch on the numerals */
.lock.is-denied .gate__row { animation: shake .42s var(--ease-out); }
.lock.is-denied .gate__line i { background: var(--alert); transform: scaleX(1); }
.lock.is-denied .gate__msg { color: var(--alert); }
.lock.is-denied .gate__label { color: var(--alert); }
.lock.is-denied .lock__ghost-in { animation: recoil .6s var(--ease-out); }
.lock.is-denied .ghost__visor { background: var(--alert); opacity: .95; animation: none; }
.lock.is-denied .lock__num span { filter: drop-shadow(4px 0 0 var(--alert)); transition: filter .15s; }
@keyframes shake { 20% { transform: translateX(-10px); } 45% { transform: translateX(8px); } 70% { transform: translateX(-4px); } }
@keyframes recoil { 30% { transform: translateY(1.2%) scale(.992); } }

/* Granted: line completes, ghost leans in, everything else steps back */
.lock.is-granting .gate__line i { transform: scaleX(1); background: var(--ok); }
.lock.is-granting .gate__go { background: var(--ok); } .lock.is-granting .gate__msg { color: var(--ok); }
.lock.is-granting .gate { transition: opacity .6s .5s; opacity: 0; pointer-events: none; }
.lock.is-granting .lock__top { opacity: 0; transition: opacity .4s; animation: none; }
.lock.is-granting .lock__ghost-in { animation: none; transform: scale(1.1) translateY(4%); filter: brightness(1.15); }
.lock.is-granting .lock__num { opacity: 0; transform: scale(1.12); transition: opacity .8s, transform 1.1s var(--ease-io); }
.lock.is-granting .ghost__visor { animation: none; opacity: 1; }
.lock.is-granting .lock__flare { animation: flare 1s var(--ease-io) .1s forwards; }
@keyframes flare { 0% { transform: scaleX(0); opacity: 1; } 60% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }

/* Small / short screens: character stays the hero, the gate compacts */
@media (max-width: 640px) {
  .lock__status { display: none; }
  .lock__ghost { height: min(100%, 128vw); bottom: 7%; }
  .lock__num { font-size: min(37cqw, 70cqh); padding-bottom: 6%; }
  .gate input { letter-spacing: .3em; }
}
@media (max-height: 520px) { .gate__label { display: none; } .lock__ghost { height: 118%; } }
@media (prefers-reduced-motion: reduce) { .lock, .lock * { animation-duration: .01s !important; animation-delay: 0s !important; transition-duration: .01s !important; } }
