@property --hue {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

@property --angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

:root {
  --bg: #06050d;
  --ink: #f6f4ff;
  --ink-soft: rgba(246, 244, 255, 0.74);
  --ink-faint: rgba(246, 244, 255, 0.5);
  --glass: rgba(255, 255, 255, 0.07);
  --glass-line: rgba(255, 255, 255, 0.16);
  --font-display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --font-body: "Space Grotesk", "Segoe UI", system-ui, sans-serif;

  /* set by main.js: pointer position in -1..1 */
  --mx: 0;
  --my: 0;

  animation: hue-spin 18s linear infinite;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- background layers ---------- */

.aurora {
  position: fixed;
  inset: -20%;
  z-index: 0;
  filter: blur(80px) saturate(140%);
  opacity: 0.55;
}

.aurora span {
  position: absolute;
  width: 55vmax;
  height: 55vmax;
  border-radius: 50%;
  mix-blend-mode: screen;
  animation: drift 22s ease-in-out infinite alternate;
}

.aurora span:nth-child(1) {
  top: 0;
  left: 5%;
  background: radial-gradient(circle, #7b2cff 0%, transparent 65%);
}

.aurora span:nth-child(2) {
  top: 10%;
  right: 0;
  background: radial-gradient(circle, #ff2e9a 0%, transparent 65%);
  animation-duration: 27s;
  animation-delay: -8s;
}

.aurora span:nth-child(3) {
  top: -10%;
  left: 35%;
  background: radial-gradient(circle, #00c2ff 0%, transparent 65%);
  animation-duration: 31s;
  animation-delay: -15s;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
}

.veil {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 45% at 50% 46%, rgba(6, 5, 13, 0.62), transparent 70%),
    radial-gradient(ellipse at center, transparent 55%, rgba(6, 5, 13, 0.7) 100%);
}

.veil::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  width: 520px;
  height: 520px;
  margin: -260px 0 0 -260px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, hsla(calc(var(--hue) + 280), 100%, 65%, 0.28), transparent 62%);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 0.6s ease;
  will-change: transform;
}

.cursor-glow.is-on {
  opacity: 1;
}

/* ---------- chrome ---------- */

.topbar,
.footbar {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px clamp(16px, 4vw, 40px);
}

.topbar {
  top: 0;
  padding-top: max(22px, env(safe-area-inset-top));
}

.footbar {
  bottom: 0;
  padding-bottom: max(22px, env(safe-area-inset-bottom));
  font-size: 0.82rem;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

.brand b {
  font-weight: 300;
  color: var(--ink-faint);
}

.lang {
  appearance: none;
  border: 1px solid var(--glass-line);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  font: 500 0.78rem/1 var(--font-display);
  letter-spacing: 0.08em;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
}

.lang:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.hint {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.mouse {
  position: relative;
  width: 16px;
  height: 24px;
  border: 1.5px solid var(--ink-faint);
  border-radius: 9px;
}

.mouse::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 5px;
  width: 2px;
  height: 5px;
  margin-left: -1px;
  border-radius: 2px;
  background: var(--ink);
  animation: scroll-dot 1.8s ease-in-out infinite;
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  z-index: 3;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 96px 16px;
  pointer-events: none;
}

.tilt {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  /* Kept flat on purpose: preserve-3d combined with backdrop-filter made the whole
     hero randomly disappear in Chromium. Depth comes from per-layer parallax instead. */
  transform:
    perspective(1100px)
    rotateX(calc(var(--my) * -9deg))
    rotateY(calc(var(--mx) * 12deg));
  will-change: transform;
}

.tilt > * {
  --depth: 0;
  pointer-events: auto;
  transform: translate3d(
    calc(var(--mx) * var(--depth) * 1px),
    calc(var(--my) * var(--depth) * -0.6px),
    0
  );
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 12px;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font: 500 0.72rem/1 var(--font-display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  --depth: 18;
  animation: rise 1s 0.1s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: hsl(calc(var(--hue) + 140) 100% 60%);
  box-shadow: 0 0 0 0 hsla(calc(var(--hue) + 140), 100%, 60%, 0.7);
  animation: pulse 2s ease-out infinite;
}

.title {
  margin: 28px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--font-display);
  line-height: 0.92;
  --depth: 30;
}

.word {
  display: inline-flex;
}

.word--main {
  font-weight: 800;
  font-size: clamp(3.1rem, 15vw, 11.5rem);
  letter-spacing: -0.035em;
}

.word--sub {
  align-items: center;
  gap: 0.9em;
  margin-top: 0.55em;
  font-weight: 300;
  font-size: clamp(1rem, 3.4vw, 2.1rem);
  letter-spacing: 0.6em;
  margin-right: -0.6em; /* compensate trailing letter-spacing */
  color: var(--ink);
}

.word--sub > span {
  display: inline-flex;
}

.word--sub i {
  display: block;
  width: clamp(28px, 7vw, 80px);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ink-soft), transparent);
}

.word--sub i:last-child {
  margin-left: -0.6em;
}

/* single letters, built by main.js */
.ch {
  --h: calc(var(--hue) + var(--i) * 34);
  --lift: 0;
  display: inline-block;
  animation: letter-in 1.1s calc(0.25s + var(--i) * 0.07s) cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.ch > span {
  display: inline-block;
  transform:
    translateY(calc(var(--lift) * -0.12em))
    scale(calc(1 + var(--lift) * 0.1));
  transition: transform 0.12s linear;
  animation: bob 5s calc(var(--i) * -0.45s) ease-in-out infinite;
}

.word--main .ch > span {
  color: hsl(var(--h) 100% 70%);
  /* 3D extrusion: direction follows the pointer */
  --ex: calc(var(--mx) * -1px);
  --ey: calc(1px + var(--my) * -0.6px);
  text-shadow:
    calc(var(--ex) * 1) calc(var(--ey) * 1) 0 hsl(var(--h) 90% 58%),
    calc(var(--ex) * 2) calc(var(--ey) * 2) 0 hsl(var(--h) 88% 52%),
    calc(var(--ex) * 3) calc(var(--ey) * 3) 0 hsl(var(--h) 86% 46%),
    calc(var(--ex) * 4) calc(var(--ey) * 4) 0 hsl(var(--h) 84% 40%),
    calc(var(--ex) * 5) calc(var(--ey) * 5) 0 hsl(var(--h) 82% 34%),
    calc(var(--ex) * 6) calc(var(--ey) * 6) 0 hsl(var(--h) 80% 28%),
    calc(var(--ex) * 7) calc(var(--ey) * 7) 0 hsl(var(--h) 78% 22%),
    calc(var(--ex) * 9) calc(var(--ey) * 12) 18px rgba(0, 0, 0, 0.55),
    0 0 42px hsla(var(--h), 100%, 60%, calc(0.35 + var(--lift) * 0.5));
}

.word--sub .ch > span {
  text-shadow: 0 0 18px hsla(var(--h), 100%, 70%, 0.7);
}

.tagline {
  margin: 34px 0 0;
  max-width: 30ch;
  font-size: clamp(1.1rem, 2.4vw, 1.5rem);
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
  text-wrap: balance;
  text-shadow: 0 2px 18px rgba(6, 5, 13, 0.85), 0 0 4px rgba(6, 5, 13, 0.6);
  --depth: 12;
  animation: rise 1s 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.sub {
  margin: 12px 0 0;
  max-width: 40ch;
  font-size: clamp(0.92rem, 1.6vw, 1.05rem);
  line-height: 1.5;
  color: var(--ink-soft);
  text-wrap: balance;
  text-shadow: 0 2px 14px rgba(6, 5, 13, 0.9), 0 0 3px rgba(6, 5, 13, 0.7);
  --depth: 6;
  animation: rise 1s 1.05s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.wave-btn {
  position: relative;
  margin-top: 34px;
  padding: 15px 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(10, 8, 22, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--ink);
  font: 500 0.82rem/1 var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  isolation: isolate;
  --depth: 22;
  transition: scale 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  animation: rise 1s 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.wave-btn::before {
  content: "";
  position: absolute;
  inset: -1.5px;
  z-index: -1;
  border-radius: inherit;
  padding: 1.5px;
  background: conic-gradient(from var(--angle), #ff3ea5, #ffb03e, #3effa8, #3ec5ff, #a03eff, #ff3ea5);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: spin-border 4s linear infinite;
}

.wave-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  border-radius: inherit;
  background: conic-gradient(from var(--angle), #ff3ea5, #ffb03e, #3effa8, #3ec5ff, #a03eff, #ff3ea5);
  filter: blur(18px);
  opacity: 0.35;
  transition: opacity 0.3s ease;
  animation: spin-border 4s linear infinite;
}

.wave-btn:hover {
  scale: 1.05;
}

.wave-btn:hover::after {
  opacity: 0.75;
}

.wave-btn:active {
  scale: 0.97;
}

.wave-btn:focus-visible,
.lang:focus-visible,
.brand:focus-visible {
  outline: 2px solid hsl(calc(var(--hue) + 190) 100% 70%);
  outline-offset: 4px;
}

/* 404 */
.title--404 .word--main {
  font-size: clamp(4rem, 26vw, 15rem);
}

.home-link {
  text-decoration: none;
  display: inline-block;
}

/* ---------- animations ---------- */

@keyframes hue-spin {
  to { --hue: 360; }
}

@keyframes spin-border {
  to { --angle: 360deg; }
}

@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(8vw, 6vh) scale(1.15); }
  100% { transform: translate(-6vw, 10vh) scale(0.95); }
}

@keyframes letter-in {
  from {
    opacity: 0;
    transform: perspective(500px) translateY(0.4em) rotateX(-80deg);
    filter: blur(12px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

@keyframes bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -0.05em; }
}

@keyframes rise {
  from {
    opacity: 0;
    translate: 0 24px;
    filter: blur(8px);
  }
  to {
    opacity: 1;
    translate: 0 0;
    filter: blur(0);
  }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 hsla(calc(var(--hue) + 140), 100%, 60%, 0.7); }
  100% { box-shadow: 0 0 0 12px hsla(calc(var(--hue) + 140), 100%, 60%, 0); }
}

@keyframes scroll-dot {
  0% { opacity: 0; transform: translateY(0); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateY(8px); }
}

/* ---------- responsive ---------- */

@media (max-width: 560px) {
  .footbar {
    font-size: 0.74rem;
  }

  .brand span {
    font-size: 0.82rem;
  }

  .word--sub {
    letter-spacing: 0.45em;
    margin-right: -0.45em;
  }
}

@media (hover: none) {
  .cursor-glow {
    display: none;
  }

  .mouse {
    border-radius: 50%;
    width: 18px;
    height: 18px;
  }

  .mouse::after {
    top: 50%;
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    animation: tap 1.8s ease-in-out infinite;
  }
}

@keyframes tap {
  0%, 100% { transform: scale(0.6); opacity: 0.4; }
  50% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    animation-duration: 90s;
  }

  .aurora span,
  .ch > span,
  .mouse::after {
    animation: none;
  }

  .ch,
  .badge,
  .tagline,
  .sub,
  .wave-btn {
    animation-duration: 0.01s;
    animation-delay: 0s;
  }
}
