/* Device side of the XP reveal: the /xp page's rain, running upwards. */

:root {
  --xp-stream-shape: 9vw;
}

/* The reveal replaces the phone UI, so nothing shows through the overlay. */
body.xp-reveal .container,
body.xp-reveal .emoji-container {
  visibility: hidden;
}

.xp-stream {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8vw;
  box-sizing: border-box;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0s linear 0.5s;
}

.xp-stream.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease, visibility 0s;
}

.xp-stream-rain {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.xp-stream-message {
  position: relative;
  margin: 0;
  text-align: center;
  font-family: var(--display-font);
  font-size: 7vw;
  font-weight: 700;
  line-height: 1.25;
  color: var(--turn-primary);
  text-shadow: 0 0 1.5vw rgba(255, 255, 255, 0.9);
  animation: xp-stream-pulse 2.4s ease-in-out infinite;
}

/* Final tally: no more waiting, so the message lands instead of pulsing. */
.xp-stream.result .xp-stream-message {
  font-size: 8.5vw;
  animation: xp-stream-land 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.35) both;
}

@keyframes xp-stream-land {
  from {
    opacity: 0;
    transform: scale(0.82);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes xp-stream-pulse {
  0%, 100% {
    opacity: 0.75;
  }
  50% {
    opacity: 1;
  }
}

.xp-stream-shape {
  position: absolute;
  /* Starts just below the screen and leaves through the top */
  bottom: calc(-1 * var(--xp-stream-shape));
  width: var(--xp-stream-shape);
  height: var(--xp-stream-shape);
  will-change: transform;
  animation: xp-stream-rise linear forwards;
}

@keyframes xp-stream-rise {
  from {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  12% {
    opacity: 0.95;
  }
  to {
    transform: translateY(calc(-100vh - 2 * var(--xp-stream-shape)))
      rotate(var(--xp-stream-spin, 180deg));
    opacity: 0.95;
  }
}

@media (prefers-reduced-motion: reduce) {
  .xp-stream-shape {
    display: none;
  }

  .xp-stream-message,
  .xp-stream.result .xp-stream-message {
    animation: none;
    opacity: 1;
  }
}
