/* Animation Keyframes */

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.2;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(1.1);
  }
}

@keyframes lightSway {
  0%,
  100% {
    transform: translateY(6px) rotate(-2deg);
  }
  50% {
    transform: translateY(1px) rotate(3deg);
  }
}

@keyframes lightGlow {
  0%,
  100% {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35), 0 0 10px currentColor;
    opacity: 0.9;
  }
  50% {
    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.4), 0 0 14px currentColor,
      0 0 22px currentColor;
    opacity: 1;
  }
}

@keyframes festiveLightDrop {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  80% {
    transform: translateY(110vh) rotate(8deg);
    opacity: 0.9;
  }
  100% {
    transform: translateY(120vh) rotate(12deg);
    opacity: 0;
  }
}

@keyframes festiveLightBulbDrop {
  0% {
    transform: translateY(6px) rotate(-2deg);
    opacity: 1;
  }
  80% {
    transform: translateY(110vh) rotate(12deg);
    opacity: 0.9;
  }
  100% {
    transform: translateY(120vh) rotate(16deg);
    opacity: 0;
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes sparkle {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.2);
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%) translateY(-100%) rotate(45deg);
  }
  100% {
    transform: translateX(100%) translateY(100%) rotate(45deg);
  }
}

@keyframes titleGlow {
  0%,
  100% {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8), 0 0 10px rgba(255, 215, 0, 0.5),
      0 0 20px rgba(255, 215, 0, 0.3);
  }
  50% {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8), 0 0 15px rgba(255, 215, 0, 0.7),
      0 0 30px rgba(255, 215, 0, 0.5);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

@keyframes messagePulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.05);
  }
}

@keyframes snowFall {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(120vh) translateX(50px) rotate(360deg);
    opacity: 0.8;
  }
}

@keyframes slideOnSnow {
  0%,
  100% {
    transform: rotate(0deg);
    transform-origin: center center;
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: rotate(-8deg);
    transform-origin: center center;
  }
  20%,
  40%,
  60%,
  80% {
    transform: rotate(8deg);
    transform-origin: center center;
  }
}

@keyframes scrollSlide {
  0% {
    transform: rotate(0deg);
    transform-origin: center center;
  }
  100% {
    transform: rotate(-360deg);
    transform-origin: center center;
  }
}

@keyframes shakeOffSnow {
  0%,
  100% {
    transform: rotate(0deg);
    transform-origin: center center;
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: rotate(-8deg);
    transform-origin: center center;
  }
  20%,
  40%,
  60%,
  80% {
    transform: rotate(8deg);
    transform-origin: center center;
  }
}

@keyframes dropToBottom {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(var(--drop-distance, calc(100vh - 200px)))
      rotate(360deg);
    opacity: 0.6;
  }
}

/* Background Animation */
body::before {
  animation: twinkle 20s ease-in-out infinite;
}

/* Background Falling Snowflakes */
.background-snow-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.background-snowflake {
  position: absolute;
  color: white;
  user-select: none;
  pointer-events: none;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
  will-change: transform, opacity;
}

/* Bottom Snow Accumulation - Persistent */
.bottom-snow-accumulation {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(
    to top,
    rgba(255, 255, 255, 0.8) 0%,
    rgba(255, 255, 255, 0.6) 20%,
    rgba(255, 255, 255, 0.4) 40%,
    rgba(255, 255, 255, 0.2) 60%,
    rgba(255, 255, 255, 0.05) 80%,
    rgba(255, 255, 255, 0) 100%
  );
  transition: height 0.3s ease, opacity 0.5s ease;
  opacity: 1;
}

.bottom-snow-accumulation.fade-out {
  opacity: 0;
  transition: opacity 0.5s ease, height 0.5s ease;
}

/* Cursor Shake Animation */
@keyframes cursorShake {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translate(-50%, -50%) rotate(-5deg);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translate(-50%, -50%) rotate(5deg);
  }
}

/* Card Shimmer Animation */
.card::before {
  animation: shimmer 3s ease-in-out infinite;
}

/* Title Glow Animation */
.main-title {
  animation: titleGlow 3s ease-in-out infinite;
}

/* Love Text Pulse Animation */
.love-text {
  animation: pulse 3s ease-in-out infinite;
}

.love-text:nth-child(2) {
  animation-delay: 0.5s;
}

.love-text:nth-child(3) {
  animation-delay: 1s;
}

.love-text:nth-child(4) {
  animation-delay: 1.5s;
}

/* Snow Slip Effect Styles */
.snow-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 99999;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.snow-overlay.active {
  opacity: 1;
}

.snow-particle {
  position: absolute;
  color: white;
  font-size: 20px;
  user-select: none;
  pointer-events: none;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
  will-change: transform;
}

.snow-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #1a3d2e 0%, #0f2a1f 100%);
  padding: 2rem 3rem;
  border-radius: 20px;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-color);
  z-index: 100000;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(255, 215, 0, 0.3),
    inset 0 0 20px rgba(255, 215, 0, 0.1);
  text-align: center;
  transition: opacity 0.5s ease;
  border: 3px solid rgba(255, 215, 0, 0.5);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.snow-message.show {
  opacity: 1;
  animation: messagePulse 2s ease-in-out infinite;
  pointer-events: auto;
  cursor: pointer;
}

.snow-message .close-button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-color);
  opacity: 0.7;
  transition: opacity 0.2s ease, transform 0.2s ease;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  z-index: 1;
}

.snow-message .close-button:hover {
  opacity: 1;
  transform: scale(1.1);
  background: rgba(255, 215, 0, 0.2);
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
}

/* Snow Slip Animation - Full Page Rotate */
body.snow-sliding,
html.snow-sliding {
  animation: slideOnSnow 1.5s ease-in-out;
  overflow: hidden;
  transform-origin: center center;
}

body.snow-sliding .container {
  animation: slideOnSnow 1.5s ease-in-out;
  transform-origin: center center;
}

/* Scroll Slip Animation - Full Page Rotate Clockwise */
body.scroll-sliding,
html.scroll-sliding {
  animation: scrollSlide 1.5s ease-in-out;
  transform-origin: center center;
}

body.scroll-sliding .container {
  animation: scrollSlide 1.5s ease-in-out;
  transform-origin: center center;
}

/* Shake Animation - Full Page Rotate */
body.snow-shaking,
html.snow-shaking {
  animation: shakeOffSnow 0.8s ease-in-out;
  overflow: hidden;
  transform-origin: center center;
}

body.snow-shaking .container {
  animation: shakeOffSnow 0.8s ease-in-out;
  transform-origin: center center;
}

/* Snow Accumulation Effect - Only at bottom */
.snow-accumulation {
  position: fixed !important;
  bottom: 0 !important;
  top: auto !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  height: 20% !important;
  max-height: 20vh !important;
  pointer-events: none;
  z-index: 99998;
  opacity: 0;
  transition: opacity 0.5s ease;
  background: linear-gradient(
    to top,
    rgba(255, 255, 255, 0.8) 0%,
    rgba(255, 255, 255, 0.6) 20%,
    rgba(255, 255, 255, 0.4) 40%,
    rgba(255, 255, 255, 0.2) 60%,
    rgba(255, 255, 255, 0.05) 80%,
    rgba(255, 255, 255, 0) 100%
  ) !important;
  transform: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.snow-accumulation.active {
  opacity: 1;
}

/* Static Snow Layer - Covers whole screen */
.static-snow-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 99997;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.static-snow-layer.active {
  opacity: 1;
}

.static-snowflake {
  position: absolute;
  color: white;
  user-select: none;
  pointer-events: none;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
  will-change: opacity;
}

/* Drop Inspirations Animation */
.spending-item.dropping {
  animation: dropToBottom 1.5s cubic-bezier(0.55, 0.055, 0.675, 0.19) forwards;
  pointer-events: none;
  z-index: 1000;
  position: fixed !important;
}

.spending-grid.dropping {
  position: relative;
}

/* After dropping, items stay at bottom */
.spending-item.dropped {
  position: fixed !important;
  bottom: 20px !important;
  transform: translateY(0) rotate(0deg) !important;
  opacity: 0.6 !important;
  pointer-events: auto;
  z-index: 1000;
  transition: opacity 0.3s ease;
}

.spending-item.dropped:hover {
  opacity: 0.9 !important;
}

/* Styled Pop-up Animation */
.styled-popup.show {
  animation: messagePulse 2s ease-in-out infinite;
}

/* Envelope Shake Animation */
@keyframes envelopeShake {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  5% {
    transform: translate(5px, 5px) rotate(3deg);
  }
  10% {
    transform: translate(0, 0) rotate(0eg);
  }
  15% {
    transform: translate(5px, 5px) rotate(-3deg);
  }
  20% {
    transform: translate(0, 0) rotate(0eg);
  }
  25% {
    transform: translate(-5px, 5px) rotate(3deg);
  }
  30% {
    transform: translate(0, 0) rotate(0deg);
  }
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  /* 0%,
  100% {
    transform: translateX(0) translateY(0) rotate(-1deg);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-3px) translateY(-2px) rotate(-2deg);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(3px) translateY(2px) rotate(0deg);
  } */
}

/* Envelope Flip Animation */
@keyframes envelopeFlip {
  0% {
    transform: rotate(-1deg) rotateY(0deg);
  }
  100% {
    transform: rotate(-1deg) rotateY(90deg);
  }
}

/* Envelope Back Flip Animation - completes the flip */
@keyframes envelopeBackFlip {
  0% {
    transform: translate(-50%, -50%) rotate(1deg) rotateY(-90deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(1deg) rotateY(0deg);
  }
}

/* Envelope Flip Back Animation - from back to front */
@keyframes envelopeFlipBack {
  0% {
    transform: translate(-50%, -50%) rotate(1deg) rotateY(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(1deg) rotateY(-90deg);
  }
}

/* Envelope Front Flip Back Animation - completes the flip back to front */
@keyframes envelopeFrontFlipBack {
  0% {
    transform: rotate(-1deg) rotateY(90deg);
  }
  100% {
    transform: rotate(-1deg) rotateY(0deg);
  }
}

/* Flap Open-Close Animation */
@keyframes flapTease {
  0% {
    transform: scaleY(1);
  }
  /* 30% {
    transform: scaleY(0.97);
  } */
  50% {
    transform: scaleY(0.92);
  }
  /* 80% {
    transform: scaleY(0.97);
  } */
  100% {
    transform: scaleY(1);
  }
}

/* Flap Shadow Animation - only opacity changes */
@keyframes flapTeaseShadow {
  0% {
    opacity: 0.3;
  }
  30% {
    opacity: 0.4;
  }
  60% {
    opacity: 0.5;
  }
  80% {
    opacity: 0.4;
  }
  100% {
    opacity: 0.3;
  }
}

/* Flap Open Animation */
@keyframes flapOpen {
  0% {
    transform: rotateX(0deg);
  }
  100% {
    transform: rotateX(-160deg);
  }
}

/* Flap Close Animation */
@keyframes flapClose {
  0% {
    transform: rotateX(-160deg);
  }
  100% {
    transform: rotateX(0deg);
  }
}

/* Flap Open Shadow Animation - only opacity changes */
@keyframes flapOpenShadow {
  0% {
    opacity: 0.5;
  }
  100% {
    opacity: 0.2;
  }
}

/* Flap Close Shadow Animation - only opacity changes */
@keyframes flapCloseShadow {
  0% {
    opacity: 0.2;
  }
  100% {
    opacity: 0.5;
  }
}

/* Envelope Slide to Bottom Animation */
@keyframes envelopeSlideDown {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(calc(100vh - 150px)) scale(0.15);
    opacity: 0;
  }
}

/* Letter Reveal Animation */
@keyframes letterReveal {
  0% {
    opacity: 0;
    transform: translateY(50px) scale(0.9) rotate(-2deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(-0.5deg);
  }
}

/* Letter Gentle Shake Animation */
@keyframes letterShake {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  10% {
    transform: translate(5px, 5px) rotate(5deg);
  }
  20% {
    transform: translate(0, 0) rotate(0eg);
  }
  30% {
    transform: translate(-5px, 5px) rotate(-5deg);
  }
  40% {
    transform: translate(0, 0) rotate(0deg);
  }
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  /* 0%,
  2% {
    transform: translateY(-0.5px) translateX(-0.5px) scale(1) rotate(-0.6deg);
  }
  4% {
    transform: translateY(0.5px) translateX(0.5px) scale(1) rotate(-0.4deg);
  }
  6% {
    transform: translateY(0) scale(1) rotate(-0.5deg);
  }
  100% {
    transform: translateY(0) scale(1) rotate(-0.5deg);
  } */
}

/* Unfold Me Hint Animation */
@keyframes unfoldHint {
  0%,
  100% {
    transform: translateY(0) scale(1.2) rotate(-2deg);
  }
  50% {
    transform: translateY(-8px) scale(1.22) rotate(-1.5deg);
  }
}
