:root {
  --box-size: 150px;
}

body {
  margin: 0;
  background-color: #0e0e0e;
  font-family: sans-serif;
  overflow-x: hidden;
}

.scroll-track {
  height: 300vh; /* 3 screens long to provide scroll depth */
}

.sticky-wrapper {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.scene {
  width: var(--box-size);
  height: var(--box-size);
  perspective: 800px;
}

.box {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-20deg) rotateY(45deg);
}

.face {
  position: absolute;
  width: var(--box-size);
  height: var(--box-size);
  background: #111;
  border: 1px solid #2a2a2a;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.8);
}

.face::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.2;
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* Positioning */
.front  { transform: translateZ(75px); }
.back   { transform: rotateY(180deg) translateZ(75px); }
.left   { transform: rotateY(-90deg) translateZ(75px); }
.right  { transform: rotateY(90deg) translateZ(75px); }
.bottom {
  transform: rotateX(-90deg) translateZ(75px);
  background: #050505;
  box-shadow: 0 0 60px 20px rgba(0, 0, 0, 0.9);
}

.box-contents {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-style: preserve-3d;
}

.item-wrapper {
  position: absolute;
  transform-style: preserve-3d;
}

.spark {
  position: absolute;
  margin-top: -10px; margin-left: -10px;
  width: 20px;
  height: 20px;
  background: radial-gradient(circle, #222222, #000000);
  border-radius: 50%;
  box-shadow: 0 0 15px 5px rgba(0, 0, 0, 0.8), 
              0 0 30px 10px rgba(0, 0, 0, 0.6);
  animation: float 3s ease-in-out infinite alternate;
}

.fragment {
  position: absolute;
  margin-top: -15px; margin-left: -15px;
  width: 30px;
  height: 30px;
  background: rgba(10, 10, 10, 0.9);
  border: 1px solid rgba(40, 40, 40, 0.5);
  /* Creates a diamond/geometric shape */
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  /* 3D rotation property */
  transform: perspective(500px) rotateY(45deg) rotateX(45deg);
  animation: spin 6s linear infinite;
}

.core {
  position: absolute;
  margin-top: -20px; margin-left: -20px;
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px); /* Glassmorphism effect */
  border: 2px solid rgba(50, 50, 50, 0.6);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.9);
  transform-style: preserve-3d;
  animation: float 4s ease-in-out infinite alternate-reverse;
}

/* Inner core of the idea */
.core::after {
  content: '';
  position: absolute;
  top: 25%; left: 25%;
  width: 50%; height: 50%;
  background: #000;
  filter: blur(2px);
}

.ring {
  position: absolute;
  margin-top: -25px; margin-left: -25px;
  width: 50px;
  height: 50px;
  border: 4px solid rgba(40, 40, 40, 0.8);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(0,0,0,0.8), inset 0 0 10px rgba(0,0,0,0.8);
  animation: spin 8s linear infinite reverse;
}

.triangle {
  position: absolute;
  margin-top: -20px; margin-left: -20px;
  width: 40px;
  height: 40px;
  background: rgba(15, 15, 15, 0.9);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  animation: float 5s ease-in-out infinite alternate;
}


/* apply these keyframes to make these objects feel like they are floating out of the box */

@keyframes float {
  from { transform: translateY(0px) rotate(0deg); }
  to { transform: translateY(-40px) rotate(10deg); }
}

@keyframes spin {
  from { transform: perspective(500px) rotateY(0deg) rotateX(45deg); }
  to { transform: perspective(500px) rotateY(360deg) rotateX(45deg); }
}

.top {
  transform-origin: top;
  /* Starting position: Closed (90deg) */
  transform: translateZ(-75px) rotateX(90deg); 
  background: #111;
  z-index: 2;
}

.lightbulb-iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 250px;
  height: 250px;
  transform: translate(150px, -50%) scale(0.35); /* move beside the box and scale down */
  border: none;
  pointer-events: none; /* so it doesn't block scroll */
}

.light-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #f7f5ee;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity 0.1s;
}

.typewriter-container {
  position: fixed;
  bottom: 30px;
  left: 30px;
  z-index: 1000;
}

#typewriter {
  color: rgb(199, 199, 199); 
  font-size: 1rem;
  border-right: 3px solid #ffffff;
  padding-right: 5px;
  max-width: calc(100vw - 60px);
  word-wrap: break-word;
  overflow-wrap: break-word;
  margin: 0;
  font-family: 'Type Machine', 'Courier New', Courier, monospace;
  animation: blink 0.7s infinite;
}

@keyframes blink {
  0%, 100% { border-color: transparent; }
  50% { border-color: rgb(199, 199, 199); }
}

.sound-toggle {
  position: fixed;
  top: 30px;
  right: 30px;
  background: transparent;
  color: rgb(199, 199, 199);
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: 0.7;
  z-index: 1000;
}

.sound-toggle:hover {
  opacity: 1;
}

.loader-container {
  position: fixed;
  /* bottom: 30px;
  right: 30px; */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
}

.loader-bar {
  width: 0px; 
  height: 2px;
  background-color: rgb(199, 199, 199);
  max-width: 150px;
  transition: width 0.1s ease-out;
}

#loader-text {
  color: rgb(199, 199, 199);
  font-family: 'Type Machine', 'Courier New', Courier, monospace;
  font-size: 1rem;
}

.start-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #0e0e0e;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-family: 'Type Machine', 'Courier New', Courier, monospace;
  font-size: 1.5rem;
  cursor: pointer;
  transition: opacity 0.5s ease-out;
}