:root {
  --bg: #060706;
  --ink: #f4f0e8;
  --muted: rgba(244, 240, 232, 0.54);
  --quiet: rgba(244, 240, 232, 0.18);
  --line: rgba(244, 240, 232, 0.28);
  --good: #c9f7df;
  --good-bright: #effff5;
  --bad: #ff9a8d;
  --bad-deep: #5b1d1a;
  --glass: rgba(9, 10, 9, 0.58);
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SF Mono", SFMono-Regular, ui-monospace, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button,
input {
  font: inherit;
}

#field {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background:
    radial-gradient(circle at 51% 45%, rgba(255, 255, 255, 0.075), transparent 30%),
    linear-gradient(135deg, #090a08 0%, #060706 48%, #0f1110 100%);
}

.grain {
  position: fixed;
  inset: -80px;
  pointer-events: none;
  opacity: 0.22;
  mix-blend-mode: screen;
  background-image:
    repeating-radial-gradient(circle at 18% 31%, rgba(255, 255, 255, 0.34) 0 0.7px, transparent 0.8px 2.7px),
    repeating-radial-gradient(circle at 82% 64%, rgba(255, 255, 255, 0.2) 0 0.8px, transparent 0.9px 3.1px);
  filter: contrast(170%);
  animation: drift 11s steps(2, end) infinite;
}

.gate {
  position: relative;
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: clamp(24px, 5vw, 64px);
  isolation: isolate;
}

.gate::before,
.gate::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
}

.gate::before {
  background:
    linear-gradient(90deg, rgba(244, 240, 232, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(244, 240, 232, 0.04) 1px, transparent 1px);
  background-size: 68px 68px;
  mask-image: radial-gradient(circle at center, black 0, transparent 69%);
  opacity: 0.28;
}

.gate::after {
  background: radial-gradient(circle at center, transparent 0 36%, rgba(0, 0, 0, 0.42) 76%, rgba(0, 0, 0, 0.72) 100%);
}

.panel {
  position: relative;
  display: grid;
  width: min(720px, 100%);
  justify-items: center;
  gap: clamp(18px, 3vh, 28px);
  padding: 2px 0 10svh;
}

.signal {
  display: grid;
  grid-template-columns: repeat(4, 6px);
  gap: 8px;
  height: 10px;
  margin: 0;
  opacity: 0.74;
}

.signal span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--quiet);
  box-shadow: 0 0 0 rgba(244, 240, 232, 0);
  animation: blink 2.6s ease-in-out infinite;
}

.signal span:nth-child(2) {
  animation-delay: 0.22s;
}

.signal span:nth-child(3) {
  animation-delay: 0.44s;
}

.signal span:nth-child(4) {
  animation-delay: 0.66s;
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: center;
  max-width: 100%;
  margin: 0;
  font-size: clamp(58px, 14vw, 154px);
  font-weight: 700;
  line-height: 0.86;
  letter-spacing: 0;
  text-align: center;
  text-shadow:
    0 0 28px rgba(255, 255, 255, 0.14),
    0 26px 80px rgba(0, 0, 0, 0.78);
  transform: translate3d(0, 0, 0);
  transition: color 180ms ease, filter 180ms ease, transform 220ms ease;
}

.brand .dot {
  color: rgba(244, 240, 232, 0.68);
}

.entry {
  display: grid;
  grid-template-columns: 1fr 0;
  width: min(430px, 100%);
  min-height: 58px;
  margin: 0;
}

.input-shell {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 58px;
  padding: 0 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.018)),
    var(--glass);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 18px 70px rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(18px);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: 0 18px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0;
  caret-color: transparent;
}

input::selection {
  color: #07100c;
  background: var(--good);
}

.terminal-cursor {
  position: absolute;
  top: 50%;
  left: 18px;
  z-index: 2;
  width: 12px;
  height: 24px;
  background: var(--ink);
  box-shadow: 0 0 18px rgba(244, 240, 232, 0.42);
  pointer-events: none;
  transform: translateY(-50%);
  will-change: opacity;
  animation: caret 1.04s steps(2, end) infinite;
}

.cursor-measurer {
  position: fixed;
  top: -1000px;
  left: -1000px;
  visibility: hidden;
  white-space: pre;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0;
}

.entry button {
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
}

.status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.gate[data-state="typing"] .input-shell {
  border-color: rgba(244, 240, 232, 0.46);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 0 5px rgba(244, 240, 232, 0.03),
    0 18px 70px rgba(0, 0, 0, 0.44);
}

.gate[data-state="checking"] .brand {
  filter: blur(0.4px);
}

.gate[data-state="checking"] .input-shell {
  border-color: rgba(244, 240, 232, 0.62);
}

.gate[data-state="good"] .brand {
  color: var(--good-bright);
  filter: drop-shadow(0 0 22px rgba(201, 247, 223, 0.32));
  transform: scale(1.015);
}

.gate[data-state="good"] .brand .dot {
  color: var(--good);
}

.gate[data-state="good"] .input-shell {
  border-color: rgba(201, 247, 223, 0.88);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 0 0 5px rgba(201, 247, 223, 0.08),
    0 0 60px rgba(201, 247, 223, 0.14),
    0 24px 90px rgba(0, 0, 0, 0.48);
}

.gate[data-state="good"] .status {
  color: var(--good);
}

.gate[data-state="bad"] {
  animation: reject 380ms cubic-bezier(0.35, 0, 0.2, 1);
}

.gate[data-state="bad"] .brand {
  color: rgba(244, 240, 232, 0.84);
  filter: blur(1.1px) contrast(1.3);
}

.gate[data-state="bad"] .input-shell {
  border-color: rgba(255, 154, 141, 0.76);
  background:
    linear-gradient(180deg, rgba(255, 154, 141, 0.11), rgba(255, 255, 255, 0.018)),
    var(--glass);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 5px rgba(255, 154, 141, 0.04),
    0 18px 70px rgba(0, 0, 0, 0.44);
}

.gate[data-state="bad"] .status {
  color: var(--bad);
}

.gate.is-opening::before {
  animation: grid-open 620ms cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

.gate.is-opening::after {
  background:
    linear-gradient(90deg, transparent 0 calc(50% - 1px), rgba(239, 255, 245, 0.94) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    radial-gradient(circle at center, rgba(239, 255, 245, 0.18), rgba(0, 0, 0, 0.9) 64%);
  animation: aperture 620ms cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

body.leaving .panel {
  animation: leave 520ms cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

@keyframes blink {
  0%,
  100% {
    background: var(--quiet);
    box-shadow: 0 0 0 rgba(244, 240, 232, 0);
  }
  40% {
    background: rgba(244, 240, 232, 0.7);
    box-shadow: 0 0 18px rgba(244, 240, 232, 0.28);
  }
}

@keyframes caret {
  0%,
  68% {
    opacity: 1;
  }
  69%,
  100% {
    opacity: 0.16;
  }
}

@keyframes drift {
  0% {
    transform: translate3d(0, 0, 0);
  }
  25% {
    transform: translate3d(-14px, 8px, 0);
  }
  50% {
    transform: translate3d(10px, -12px, 0);
  }
  75% {
    transform: translate3d(16px, 10px, 0);
  }
  100% {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes reject {
  0%,
  100% {
    transform: translateX(0);
  }
  22% {
    transform: translateX(-10px);
  }
  44% {
    transform: translateX(8px);
  }
  66% {
    transform: translateX(-4px);
  }
}

@keyframes grid-open {
  to {
    opacity: 0.82;
    transform: scaleX(1.18);
  }
}

@keyframes aperture {
  0% {
    clip-path: inset(0 50% 0 50%);
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  100% {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }
}

@keyframes leave {
  to {
    opacity: 0;
    filter: blur(8px);
    transform: scale(1.04);
  }
}

@media (max-width: 560px) {
  .gate {
    padding: 20px;
  }

  .panel {
    gap: 18px;
    padding-bottom: 8svh;
  }

  .brand {
    font-size: clamp(54px, 18vw, 88px);
  }

  .entry {
    width: min(360px, 100%);
  }

  .input-shell {
    min-height: 54px;
    padding: 0 15px;
  }

  input,
  .cursor-measurer {
    font-size: 18px;
  }

  input {
    padding: 0 15px;
  }

  .terminal-cursor {
    left: 15px;
    height: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
