/* ============================================
   中秋集月饼H5 - 桂花飘落动画
   纯CSS animation实现
   ============================================ */

/* --- 桂花飘落粒子容器 --- */
.osmanthus-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

/* --- 桂花基础样式 --- */
.guanghua {
  position: absolute;
  top: -10px;
  width: 6px;
  height: 6px;
  background: #ffd700;
  border-radius: 50%;
  animation: fall linear infinite;
  box-shadow: 0 0 3px rgba(255, 215, 0, 0.6);
  opacity: 0.9;
}

/* 桂花变体 - 不同颜色和大小 */
.guanghua.small {
  width: 4px;
  height: 4px;
  background: #ffed4a;
  box-shadow: 0 0 2px rgba(255, 237, 74, 0.5);
}

.guanghua.medium {
  width: 6px;
  height: 6px;
  background: #ffd700;
  box-shadow: 0 0 4px rgba(255, 215, 0, 0.6);
}

.guanghua.large {
  width: 8px;
  height: 8px;
  background: #ffb300;
  box-shadow: 0 0 6px rgba(255, 179, 0, 0.7);
}

/* --- 桂花飘落关键帧动画 --- */
@keyframes fall {
  0% {
    transform: translateY(-5vh) translateX(0px) rotate(0deg) scale(1);
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  50% {
    transform: translateY(50vh) translateX(20px) rotate(360deg) scale(1.1);
    opacity: 0.8;
  }
  80% {
    opacity: 0.6;
  }
  100% {
    transform: translateY(105vh) translateX(-15px) rotate(720deg) scale(0.8);
    opacity: 0;
  }
}

/* --- 带摇摆的飘落 --- */
@keyframes fallSway {
  0% {
    transform: translateY(-5vh) translateX(0px) rotate(0deg);
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  25% {
    transform: translateY(25vh) translateX(25px) rotate(180deg);
    opacity: 0.9;
  }
  50% {
    transform: translateY(50vh) translateX(-15px) rotate(360deg);
    opacity: 0.75;
  }
  75% {
    transform: translateY(75vh) translateX(20px) rotate(540deg);
    opacity: 0.5;
  }
  95% {
    opacity: 0.2;
  }
  100% {
    transform: translateY(105vh) translateX(10px) rotate(720deg);
    opacity: 0;
  }
}

/* --- 快速飘落 --- */
@keyframes fallFast {
  0% {
    transform: translateY(-5vh) translateX(0px) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  60% {
    transform: translateY(65vh) translateX(30px) rotate(400deg);
    opacity: 0.7;
  }
  100% {
    transform: translateY(105vh) translateX(-10px) rotate(720deg);
    opacity: 0;
  }
}

/* --- 慢速飘落 --- */
@keyframes fallSlow {
  0% {
    transform: translateY(-5vh) translateX(0px) rotate(0deg);
    opacity: 0;
  }
  5% {
    opacity: 0.8;
  }
  50% {
    transform: translateY(50vh) translateX(-20px) rotate(300deg);
    opacity: 0.6;
  }
  100% {
    transform: translateY(105vh) translateX(15px) rotate(540deg);
    opacity: 0;
  }
}

/* --- 桂花花瓣形状（4瓣） --- */
.guanghua-petal {
  position: absolute;
  top: -15px;
  width: 12px;
  height: 12px;
  animation: petalFall linear infinite;
}

.guanghua-petal::before,
.guanghua-petal::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #ffb300;
}

.guanghua-petal::before {
  width: 100%;
  height: 50%;
  border-radius: 50% 50% 0 0;
  background: linear-gradient(180deg, #ffd700, #ffb300);
}

.guanghua-petal::after {
  width: 50%;
  height: 100%;
  border-radius: 50% 0 0 50%;
  background: linear-gradient(90deg, #ffd700, #ffb300);
}

@keyframes petalFall {
  0% {
    transform: translateY(-5vh) rotate(0deg);
    opacity: 0;
  }
  10% { opacity: 1; }
  50% {
    transform: translateY(55vh) rotate(180deg) translateX(15px);
    opacity: 0.7;
  }
  90% { opacity: 0.3; }
  100% {
    transform: translateY(105vh) rotate(360deg) translateX(-10px);
    opacity: 0;
  }
}

/* --- 桂花簇（多瓣组合） --- */
.guanghua-cluster {
  position: absolute;
  top: -20px;
  width: 16px;
  height: 16px;
  animation: clusterFall linear infinite;
}

.guanghua-cluster::before {
  content: '';
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  background: #ffd700;
  border-radius: 50%;
  box-shadow:
    -5px 4px 0 -1px #ffb300,
    5px 4px 0 -1px #ffb300,
    0 8px 0 0 #ff9800;
}

@keyframes clusterFall {
  0% {
    transform: translateY(-5vh) rotate(0deg) translateX(0);
    opacity: 0;
  }
  8% { opacity: 1; }
  33% {
    transform: translateY(35vh) rotate(120deg) translateX(12px);
    opacity: 0.85;
  }
  66% {
    transform: translateY(65vh) rotate(240deg) translateX(-8px);
    opacity: 0.5;
  }
  100% {
    transform: translateY(105vh) rotate(360deg) translateX(5px);
    opacity: 0;
  }
}

/* --- 为每朵桂花设置不同位置和延迟（stagger） --- */
/* 第1-30朵桂花 - 分散分布 */
.guanghua:nth-child(1) { left: 3%; animation-duration: 4s; animation-delay: 0s; }
.guanghua:nth-child(2) { left: 8%; animation-duration: 5s; animation-delay: 0.3s; }
.guanghua:nth-child(3) { left: 13%; animation-duration: 3.5s; animation-delay: 0.7s; }
.guanghua:nth-child(4) { left: 18%; animation-duration: 6s; animation-delay: 1.1s; }
.guanghua:nth-child(5) { left: 23%; animation-duration: 4.5s; animation-delay: 0.5s; }
.guanghua:nth-child(6) { left: 28%; animation-duration: 5.5s; animation-delay: 1.5s; }
.guanghua:nth-child(7) { left: 33%; animation-duration: 3.8s; animation-delay: 0.2s; }
.guanghua:nth-child(8) { left: 38%; animation-duration: 4.8s; animation-delay: 2.0s; }
.guanghua:nth-child(9) { left: 43%; animation-duration: 5.2s; animation-delay: 0.9s; }
.guanghua:nth-child(10) { left: 48%; animation-duration: 4.2s; animation-delay: 1.3s; }
.guanghua:nth-child(11) { left: 53%; animation-duration: 5.8s; animation-delay: 0.4s; }
.guanghua:nth-child(12) { left: 58%; animation-duration: 3.6s; animation-delay: 1.7s; }
.guanghua:nth-child(13) { left: 63%; animation-duration: 5.4s; animation-delay: 2.2s; }
.guanghua:nth-child(14) { left: 68%; animation-duration: 4.6s; animation-delay: 0.6s; }
.guanghua:nth-child(15) { left: 73%; animation-duration: 6.2s; animation-delay: 1.9s; }
.guanghua:nth-child(16) { left: 78%; animation-duration: 3.9s; animation-delay: 0.8s; }
.guanghua:nth-child(17) { left: 83%; animation-duration: 5.1s; animation-delay: 2.5s; }
.guanghua:nth-child(18) { left: 88%; animation-duration: 4.4s; animation-delay: 1.0s; }
.guanghua:nth-child(19) { left: 93%; animation-duration: 5.6s; animation-delay: 0.1s; }
.guanghua:nth-child(20) { left: 6%; animation-duration: 4.7s; animation-delay: 3.0s; }
.guanghua:nth-child(21) { left: 16%; animation-duration: 3.7s; animation-delay: 2.8s; }
.guanghua:nth-child(22) { left: 26%; animation-duration: 5.9s; animation-delay: 3.5s; }
.guanghua:nth-child(23) { left: 41%; animation-duration: 4.1s; animation-delay: 2.3s; }
.guanghua:nth-child(24) { left: 56%; animation-duration: 5.3s; animation-delay: 3.2s; }
.guanghua:nth-child(25) { left: 71%; animation-duration: 3.4s; animation-delay: 4.0s; }
.guanghua:nth-child(26) { left: 86%; animation-duration: 6.1s; animation-delay: 2.7s; }
.guanghua:nth-child(27) { left: 11%; animation-duration: 4.9s; animation-delay: 3.8s; }
.guanghua:nth-child(28) { left: 36%; animation-duration: 5.7s; animation-delay: 4.2s; }
.guanghua:nth-child(29) { left: 61%; animation-duration: 3.8s; animation-delay: 3.4s; }
.guanghua:nth-child(30) { left: 95%; animation-duration: 5.0s; animation-delay: 4.5s; }

/* --- 摇摆动画的桂花 --- */
.guanghua.sway:nth-child(odd) { animation-name: fallSway; }
.guanghua.sway:nth-child(even) { animation-name: fallFast; }
.guanghua.slow { animation-name: fallSlow; }

/* --- 闪光粒子（额外装饰） --- */
.sparkle-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 51;
  overflow: hidden;
}

.sparkle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #fff;
  border-radius: 50%;
  animation: sparkleTwinkle ease-in-out infinite;
}

@keyframes sparkleTwinkle {
  0%, 100% { opacity: 0; transform: scale(0); }
  50% { opacity: 0.8; transform: scale(1); }
}

.sparkle:nth-child(1) { top: 10%; left: 15%; animation-duration: 3s; animation-delay: 0s; }
.sparkle:nth-child(2) { top: 25%; left: 40%; animation-duration: 2.5s; animation-delay: 0.8s; }
.sparkle:nth-child(3) { top: 15%; left: 65%; animation-duration: 3.5s; animation-delay: 1.5s; }
.sparkle:nth-child(4) { top: 35%; left: 85%; animation-duration: 2.8s; animation-delay: 0.3s; }
.sparkle:nth-child(5) { top: 8%; left: 25%; animation-duration: 3.2s; animation-delay: 2.0s; }
.sparkle:nth-child(6) { top: 45%; left: 55%; animation-duration: 2.3s; animation-delay: 1.2s; }
.sparkle:nth-child(7) { top: 20%; left: 75%; animation-duration: 3.8s; animation-delay: 0.6s; }
.sparkle:nth-child(8) { top: 30%; left: 10%; animation-duration: 2.6s; animation-delay: 2.5s; }
.sparkle:nth-child(9) { top: 5%; left: 50%; animation-duration: 3.4s; animation-delay: 1.8s; }
.sparkle:nth-child(10) { top: 28%; left: 92%; animation-duration: 2.9s; animation-delay: 0.4s; }

/* --- 云朵飘过 --- */
.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 50%;
  filter: blur(8px);
  animation: cloudDrift linear infinite;
}

.cloud:nth-child(1) {
  width: 120px;
  height: 40px;
  top: 12%;
  animation-duration: 25s;
  animation-delay: 0s;
}

.cloud:nth-child(2) {
  width: 80px;
  height: 30px;
  top: 25%;
  animation-duration: 30s;
  animation-delay: 8s;
}

.cloud:nth-child(3) {
  width: 150px;
  height: 50px;
  top: 8%;
  animation-duration: 35s;
  animation-delay: 15s;
}

@keyframes cloudDrift {
  0% { transform: translateX(-200px); }
  100% { transform: translateX(calc(100vw + 200px)); }
}

/* --- 禁止动画偏好 --- */
@media (prefers-reduced-motion: reduce) {
  .guanghua,
  .guanghua-petal,
  .guanghua-cluster,
  .sparkle,
  .cloud,
  .moon {
    animation: none !important;
  }
}

/* --- 月饼卡片集齐动画 --- */
@keyframes mooncakeGlow {
  0%, 100% { box-shadow: 0 4px 15px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 4px 25px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 215, 0, 0.3); }
}

.mooncake-collected {
  animation: mooncakeGlow 2s ease-in-out infinite;
}

/* --- 按钮点击波纹 --- */
@keyframes ripple {
  0% { transform: scale(0); opacity: 0.6; }
  100% { transform: scale(4); opacity: 0; }
}

.btn-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  animation: ripple 0.6s linear forwards;
  pointer-events: none;
}
