/* ============================================================
   Components — 复用模块。所有页面共享。
   ============================================================ */

/* —— 顶部导航（站内通用） —— */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  background: color-mix(in oklch, var(--bg) 78%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav__inner {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(20px, 4vw, 48px);
  display: flex;
  align-items: center;
  gap: var(--s-8);
}
.nav__brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
}
.nav__brand .mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), oklch(72% 0.18 290));
  position: relative;
  overflow: hidden;
}
.nav__brand .mark::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 3px;
  background: linear-gradient(135deg, oklch(96% 0.04 70), oklch(82% 0.13 35));
  mix-blend-mode: screen;
  opacity: 0.85;
}
.nav__links {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  flex: 1;
}
.nav__links a {
  padding: 6px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--fg-2);
  transition: color var(--d-fast) var(--ease-out), background-color var(--d-fast) var(--ease-out);
}
.nav__links a:hover { color: var(--fg); background: var(--surface-2); }
.nav__links a[aria-current='page'] { color: var(--fg); background: var(--surface-2); }
.nav__cta { display: flex; gap: var(--s-2); margin-left: auto; align-items: center; }

/* —— 按钮 —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--fg);
  transition: transform var(--d-fast) var(--ease-out),
              background-color var(--d-fast) var(--ease-out),
              border-color var(--d-fast) var(--ease-out),
              box-shadow var(--d-fast) var(--ease-out);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.btn--primary:hover { background: oklch(28% 0.012 250); }
[data-theme='dark'] .btn--primary:hover { background: oklch(86% 0.005 250); }

.btn--accent {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn--accent:hover { background: var(--accent-hover); }

.btn--ghost {
  background: transparent;
  color: var(--fg-2);
}
.btn--ghost:hover { background: var(--surface-2); color: var(--fg); }

.btn--outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--fg);
}
.btn--outline:hover { background: var(--surface-2); }

.btn--lg { padding: 12px 20px; font-size: 15px; border-radius: var(--r-md); }
.btn--sm { padding: 5px 10px; font-size: 13px; border-radius: var(--r-sm); }

.btn--icon { padding: 8px; aspect-ratio: 1; }

/* —— 卡片 —— */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  transition: border-color var(--d-base) var(--ease-out),
              box-shadow var(--d-base) var(--ease-out),
              transform var(--d-base) var(--ease-out);
}
.card--hover:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

/* —— 输入 —— */
.input, .textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--fg);
  transition: border-color var(--d-fast) var(--ease-out),
              box-shadow var(--d-fast) var(--ease-out);
  font-family: inherit;
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.55; }

/* —— Pill / 标签 —— */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--fg-2);
  border: 1px solid var(--border);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.pill--accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill--success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.pill--warn  { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill--danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.pill__dot--pulse {
  position: relative;
}
.pill__dot--pulse::after {
  content: '';
  position: absolute; inset: -4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.3;
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(0.6); opacity: 0.5; }
  100% { transform: scale(2);   opacity: 0;   }
}

/* —— KBD —— */
kbd, .kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-bottom-width: 1.5px;
  border-radius: var(--r-xs);
  font-size: 11px;
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
}

/* —— Procedural 图像（替代真实图）。每个 --img-* 是一个独立"作品" —— */
.proc-img {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-2);
  isolation: isolate;
}
.proc-img::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--proc-grad, conic-gradient(from 90deg at 50% 50%, oklch(70% 0.16 280), oklch(82% 0.14 80), oklch(72% 0.18 200), oklch(70% 0.16 280)));
  filter: blur(0px) saturate(1.05);
}
.proc-img::after {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 60% at 30% 30%, oklch(95% 0.04 60 / 0.55), transparent 60%),
    radial-gradient(70% 60% at 70% 80%, oklch(45% 0.18 280 / 0.4), transparent 60%);
  mix-blend-mode: overlay;
}
.proc-img__caption {
  position: absolute;
  left: 10px; right: 10px; bottom: 10px;
  font-size: 11px;
  color: oklch(99% 0.002 240);
  background: oklch(15% 0.012 250 / 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  letter-spacing: 0.01em;
  line-height: 1.4;
  font-weight: 500;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--d-base) var(--ease-out), transform var(--d-base) var(--ease-out);
}
.proc-img:hover .proc-img__caption { opacity: 1; transform: none; }
.proc-img:hover::before { transform: scale(1.04); transition: transform 800ms var(--ease-out); }

/* 6 种预设"画风"梯度 */
.proc-img--neon    { --proc-grad: conic-gradient(from 130deg at 50% 50%, oklch(58% 0.20 320), oklch(66% 0.22 30), oklch(60% 0.20 200), oklch(58% 0.20 320)); }
.proc-img--warm    { --proc-grad: linear-gradient(160deg, oklch(86% 0.10 60) 0%, oklch(72% 0.16 35) 50%, oklch(45% 0.16 25) 100%); }
.proc-img--cosmos  { --proc-grad: radial-gradient(80% 80% at 30% 40%, oklch(72% 0.14 320), oklch(40% 0.18 280) 50%, oklch(18% 0.10 280) 100%); }
.proc-img--ocean   { --proc-grad: linear-gradient(170deg, oklch(90% 0.04 220) 0%, oklch(70% 0.10 230) 50%, oklch(40% 0.12 240) 100%); }
.proc-img--mono    { --proc-grad: linear-gradient(150deg, oklch(94% 0 0) 0%, oklch(54% 0 0) 60%, oklch(20% 0 0) 100%); }
.proc-img--forest  { --proc-grad: radial-gradient(70% 70% at 60% 30%, oklch(85% 0.10 110), oklch(50% 0.14 145) 60%, oklch(28% 0.10 145) 100%); }
.proc-img--ember   { --proc-grad: conic-gradient(from 200deg at 70% 70%, oklch(65% 0.20 30), oklch(55% 0.22 15), oklch(78% 0.16 75), oklch(65% 0.20 30)); }
.proc-img--lilac   { --proc-grad: linear-gradient(140deg, oklch(92% 0.04 320) 0%, oklch(75% 0.12 300) 50%, oklch(55% 0.16 290) 100%); }
.proc-img--mist    { --proc-grad: linear-gradient(160deg, oklch(96% 0.005 200) 0%, oklch(82% 0.04 220) 60%, oklch(60% 0.06 240) 100%); }

/* —— 网格分隔（用细线，不用阴影） —— */
.divider { height: 1px; background: var(--border); border: 0; }
.divider-strong { background: var(--border-strong); }

/* —— Table —— */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-feature-settings: 'tnum';
}
.table th {
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
  background: var(--surface-2);
}
.table tbody tr {
  transition: background-color var(--d-fast) var(--ease-out);
}
.table tbody tr:hover { background: var(--surface-2); }

/* —— Stat —— */
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat__label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.stat__value {
  font-family: var(--font-display);
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 580;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.stat__delta {
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.stat__delta--up { color: var(--success); }
.stat__delta--down { color: var(--danger); }

/* —— Reveal animation (used with IntersectionObserver) ——
   默认可见：JS 失败时内容仍能正常渲染。
   只有当 <html class="js"> 标记存在时才进入"待入场"态，由 IO 触发 .is-in。 */
.reveal { opacity: 1; transform: none; }
html.js .reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--d-slow) var(--ease-out), transform var(--d-slow) var(--ease-out);
}
html.js .reveal.is-in {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  html.js .reveal { opacity: 1; transform: none; transition: none; }
}

/* —— Footer —— */
.footer {
  border-top: 1px solid var(--border);
  padding: var(--s-12) 0 var(--s-10);
  margin-top: var(--s-24);
  font-size: 13px;
  color: var(--muted);
}
.footer__grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: var(--s-10);
  margin-bottom: var(--s-10);
}
.footer__col h5 { color: var(--fg); margin-bottom: var(--s-3); font-size: 13px; }
.footer__col ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.footer__col a { transition: color var(--d-fast) var(--ease-out); }
.footer__col a:hover { color: var(--fg); }
.footer__bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--s-6);
  border-top: 1px solid var(--border);
  font-size: 12px;
}

@media (max-width: 800px) {
  .footer__grid { grid-template-columns: 1fr 1fr; }
  .nav__links a:not(.nav__brand) { display: none; }
}
