/* ===== 页面加载动画系统 ===== */

/* 基础动画变量 */
:root {
  --animation-duration-fast: 0.3s;
  --animation-duration-normal: 0.6s;
  --animation-duration-slow: 1s;
  --animation-easing-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --animation-easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --animation-easing-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

/* 初始隐藏状态 - 所有动画元素默认隐藏 */
[data-animate] {
  opacity: 0;
  will-change: transform, opacity;
}

/* ===== 页面加载遮罩动画 ===== */
.page-loader {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #FF8C00 0%, #FFA500 50%, #FF8C00 100%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.page-loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* 加载动画内容 */
.loader-content {
  text-align: center;
  color: white;
}

/* 棒球旋转动画 */
.loader-baseball {
  width: 80px;
  height: 80px;
  margin: 0 auto 2rem;
  position: relative;
  animation: spin 2s linear infinite;
}

.loader-baseball::before {
  content: '⚾';
  font-size: 80px;
  display: block;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.2));
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 加载文字 */
.loader-text {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  animation: pulse 1.5s ease-in-out infinite;
}

.loader-text::after {
  content: '';
  animation: loadingDots 1.5s steps(4, end) infinite;
}

@keyframes loadingDots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
  100% { content: ''; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* 进度条 */
.loader-progress {
  width: 200px;
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  margin-top: 2rem;
  overflow: hidden;
  position: relative;
}

.loader-progress-bar {
  height: 100%;
  background: white;
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

/* ===== 入场动画类型 ===== */

/* 1. 淡入上浮 - 最常用 */
[data-animate="fade-up"] {
  transform: translateY(40px);
}

[data-animate="fade-up"].animated {
  animation: fadeUp var(--animation-duration-normal) var(--animation-easing-expo) forwards;
}

@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 2. 淡入下沉 */
[data-animate="fade-down"] {
  transform: translateY(-40px);
}

[data-animate="fade-down"].animated {
  animation: fadeDown var(--animation-duration-normal) var(--animation-easing-expo) forwards;
}

@keyframes fadeDown {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 3. 淡入左滑 */
[data-animate="fade-left"] {
  transform: translateX(-60px);
}

[data-animate="fade-left"].animated {
  animation: fadeLeft var(--animation-duration-normal) var(--animation-easing-expo) forwards;
}

@keyframes fadeLeft {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 4. 淡入右滑 */
[data-animate="fade-right"] {
  transform: translateX(60px);
}

[data-animate="fade-right"].animated {
  animation: fadeRight var(--animation-duration-normal) var(--animation-easing-expo) forwards;
}

@keyframes fadeRight {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 5. 缩放淡入 */
[data-animate="zoom-in"] {
  transform: scale(0.8);
}

[data-animate="zoom-in"].animated {
  animation: zoomIn var(--animation-duration-normal) var(--animation-easing-bounce) forwards;
}

@keyframes zoomIn {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 6. 缩放淡出 */
[data-animate="zoom-out"] {
  transform: scale(1.2);
}

[data-animate="zoom-out"].animated {
  animation: zoomOut var(--animation-duration-normal) var(--animation-easing-expo) forwards;
}

@keyframes zoomOut {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 7. 翻转进入 */
[data-animate="flip-x"] {
  transform: perspective(400px) rotateX(90deg);
}

[data-animate="flip-x"].animated {
  animation: flipX var(--animation-duration-slow) var(--animation-easing-expo) forwards;
}

@keyframes flipX {
  to {
    opacity: 1;
    transform: perspective(400px) rotateX(0deg);
  }
}

/* 8. 弹性弹出 */
[data-animate="bounce"] {
  transform: scale(0);
}

[data-animate="bounce"].animated {
  animation: bounceIn var(--animation-duration-slow) var(--animation-easing-bounce) forwards;
}

@keyframes bounceIn {
  0% { opacity: 0; transform: scale(0); }
  50% { transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

/* 9. 文字逐字显示 */
[data-animate="typewriter"] {
  overflow: hidden;
  white-space: nowrap;
  border-right: 3px solid var(--orange);
  width: 0;
}

[data-animate="typewriter"].animated {
  animation: typing 1s steps(20, end) forwards, blink-caret 0.75s step-end infinite;
  width: auto;
}

@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blink-caret {
  from, to { border-color: transparent; }
  50% { border-color: var(--orange); }
}

/* 10. 旋转淡入 */
[data-animate="rotate-in"] {
  transform: rotate(-180deg) scale(0);
}

[data-animate="rotate-in"].animated {
  animation: rotateIn var(--animation-duration-slow) var(--animation-easing-bounce) forwards;
}

@keyframes rotateIn {
  to {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
}

/* ===== 延迟类 - 控制动画顺序 ===== */
[data-delay="1"] { animation-delay: 0.1s !important; }
[data-delay="2"] { animation-delay: 0.2s !important; }
[data-delay="3"] { animation-delay: 0.3s !important; }
[data-delay="4"] { animation-delay: 0.4s !important; }
[data-delay="5"] { animation-delay: 0.5s !important; }
[data-delay="6"] { animation-delay: 0.6s !important; }
[data-delay="7"] { animation-delay: 0.7s !important; }
[data-delay="8"] { animation-delay: 0.8s !important; }
[data-delay="9"] { animation-delay: 0.9s !important; }
[data-delay="10"] { animation-delay: 1s !important; }

/* ===== 持续时间类 ===== */
[data-duration="fast"] { animation-duration: var(--animation-duration-fast) !important; }
[data-duration="normal"] { animation-duration: var(--animation-duration-normal) !important; }
[data-duration="slow"] { animation-duration: var(--animation-duration-slow) !important; }

/* ===== 交错动画组 ===== */
.stagger-group {
  --stagger-delay: 0.1s;
}

.stagger-group > * {
  opacity: 0;
  transform: translateY(30px);
}

.stagger-group.animated > *:nth-child(1) { animation: fadeUp var(--animation-duration-normal) var(--animation-easing-expo) 0.1s forwards; }
.stagger-group.animated > *:nth-child(2) { animation: fadeUp var(--animation-duration-normal) var(--animation-easing-expo) 0.2s forwards; }
.stagger-group.animated > *:nth-child(3) { animation: fadeUp var(--animation-duration-normal) var(--animation-easing-expo) 0.3s forwards; }
.stagger-group.animated > *:nth-child(4) { animation: fadeUp var(--animation-duration-normal) var(--animation-easing-expo) 0.4s forwards; }
.stagger-group.animated > *:nth-child(5) { animation: fadeUp var(--animation-duration-normal) var(--animation-easing-expo) 0.5s forwards; }
.stagger-group.animated > *:nth-child(6) { animation: fadeUp var(--animation-duration-normal) var(--animation-easing-expo) 0.6s forwards; }

/* ===== 滚动触发动画 ===== */
[data-scroll-animate] {
  opacity: 0;
  transform: translateY(50px);
  transition: opacity 0.6s var(--animation-easing-expo), 
              transform 0.6s var(--animation-easing-expo);
}

[data-scroll-animate].in-view {
  opacity: 1;
  transform: translateY(0);
}

/* 滚动动画变体 */
[data-scroll-animate="fade-left"] {
  transform: translateX(-50px);
}

[data-scroll-animate="fade-right"] {
  transform: translateX(50px);
}

[data-scroll-animate="zoom-in"] {
  transform: scale(0.9);
}

[data-scroll-animate].in-view {
  opacity: 1;
  transform: translate(0) scale(1);
}

/* ===== 特殊效果 ===== */

/* 鼠标跟随光效 */
.cursor-glow {
  position: fixed;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(255,140,0,0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  transform: translate(-50%, -50%);
  transition: opacity 0.3s ease;
  opacity: 0;
}

.cursor-glow.active {
  opacity: 1;
}

/* 文字填充动画 */
.text-fill-animate {
  background: linear-gradient(to right, #FF8C00 50%, #333 50%);
  background-size: 200% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: background-position 0.5s ease;
}

.text-fill-animate.animated {
  background-position: 0% 0;
}

/* 图片遮罩揭示 */
.mask-reveal {
  position: relative;
  overflow: hidden;
}

.mask-reveal::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--orange);
  transform: translateX(0);
  transition: transform 0.8s var(--animation-easing-expo);
}

.mask-reveal.animated::after {
  transform: translateX(100%);
}

/* 分割线动画 */
.line-divider {
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--orange), transparent);
  transition: width 1s var(--animation-easing-expo);
}

.line-divider.animated {
  width: 100%;
}

/* ===== 性能优化 ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  [data-animate],
  [data-scroll-animate] {
    opacity: 1;
    transform: none;
  }
}

/* ===== 响应式调整 ===== */
@media (max-width: 768px) {
  .loader-baseball {
    width: 60px;
    height: 60px;
  }
  
  .loader-baseball::before {
    font-size: 60px;
  }
  
  .loader-text {
    font-size: 1.2rem;
  }
  
  [data-animate="fade-left"],
  [data-animate="fade-right"] {
    transform: translateX(0) translateY(30px);
  }
  
  [data-animate="fade-left"].animated {
    animation-name: fadeUp;
  }
  
  [data-animate="fade-right"].animated {
    animation-name: fadeUp;
  }
}