*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  overflow: hidden; background: #000; color: #ece8ff;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.stage {
  position: relative; height: 100vh; height: 100dvh; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 50%, rgba(95, 55, 210, 0.2) 0%, rgba(45, 15, 110, 0.07) 38%, transparent 66%);
}
.site-name {
  position: fixed; top: 22px; left: 28px; margin: 0;
  font-size: 13px; letter-spacing: 0.35em; text-transform: uppercase; opacity: 0.55;
}

/* Cube scene: float (bob) > cube (orientation, driven by cube.js). Viewed straight on; perspective adds the depth. */
.cube-scene { --size: min(56vmin, 480px); width: var(--size); height: var(--size); perspective: calc(var(--size) * 2.2); }
.cube-float, .cube-intro, .cube { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
/* Push the cube back half a side so the front face sits at the scene plane: it renders at exactly --size
   and perspective only shrinks the far edges, instead of the front face ballooning over the arrows. */
.cube-float { translate: 0 0 calc(var(--size) / -2); animation: cube-bob 5s ease-in-out infinite; }
.cube { transition: transform 800ms cubic-bezier(0.45, -0.25, 0.3, 1.25); }
@keyframes cube-bob {
  0%, 100% { transform: translateY(-4%); }
  50% { transform: translateY(4%); }
}
/* Intro: tumble in on a tilted axis at a steady, readable speed, overshoot slightly, then settle onto the home face.
   cube.js swaps `is-intro-pending` for `is-spinning-in` only after a frame has painted, so a slow first load can't
   swallow the spin before anything is on screen; the cube stays hidden until then.
   Runs on its own wrapper with a plain `transform` animation: Safari froze the spin when it animated the individual
   `rotate`/`scale` properties on the element whose `transform` cube.js drives. Content stays hidden until it lands. */
@media (prefers-reduced-motion: no-preference) {
  .cube-intro.is-intro-pending { visibility: hidden; }
  .cube-intro.is-spinning-in { animation: cube-spin-in 2.2s both; }
  .cube-intro.is-spinning-in .face-content { opacity: 0; visibility: hidden; }
}
@keyframes cube-spin-in {
  0% { transform: rotate3d(0.6, 1, 0.2, -540deg) scale3d(0.35, 0.35, 0.35); animation-timing-function: cubic-bezier(0.3, 0.55, 0.4, 1); }
  82% { transform: rotate3d(0.6, 1, 0.2, 7deg) scale3d(1.02, 1.02, 1.02); animation-timing-function: ease-in-out; }
  100% { transform: rotate3d(0.6, 1, 0.2, 0deg) scale3d(1, 1, 1); }
}

/* Glass faces: translucent so the far edges show through; only the current face carries readable content. */
.cube-face {
  position: absolute; inset: 0; display: grid; cursor: pointer; user-select: none;
  border-radius: calc(var(--size) * 0.09);
  background: linear-gradient(140deg, rgba(165, 125, 255, 0.3), rgba(95, 55, 215, 0.12) 55%, rgba(65, 25, 170, 0.24));
  border: 1px solid rgba(205, 185, 255, 0.55);
  box-shadow: inset 0 0 calc(var(--size) * 0.12) rgba(175, 145, 255, 0.4);
  transition: background 0.4s;
}
.cube-face::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.16), transparent 38%);
}
.cube-face.is-current {
  cursor: default; user-select: text;
  background: linear-gradient(140deg, rgba(110, 75, 220, 0.34), rgba(45, 20, 120, 0.4));
}
.is-current .face-content { text-shadow: 0 1px 8px rgba(15, 5, 45, 0.9); }
/* Clicks pass through the current face's glass to the side faces framing it; the face behind takes none. */
.cube-face.is-current, .cube-face.is-behind { pointer-events: none; }
.is-current .face-content { pointer-events: auto; }
.cube-face:not(.is-current):hover {
  background: linear-gradient(140deg, rgba(190, 155, 255, 0.45), rgba(125, 85, 240, 0.25) 55%, rgba(90, 50, 205, 0.36));
}
.face-content {
  display: flex; flex-direction: column; justify-content: center; justify-content: safe center; gap: 0.35em; min-height: 0;
  margin: 12%; overflow: auto; opacity: 0; visibility: hidden; transition: opacity 0.4s, visibility 0.4s;
  font-size: clamp(12px, calc(var(--size) * 0.036), 17px); line-height: 1.5;
}
.is-current .face-content { opacity: 1; visibility: visible; }
/* Paragraph-length copy (About): smaller type and a slimmer margin so it fits without scrolling. */
.face-content.face-content--long { margin: 9%; font-size: clamp(10.5px, calc(var(--size) * 0.03), 15px); line-height: 1.45; }

.face-content h1, .face-content h2 { margin: 0; }
.face-content .eyebrow { font-size: 0.8em; letter-spacing: 0.3em; text-transform: uppercase; color: #a993ff; }
.face-content .title { font-size: 1.8em; line-height: 1.15; font-weight: 700; }
.face-content p { margin: 0; }
.face-content ul { margin: 0.2em 0 0; padding-left: 1.1em; }
.face-content a { color: #d2c8ff; }

.cube-arrows button {
  position: fixed; z-index: 10; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(170, 145, 255, 0.35); background: rgba(20, 12, 40, 0.75);
  color: #c9beff; font-size: 18px; cursor: pointer;
}
.cube-arrows button:hover, .cube-arrows button:focus-visible { background: rgba(70, 45, 150, 0.8); }
.cube-arrows [data-arrow='ArrowUp'] { top: 18px; left: 50%; translate: -50% 0; }
.cube-arrows [data-arrow='ArrowDown'] { bottom: 18px; left: 50%; translate: -50% 0; }
.cube-arrows [data-arrow='ArrowLeft'] { left: 18px; top: 50%; translate: 0 -50%; }
.cube-arrows [data-arrow='ArrowRight'] { right: 18px; top: 50%; translate: 0 -50%; }
.hint { position: fixed; right: 24px; bottom: 22px; margin: 0; font-size: 12px; letter-spacing: 0.1em; opacity: 0.4; }

@media (max-width: 640px) {
  .stage { padding-bottom: 72px; }
  .cube-scene { --size: min(80vw, 50vh); }
  .face-content { margin: 10%; }
  /* Edge arrows would overlap a wide cube: gather them into a bottom row. */
  .cube-arrows { position: fixed; bottom: 18px; left: 50%; translate: -50% 0; display: flex; gap: 12px; z-index: 10; }
  .cube-arrows [data-arrow] { position: static; translate: none; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cube-float { animation: none; }
  .cube { transition-duration: 1ms; }
}
