/* ====================
   动画样式文件
   ==================== */

/* ====================
   关键帧动画定义
   ==================== */

/* 按钮点击缩放动画 */
@keyframes buttonClick {
  0% { transform: scale(1); }
  50% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

/* 卡片洗牌动画 */
@keyframes cardShuffle {
  0% { transform: translateX(0) rotateY(0); }
  25% { transform: translateX(-10px) rotateY(15deg); }
  50% { transform: translateX(0) rotateY(0); }
  75% { transform: translateX(10px) rotateY(-15deg); }
  100% { transform: translateX(0) rotateY(0); }
}

/* 卡片快速切换动画 */
@keyframes cardFlip {
  0% {
    transform: perspective(400px) rotateY(0);
    opacity: 1;
  }
  50% {
    transform: perspective(400px) rotateY(90deg);
    opacity: 0.5;
  }
  100% {
    transform: perspective(400px) rotateY(0);
    opacity: 1;
  }
}

/* 卡片滑入动画 - 从右侧 */
@keyframes slideInRight {
  0% {
    transform: translateX(120%) scale(0.9);
    opacity: 0;
  }
  100% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

/* 卡片滑入动画 - 从左侧 */
@keyframes slideInLeft {
  0% {
    transform: translateX(-120%) scale(0.9);
    opacity: 0;
  }
  100% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

/* 卡片滑出动画 - 向左 */
@keyframes slideOutLeft {
  0% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateX(-120%) scale(0.9);
    opacity: 0;
  }
}

/* 卡片滑出动画 - 向右 */
@keyframes slideOutRight {
  0% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateX(120%) scale(0.9);
    opacity: 0;
  }
}

/* 弹窗弹出动画 */
@keyframes popIn {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  70% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 弹窗关闭动画 */
@keyframes popOut {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.5);
    opacity: 0;
  }
}

/* 文字弹跳动画 */
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* 文字逐字弹跳 */
@keyframes letterBounce {
  0% {
    transform: translateY(-20px);
    opacity: 0;
  }
  60% {
    transform: translateY(5px);
    opacity: 1;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 淡入动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 淡出动画 */
@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

/* 心跳动画 */
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.2); }
  50% { transform: scale(1); }
  75% { transform: scale(1.1); }
}

/* 脉冲动画 */
@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 159, 67, 0.7);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 20px rgba(255, 159, 67, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 159, 67, 0);
  }
}

/* 摇晃动画 */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* 旋转动画 */
@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 抽签滚动动画 */
@keyframes slotSpin {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-100%);
  }
}

/* 抽签结果弹出 */
@keyframes slotReveal {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.1) rotate(10deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

/* 闪烁动画 */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 渐变背景动画 */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ====================
   动画应用类
   ==================== */

/* 按钮点击动画 */
.btn-click {
  animation: buttonClick 0.2s ease;
}

/* 卡片洗牌动画 */
.card-shuffle {
  animation: cardShuffle 0.3s ease infinite;
}

/* 卡片翻转动画 */
.card-flip {
  animation: cardFlip 0.6s ease;
}

/* 卡片滑入 - 从右侧 */
.slide-in-right {
  animation: slideInRight 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 卡片滑入 - 从左侧 */
.slide-in-left {
  animation: slideInLeft 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 卡片滑出 - 向左 */
.slide-out-left {
  animation: slideOutLeft 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 卡片滑出 - 向右 */
.slide-out-right {
  animation: slideOutRight 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 弹窗弹出 */
.pop-in {
  animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* 弹窗关闭 */
.pop-out {
  animation: popOut 0.3s ease forwards;
}

/* 文字弹跳 */
.text-bounce {
  animation: bounce 0.6s ease;
}

/* 文字逐字弹跳容器 */
.letter-bounce-container span {
  display: inline-block;
  animation: letterBounce 0.5s ease forwards;
  opacity: 0;
}

/* 为每个字母添加延迟 */
.letter-bounce-container span:nth-child(1) { animation-delay: 0s; }
.letter-bounce-container span:nth-child(2) { animation-delay: 0.05s; }
.letter-bounce-container span:nth-child(3) { animation-delay: 0.1s; }
.letter-bounce-container span:nth-child(4) { animation-delay: 0.15s; }
.letter-bounce-container span:nth-child(5) { animation-delay: 0.2s; }
.letter-bounce-container span:nth-child(6) { animation-delay: 0.25s; }
.letter-bounce-container span:nth-child(7) { animation-delay: 0.3s; }
.letter-bounce-container span:nth-child(8) { animation-delay: 0.35s; }
.letter-bounce-container span:nth-child(9) { animation-delay: 0.4s; }
.letter-bounce-container span:nth-child(10) { animation-delay: 0.45s; }

/* 淡入 */
.fade-in {
  animation: fadeIn 0.5s ease;
}

/* 淡出 */
.fade-out {
  animation: fadeOut 0.5s ease forwards;
}

/* 心跳 */
.heartbeat {
  animation: heartbeat 0.6s ease;
}

/* 脉冲效果 */
.pulse {
  animation: pulse 2s infinite;
}

/* 摇晃 */
.shake {
  animation: shake 0.5s ease;
}

/* 旋转 */
.rotate {
  animation: rotate 1s linear;
}

/* 抽签滚动 */
.slot-spin {
  animation: slotSpin 0.1s linear infinite;
}

/* 抽签结果弹出 */
.slot-reveal {
  animation: slotReveal 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* 闪烁 */
.blink {
  animation: blink 1s ease infinite;
}

/* 渐变背景 */
.gradient-animate {
  background: linear-gradient(-45deg, #FF9F43, #FFBE76, #FF9F43, #F0932B);
  background-size: 400% 400%;
  animation: gradientShift 3s ease infinite;
}

/* ====================
   动画辅助类
   ==================== */

/* 动画延迟 */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }

/* 动画速度 */
.speed-fast { animation-duration: 0.2s; }
.speed-normal { animation-duration: 0.5s; }
.speed-slow { animation-duration: 1s; }

/* 动画迭代次数 */
.once { animation-iteration-count: 1; }
.twice { animation-iteration-count: 2; }
.infinite { animation-iteration-count: infinite; }

/* ====================
   过渡效果
   ==================== */

/* 悬停放大 */
.hover-scale {
  transition: transform var(--transition-normal);
}

.hover-scale:hover {
  transform: scale(1.05);
}

/* 悬停阴影 */
.hover-shadow {
  transition: box-shadow var(--transition-normal);
}

.hover-shadow:hover {
  box-shadow: var(--shadow-heavy);
}

/* 悬停上移 */
.hover-up {
  transition: transform var(--transition-normal);
}

.hover-up:hover {
  transform: translateY(-5px);
}

/* ====================
   推荐结果动画
   ==================== */

/* 推荐卡片入场动画 */
.food-card.animate-in {
  animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

/* 为每张卡片添加延迟 */
.food-card.animate-in:nth-child(1) {
  animation-delay: 0s;
}

.food-card.animate-in:nth-child(2) {
  animation-delay: 0.1s;
}

.food-card.animate-in:nth-child(3) {
  animation-delay: 0.2s;
}

/* ====================
   抽签动画
   ==================== */

/* 抽签卡片容器 */
.draw-animation-container {
  position: relative;
  height: 200px;
  overflow: hidden;
}

/* 抽签项 */
.draw-item {
  position: absolute;
  width: 100%;
  opacity: 0;
  transition: all 0.3s ease;
}

.draw-item.active {
  opacity: 1;
}

/* 抽签结果高亮 */
.draw-result {
  animation: slotReveal 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

/* ====================
   运势动画
   ==================== */

/* 运势图标旋转 */
.fortune-icon-animate {
  animation: rotate 2s linear infinite;
}

/* 运势文字闪烁 */
.fortune-text-animate {
  animation: blink 1.5s ease infinite;
}

/* ====================
   禁用动画类
   ==================== */

/* 当用户禁用动画时 */
.no-animations * {
  animation: none !important;
  transition: none !important;
}

.no-animations .particle {
  display: none;
}
