/* ========================================
   世界级优化 - 2025
   性能+交互+可访问性全面升级
   ======================================== */

/* ===== 性能优化 ===== */

/* 图片懒加载优化 - loading和decoding应在HTML中设置 */
/* <img loading="lazy" decoding="async"> */

/* 关键性能提升 */
*,
*::before,
*::after {
  will-change: auto;
}

.card, .hero-section, .sidebar {
  will-change: transform;
}

/* ===== 3D卡片Hover效果 ===== */
.story-panel,
.vision-card,
.timeline-item,
.contact-card,
.service-card,
.company-overview-card {
  transform-style: preserve-3d !important;
  will-change: transform !important;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1) !important,
              box-shadow 0.6s cubic-bezier(0.4, 0, 0.2, 1) !important;
  position: relative !important;
  cursor: pointer !important;
}

.story-panel:hover,
.vision-card:hover,
.timeline-item:hover,
.contact-card:hover,
.service-card:hover,
.company-overview-card:hover {
  transform: perspective(1000px) rotateY(2deg) rotateX(2deg) translateY(-4px) !important;
  box-shadow: 
    0 20px 60px rgba(93, 125, 173, 0.4),
    0 10px 30px rgba(93, 125, 173, 0.3) !important;
}

/* 鼠标追踪高光效果 */
.story-panel::before,
.vision-card::before,
.timeline-item::before,
.contact-card::before,
.service-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(255, 255, 255, 0.15),
    transparent 40%
  );
  opacity: 0;
  transition: opacity 0.3s;
  border-radius: inherit;
  z-index: 1;
  pointer-events: none;
}

.story-panel:hover::before,
.vision-card:hover::before,
.timeline-item:hover::before,
.contact-card:hover::before,
.service-card:hover::before {
  opacity: 1;
}

/* ===== 动画图标系统 ===== */
svg, .icon {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

svg:hover, .icon:hover {
  transform: scale(1.1) rotate(5deg);
}

/* 特定图标动画 */
.back-to-top svg {
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.hamburger span {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.active .hamburger span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.sidebar.active .hamburger span:nth-child(2) {
  opacity: 0;
}

.sidebar.active .hamburger span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== 按钮加载状态 ===== */
button {
  position: relative;
}

button.loading {
  pointer-events: none;
  color: transparent !important;
}

button.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== 点击波纹效果 ===== */
button, .pill-link, .nav-link {
  position: relative;
  overflow: hidden;
}

button::after, .pill-link::after, .nav-link::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

button:active::after, 
.pill-link:active::after, 
.nav-link:active::after {
  width: 300px;
  height: 300px;
}

/* ===== 输入框增强 ===== */
input, textarea, select {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

input:focus, textarea:focus, select:focus {
  transform: scale(1.02);
  box-shadow: 
    0 0 0 4px rgba(93, 125, 173, 0.1),
    0 4px 12px rgba(93, 125, 173, 0.15);
}

/* 错误状态 */
input.error, textarea.error {
  border-color: #ef4444 !important;
  animation: shake 0.5s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* ===== ARIA增强和可访问性 ===== */

/* Focus可见性增强 */
*:focus {
  outline: 3px solid rgba(93, 125, 173, 0.5);
  outline-offset: 2px;
}

/* 跳过导航链接 */
.skip-to-main {
  position: absolute;
  left: -9999px;
  z-index: 999;
  padding: 1rem;
  background: var(--glass-strong);
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
}

.skip-to-main:focus {
  left: 1rem;
  top: 1rem;
}

/* 屏幕阅读器专用 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ===== Command K搜索面板 ===== */
.command-palette {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  width: 90%;
  max-width: 600px;
  background: var(--glass-strong);
  backdrop-filter: blur(40px);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.command-palette.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

.command-palette input {
  width: 100%;
  padding: 1rem;
  border: none;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.command-palette .results {
  max-height: 400px;
  overflow-y: auto;
}

.command-palette .result-item {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.command-palette .result-item:hover {
  background: rgba(93, 125, 173, 0.1);
}

/* ===== 骨架屏加载 ===== */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0.1) 100%
  );
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
}

.skeleton-title {
  height: 2em;
  width: 60%;
  margin-bottom: 1em;
}

/* ===== 深色模式增强 ===== */
@media (prefers-color-scheme: dark) {
  
  .command-palette {
    background: rgba(26, 26, 46, 0.95);
  }
  
  .story-panel:hover::before,
  .vision-card:hover::before,
  .timeline-item:hover::before,
  .contact-card:hover::before,
  .service-card:hover::before {
    background: radial-gradient(
      600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
      rgba(255, 255, 255, 0.08),
      transparent 40%
    );
  }
  
  input:focus, textarea:focus, select:focus {
    box-shadow: 
      0 0 0 4px rgba(255, 255, 255, 0.1),
      0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

/* ===== 手势提示 ===== */
.swipe-hint {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 999px;
  font-size: 0.875rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
}

.swipe-hint.show {
  opacity: 1;
}

/* ===== 滚动优化 ===== */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== 打印样式优化 ===== */
@media print {
  .sidebar,
  .mobile-header,
  .back-to-top,
  .command-palette {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .main {
    margin: 0;
    box-shadow: none;
  }
}

/* ===== 高对比度模式支持 ===== */
@media (prefers-contrast: high) {
  :root {
    --text: #000;
    --bg-start: #fff;
    --bg-end: #f0f0f0;
  }
  
  button, .pill-link {
    border: 2px solid currentColor;
  }
}

/* ===== 性能监控标记 ===== */
.perf-mark {
  display: none;
}


/* ===== merged from micro-interactions.css ===== */
/* ========================================
   微交互增强 - 极致细节
   让每个交互都有灵魂
   ======================================== */

/* ===== 页面加载动画 ===== */
@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;
  }
}
