* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #06050f; }

.gate {
  --mx: 50vw;
  --my: 50vh;
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, Roboto, sans-serif;
  perspective: 1100px;
  -webkit-tap-highlight-color: transparent;
}

.gate-stars { position: absolute; inset: 0; width: 100%; height: 100%; }

.gate-aurora {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  mix-blend-mode: screen;
  pointer-events: none;
  animation: gate-orbit 18s ease-in-out infinite alternate;
}
.gate-aurora.a1 { background: radial-gradient(circle, #7c5cff 0%, transparent 62%); top: -25vmax; left: -20vmax; }
.gate-aurora.a2 { background: radial-gradient(circle, #2dd4bf 0%, transparent 62%); bottom: -30vmax; right: -20vmax; animation-duration: 22s; animation-delay: -6s; }
.gate-aurora.a3 { background: radial-gradient(circle, #f472b6 0%, transparent 60%); top: 20%; left: 35%; width: 50vmax; height: 50vmax; opacity: 0.35; animation-duration: 26s; animation-delay: -12s; }
@keyframes gate-orbit {
  0% { transform: translate(0, 0) scale(1) rotate(0deg); }
  50% { transform: translate(12vmax, 8vmax) scale(1.25) rotate(120deg); }
  100% { transform: translate(-8vmax, 14vmax) scale(0.9) rotate(240deg); }
}

.gate-grid {
  position: absolute;
  left: -50%;
  right: -50%;
  bottom: -10%;
  height: 55%;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(160, 140, 255, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(160, 140, 255, 0.22) 1px, transparent 1px);
  background-size: 60px 60px;
  transform: rotateX(72deg);
  transform-origin: top;
  mask-image: linear-gradient(to top, #000 10%, transparent 85%);
  animation: gate-grid 2.6s linear infinite;
  transition: opacity 0.6s;
}
@keyframes gate-grid { to { background-position: 0 60px, 0 0; } }

.gate::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(420px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.09), transparent 60%);
}

.gate-noise {
  position: absolute;
  inset: -50%;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: gate-noise 0.6s steps(4) infinite;
}
@keyframes gate-noise {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-1%, 3%); }
}

/* Formas abstractas de vidro a subir e a rodar. */
.gate-shapes { position: absolute; inset: 0; pointer-events: none; transition: opacity 0.6s; }
.gate-shape {
  --size: 32px;
  position: absolute;
  bottom: -80px;
  width: var(--size);
  height: var(--size);
  opacity: 0;
  animation: gate-rise linear infinite;
}
.gate-shape.orb {
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, hsla(var(--h), 100%, 85%, 0.95), hsla(var(--h), 90%, 55%, 0.55) 55%, transparent 72%);
  box-shadow: 0 0 30px hsla(var(--h), 90%, 60%, 0.45);
}
.gate-shape.ring { border-radius: 50%; border: 2px solid hsla(var(--h), 95%, 72%, 0.8); box-shadow: 0 0 18px hsla(var(--h), 90%, 60%, 0.4), inset 0 0 12px hsla(var(--h), 90%, 60%, 0.35); }
.gate-shape.square {
  border-radius: 28%;
  background: linear-gradient(135deg, hsla(var(--h), 95%, 75%, 0.45), hsla(var(--h), 90%, 50%, 0.12));
  border: 1px solid hsla(var(--h), 95%, 80%, 0.5);
  backdrop-filter: blur(4px);
}
.gate-shape.pill { height: calc(var(--size) * 0.42); border-radius: 999px; background: linear-gradient(90deg, hsla(var(--h), 95%, 70%, 0.7), transparent); }
.gate-shape.tri {
  background: linear-gradient(160deg, hsla(var(--h), 95%, 78%, 0.75), hsla(var(--h), 90%, 50%, 0.2));
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
@keyframes gate-rise {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.9; }
  85% { opacity: 0.75; }
  100% { transform: translate(var(--drift), -118vh) rotate(var(--rot)); opacity: 0; }
}

.gate-card {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: min(460px, calc(100vw - 36px));
  padding: 48px 48px 44px;
  border-radius: 32px;
  text-align: center;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 30px 120px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(18px) saturate(140%);
  transform-style: preserve-3d;
  transition: transform 0.25s ease-out;
  /* backwards e não both: o estado final sobrepunha-se à inclinação feita em JS. */
  animation: gate-pop 1.1s cubic-bezier(0.2, 0.9, 0.2, 1.15) backwards;
}
.gate-card[hidden] { display: none; }
.gate-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1.5px;
  background: conic-gradient(from var(--ang, 0deg), #7c5cff, #2dd4bf, #38bdf8, #f472b6, #7c5cff);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: gate-spin 6s linear infinite;
  opacity: 0.85;
  pointer-events: none;
}
@property --ang { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes gate-spin { to { --ang: 360deg; } }
@keyframes gate-pop {
  from { opacity: 0; transform: translateY(40px) scale(0.85) rotateX(25deg); filter: blur(12px); }
  to { opacity: 1; transform: none; filter: none; }
}

.gate-logo {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border-radius: 26px;
  background: linear-gradient(145deg, #7c5cff, #2dd4bf 60%, #38bdf8);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2) inset, 0 18px 50px rgba(124, 92, 255, 0.45), 0 0 90px rgba(45, 212, 191, 0.3);
  transform: translateZ(60px);
  animation: gate-float 4s ease-in-out infinite;
}
.gate-logo svg { width: 60px; height: 60px; overflow: visible; }
.gate-logo .hex { fill: none; stroke: #fff; stroke-width: 6; stroke-linejoin: round; transform-origin: 50% 50%; animation: gate-hex 8s linear infinite; }
.gate-logo .core { fill: #fff; transform-origin: 50% 50%; animation: gate-core 2.4s ease-in-out infinite; }
.gate-logo.small { width: 64px; height: 64px; border-radius: 19px; }
.gate-logo.small svg { width: 42px; height: 42px; }
@keyframes gate-float {
  0%, 100% { transform: translateZ(60px) translateY(0) rotate(-3deg); }
  50% { transform: translateZ(60px) translateY(-10px) rotate(3deg); }
}
@keyframes gate-hex { to { transform: rotate(360deg); } }
@keyframes gate-core { 50% { transform: scale(0.7) rotate(180deg); opacity: 0.75; } }

.gate-title {
  position: relative;
  margin: 4px 0 0;
  font-size: clamp(40px, 11vw, 66px);
  white-space: nowrap;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(90deg, #fff, #c4b5fd, #5eead4, #7dd3fc, #fff);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transform: translateZ(40px);
  animation: gate-shine 6s linear infinite;
}
.gate-title::before,
.gate-title::after { content: attr(data-text); position: absolute; inset: 0; opacity: 0; }
.gate-title::before { color: #ff2d75; animation: gate-glitch 4.2s infinite steps(1); }
.gate-title::after { color: #00e5ff; animation: gate-glitch 4.2s infinite steps(1) reverse; }
@keyframes gate-shine { to { background-position: 300% 0; } }
@keyframes gate-glitch {
  0%, 88%, 100% { opacity: 0; transform: none; clip-path: none; }
  89% { opacity: 0.8; transform: translate(-4px, 1px); clip-path: inset(10% 0 55% 0); }
  91% { opacity: 0.8; transform: translate(4px, -2px); clip-path: inset(60% 0 8% 0); }
  93% { opacity: 0.8; transform: translate(-2px, 2px); clip-path: inset(35% 0 35% 0); }
  95% { opacity: 0; }
}

.gate-sub { min-height: 1.6em; margin: 0; font-size: clamp(16px, 2.4vw, 20px); color: rgba(255, 255, 255, 0.78); transform: translateZ(30px); }
.gate-caret { margin-left: 2px; color: #5eead4; animation: gate-blink 0.9s steps(1) infinite; }
@keyframes gate-blink { 50% { opacity: 0; } }

.gate-btn {
  position: relative;
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 17px 38px;
  border: 0;
  border-radius: 999px;
  font: 700 18px/1 inherit;
  letter-spacing: 0.02em;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(110deg, #7c5cff, #2dd4bf 50%, #38bdf8);
  background-size: 200% 100%;
  transform: translateZ(50px);
  transition: transform 0.18s ease-out, opacity 0.2s;
  animation: gate-shine 4s linear infinite, gate-pulse 2.4s ease-in-out infinite;
  overflow: hidden;
}
.gate-btn:disabled { cursor: default; opacity: 0.75; }
.gate-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s; }
.gate-btn:hover svg { transform: translateX(5px); }
.gate-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  animation: gate-sweep 3.2s ease-in-out infinite;
}
.gate-btn:focus-visible { outline: 3px solid #5eead4; outline-offset: 4px; }
@keyframes gate-pulse {
  0%, 100% { box-shadow: 0 10px 40px rgba(124, 92, 255, 0.45), 0 0 0 0 rgba(94, 234, 212, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.25) inset; }
  50% { box-shadow: 0 14px 60px rgba(45, 212, 191, 0.5), 0 0 0 14px rgba(94, 234, 212, 0), 0 0 0 1px rgba(255, 255, 255, 0.25) inset; }
}
@keyframes gate-sweep { 0%, 55% { left: -60%; } 100% { left: 130%; } }

/* Formulário do token. */
.gate-login { gap: 14px; padding-top: 40px; }
.gate-login h2 { margin: 6px 0 0; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.gate-muted { margin: -4px 0 6px; color: rgba(255, 255, 255, 0.7); font-size: 16px; }
.gate-login input {
  width: 100%;
  padding: 15px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(10, 8, 30, 0.55);
  color: #fff;
  font: 500 17px/1.2 inherit;
  letter-spacing: 0.08em;
  text-align: center;
  outline: none;
  transform: translateZ(30px);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.gate-login input:focus { border-color: #5eead4; box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.2), 0 0 40px rgba(124, 92, 255, 0.35); }
.gate-error { min-height: 1.2em; margin: 0; font-size: 14px; color: #fda4af; }
.gate-login .gate-btn { width: 100%; margin-top: 2px; }
.gate-card.arriving { animation: gate-arrive 0.9s cubic-bezier(0.2, 0.9, 0.2, 1.15) backwards; }
@keyframes gate-arrive {
  from { opacity: 0; transform: translateZ(-700px) scale(0.2) rotate(-20deg); filter: blur(10px); }
  to { opacity: 1; transform: none; filter: none; }
}
.gate-card.shake { animation: gate-shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes gate-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(5px); }
  30%, 50%, 70% { transform: translateX(-10px); }
  40%, 60% { transform: translateX(10px); }
}

.gate-spark {
  position: absolute;
  z-index: 5;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: hsl(var(--h), 95%, 68%);
  box-shadow: 0 0 12px hsl(var(--h), 95%, 60%);
  pointer-events: none;
  animation: gate-spark 1s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}
@keyframes gate-spark { to { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; } }

/* Saídas: o cartão é sugado pelo warp; no fim um clarão leva à aplicação. */
.gate-card.leaving { animation: gate-suck 0.9s cubic-bezier(0.6, 0, 0.9, 0.4) forwards; pointer-events: none; }
@keyframes gate-suck {
  40% { transform: scale(1.06); filter: none; }
  100% { transform: translateZ(-900px) scale(0.1) rotate(25deg); opacity: 0; filter: blur(8px); }
}
.gate-flash {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, #fff 0%, rgba(200, 190, 255, 0.9) 30%, transparent 70%);
}
.gate.done .gate-shapes,
.gate.done .gate-grid { opacity: 0; }
.gate.done .gate-flash { animation: gate-flash 1.3s ease-in forwards; }
@keyframes gate-flash { 0%, 45% { opacity: 0; } 100% { opacity: 1; } }

@media (max-width: 600px) {
  .gate-card { padding: 36px 26px 32px; border-radius: 28px; }
  .gate-logo { width: 78px; height: 78px; border-radius: 22px; }
  .gate-logo svg { width: 50px; height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  .gate *, .gate *::before, .gate *::after { animation: none !important; transition: none !important; }
}
