/* 增强版动画系统 */

/* 打字机动画 */
@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blink-caret {
  from, to { border-color: transparent; }
  50% { border-color: var(--text-green); }
}

/* 淡入动画 - 增强版 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(30px);
    filter: blur(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* 淡出动画 */
@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translateY(-30px);
    filter: blur(5px);
  }
}

/* 脉冲动画 - 增强版 */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(0.98);
  }
}

/* 故障艺术效果 - 增强版 */
@keyframes glitch {
  0%, 90%, 100% {
    transform: translate(0);
    text-shadow: 0 0 10px var(--text-red);
  }
  91% {
    transform: translate(-4px, 4px);
    text-shadow:
      -4px 4px 10px var(--text-red),
      4px -4px 10px var(--glitch-color),
      0 0 20px var(--neon-blue);
  }
  93% {
    transform: translate(4px, -4px);
    text-shadow:
      4px -4px 10px var(--text-green),
      -4px 4px 10px var(--text-red),
      0 0 20px var(--neon-red);
  }
  95% {
    transform: translate(-3px, -3px);
    text-shadow:
      -3px -3px 10px var(--glitch-color),
      3px 3px 10px var(--text-red),
      0 0 20px var(--neon-green);
  }
  97% {
    transform: translate(2px, 2px);
    text-shadow:
      2px 2px 10px var(--text-red),
      -2px -2px 10px var(--neon-blue);
  }
}

/* 闪烁警告动画 - 增强版 */
@keyframes warning-flash {
  0%, 100% {
    background-color: transparent;
    border-color: var(--text-red);
    box-shadow: 0 0 10px rgba(255, 8, 68, 0.2);
  }
  50% {
    background-color: rgba(255, 8, 68, 0.15);
    border-color: var(--neon-red);
    box-shadow:
      0 0 30px rgba(255, 8, 68, 0.5),
      inset 0 0 20px rgba(255, 8, 68, 0.2);
  }
}

/* 资源条动画 */
@keyframes resource-decrease {
  0% {
    transform: scaleX(1);
  }
  50% {
    transform: scaleX(0.95);
  }
  100% {
    transform: scaleX(1);
  }
}

/* 选择按钮悬停动画 */
.choice-btn {
  position: relative;
  overflow: hidden;
}

/* 屏幕切换动画 */
.screen-transition-out {
  animation: fadeOut 0.6s ease forwards;
}

.screen-transition-in {
  animation: fadeIn 0.6s ease forwards;
}

/* 数字滚动动画 - 增强版 */
@keyframes number-roll {
  0% {
    transform: translateY(-30px) rotateX(90deg);
    opacity: 0;
  }
  50% {
    transform: translateY(5px) rotateX(-10deg);
  }
  100% {
    transform: translateY(0) rotateX(0);
    opacity: 1;
  }
}

.number-roll {
  animation: number-roll 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 按钮点击反馈 */
.btn-primary:active,
.btn-secondary:active,
.choice-btn:active {
  transform: scale(0.97);
}

/* 加载动画 */
@keyframes loading-dots {
  0%, 20% {
    content: '.';
  }
  40% {
    content: '..';
  }
  60%, 100% {
    content: '...';
  }
}

.loading::after {
  content: '';
  animation: loading-dots 1.5s infinite;
}

/* 震动效果（用于危险状态） - 增强版 */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
  20%, 40%, 60%, 80% { transform: translateX(8px); }
}

.shake {
  animation: shake 0.6s ease;
}

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

/* 扫描线效果 - 增强版 */
@keyframes scanline {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100vh);
  }
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(
    to bottom,
    transparent,
    var(--text-green) 50%,
    transparent
  );
  opacity: 0.15;
  animation: scanline 6s linear infinite;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 0 10px var(--text-green);
}

/* 文字出现动画 */
.text-appear {
  animation: fadeIn 1s ease;
}

/* 危险状态闪烁 */
.danger-blink {
  animation: warning-flash 1s infinite;
}

/* 成功状态发光 - 增强版 */
@keyframes success-glow {
  0%, 100% {
    box-shadow: 0 0 10px var(--text-green);
  }
  50% {
    box-shadow:
      0 0 25px var(--text-green),
      0 0 40px rgba(0, 255, 65, 0.6),
      inset 0 0 15px rgba(0, 255, 65, 0.2);
  }
}

.success-glow {
  animation: success-glow 2s ease infinite;
}

/* 数据流动画 */
@keyframes dataFlow {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* 霓虹闪烁 */
@keyframes neonFlicker {
  0%, 100% {
    opacity: 1;
    text-shadow:
      0 0 10px currentColor,
      0 0 20px currentColor,
      0 0 30px currentColor;
  }
  10%, 15%, 25%, 30% {
    opacity: 0.8;
    text-shadow:
      0 0 5px currentColor,
      0 0 10px currentColor;
  }
  12%, 28% {
    opacity: 1;
    text-shadow:
      0 0 15px currentColor,
      0 0 30px currentColor,
      0 0 45px currentColor;
  }
}

/* 终端光标闪烁 */
@keyframes cursorBlink {
  0%, 49% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0;
  }
}

/* 电路板脉冲 */
@keyframes circuitPulse {
  0%, 100% {
    box-shadow:
      0 0 5px var(--text-green),
      inset 0 0 5px rgba(0, 255, 65, 0.1);
  }
  50% {
    box-shadow:
      0 0 20px var(--text-green),
      0 0 30px rgba(0, 255, 65, 0.5),
      inset 0 0 15px rgba(0, 255, 65, 0.3);
  }
}

/* 矩阵雨效果（可选） */
@keyframes matrixRain {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(100vh);
    opacity: 0;
  }
}

/* 故障扫描 */
@keyframes glitchScan {
  0%, 100% {
    clip-path: inset(0 0 0 0);
  }
  10% {
    clip-path: inset(20% 0 60% 0);
  }
  20% {
    clip-path: inset(60% 0 20% 0);
  }
  30% {
    clip-path: inset(40% 0 40% 0);
  }
  40% {
    clip-path: inset(0 0 0 0);
  }
}

/* 能量充能动画 */
@keyframes energyCharge {
  0% {
    background-position: 0% 50%;
    box-shadow: 0 0 10px var(--text-green);
  }
  50% {
    background-position: 100% 50%;
    box-shadow:
      0 0 20px var(--text-green),
      0 0 40px rgba(0, 255, 65, 0.5);
  }
  100% {
    background-position: 0% 50%;
    box-shadow: 0 0 10px var(--text-green);
  }
}

