/* ========================================
   世界级优化 - 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;
}
