/* ========================================
   微交互增强 - 极致细节
   让每个交互都有灵魂
   ======================================== */

/* ===== 页面加载动画 ===== */
@keyframes pageLoad {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body {
  animation: pageLoad 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 滚动视差效果 ===== */
.parallax {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 按钮磁吸效果 ===== */
.cta-box button,
.contact-btn,
.pill-link {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cta-box button:hover,
.contact-btn:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 
    0 10px 30px rgba(93, 125, 173, 0.3),
    0 0 20px rgba(93, 125, 173, 0.2);
}

/* ===== 文字渐入效果 ===== */
@keyframes textFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h1, h2, h3 {
  animation: textFadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

h2 {
  animation-delay: 0.1s;
  animation-fill-mode: both;
}

h3 {
  animation-delay: 0.2s;
  animation-fill-mode: both;
}

/* ===== 链接下划线动画 ===== */
a:not(.pill-link):not(.nav-link) {
  position: relative;
  text-decoration: none;
}

a:not(.pill-link):not(.nav-link)::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: currentColor;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

a:not(.pill-link):not(.nav-link):hover::after {
  width: 100%;
}

/* ===== 卡片磁场效果 ===== */
@media (hover: hover) {
  .story-panel,
  .vision-card,
  .timeline-item,
  .contact-card,
  .service-card {
    position: relative;
  }
  
  .story-panel::after,
  .vision-card::after,
  .timeline-item::after,
  .contact-card::after,
  .service-card::after {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(
      135deg,
      rgba(93, 125, 173, 0.3),
      rgba(93, 125, 173, 0.1),
      transparent
    );
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: -1;
  }
  
  .story-panel:hover::after,
  .vision-card:hover::after,
  .timeline-item:hover::after,
  .contact-card:hover::after,
  .service-card:hover::after {
    opacity: 1;
  }
}

/* ===== 输入框脉冲效果 ===== */
@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(93, 125, 173, 0.4);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(93, 125, 173, 0);
  }
}

input:focus,
textarea:focus {
  animation: pulse 2s infinite;
}

/* ===== 数字计数动画 ===== */
@keyframes countUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.stat-number {
  display: inline-block;
  overflow: hidden;
}

.stat-number span {
  display: inline-block;
  animation: countUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 滚动进度条 ===== */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  z-index: 9999;
  transition: width 0.1s;
}

/* ===== 悬浮提示 ===== */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-5px);
  padding: 0.5rem 0.75rem;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 0.875rem;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 1000;
}

[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(-10px);
}

/* ===== 背景渐变动画 ===== */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.background-gradient {
  background-size: 200% 200%;
  animation: gradientShift 15s ease infinite;
}

/* ===== Hero标题打字效果 ===== */
@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blink {
  50% {
    border-color: transparent;
  }
}

.hero-title.typing {
  overflow: hidden;
  border-right: 3px solid;
  white-space: nowrap;
  animation: 
    typing 2s steps(20) 1s forwards,
    blink 0.75s step-end infinite;
}

/* ===== 卡片翻转效果 ===== */
.flip-card {
  perspective: 1000px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s;
  transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}

.flip-card-back {
  transform: rotateY(180deg);
}

/* ===== 粒子效果背景 ===== */
.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  animation: float 10s infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100vh) translateX(100px);
    opacity: 0;
  }
}

/* ===== 按钮扫光效果 ===== */
.shine-effect {
  position: relative;
  overflow: hidden;
}

.shine-effect::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s;
}

.shine-effect:hover::before {
  left: 100%;
}

/* ===== 页面切换过渡 ===== */
.page-transition {
  position: fixed;
  inset: 0;
  background: var(--bg-start);
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
}

.page-transition.active {
  opacity: 1;
  pointer-events: all;
}

/* ===== 弹簧动画 ===== */
@keyframes spring {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  75% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

.spring-animation {
  animation: spring 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ===== 图片懒加载占位 ===== */
img[loading="lazy"] {
  background: linear-gradient(
    90deg,
    #f0f0f0 0%,
    #f8f8f8 50%,
    #f0f0f0 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

img[loading="lazy"].loaded {
  animation: none;
  background: none;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* ===== 状态指示器 ===== */
.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  position: relative;
}

.status-indicator.online {
  background: #10b981;
}

.status-indicator.offline {
  background: #ef4444;
}

.status-indicator.online::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px solid #10b981;
  border-radius: 50%;
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* ===== 进度条动画 ===== */
.progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(93, 125, 173, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 999px;
}

/* ===== 通知Toast ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ===== 选中文本样式 ===== */
::selection {
  background: rgba(93, 125, 173, 0.3);
  color: inherit;
}

::-moz-selection {
  background: rgba(93, 125, 173, 0.3);
  color: inherit;
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(93, 125, 173, 0.1);
}

::-webkit-scrollbar-thumb {
  background: rgba(93, 125, 173, 0.3);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(93, 125, 173, 0.5);
  background-clip: content-box;
}

/* ===== 响应式断点增强 ===== */
@media (max-width: 768px) {
  /* 移动端简化动画 */
  .story-panel:hover,
  .vision-card:hover,
  .timeline-item:hover {
    transform: translateY(-2px);
  }
  
  /* 移动端禁用某些效果 */
  .parallax {
    transform: none !important;
  }
}

/* ===== 打印样式 ===== */
@media print {
  .scroll-progress,
  .toast,
  .particles {
    display: none !important;
  }
  
  * {
    animation: none !important;
    transition: none !important;
  }
}
