/*
 * 嘉星晶电官网 - 动画样式
 */

/* ========================================
   页面加载动效
   ======================================== */

/* Hero区标题渐入 */
.hero-title {
  animation: fadeInLeft 0.8s ease forwards;
}

.hero-subtitle {
  animation: fadeInLeft 0.8s ease 0.2s forwards;
  opacity: 0;
}

.hero-stats {
  animation: fadeInUp 0.6s ease 0.4s forwards;
  opacity: 0;
}

.hero-actions {
  animation: fadeInUp 0.6s ease 0.6s forwards;
  opacity: 0;
}

.hero-image {
  animation: fadeInRight 0.8s ease 0.3s forwards;
  opacity: 0;
}

/* 核心数据数字依次淡入 */
.hero-stat:nth-child(1) {
  animation-delay: 0.4s;
}

.hero-stat:nth-child(2) {
  animation-delay: 0.6s;
}

.hero-stat:nth-child(3) {
  animation-delay: 0.8s;
}

/* ========================================
   淡入动画
   ======================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ========================================
   滑入动画
   ======================================== */
@keyframes slideInUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ========================================
   缩放动画
   ======================================== */
@keyframes scaleIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes scaleOut {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.8);
    opacity: 0;
  }
}

/* ========================================
   脉冲动画
   ======================================== */
@keyframes pulse {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.05);
  }
}

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

/* ========================================
   数字滚动动画
   ======================================== */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.number-animate {
  animation: countUp 0.8s ease forwards;
}

/* ========================================
   数据图表动画
   ======================================== */

/* 环形图填充 */
@keyframes ringFill {
  from {
    stroke-dashoffset: 100;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.chart-ring-fill {
  animation: ringFill 1.5s ease forwards;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

/* 条形图生长 */
@keyframes barGrow {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

.bar-animate {
  animation: barGrow 1s ease forwards;
  width: 0;
}

/* ========================================
   滚动触发动画
   ======================================== */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

.animate-on-scroll.animate-left {
  transform: translateX(-30px);
}

.animate-on-scroll.animate-left.visible {
  transform: translateX(0);
}

.animate-on-scroll.animate-right {
  transform: translateX(30px);
}

.animate-on-scroll.animate-right.visible {
  transform: translateX(0);
}

.animate-on-scroll.animate-scale {
  transform: scale(0.9);
}

.animate-on-scroll.animate-scale.visible {
  transform: scale(1);
}

/* 交错动画 */
.stagger-item {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.stagger-item.visible {
  opacity: 1;
  transform: translateY(0);
}

.stagger-item:nth-child(1) { transition-delay: 0s; }
.stagger-item:nth-child(2) { transition-delay: 0.1s; }
.stagger-item:nth-child(3) { transition-delay: 0.2s; }
.stagger-item:nth-child(4) { transition-delay: 0.3s; }
.stagger-item:nth-child(5) { transition-delay: 0.4s; }
.stagger-item:nth-child(6) { transition-delay: 0.5s; }

/* ========================================
   导航交互动画
   ======================================== */

/* 下拉菜单展开 */
.nav-dropdown {
  animation: dropdownOpen 0.3s ease forwards;
}

@keyframes dropdownOpen {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 下划线滑入 */
.nav-link::after {
  transition: width 0.3s ease;
}

/* ========================================
   卡片交互动画
   ======================================== */
.card,
.highlight-card,
.news-card,
.product-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.card:hover,
.highlight-card:hover,
.news-card:hover,
.product-card:hover {
  transform: translateY(-5px);
}

/* 图片放大 */
.news-image img {
  transition: transform 0.5s ease;
}

.news-card:hover .news-image img {
  transform: scale(1.05);
}

/* 科技浅蓝叠加层 */
.news-image::after {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.news-card:hover .news-image::after {
  opacity: 1;
  background: linear-gradient(180deg, transparent 0%, rgba(74, 144, 217, 0.2) 100%);
}

/* ========================================
   按钮交互动画
   ======================================== */
.btn {
  transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: scale(0.95);
  transition-duration: 0.1s;
}

/* 边框按钮填充 */
.btn-outline {
  transition: background-color 0.3s ease, color 0.3s ease;
}

.btn-outline:hover {
  background: var(--color-accent);
  color: var(--color-text-white);
}

/* ========================================
   加载动画
   ======================================== */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  animation: spin 1s linear infinite;
}

/* 点状加载 */
@keyframes dotPulse {
  0%, 100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

.loading-dots span {
  animation: dotPulse 1s ease infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ========================================
   波纹动画
   ======================================== */
@keyframes ripple {
  from {
    transform: scale(0);
    opacity: 1;
  }
  to {
    transform: scale(4);
    opacity: 0;
  }
}

.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  background: rgba(74, 144, 217, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
}

.ripple:active::after {
  animation: ripple 0.6s ease forwards;
}

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

.gradient-animate {
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
}

/* ========================================
   浮动动画
   ======================================== */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.float-animate {
  animation: float 3s ease-in-out infinite;
}

/* ========================================
   减少动画模式（无障碍）
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .hero-title,
  .hero-subtitle,
  .hero-stats,
  .hero-actions,
  .hero-image,
  .hero-stat {
    opacity: 1;
    animation: none;
  }

  .animate-on-scroll,
  .stagger-item {
    opacity: 1;
    transform: none;
  }
}