/* ============================================================
   common.css —— 全站公共样式
   被 index.html / board.html / detail.html / home.html 共用：
     <link rel="stylesheet" href="common.css">
   必须放在各页内联 <style> 之前，这样页面私有规则才能正常覆盖。

   收录范围：设计令牌 / 基础重置 / 涨跌色 / 网格背景 / Header / Brand /
   按钮 / 主题·隐私图标 / Toast / Banner / 入场动画 / 无障碍。
   页面私有部分（表格、卡片、图表、响应式、移动端专属）仍留在各自 <style>。
   ============================================================ */

/* ============================================================ 1. Design tokens
   取四页的并集：补了 --ease-bounce / --sp-8 / --z-modal，
   --z-toast 统一为最高层级 9999（原来 detail/board/home 是 100，语义不变）。
   注意：board 需要真正的等宽字体，在 board.html 里单独覆盖 --font-mono。 */
:root {
  --bg-deep: #070b14;
  --bg-base: #0a0e1a;
  --surface-1: #0d1321;
  --surface-2: #141b2d;
  --surface-3: #1a2340;
  --surface-4: #212d4a;

  --cyan: #00d4ff;
  --cyan-dim: rgba(0, 212, 255, 0.15);
  --cyan-glow: rgba(0, 212, 255, 0.4);
  --purple: #7b5cff;
  --purple-dim: rgba(123, 92, 255, 0.15);
  --purple-glow: rgba(123, 92, 255, 0.4);
  --gold: #ffd93d;

  /* 涨=红 跌=绿（A 股惯例，勿改） */
  --up: #ff3366;
  --up-dim: rgba(255, 51, 102, 0.15);
  --down: #00e088;
  --down-dim: rgba(0, 224, 136, 0.15);
  --flat: #5a6a8a;
  --warn: #ffa500;

  --text: #e8eaf0;
  --text-dim: #8a94a8;
  --text-faint: #4a5568;

  --border: rgba(123, 92, 255, 0.2);
  --border-dim: rgba(123, 92, 255, 0.1);

  --sp-1: 4px; --sp-2: 6px; --sp-3: 10px; --sp-4: 14px;
  --sp-5: 18px; --sp-6: 24px; --sp-7: 32px; --sp-8: 48px;

  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  --t-fast: 120ms; --t-mid: 240ms; --t-slow: 400ms; --t-enter: 600ms;

  --font-mono: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;

  --z-dropdown: 60; --z-sticky: 80; --z-modal: 100; --z-toast: 9999;
}

:root[data-theme="light"] {
  --bg-deep: #f8f9fc;
  --bg-base: #ffffff;
  --surface-1: #f0f2f7;
  --surface-2: #e8ebf2;
  --surface-3: #dfe3ed;
  --surface-4: #d0d5e0;

  --cyan: #0099cc;
  --cyan-dim: rgba(0, 153, 204, 0.1);
  --cyan-glow: rgba(0, 153, 204, 0.3);
  --purple: #5b3fd9;
  --purple-dim: rgba(91, 63, 217, 0.1);
  --purple-glow: rgba(91, 63, 217, 0.3);

  --text: #1a1f36;
  --text-dim: #5a6478;
  --text-faint: #8a94a8;

  --border: rgba(91, 63, 217, 0.2);
  --border-dim: rgba(91, 63, 217, 0.1);

  --up: #dc2626;
  --up-dim: rgba(220, 38, 38, 0.1);
  --down: #16a34a;
  --down-dim: rgba(22, 163, 74, 0.1);
}

/* ============================================================ 2. Base */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

/* 隐藏 Vue 未编译时的双花括号占位 */
[v-cloak] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ============================================================ 3. 数字 / 涨跌色 */
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }

/* ============================================================ 4. Grid background
   home 需要不同的径向遮罩参数，在 home.html 里覆盖。 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(var(--border-dim) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-dim) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 50% at 50% 20%, black 20%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 50% at 50% 20%, black 20%, transparent 100%);
  pointer-events: none;
}

/* ============================================================ 4.5 背景粒子（tsParticles）
   容器由 particles.js 自动注入到 body 第一个子元素处。与上面的 body::before 网格
   同为 z-index:0，靠 DOM 顺序压在网格之上；各页 .wrap 是 z-index:1，内容再盖上来。
   pointer-events:none 保证不挡点击（鼠标交互靠 tsParticles 挂 window 实现）。 */
.fund-particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.fund-particles canvas { display: block; }

/* 打印时不渲染背景动效 */
@media print {
  .fund-particles { display: none !important; }
}

/* ============================================================ 5. Header / Brand
   只放四页一致的部分；margin-bottom / padding / gap / flex 等差异由各页覆盖。 */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
  position: relative;
  z-index: var(--z-sticky);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.mark-link { display: flex; }

.mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex: none;
  display: block;
  box-shadow:
    0 0 0 1px var(--border),
    0 0 20px var(--purple-glow);
  transition: box-shadow var(--t-mid) var(--ease-out);
}

.mark:hover {
  box-shadow:
    0 0 0 1px var(--cyan),
    0 0 30px var(--cyan-glow);
}

/* ============================================================ 6. Buttons */
button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--r-md);
  border: 1px solid var(--border-dim);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 16px;
  transition:
    background-color var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out),
    color var(--t-fast) var(--ease-out),
    transform var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out);
}

button:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 16px var(--cyan-dim);
}

button:active { transform: scale(0.97); }

button.primary {
  background: linear-gradient(135deg, var(--cyan) 0%, var(--purple) 100%);
  border-color: transparent;
  color: white;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 212, 255, 0.25);
}

button.primary:hover {
  color: white;
  filter: brightness(1.1);
  box-shadow: 0 6px 24px rgba(0, 212, 255, 0.35);
}

button.ghost { background: transparent; }
button.ghost:hover { background: var(--surface-2); }

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button:disabled:hover {
  transform: none;
  border-color: var(--border);
  color: var(--text);
}

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
}

/* 扩大点击热区 */
.icon-btn::before { content: ''; position: absolute; inset: -6px; }
.icon-btn svg { width: 18px; height: 18px; display: block; }

/* ============================================================ 7. 主题 / 隐私图标 */
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
:root[data-theme="light"] .i-sun { display: none; }
:root[data-theme="light"] .i-moon { display: block; }

:root[data-privacy="off"] .i-eye { display: block; }
:root[data-privacy="off"] .i-eye-off { display: none; }
:root[data-privacy="on"] .i-eye { display: none; }
:root[data-privacy="on"] .i-eye-off { display: block; }

/* ============================================================ 8. Toast */
.toast-wrap {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  pointer-events: none;
  max-width: 420px;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 18px;
  border-radius: var(--r-lg);
  font-size: 13px;
  line-height: 1.6;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 24px var(--cyan-dim);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  pointer-events: auto;
  animation: toastIn var(--t-mid) var(--ease-out) both;
  position: relative;
  min-width: 280px;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--cyan);
  border-radius: var(--r-lg) 0 0 var(--r-lg);
}

.toast.err::before { background: var(--up); }
.toast.err { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 24px var(--up-dim); }

.toast.warn::before { background: var(--warn); }
.toast.warn { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 24px rgba(255, 165, 0, 0.2); }

.toast-msg { flex: 1; }

.toast-close {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: var(--r-sm);
  padding: 0;
  font-size: 16px;
  line-height: 1;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}

.toast-close:hover {
  background: var(--surface-3);
  color: var(--text);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: none; }
}

@keyframes toastOut {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateX(24px); }
}

.toast.out { animation: toastOut var(--t-fast) var(--ease-out) both; }

/* ============================================================ 9. 动画 */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

@keyframes pop {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* ============================================================ 11. Reduced motion
   各页还会在自己的 <style> 里补 button:hover / .card:hover / .spin 等。 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
