/**
 * Premium Enhanced Theme - 性能优化的视觉增强
 * 在 premium-theme.css 基础上添加渐进增强
 * 所有动画都经过性能优化，使用 GPU 加速
 */

/* ============================================
   性能优化基础设置
   ============================================ */

/* 为所有可能动画的元素启用 GPU 加速 */
:is(
  .stock-card, .decision-card, .tracking-review-card, .news-card,
  .catalyst-stat, .metric-tile, .summary-card, .detail-section,
  .button, .btn, .stock-action-link, .chip, .badge
) {
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-font-smoothing: subpixel-antialiased;
}

/* 优化滚动性能 */
.stock-list,
.decision-card-grid,
.tracking-review-list,
.decision-signal-list {
  contain: layout style paint;
  content-visibility: auto;
}

/* ============================================
   微动效增强 - 细腻的交互反馈
   ============================================ */

/* 卡片悬停效果增强 */
:is(.stock-card, .decision-card, .tracking-review-card, .news-card,
    .catalyst-stat, .radar-card, .notice-card, .risk-card):hover {
  transform: translateY(-4px) translateZ(0) scale(1.005);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 24px 48px rgba(15, 23, 42, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.98) !important;
  border-color: rgba(148, 163, 184, 0.42) !important;
  transition:
    transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 280ms cubic-bezier(0.34, 1.56, 0.64, 1),
    border-color 280ms ease;
}

/* 卡片按下效果 */
:is(.stock-card, .decision-card, .tracking-review-card):active {
  transform: translateY(-1px) translateZ(0) scale(1.002);
  transition-duration: 80ms;
}

/* 按钮悬停增强 - 更明显的反馈 */
:is(.button, .btn, .action-button, .search-button,
    .catalyst-button, .stock-action-link):hover:not(:disabled) {
  transform: translateY(-2px) translateZ(0);
  box-shadow:
    0 2px 4px rgba(15, 23, 42, 0.06),
    0 12px 28px rgba(15, 23, 42, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.98) !important;
  filter: brightness(1.05) saturate(1.05);
  transition:
    transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 220ms ease,
    filter 220ms ease;
}

/* 按钮按下效果 */
:is(.button, .btn, .action-button, .search-button):active:not(:disabled) {
  transform: translateY(0) translateZ(0) scale(0.98);
  transition-duration: 60ms;
}

/* 输入框聚焦增强 */
:is(input, select, textarea):focus {
  transform: translateZ(0);
  box-shadow:
    0 0 0 4px rgba(15, 23, 42, 0.08),
    0 2px 8px rgba(15, 23, 42, 0.06),
    inset 0 1px 2px rgba(15, 23, 42, 0.04) !important;
  transition:
    border-color 200ms ease,
    box-shadow 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================
   骨架屏加载效果
   ============================================ */

/* 骨架屏基础样式 */
.skeleton,
.loading-skeleton {
  position: relative;
  overflow: hidden;
  background: linear-gradient(
    90deg,
    #f1f5f9 0%,
    #e2e8f0 20%,
    #f1f5f9 40%,
    #f1f5f9 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.8s ease-in-out infinite;
  border-radius: inherit;
}

.skeleton::after,
.loading-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.6) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: skeleton-shine 2s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes skeleton-shine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* 骨架屏卡片 */
.stock-card.skeleton,
.decision-card.skeleton,
.tracking-review-card.skeleton {
  pointer-events: none;
  min-height: 220px;
}

.stock-card.skeleton > *,
.decision-card.skeleton > *,
.tracking-review-card.skeleton > * {
  visibility: hidden;
}

/* ============================================
   视觉层次增强
   ============================================ */

/* 标题下划线动画 */
h1::after,
.hero h1::after,
.catalyst-hero h1::after,
.radar-hero h1::after,
#pair-title::after {
  transform-origin: left center;
  animation: title-underline-grow 600ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes title-underline-grow {
  from {
    width: 0;
    opacity: 0;
  }
  to {
    width: 54px;
    opacity: 1;
  }
}

/* 数字跳动效果 */
@property --num {
  syntax: '<integer>';
  initial-value: 0;
  inherits: false;
}

.metric-tile strong,
.decision-metric strong,
.tracking-review-metric strong,
.decision-score {
  animation: number-pop 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes number-pop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 徽章脉冲效果 */
.nav-red-dot,
.catalyst-notice-card.is-unread .catalyst-notice-card__tag {
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.9;
  }
}

/* ============================================
   渐进式加载动画
   ============================================ */

/* 卡片淡入效果 */
.stock-card,
.decision-card,
.tracking-review-card,
.news-card,
.catalyst-stat {
  animation: card-fade-in 400ms cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

/* 为列表中的卡片添加延迟 */
.stock-card:nth-child(1) { animation-delay: 0ms; }
.stock-card:nth-child(2) { animation-delay: 40ms; }
.stock-card:nth-child(3) { animation-delay: 80ms; }
.stock-card:nth-child(4) { animation-delay: 120ms; }
.stock-card:nth-child(5) { animation-delay: 160ms; }
.stock-card:nth-child(n+6) { animation-delay: 200ms; }

.decision-card:nth-child(1) { animation-delay: 0ms; }
.decision-card:nth-child(2) { animation-delay: 30ms; }
.decision-card:nth-child(3) { animation-delay: 60ms; }
.decision-card:nth-child(4) { animation-delay: 90ms; }
.decision-card:nth-child(5) { animation-delay: 120ms; }
.decision-card:nth-child(n+6) { animation-delay: 150ms; }

@keyframes card-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px) translateZ(0);
  }
  to {
    opacity: 1;
    transform: translateY(0) translateZ(0);
  }
}

/* ============================================
   色彩增强 - 更好的视觉对比
   ============================================ */

/* 涨跌颜色增强 */
.up,
.positive,
.is-positive strong,
.decision-card.is-positive .decision-score {
  color: #dc2626 !important;
  font-weight: 800;
  text-shadow: 0 0 1px rgba(220, 38, 38, 0.1);
}

.down,
.negative,
.is-risk strong,
.decision-card.is-risk .decision-score {
  color: #059669 !important;
  font-weight: 800;
  text-shadow: 0 0 1px rgba(5, 150, 105, 0.1);
}

/* 重要信息高亮 */
.decision-card.is-positive,
.tracking-review-card.is-verified,
.catalyst-notice-card.is-unread {
  position: relative;
}

.decision-card.is-positive::before,
.tracking-review-card.is-verified::before,
.catalyst-notice-card.is-unread::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    circle at 50% 0%,
    rgba(220, 38, 38, 0.08),
    transparent 60%
  );
  transition: opacity 300ms ease;
}

.decision-card.is-positive:hover::before,
.tracking-review-card.is-verified:hover::before,
.catalyst-notice-card.is-unread:hover::before {
  opacity: 1;
}

/* ============================================
   搜索栏增强
   ============================================ */

.search-bar {
  position: relative;
  transition: all 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.search-bar:focus-within {
  transform: translateY(-2px) translateZ(0);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 0 0 4px rgba(14, 122, 98, 0.12),
    0 20px 40px rgba(48, 46, 39, 0.16) !important;
}

/* 搜索图标动画 */
.search-bar::before {
  transition: all 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.search-bar:focus-within::before {
  transform: translateY(-55%) scale(1.1);
  border-color: rgba(14, 122, 98, 0.7);
}

.search-bar:focus-within::after {
  background: rgba(14, 122, 98, 0.7);
}

/* ============================================
   工具提示增强
   ============================================ */

/* 为带 title 属性的元素添加更好的提示 */
[title] {
  position: relative;
  cursor: help;
}

/* ============================================
   滚动条美化
   ============================================ */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(148, 163, 184, 0.08);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 5px;
  transition: background 200ms ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}

::-webkit-scrollbar-thumb:active {
  background: rgba(148, 163, 184, 0.7);
}

/* Firefox 滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) rgba(148, 163, 184, 0.08);
}

/* ============================================
   表格增强
   ============================================ */

table {
  animation: table-fade-in 400ms ease-out;
}

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

tr {
  transition: background-color 200ms ease;
}

tr:hover {
  background-color: rgba(148, 163, 184, 0.04) !important;
}

/* ============================================
   通知和提醒增强
   ============================================ */

.catalyst-notice-board,
.import-notice,
.batch-alert {
  animation: notice-slide-in 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes notice-slide-in {
  from {
    opacity: 0;
    transform: translateY(-20px) translateZ(0);
  }
  to {
    opacity: 1;
    transform: translateY(0) translateZ(0);
  }
}

/* ============================================
   加载状态优化
   ============================================ */

/* 优化现有的加载动画 */
.loading-card::after,
[class*="loading"]::after {
  animation: premium-spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

@keyframes premium-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* AI 运行状态增强 */
:is(.ai-radar-running, button[aria-busy="true"], .button[aria-busy="true"],
    .btn[aria-busy="true"], .is-loading, .is-running) {
  position: relative;
  overflow: hidden;
}

:is(.ai-radar-running, button[aria-busy="true"], .button[aria-busy="true"],
    .btn[aria-busy="true"], .is-loading, .is-running)::after {
  animation: ai-radar-sheen 2.5s ease-in-out infinite;
}

/* ============================================
   响应式优化
   ============================================ */

@media (max-width: 900px) {
  /* 移动端减少动画复杂度 */
  .stock-card:hover,
  .decision-card:hover,
  .tracking-review-card:hover {
    transform: translateY(-2px) translateZ(0);
  }

  /* 移动端简化阴影 */
  .stock-card:hover,
  .decision-card:hover {
    box-shadow:
      0 1px 2px rgba(15, 23, 42, 0.06),
      0 16px 32px rgba(15, 23, 42, 0.1) !important;
  }
}

@media (max-width: 640px) {
  /* 小屏幕进一步简化 */
  .stock-card:nth-child(n+4),
  .decision-card:nth-child(n+4) {
    animation-delay: 100ms;
  }
}

/* ============================================
   性能优化 - 减少重绘
   ============================================ */

/* 使用 will-change 提示浏览器 */
.stock-card:hover,
.decision-card:hover,
.tracking-review-card:hover,
.button:hover,
.btn:hover {
  will-change: transform, box-shadow;
}

/* 动画结束后移除 will-change */
.stock-card,
.decision-card,
.tracking-review-card {
  will-change: auto;
}

/* ============================================
   暗色模式支持（预留）
   ============================================ */

@media (prefers-color-scheme: dark) {
  /* 如果需要暗色模式，可以在这里添加 */
  /* 目前保持浅色主题 */
}

/* ============================================
   打印样式优化
   ============================================ */

@media print {
  /* 打印时移除所有动画和阴影 */
  * {
    animation: none !important;
    transition: none !important;
    box-shadow: none !important;
  }

  .stock-card,
  .decision-card,
  .tracking-review-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* ============================================
   辅助功能增强
   ============================================ */

/* 键盘导航焦点样式 */
:focus-visible {
  outline: 3px solid rgba(14, 122, 98, 0.5);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .stock-card:hover,
  .decision-card:hover,
  .button:hover {
    transform: none;
  }
}

/* ============================================
   微交互细节
   ============================================ */

/* Chip 悬停效果 */
:is(.chip, .badge, .pill, [class*="chip"], [class*="badge"]):hover {
  transform: translateY(-1px) translateZ(0);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  transition: all 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 链接悬停效果 */
a:not(.button):not(.btn):not(.stock-action-link):hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  transition: all 200ms ease;
}

/* Rise analysis cards contain dense Chinese reading text. Do not scale or
   translate them on hover; transformed layers make the stock logic look soft. */
#stock-list .stock-card,
#stock-list .stock-card:hover,
#stock-list .stock-card:active,
#stock-list .analysis-main-link,
#stock-list .analysis-main-link:hover,
#stock-list .analysis-main-link:active {
  transform: none !important;
  backface-visibility: visible !important;
  will-change: auto !important;
}

#stock-list .stock-card:hover {
  border-color: rgba(148, 163, 184, 0.34) !important;
  box-shadow: 0 0 0 1px rgba(95, 143, 122, 0.10) !important;
}

/* 选择文本样式增强 */
::selection {
  background: rgba(14, 122, 98, 0.2);
  color: inherit;
  text-shadow: none;
}

::-moz-selection {
  background: rgba(14, 122, 98, 0.2);
  color: inherit;
  text-shadow: none;
}

/* ============================================
   特殊效果 - 玻璃态增强
   ============================================ */

.hero__content,
.hero__panel,
.toolbar,
.top-nav,
.export-panel {
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
}

/* ============================================
   数据可视化增强
   ============================================ */

/* 进度条样式 */
.progress-bar {
  position: relative;
  height: 6px;
  background: rgba(148, 163, 184, 0.15);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    var(--premium-accent),
    var(--premium-accent-strong)
  );
  border-radius: inherit;
  transform-origin: left center;
  animation: progress-fill 1s ease-out forwards;
}

@keyframes progress-fill {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(var(--progress, 1));
  }
}

/* ============================================
   性能监控提示
   ============================================ */

/*
  性能优化清单：
  ✓ 使用 transform 和 opacity 进行动画（GPU 加速）
  ✓ 避免 layout 和 paint 触发
  ✓ 使用 will-change 提示浏览器
  ✓ 使用 content-visibility 优化渲染
  ✓ 使用 contain 属性隔离渲染
  ✓ 响应式动画简化
  ✓ 支持 prefers-reduced-motion
  ✓ 合理使用 animation-delay
  ✓ 优化选择器性能
*/

/* ============================================
   工具类
   ============================================ */

/* 隐藏元素 */
.hidden {
  display: none !important;
}
