/* ============================================================
 * TalkCode Global Design System
 * 统一的设计令牌、动效系统、暗黑模式、组件库
 * ============================================================ */

/* ========== 设计令牌 ========== */
:root {
  /* 主色调 */
  --tc-primary: #6366f1;
  --tc-primary-dark: #4f46e5;
  --tc-primary-light: #818cf8;
  --tc-primary-50: #eef2ff;
  --tc-primary-100: #e0e7ff;

  /* 强调色 */
  --tc-accent: #ec4899;
  --tc-accent-dark: #db2777;
  --tc-success: #22c55e;
  --tc-warning: #f59e0b;
  --tc-danger: #ef4444;
  --tc-info: #3b82f6;

  /* 中性色 */
  --tc-bg: #fafafe;
  --tc-surface: #ffffff;
  --tc-surface-2: #f4f5fa;
  --tc-text: #1a1d29;
  --tc-text-secondary: #5a6178;
  --tc-text-muted: #94a0b8;
  --tc-border: #e8eaf2;
  --tc-border-hover: #d0d4e2;

  /* 渐变 */
  --tc-gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  --tc-gradient-blue: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  --tc-gradient-purple: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
  --tc-gradient-green: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  --tc-gradient-orange: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  --tc-gradient-sunset: linear-gradient(135deg, #f97316 0%, #ec4899 50%, #8b5cf6 100%);
  --tc-gradient-ocean: linear-gradient(135deg, #06b6d4 0%, #3b82f6 50%, #6366f1 100%);
  --tc-gradient-aurora: linear-gradient(135deg, #10b981 0%, #06b6d4 50%, #6366f1 100%);

  /* 阴影 */
  --tc-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --tc-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --tc-shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --tc-shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.1);
  --tc-shadow-xl: 0 24px 48px rgba(15, 23, 42, 0.12);
  --tc-shadow-glow: 0 0 24px rgba(99, 102, 241, 0.15);

  /* 圆角 */
  --tc-radius-sm: 0.5rem;
  --tc-radius-md: 0.75rem;
  --tc-radius-lg: 1rem;
  --tc-radius-xl: 1.5rem;
  --tc-radius-full: 9999px;

  /* 过渡 */
  --tc-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --tc-transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --tc-transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --tc-transition-spring: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* 字体 */
  --tc-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', sans-serif;
  --tc-font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
}

/* ========== 暗黑模式 ========== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tc-bg: #0d1117;
    --tc-surface: #161b28;
    --tc-surface-2: #1c2233;
    --tc-text: #e6edf3;
    --tc-text-secondary: #9198b3;
    --tc-text-muted: #6b7388;
    --tc-border: #2a3042;
    --tc-border-hover: #3a4258;
    --tc-primary-50: rgba(99, 102, 241, 0.1);
    --tc-primary-100: rgba(99, 102, 241, 0.15);
    --tc-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --tc-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --tc-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
    --tc-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    --tc-shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.55);
  }
}

[data-theme="dark"] {
  --tc-bg: #0d1117;
  --tc-surface: #161b28;
  --tc-surface-2: #1c2233;
  --tc-text: #e6edf3;
  --tc-text-secondary: #9198b3;
  --tc-text-muted: #6b7388;
  --tc-border: #2a3042;
  --tc-border-hover: #3a4258;
  --tc-primary-50: rgba(99, 102, 241, 0.1);
  --tc-primary-100: rgba(99, 102, 241, 0.15);
  --tc-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --tc-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --tc-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --tc-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --tc-shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.55);
}

/* ========== 关键帧动画 ========== */
@keyframes tcFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes tcFadeInScale {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes tcSlideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes tcSlideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes tcFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

@keyframes tcPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

@keyframes tcShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes tcGradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes tcRipple {
  to { transform: scale(4); opacity: 0; }
}

@keyframes tcSpin {
  to { transform: rotate(360deg); }
}

@keyframes tcBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes tcGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.3); }
  50% { box-shadow: 0 0 40px rgba(99, 102, 241, 0.5); }
}

@keyframes tcHeartbeat {
  0%, 100% { transform: scale(1); }
  10%, 30% { transform: scale(0.9); }
  20%, 40% { transform: scale(1.1); }
}

/* ========== Scroll Reveal ========== */
[data-reveal] {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
[data-reveal].tc-revealed {
  opacity: 1;
  transform: translateY(0);
}
[data-reveal-delay="1"] { transition-delay: 0.1s; }
[data-reveal-delay="2"] { transition-delay: 0.2s; }
[data-reveal-delay="3"] { transition-delay: 0.3s; }
[data-reveal-delay="4"] { transition-delay: 0.4s; }
[data-reveal-delay="5"] { transition-delay: 0.5s; }

/* ========== 玻璃拟态 ========== */
.tc-glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .tc-glass,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tc-glass {
    background: rgba(22, 27, 40, 0.7);
    border: 1px solid rgba(42, 48, 66, 0.3);
  }
}

/* ========== 渐变文本 ========== */
.tc-gradient-text {
  background: var(--tc-gradient-primary);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: tcGradientShift 5s ease infinite;
}

.tc-gradient-text-blue {
  background: var(--tc-gradient-ocean);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tc-gradient-text-sunset {
  background: var(--tc-gradient-sunset);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ========== 增强按钮 ========== */
.tc-btn-ripple {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.tc-btn-ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.6);
  opacity: 0;
  border-radius: 100%;
  transform: scale(1, 1) translate(-50%, -50%);
  transform-origin: 50% 50%;
  pointer-events: none;
}

.tc-btn-ripple:active::after {
  animation: tcRipple 0.5s ease-out;
}

/* ========== 骨架屏 ========== */
.tc-skeleton {
  background: linear-gradient(
    90deg,
    var(--tc-surface-2) 25%,
    var(--tc-border) 50%,
    var(--tc-surface-2) 75%
  );
  background-size: 200% 100%;
  animation: tcShimmer 1.5s infinite;
  border-radius: var(--tc-radius-md);
}

.tc-skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.tc-skeleton-card {
  height: 320px;
  border-radius: var(--tc-radius-lg);
}

/* ========== 悬浮卡片 ========== */
.tc-hover-lift {
  transition: var(--tc-transition-spring);
  will-change: transform;
}

.tc-hover-lift:hover {
  transform: translateY(-8px);
}

/* ========== 气泡光效 ========== */
.tc-glow-on-hover {
  transition: var(--tc-transition);
}

.tc-glow-on-hover:hover {
  box-shadow: var(--tc-shadow-glow);
}

/* ========== 滚动条美化 ========== */
.tc-custom-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.tc-custom-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.tc-custom-scroll::-webkit-scrollbar-thumb {
  background: var(--tc-border-hover);
  border-radius: var(--tc-radius-full);
}

.tc-custom-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--tc-primary-light);
}

/* ========== 页面切换动画 ========== */
.tc-page-enter {
  animation: tcFadeIn 0.4s ease;
}

.tc-page-enter-stagger > * {
  opacity: 0;
  animation: tcFadeIn 0.4s ease forwards;
}
.tc-page-enter-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.tc-page-enter-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.tc-page-enter-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.tc-page-enter-stagger > *:nth-child(4) { animation-delay: 0.2s; }
.tc-page-enter-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.tc-page-enter-stagger > *:nth-child(6) { animation-delay: 0.3s; }
.tc-page-enter-stagger > *:nth-child(7) { animation-delay: 0.35s; }
.tc-page-enter-stagger > *:nth-child(8) { animation-delay: 0.4s; }

/* ========== 浮动装饰元素 ========== */
.tc-float-deco {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

/* ========== 增强输入框 ========== */
.tc-input-group {
  position: relative;
}

.tc-input-group input,
.tc-input-group textarea,
.tc-input-group select {
  transition: var(--tc-transition);
}

.tc-input-group input:focus,
.tc-input-group textarea:focus,
.tc-input-group select:focus {
  border-color: var(--tc-primary) !important;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12) !important;
}

/* ========== 渐变边框 ========== */
.tc-border-gradient {
  position: relative;
  background: var(--tc-surface);
  border-radius: var(--tc-radius-lg);
}

.tc-border-gradient::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: var(--tc-gradient-primary);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ========== 增强卡片 ========== */
.tc-card {
  background: var(--tc-surface);
  border: 1px solid var(--tc-border);
  border-radius: var(--tc-radius-lg);
  box-shadow: var(--tc-shadow-sm);
  transition: var(--tc-transition);
}

.tc-card:hover {
  box-shadow: var(--tc-shadow-lg);
  border-color: var(--tc-border-hover);
}

/* ========== 响应式工具类 ========== */
.tc-hidden-mobile { display: initial; }
@media (max-width: 768px) {
  .tc-hidden-mobile { display: none !important; }
}

.tc-hidden-desktop { display: none; }
@media (max-width: 768px) {
  .tc-hidden-desktop { display: initial !important; }
}

/* ========== 噪点背景纹理 ========== */
.tc-noise-bg::before {
  content: '';
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(rgba(0,0,0,0.015) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.6;
}

/* ========== 全局过渡入场 ========== */
.tc-fade-in { animation: tcFadeIn 0.5s ease; }
.tc-fade-in-scale { animation: tcFadeInScale 0.4s ease; }
.tc-slide-in-left { animation: tcSlideInLeft 0.5s ease; }
.tc-slide-in-right { animation: tcSlideInRight 0.5s ease; }

/* ========== 减少动画 (a11y) ========== */
@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;
  }
  [data-reveal] {
    opacity: 1;
    transform: none;
  }
}
