/* ============================================
   阙外 Premium 共享组件库 v3.0 — HNW Edition
   8组件 — 导航/页脚/卡片/标签/按钮/排版/布局/分隔
   依赖: quewai_tokens.css
   v3.0: 面向高净值用户调性升级
   ============================================ */

/* ===== 0. 全局排版精调 ===== */
html {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  letter-spacing: 0.008em;
}

body {
  font-family: var(--qw-sans);
  font-weight: 400;
  line-height: 1.7;
}

/* 衬线标题增强 */
.qw-serif, h1.qw-serif, h2.qw-serif {
  font-family: 'Noto Serif SC', 'STSong', 'Songti SC', Georgia, 'Times New Roman', var(--qw-serif), serif;
  font-weight: 500;
  letter-spacing: 0.03em;
}

/* ===== 1. 导航栏 .qw-nav ===== */
.qw-nav {
  position: sticky;
  top: 0;
  z-index: var(--qw-z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--qw-space-xl);
  height: 64px;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.qw-nav.scrolled {
  border-bottom-color: var(--qw-border-light);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}

[data-theme="dark"] .qw-nav {
  background: rgba(15, 23, 42, 0.85);
}
[data-theme="dark"] .qw-nav.scrolled {
  background: rgba(15, 23, 42, 0.95);
  border-bottom-color: rgba(255,255,255,0.06);
}

.qw-nav-brand {
  display: flex;
  align-items: center;
  gap: var(--qw-space-sm);
  font-family: 'Noto Serif SC', 'STSong', 'Songti SC', Georgia, var(--qw-serif), serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--qw-brand);
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: color 0.3s ease;
}

.qw-nav-brand:hover {
  color: var(--qw-gold);
}

.qw-nav-links {
  display: flex;
  align-items: center;
  gap: var(--qw-space-xl);
  list-style: none;
  margin: 0;
  padding: 0;
}

.qw-nav-links a {
  font-size: 0.875rem;
  color: var(--qw-text-secondary);
  text-decoration: none;
  transition: color 0.25s ease;
  font-weight: 450;
  letter-spacing: 0.02em;
  position: relative;
}

.qw-nav-links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1.5px;
  background: var(--qw-gold);
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.qw-nav-links a:hover,
.qw-nav-links a.active {
  color: var(--qw-gold);
}
.qw-nav-links a:hover::after,
.qw-nav-links a.active::after {
  width: 100%;
}

@media (max-width: 640px) {
  .qw-nav {
    padding: 0 var(--qw-space-md);
    height: 52px;
  }
  .qw-nav-links { gap: var(--qw-space-md); }
  .qw-nav-links a { font-size: 0.8rem; }
}

/* ===== 2. 页脚 .qw-footer ===== */
.qw-footer {
  padding: var(--qw-space-xl) 0 var(--qw-space-lg);
  border-top: 1px solid var(--qw-border-light);
  background: var(--qw-surface-subtle);
  color: var(--qw-text-muted);
  font-size: var(--qw-text-sm);
  width: 100%;
}

.qw-footer-inner {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--qw-space-lg);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--qw-space-md);
}

.qw-footer-brand {
  font-family: 'Noto Serif SC', 'STSong', 'Songti SC', Georgia, var(--qw-serif), serif;
  font-size: 1.15rem;
  color: var(--qw-brand);
  font-weight: 600;
  letter-spacing: 0.03em;
}
.qw-footer-caption {
  margin-top: 4px;
}

.qw-footer-links {
  display: flex;
  gap: var(--qw-space-lg);
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.qw-footer-links a {
  color: var(--qw-text-muted);
  text-decoration: none;
  transition: color 0.25s ease;
  font-size: 0.875rem;
}

.qw-footer-links a:hover { color: var(--qw-gold); }

.qw-footer-bottom {
  max-width: 1080px;
  width: 100%;
  margin: var(--qw-space-lg) auto 0;
  padding: var(--qw-space-md) var(--qw-space-lg) 0;
  border-top: 1px solid var(--qw-border-light);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--qw-space-sm);
  font-size: 0.75rem;
}

@media (max-width: 768px) {
  .qw-footer { padding: var(--qw-space-lg) 0; }
  .qw-footer-inner { flex-direction: column; gap: var(--qw-space-md); }
  .qw-footer-bottom { flex-direction: column; text-align: center; }
}

/* ===== 3. 卡片系统 ===== */
.qw-card {
  background: var(--qw-surface);
  border: 1px solid var(--qw-border);
  border-radius: var(--qw-radius-lg);
  padding: var(--qw-space-xl);
  box-shadow: var(--qw-shadow);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.qw-card-hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--qw-shadow-lg);
  border-color: var(--qw-border-focus);
}

/* Premium 研报卡片变体 */
.qw-card-research {
  background: var(--qw-surface);
  border: 1px solid var(--qw-border-light);
  border-radius: var(--qw-radius-lg);
  padding: var(--qw-space-xl);
  box-shadow: none;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.qw-card-research::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(180deg, var(--qw-gold), var(--qw-gold-light));
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.qw-card-research:hover {
  transform: translateX(4px);
  border-color: var(--qw-gold);
  box-shadow: var(--qw-shadow-lg);
}
.qw-card-research:hover::before {
  width: 3px;
  opacity: 0.8;
}

/* 精选卡片 */
.qw-card-featured {
  border-color: var(--qw-gold);
  box-shadow: var(--qw-shadow-md), 0 0 0 1px var(--qw-gold-subtle);
}

.qw-card-featured::after {
  content: '精选';
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--qw-gold);
  text-transform: uppercase;
  padding: 2px 8px;
  background: var(--qw-gold-subtle);
  border-radius: 3px;
}

.qw-card-glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .qw-card-glass {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(255, 255, 255, 0.08);
}

/* ===== 4. 标签 .qw-tag ===== */
.qw-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: var(--qw-radius-full);
  font-size: 0.7rem;
  font-weight: 550;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-transform: uppercase;
}

.qw-tag-default {
  background: var(--qw-surface-subtle);
  color: var(--qw-text-secondary);
  border: 1px solid var(--qw-border);
}

.qw-tag-gold {
  background: var(--qw-gold-subtle);
  color: var(--qw-gold);
  border: 1px solid rgba(184, 148, 46, 0.2);
}

.qw-tag-brand {
  background: var(--qw-brand-subtle);
  color: var(--qw-brand);
  border: 1px solid rgba(30, 58, 95, 0.15);
}

.qw-tag-outline {
  background: transparent;
  color: var(--qw-text-secondary);
  border: 1px solid var(--qw-border);
}

.qw-tag-success { background: var(--qw-success-bg); color: var(--qw-success); }

.qw-tag-layer-1 { background: var(--qw-layer-1); color: #fff; }
.qw-tag-layer-2 { background: var(--qw-layer-2); color: #fff; }
.qw-tag-layer-3 { background: var(--qw-layer-3); color: #fff; }
.qw-tag-layer-4 { background: var(--qw-layer-4); color: #fff; }

/* 带圆点的分类标签 */
.qw-tag-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 550;
  letter-spacing: 0.04em;
  color: var(--qw-text-secondary);
}
.qw-tag-dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--qw-gold);
}

/* ===== 5. 按钮 .qw-btn ===== */
.qw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--qw-radius-md);
  font-size: 0.85rem;
  font-weight: 550;
  letter-spacing: 0.02em;
  cursor: pointer;
  border: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  white-space: nowrap;
}

.qw-btn-primary {
  background: var(--qw-brand);
  color: #fff;
  box-shadow: var(--qw-shadow-sm);
}
.qw-btn-primary:hover {
  background: var(--qw-brand-light);
  box-shadow: var(--qw-shadow-md);
  transform: translateY(-1px);
}

.qw-btn-gold {
  background: var(--qw-gold);
  color: #fff;
  box-shadow: var(--qw-shadow-sm);
}
.qw-btn-gold:hover {
  background: var(--qw-gold-light);
  box-shadow: var(--qw-shadow-md);
  transform: translateY(-1px);
}

.qw-btn-outline {
  background: transparent;
  border: 1.5px solid var(--qw-border);
  color: var(--qw-text-secondary);
}
.qw-btn-outline:hover {
  border-color: var(--qw-gold);
  color: var(--qw-gold);
  background: var(--qw-gold-subtle);
}

.qw-btn-ghost {
  background: transparent;
  color: var(--qw-text-secondary);
}
.qw-btn-ghost:hover {
  color: var(--qw-gold);
  background: var(--qw-gold-subtle);
}

.qw-btn-sm { padding: 6px 16px; font-size: 0.8rem; }
.qw-btn-lg { padding: 14px 32px; font-size: 1rem; }

/* ===== 6. 排版辅助 ===== */
.qw-text-balance { text-wrap: balance; }
.qw-text-gold { color: var(--qw-gold); }
.qw-text-muted { color: var(--qw-text-muted); }
.qw-text-sm { font-size: 0.85rem; }
.qw-text-xs { font-size: 0.75rem; }
.qw-text-lg { font-size: 1.15rem; }
.qw-text-xl { font-size: 1.5rem; }

.qw-leading-relaxed { line-height: 1.75; }
.qw-leading-loose { line-height: 1.85; }

.qw-font-serif {
  font-family: 'Noto Serif SC', 'STSong', 'Songti SC', Georgia, var(--qw-serif), serif;
  letter-spacing: 0.03em;
}

/* ===== 7. 布局辅助 ===== */
.qw-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--qw-space-lg);
}

.qw-section {
  padding: var(--qw-space-2xl) 0;
}

.qw-divider {
  width: 100%;
  height: 1px;
  background: var(--qw-border-light);
  margin: var(--qw-space-xl) 0;
}

.qw-divider-gold {
  width: 60px;
  height: 2px;
  background: var(--qw-gold);
  margin: var(--qw-space-lg) auto;
  opacity: 0.5;
}

/* 章节标题 */
.qw-section-title {
  font-family: 'Noto Serif SC', 'STSong', 'Songti SC', Georgia, var(--qw-serif), serif;
  font-size: 1.4rem;
  font-weight: 550;
  color: var(--qw-text);
  letter-spacing: 0.04em;
  margin-bottom: var(--qw-space-sm);
}

.qw-section-subtitle {
  font-size: 0.9rem;
  color: var(--qw-text-muted);
  margin-bottom: var(--qw-space-xl);
  font-weight: 400;
}

/* 金色微标 */
.qw-ornament {
  display: block;
  width: 30px;
  height: 2px;
  background: var(--qw-gold);
  opacity: 0.4;
  margin: var(--qw-space-md) 0;
}

/* ===== 8. 分隔 ===== */
.qw-separator {
  width: 100%;
  height: 1px;
  background: var(--qw-border-light);
  margin: 0;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .qw-container { padding: 0 var(--qw-space-md); }
  .qw-card, .qw-card-research { padding: var(--qw-space-lg); }
  .qw-section { padding: var(--qw-space-xl) 0; }
}

/* ===== 动画工具类 ===== */
.qw-fade-up {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.qw-fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

.qw-fade-in {
  opacity: 0;
  transition: opacity 0.8s ease;
}
.qw-fade-in.visible {
  opacity: 1;
}

/* 交错延迟 */
.qw-stagger > *:nth-child(1) { transition-delay: 0s; }
.qw-stagger > *:nth-child(2) { transition-delay: 0.08s; }
.qw-stagger > *:nth-child(3) { transition-delay: 0.16s; }
.qw-stagger > *:nth-child(4) { transition-delay: 0.24s; }
.qw-stagger > *:nth-child(5) { transition-delay: 0.32s; }
.qw-stagger > *:nth-child(6) { transition-delay: 0.40s; }

/* ===== 9. Callout .qw-callout ===== */
.qw-callout {
  display: flex;
  gap: var(--qw-callout-gap);
  padding: var(--qw-callout-padding);
  margin: var(--qw-space-lg) 0;
  border-radius: var(--qw-callout-radius);
  border: 1px solid;
  font-size: var(--qw-text-sm);
  line-height: var(--qw-leading-normal);
}
.qw-callout-icon {
  flex-shrink: 0;
  font-size: var(--qw-callout-icon-size);
  width: 1.4em;
  text-align: center;
  line-height: 1.4;
}
.qw-callout-body { flex: 1; min-width: 0; }
.qw-callout-body p:last-child { margin-bottom: 0; }
.qw-callout-body strong { color: inherit; }

.qw-callout-blue   { background: var(--qw-callout-blue-bg);   border-color: var(--qw-callout-blue-border);   color: var(--qw-callout-blue-text); }
.qw-callout-green  { background: var(--qw-callout-green-bg);  border-color: var(--qw-callout-green-border);  color: var(--qw-callout-green-text); }
.qw-callout-yellow { background: var(--qw-callout-yellow-bg); border-color: var(--qw-callout-yellow-border); color: var(--qw-callout-yellow-text); }
.qw-callout-red    { background: var(--qw-callout-red-bg);    border-color: var(--qw-callout-red-border);    color: var(--qw-callout-red-text); }
.qw-callout-purple { background: var(--qw-callout-purple-bg); border-color: var(--qw-callout-purple-border); color: var(--qw-callout-purple-text); }
.qw-callout-gray   { background: var(--qw-callout-gray-bg);   border-color: var(--qw-callout-gray-border);   color: var(--qw-callout-gray-text); }

/* ===== 10. Toggle .qw-toggle ===== */
.qw-toggle { margin: var(--qw-space-md) 0; }
.qw-toggle summary {
  cursor: pointer;
  font-weight: var(--qw-weight-semibold);
  color: var(--qw-text);
  padding: var(--qw-space-sm) 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--qw-space-sm);
  user-select: none;
  transition: color var(--qw-transition-fast);
}
.qw-toggle summary::-webkit-details-marker { display: none; }
.qw-toggle summary::before {
  content: '\25B8';
  font-size: 0.8em;
  color: var(--qw-text-muted);
  transition: transform var(--qw-transition-fast);
  flex-shrink: 0;
}
.qw-toggle[open] summary::before { content: '\25BE'; }
.qw-toggle summary:hover { color: var(--qw-gold); }
.qw-toggle-body {
  padding-left: var(--qw-toggle-indent);
  margin-top: var(--qw-space-xs);
  border-left: var(--qw-toggle-bar-width) solid var(--qw-toggle-bar-color);
  padding-top: var(--qw-space-xs);
  padding-bottom: var(--qw-space-xs);
}

/* ===== 11. Sticky TOC .qw-toc-sidebar ===== */
.qw-toc-sidebar {
  position: fixed;
  top: 80px;
  width: var(--qw-toc-width);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  font-size: var(--qw-text-xs);
  color: var(--qw-text-muted);
  scrollbar-width: thin;
  z-index: var(--qw-z-sticky);
  display: none;
}
@media (min-width: 1300px) {
  .qw-toc-sidebar { display: block; }
}
.qw-toc-sidebar a {
  display: block;
  padding: 4px 0;
  color: var(--qw-text-muted);
  text-decoration: none;
  line-height: 1.5;
  transition: color var(--qw-transition-fast);
}
.qw-toc-sidebar a:hover { color: var(--qw-toc-hover-color); }
.qw-toc-sidebar a.active { color: var(--qw-toc-active-color); font-weight: var(--qw-weight-semibold); }
.qw-toc-sidebar .qw-toc-h3 { padding-left: var(--qw-space-md); }
