@property --sky-angle {
  syntax: "<angle>";
  initial-value: 45deg;
  inherits: true;
}

:root {
  --star-tail-color: rgba(0, 0, 255, 0);
}

.sky-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

.night {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  animation: driftSky 240s ease-in-out infinite;
  animation-delay: var(--sky-delay, 0s);
}

@keyframes driftSky {
  0% {
    transform: rotate(45deg);
    --sky-angle: 45deg;
  }
  50% {
    transform: rotate(135deg);
    --sky-angle: 135deg;
  }
  100% {
    transform: rotate(45deg);
    --sky-angle: 45deg;
  }
}

.shooting_star {
  position: absolute;
  height: 2px;
  background: linear-gradient(-45deg, var(--accent), var(--star-tail-color));
  border-radius: 999px;
  filter: drop-shadow(0 0 6px var(--accent));
  opacity: 0; /* Invisible while resting */
  display: flex;
  align-items: center;
  justify-content: flex-end; /* Keep head of tail at the right */
}

.shooting_star.is-shooting {
  opacity: 1;
  animation:
    tail 3000ms ease-in-out forwards,
    shooting 3000ms ease-in-out forwards;
}

.shooting_star .star-icon {
  font-size: 1rem;
  color: var(--accent);
  font-variation-settings: "FILL" 1;
  /* Reset positioning to stay in flex flow */
  position: relative;
  /* Use translate to center the glyph on the 2px tail line */
  translate: 0.4rem 0;
  rotate: 90deg;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shooting_star.is-shooting .star-icon {
  animation: star-glow 3000ms ease-in-out forwards;
}

@keyframes tail {
  0% {
    width: 0;
  }
  30% {
    width: 100px;
  }
  100% {
    width: 0;
  }
}

@keyframes star-glow {
  0% {
    scale: 0;
    opacity: 0;
  }
  30% {
    scale: 1.2;
    opacity: 1;
  }
  100% {
    scale: 0;
    opacity: 0;
  }
}

@keyframes shooting {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(1000px);
  }
}
