*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --void: #050505;
  --ink: #000000;
  --bone: rgba(232, 223, 200, 0.86);
  --bone-dim: rgba(232, 223, 200, 0.55);
  --bone-faint: rgba(232, 223, 200, 0.25);
  --bone-ghost: rgba(232, 223, 200, 0.14);
  --font-serif: "Century Schoolbook", "Georgia", "Times New Roman", serif;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font-serif);
}

body {
  overflow: hidden;
}

.portal-stage {
  position: relative;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--ink);
  display: grid;
  place-items: center;
  perspective: 800px;
}

.portal-stage::before {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at center, rgba(232, 223, 200, 0.06), transparent 55%),
    radial-gradient(circle at center, rgba(232, 223, 200, 0.03), transparent 70%);
  opacity: 0.85;
  pointer-events: none;
  z-index: 0;
}

.portal-fragments {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.portal-fragment-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.fragment {
  position: absolute;
  white-space: nowrap;
  color: rgba(232, 223, 200, 0.7);
  font-size: clamp(0.7rem, 1.6vmin, 1.05rem);
  letter-spacing: 0.12em;
  text-transform: lowercase;
  mix-blend-mode: screen;
  will-change: transform, opacity, filter;
}

.portal-core {
  position: relative;
  width: min(105vmin, 660px);
  height: min(105vmin, 660px);
  display: grid;
  place-items: center;
  z-index: 2;
  transform-style: preserve-3d;
}

.portal-core::before {
  content: none;
}

.portal-core:hover::before,
.portal-core:focus-within::before,
.portal-core.is-awake::before {
  opacity: 0;
  transform: none;
}

.portal-ampersand {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotateY(0deg);
  transform-origin: 50% 50%;
  transform-style: preserve-3d;
  font-size: clamp(2.6rem, 6vmin, 4.2rem);
  letter-spacing: 0.08em;
  color: rgba(232, 223, 200, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 360ms ease;
  will-change: transform;
  text-shadow:
    0 0 12px rgba(232, 223, 200, 0.32),
    0 0 28px rgba(232, 223, 200, 0.18);
  filter: drop-shadow(0 0 10px rgba(232, 223, 200, 0.22));
  z-index: 3;
}

.portal-core:hover .portal-ampersand,
.portal-core:focus-within .portal-ampersand,
.portal-core.is-awake .portal-ampersand {
  opacity: 0.65;
  animation: ampersand-spin 14s linear infinite;
  pointer-events: auto;
}

@keyframes ampersand-spin {
  0% {
    transform: translate(-50%, -50%) rotateY(0deg) scaleX(1);
  }
  25% {
    transform: translate(-50%, -50%) rotateY(90deg) scaleX(0.06);
  }
  50% {
    transform: translate(-50%, -50%) rotateY(180deg) scaleX(1);
  }
  75% {
    transform: translate(-50%, -50%) rotateY(270deg) scaleX(0.06);
  }
  100% {
    transform: translate(-50%, -50%) rotateY(360deg) scaleX(1);
  }
}

.portal-core.is-engaged .portal-ampersand {
  opacity: 0;
  pointer-events: none;
}

.portal-form {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  filter: blur(6px);
  pointer-events: none;
  transition: opacity 360ms ease, transform 360ms ease, filter 360ms ease;
  z-index: 2;
}

.portal-core:focus-within .portal-form,
.portal-core.is-awake .portal-form {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
  pointer-events: auto;
}

.portal-form input {
  min-width: min(52vmin, 280px);
  background: transparent;
  border: none;
  border-bottom: none;
  color: #ffffff;
  -webkit-text-fill-color: #ffffff;
  font-family: var(--font-serif);
  font-size: clamp(1rem, 2.2vmin, 1.35rem);
  letter-spacing: 0.04em;
  padding: 6px 2px;
  outline: none;
  text-align: center;
  direction: ltr;
  caret-color: #ffffff;
}

.portal-form input::placeholder {
  color: var(--bone-faint);
}

.portal-form input:focus-visible {
  outline: none;
}

.portal-form input:-webkit-autofill,
.portal-form input:-webkit-autofill:hover,
.portal-form input:-webkit-autofill:focus {
  -webkit-text-fill-color: #ffffff;
  box-shadow: 0 0 0 1000px var(--ink) inset;
  transition: background-color 9999s ease-out 0s;
}

.portal-hint {
  position: absolute;
  top: calc(50% + 38px);
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: var(--bone-faint);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 360ms ease, transform 360ms ease;
  pointer-events: none;
}

.portal-core:hover .portal-hint,
.portal-core:focus-within .portal-hint,
.portal-core.is-awake .portal-hint {
  opacity: 0.9;
  transform: translateY(0);
}

.portal-status {
  position: absolute;
  top: calc(50% + 72px);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  color: rgba(232, 223, 200, 0.45);
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}

.portal-status.is-visible {
  opacity: 1;
}

.portal-core.is-confirmed .portal-form {
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  filter: blur(6px);
  pointer-events: none;
}

.portal-core.is-confirmed::before {
  opacity: 0.25;
}

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

@media (max-width: 520px) {
  .portal-form input {
    min-width: min(70vw, 250px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-ampersand {
    animation: none;
  }

  .portal-form,
  .portal-hint,
  .portal-core::before {
    transition: none;
  }
}
