/* 趣味交互 + AI 元素样式 */

/* ==================== Confetti 彩纸庆祝 ==================== */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 99999;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -20px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg) scale(0.3); opacity: 0; }
}

/* ==================== 点击涟漪 ==================== */
.ripple {
  position: fixed;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 169, 110, 0.4) 0%, transparent 70%);
  transform: scale(0);
  animation: rippleEffect 0.8s ease-out forwards;
  pointer-events: none;
  z-index: 99998;
}

@keyframes rippleEffect {
  to { transform: scale(4); opacity: 0; }
}

/* ==================== 打字机效果 ==================== */
.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--color-accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorBlink 1s step-end infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ==================== 双击点赞心形 ==================== */
.floating-heart {
  position: fixed;
  pointer-events: none;
  z-index: 99999;
  animation: heartFloat 1.5s ease-out forwards;
  font-size: 24px;
  color: var(--color-accent);
}

@keyframes heartFloat {
  0% { transform: translateY(0) scale(0.5); opacity: 1; }
  50% { transform: translateY(-60px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-120px) scale(0.8); opacity: 0; }
}

/* ==================== 滚动故事卡片 ==================== */
.scroll-story-card {
  position: relative;
  transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.scroll-story-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(200, 169, 110, 0.1), transparent 60%);
  opacity: 0;
  transition: opacity 0.6s;
}

.scroll-story-card.in-view {
  transform: translateY(0) scale(1);
  box-shadow: var(--shadow-lg);
}

.scroll-story-card.in-view::after {
  opacity: 1;
}

/* ==================== Shimmer 闪光效果 ==================== */
.shimmer-card {
  position: relative;
  overflow: hidden;
}

.shimmer-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transform: skewX(-25deg);
  z-index: 1;
  pointer-events: none;
  opacity: 0;
}

.shimmer-card.active::before {
  opacity: 1;
  animation: shimmerSweep 1.5s ease-in-out;
}

@keyframes shimmerSweep {
  0% { left: -100%; }
  100% { left: 200%; }
}

/* ==================== Spotlight 聚焦效果 ==================== */
.spotlight-container {
  position: relative;
  overflow: hidden;
}

.spotlight-container .spotlight {
  position: absolute;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(200, 169, 110, 0.12) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 0;
  transition: opacity 0.3s;
  opacity: 0;
}

.spotlight-container:hover .spotlight {
  opacity: 1;
}

/* ==================== 卡片翻转 ==================== */
.flip-card-container {
  perspective: 1000px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-card-container:hover .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
}

.flip-card-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotateY(180deg);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

/* ==================== Glitch 故障艺术文字 ==================== */
@keyframes glitchShift {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, -1px); }
  80% { transform: translate(2px, 1px); }
}

.glitch-text:hover {
  animation: glitchShift 0.3s ease-in-out;
  text-shadow: 2px 0 var(--color-accent), -2px 0 rgba(200, 169, 110, 0.5);
}

/* ==================== 微振动 ==================== */
@keyframes microShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

.micro-shake:hover {
  animation: microShake 0.3s ease-in-out;
}

/* ========================================
   AI 元素样式
   ======================================== */

/* ==================== 神经网络粒子动画 ==================== */
.neural-network {
  position: relative;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.neural-node {
  position: absolute;
  width: 6px;
  height: 6px;
  background: rgba(200, 169, 110, 0.8);
  border-radius: 50%;
  animation: neuralPulse 3s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(200, 169, 110, 0.6);
}

.neural-line {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, rgba(200, 169, 110, 0.4), rgba(200, 169, 110, 0.8), rgba(200, 169, 110, 0.4));
  animation: neuralFlow 4s ease-in-out infinite;
  transform-origin: left center;
  opacity: 0.6;
}

@keyframes neuralPulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(2); opacity: 1; }
}

@keyframes neuralFlow {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.8; }
}

/* ==================== AI 脉冲环 ==================== */
.ai-pulse-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ai-pulse-ring::before,
.ai-pulse-ring::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(200, 169, 110, 0.4);
  animation: aiRingPulse 2.5s ease-out infinite;
}

.ai-pulse-ring::before {
  animation-delay: 0s;
}

.ai-pulse-ring::after {
  animation-delay: 1.25s;
}

@keyframes aiRingPulse {
  0% { width: 100%; height: 100%; opacity: 1; }
  100% { width: 250%; height: 250%; opacity: 0; }
}

/* ==================== AI 智能助手聊天 ==================== */
.ai-chat-widget {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 360px;
  max-height: 480px;
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-neutral-200);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.ai-chat-widget.active {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.ai-chat-header {
  background: linear-gradient(135deg, #0A1F3F 0%, #1A3A6B 100%);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.ai-chat-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.ai-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.ai-chat-avatar::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: #27ae60;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: aiOnlinePulse 2s infinite;
}

@keyframes aiOnlinePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(39, 174, 96, 0); }
}

.ai-chat-avatar svg {
  width: 22px;
  height: 22px;
  color: #fff;
}

.ai-chat-header-text h4 {
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  margin: 0;
}

.ai-chat-header-text span {
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
}

.ai-chat-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 250px;
  max-height: 300px;
}

.ai-chat-message {
  display: flex;
  gap: var(--space-2);
  max-width: 85%;
  animation: aiMsgSlide 0.3s ease-out;
}

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

.ai-chat-message.ai {
  align-self: flex-start;
}

.ai-chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-chat-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.ai-chat-message.ai .ai-chat-bubble {
  background: var(--bg-light);
  color: var(--color-text-primary);
  border-top-left-radius: 4px;
}

.ai-chat-message.user .ai-chat-bubble {
  background: var(--color-accent);
  color: var(--color-neutral-900);
  border-top-right-radius: 4px;
}

.ai-chat-typing {
  display: flex;
  gap: 3px;
  padding: var(--space-3) var(--space-4);
}

.ai-chat-typing span {
  width: 7px;
  height: 7px;
  background: var(--color-accent);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.ai-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.ai-chat-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-neutral-200);
  display: flex;
  gap: var(--space-2);
}

.ai-chat-footer input {
  flex: 1;
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-family: inherit;
}

.ai-chat-footer input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.ai-chat-footer button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--color-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.ai-chat-footer button:hover {
  background: var(--color-accent-dark);
}

/* AI 悬浮入口 */
.ai-chat-trigger {
  position: fixed;
  bottom: 160px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6C5CE7 0%, #4834d4 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.4);
  z-index: 10000;
  transition: all var(--transition-base);
  animation: aiBtnFloat 3s ease-in-out infinite;
}

.ai-chat-trigger:hover {
  transform: scale(1.15);
  box-shadow: 0 8px 30px rgba(108, 92, 231, 0.6);
}

@keyframes aiBtnFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.ai-chat-trigger svg {
  width: 26px;
  height: 26px;
  color: #fff;
}

/* ==================== AI 市场情绪指示器 ==================== */
.ai-sentiment-gauge {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  background: linear-gradient(135deg, rgba(10, 31, 63, 0.05) 0%, rgba(200, 169, 110, 0.05) 100%);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(200, 169, 110, 0.2);
}

.ai-sentiment-gauge-inner {
  flex: 1;
}

.ai-sentiment-label {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-1);
}

.ai-sentiment-value {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--color-accent);
}

.ai-sentiment-bar-wrap {
  flex: 3;
  height: 8px;
  background: linear-gradient(90deg, #c0392b 0%, #e67e22 25%, #f1c40f 50%, #2ecc71 75%, #27ae60 100%);
  border-radius: var(--radius-full);
  position: relative;
  overflow: hidden;
}

.ai-sentiment-indicator {
  position: absolute;
  top: -4px;
  width: 16px;
  height: 16px;
  background: #fff;
  border: 3px solid var(--color-accent);
  border-radius: 50%;
  transform: translateX(-50%);
  transition: left 1s ease;
  box-shadow: 0 0 10px rgba(200, 169, 110, 0.5);
}

.ai-sentiment-desc {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: var(--space-2);
}

/* ==================== AI 分析徽章 ==================== */
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.1), rgba(72, 52, 212, 0.1));
  border: 1px solid rgba(108, 92, 231, 0.3);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--font-medium);
  color: #6C5CE7;
}

.ai-badge svg {
  width: 14px;
  height: 14px;
}

.ai-badge.gold {
  background: linear-gradient(135deg, rgba(200, 169, 110, 0.1), rgba(180, 150, 100, 0.1));
  border-color: rgba(200, 169, 110, 0.3);
  color: var(--color-accent);
}

/* ==================== AI 思考点动画 ==================== */
.ai-thinking {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.ai-thinking span {
  width: 8px;
  height: 8px;
  background: #6C5CE7;
  border-radius: 50%;
  animation: aiThinkBounce 1.4s ease-in-out infinite;
}

.ai-thinking span:nth-child(2) { animation-delay: 0.2s; }
.ai-thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiThinkBounce {
  0%, 60%, 100% { transform: scale(1); opacity: 0.4; }
  30% { transform: scale(1.3); opacity: 1; }
}

/* ==================== 数据流动画 ==================== */
.data-stream-line {
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-accent), transparent);
  animation: dataStreamFlow 3s linear infinite;
  opacity: 0.6;
}

@keyframes dataStreamFlow {
  0% { transform: translateX(-100%); opacity: 0; }
  50% { opacity: 0.8; }
  100% { transform: translateX(200%); opacity: 0; }
}

/* ==================== 键盘快捷键提示 ==================== */
.kbd-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 31, 63, 0.9);
  color: #fff;
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-full);
  font-size: 11px;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(200, 169, 110, 0.3);
}

.kbd-hint.visible {
  opacity: 1;
}

.kbd-hint kbd {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 6px;
  border-radius: 3px;
  margin: 0 2px;
  color: var(--color-accent);
  font-family: monospace;
}

/* ==================== 扫光按钮 ==================== */
.btn-glow-sweep {
  position: relative;
  overflow: hidden;
}

.btn-glow-sweep::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -75%;
  width: 50%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  transform: skewX(-25deg);
  transition: none;
}

.btn-glow-sweep:hover::after {
  animation: btnSweep 0.6s ease-out;
}

@keyframes btnSweep {
  0% { left: -75%; }
  100% { left: 125%; }
}

/* 移动端适配 */
@media (max-width: 640px) {
  .ai-chat-widget {
    left: var(--space-4);
    right: var(--space-4);
    bottom: 90px;
    width: auto;
    max-height: 60vh;
  }

  .ai-chat-trigger {
    bottom: 140px;
    right: var(--space-4);
    width: 48px;
    height: 48px;
  }

  .ai-chat-footer button {
    width: 32px;
    height: 32px;
  }
}
