/* ============================================================
   宋氏宗亲平台 · 基础层
   传承千年宗脉 · 联结天下宋氏
   设计令牌见 design-tokens.css（单一事实源，勿在此重复定义）
   ============================================================ */

/* ---------- 重置 ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--f-sans);
  color: var(--c-ink);
  background: var(--c-bg);
  line-height: 1.7;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg, video { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }

::selection { background: var(--c-gold-light); color: var(--c-ink); }

/* 滚动条（精致细边） */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-line); border-radius: 4px; border: 2px solid var(--c-bg); }
::-webkit-scrollbar-thumb:hover { background: var(--c-gold-light); }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- 排版 ---------- */
h1, h2, h3, h4, h5 { font-family: var(--f-serif); font-weight: 700; line-height: 1.3; color: var(--c-ink); letter-spacing: 0.02em; }
h1 { font-size: clamp(1.9rem, 3.6vw, 3rem); }
h2 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); }
h4 { font-size: 1.1rem; }
p { margin-bottom: var(--sp-3); }
small { font-size: 0.82rem; }
.text-gold { color: var(--c-gold); }
.text-jade { color: var(--c-jade); }
.text-gray { color: var(--c-gray); }
.text-red { color: var(--c-red); }
.text-center { text-align: center; }
.text-serif { font-family: var(--f-serif); }
.text-brush { font-family: var(--f-brush); }

/* ---------- 布局 ---------- */
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--sp-5); }
.section { padding: var(--sp-12) 0; }
.section-sm { padding: var(--sp-8) 0; }
.row { display: flex; gap: var(--sp-4); }
.col { display: flex; flex-direction: column; }
.between { justify-content: space-between; }
.center { align-items: center; justify-content: center; }
.items-center { align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-6 { gap: var(--sp-6); }
.mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--c-line);
  transition: box-shadow var(--t-base);
}
.site-header.scrolled { box-shadow: var(--sh-md); }
.header-inner {
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--sp-6);
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--sp-5);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0; }
.brand-seal {
  width: 42px; height: 42px; border-radius: var(--r-md);
  background: var(--grad-ink); color: var(--c-gold);
  display: grid; place-items: center;
  font-family: var(--f-brush); font-size: 1.5rem;
  box-shadow: var(--sh-gold);
  position: relative;
}
.brand-seal::after {
  content: ''; position: absolute; inset: 3px; border-radius: 5px;
  border: 1px solid rgba(201, 169, 98, 0.35);
}
/* 品牌标识：使用统一 SVG logo */
.brand-seal.logo { background: transparent !important; box-shadow: none !important; }
.brand-seal.logo::after { display: none; }
.brand-seal.logo img { width: 100%; height: 100%; display: block; border-radius: inherit; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-family: var(--f-serif); font-weight: 700; font-size: 1.12rem; letter-spacing: 0.08em; }
.brand-sub { font-size: 0.68rem; color: var(--c-gray); letter-spacing: 0.2em; }

.nav { display: flex; align-items: center; gap: 2px; flex: 1; }
.nav-link {
  position: relative; padding: 8px 14px; border-radius: var(--r-md);
  font-size: 0.92rem; color: var(--c-charcoal); font-weight: 500;
  transition: color var(--t-fast), background var(--t-fast);
  white-space: nowrap;
}
.nav-link:hover { color: var(--c-gold-dark); background: var(--c-gold-soft); }
.nav-link.active { color: var(--c-gold-dark); font-weight: 700; }
.nav-link.active::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: 2px; height: 2px;
  background: var(--grad-gold); border-radius: 2px;
}

.header-actions { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-md);
  display: grid; place-items: center; color: var(--c-charcoal);
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
.icon-btn:hover { background: var(--c-gold-soft); color: var(--c-gold-dark); }
.icon-btn .badge-dot {
  position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px;
  border-radius: var(--r-full); background: var(--c-red); color: #fff;
  font-size: 0.62rem; display: grid; place-items: center; padding: 0 4px;
}
.avatar-chip {
  display: flex; align-items: center; gap: var(--sp-2); padding: 4px 10px 4px 4px;
  border-radius: var(--r-full); border: 1px solid var(--c-line);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.avatar-chip:hover { border-color: var(--c-gold); box-shadow: var(--sh-sm); }
.avatar-chip .avatar { width: 30px; height: 30px; font-size: 0.85rem; }
.avatar-chip .chip-name { font-size: 0.86rem; font-weight: 600; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 移动端菜单按钮 */
.menu-toggle { display: none; }

/* ---------- 页脚 ---------- */
.site-footer {
  background: var(--c-ink); color: rgba(255,255,255,0.72);
  padding: var(--sp-12) 0 var(--sp-6); margin-top: var(--sp-16);
  font-size: 0.86rem;
}
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: var(--sp-8); }
.footer-brand .brand-seal { margin-bottom: var(--sp-4); }
.footer-brand p { color: rgba(255,255,255,0.55); max-width: 320px; }
.footer-col h5 { color: var(--c-gold); font-size: 0.95rem; margin-bottom: var(--sp-4); letter-spacing: 0.1em; }
.footer-col a { display: block; color: rgba(255,255,255,0.65); padding: 4px 0; transition: color var(--t-fast); }
.footer-col a:hover { color: var(--c-gold); }
.footer-bottom {
  margin-top: var(--sp-8); padding-top: var(--sp-5);
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; justify-content: space-between; align-items: center;
  color: rgba(255,255,255,0.45); font-size: 0.78rem; flex-wrap: wrap; gap: var(--sp-3);
}

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 10px 22px; border-radius: var(--r-md); font-size: 0.94rem; font-weight: 600;
  transition: all var(--t-base); white-space: nowrap; border: 1px solid transparent;
  font-family: var(--f-sans); position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0; background: rgba(255,255,255,0);
  transition: background var(--t-fast);
}
.btn:active { transform: translateY(1px); }
.btn:active::after { background: rgba(255,255,255,0.15); }
.btn-primary { background: var(--grad-gold-rich); color: var(--c-ink); box-shadow: var(--sh-sm), var(--sh-gold); }
.btn-primary:hover { box-shadow: var(--sh-md), var(--sh-gold-lg); transform: translateY(-1px); }
.btn-ink { background: var(--c-ink); color: var(--c-gold); box-shadow: var(--sh-sm); }
.btn-ink:hover { background: var(--c-ink-2); transform: translateY(-1px); box-shadow: var(--sh-md); }
.btn-outline { border-color: var(--c-gold); color: var(--c-gold-dark); background: transparent; }
.btn-outline:hover { background: var(--c-gold-soft); border-color: var(--c-gold-dark); }
.btn-ghost { color: var(--c-charcoal); }
.btn-ghost:hover { background: var(--c-bg-2); }
.btn-jade { background: var(--grad-jade); color: #fff; box-shadow: var(--sh-sm); }
.btn-jade:hover { transform: translateY(-1px); box-shadow: var(--sh-md); }
.btn-danger { background: var(--c-red); color: #fff; box-shadow: var(--sh-sm); }
.btn-danger:hover { background: #9E2E2E; transform: translateY(-1px); }
.btn-sm { padding: 6px 14px; font-size: 0.84rem; border-radius: var(--r-sm); }
.btn-lg { padding: 14px 34px; font-size: 1.02rem; }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn:disabled::after { display: none; }

.card {
  background: var(--c-surface); border-radius: var(--r-lg); border: 1px solid var(--c-line-2);
  box-shadow: var(--sh-xs); transition: box-shadow var(--t-base), transform var(--t-base), border-color var(--t-base);
}
.card-hover:hover { box-shadow: var(--sh-md); transform: translateY(-3px); border-color: var(--c-gold-light); }
.card-pad { padding: var(--sp-6); }
.card-head { padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--c-line-2); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.card-body { padding: var(--sp-6); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: var(--r-full); font-size: 0.76rem;
  background: var(--c-bg-2); color: var(--c-gray); font-weight: 500;
}
.tag-gold { background: var(--c-gold-soft); color: var(--c-gold-dark); }
.tag-jade { background: var(--c-jade-soft); color: var(--c-jade); }
.tag-red { background: #FDECEC; color: var(--c-red); }
.tag-blue { background: #E9F0F8; color: var(--c-blue); }
.tag-gray { background: var(--c-bg-2); color: var(--c-gray); }

.avatar {
  border-radius: var(--r-full); display: grid; place-items: center;
  font-family: var(--f-serif); font-weight: 700; flex-shrink: 0;
  background: var(--grad-gold); color: var(--c-ink); overflow: hidden;
}
.avatar-xs { width: 24px; height: 24px; font-size: 0.72rem; }
.avatar-sm { width: 34px; height: 34px; font-size: 0.88rem; }
.avatar-md { width: 44px; height: 44px; font-size: 1.05rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.5rem; }
.avatar-xl { width: 96px; height: 96px; font-size: 2.4rem; }

.input, .textarea, .select {
  width: 100%; padding: 11px 14px; border-radius: var(--r-md);
  border: 1px solid var(--c-line); background: var(--c-surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  font-size: 0.94rem;
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--c-gray-2); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--c-gold);
  box-shadow: 0 0 0 3px var(--c-gold-tint);
  background: var(--c-surface);
}
.textarea { resize: vertical; min-height: 90px; line-height: 1.7; }
.field { margin-bottom: var(--sp-4); }
.field-label { display: block; font-size: 0.84rem; color: var(--c-charcoal); margin-bottom: 6px; font-weight: 600; }
.field-hint { font-size: 0.76rem; color: var(--c-gray-2); margin-top: 4px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input-prefix { position: absolute; left: 12px; color: var(--c-gray); font-size: 0.9rem; pointer-events: none; }
.input-group .input.has-prefix { padding-left: 34px; }

/* 分段控件 */
.seg { display: inline-flex; padding: 3px; background: var(--c-bg-2); border-radius: var(--r-md); gap: 2px; }
.seg-item { padding: 7px 18px; border-radius: var(--r-sm); font-size: 0.88rem; color: var(--c-gray); font-weight: 600; transition: all var(--t-fast); }
.seg-item:hover { color: var(--c-charcoal); }
.seg-item.active { background: var(--c-surface); color: var(--c-gold-dark); box-shadow: var(--sh-sm); }

/* 徽章 */
.badge-dot-inline { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }

/* 分割线 */
.divider { height: 1px; background: var(--c-line); margin: var(--sp-6) 0; border: none; }
.divider-gold { height: 2px; width: 48px; background: var(--grad-gold); margin: var(--sp-4) auto; border-radius: 2px; }

/* 区块标题 */
.section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-8); }
.section-title .st-main { display: flex; flex-direction: column; }
.section-title h2 { display: flex; align-items: center; gap: var(--sp-3); }
.section-title .st-en { font-family: var(--f-serif); font-size: 0.78rem; color: var(--c-gray-2); letter-spacing: 0.3em; text-transform: uppercase; }
.section-title .st-desc { font-size: 0.9rem; color: var(--c-gray); margin-top: 4px; }
.section-more { color: var(--c-gold-dark); font-size: 0.88rem; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; transition: gap var(--t-fast); }
.section-more:hover { gap: 8px; }

/* 空态 / 加载 */
.state-box { padding: var(--sp-16) var(--sp-6); text-align: center; color: var(--c-gray); }
.state-box .state-icon { font-size: 3rem; margin-bottom: var(--sp-4); opacity: 0.5; }
.loading-dots { display: inline-flex; gap: 5px; }
.loading-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--c-gold); animation: dotPulse 1.2s infinite ease-in-out; }
.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotPulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1.2); } }

/* 骨架屏 */
.skeleton { background: linear-gradient(90deg, var(--c-bg-2) 25%, var(--c-line-2) 50%, var(--c-bg-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-md); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* 提示条 */
.alert { padding: 12px 16px; border-radius: var(--r-md); font-size: 0.88rem; display: flex; align-items: center; gap: var(--sp-2); }
.alert-info { background: #E9F0F8; color: var(--c-blue); }
.alert-warn { background: #FDF3E5; color: var(--c-orange); }
.alert-error { background: #FDECEC; color: var(--c-red); }
.alert-success { background: var(--c-jade-soft); color: var(--c-jade); }

/* 徽标圆点计数 */
.count-pill { min-width: 18px; height: 18px; border-radius: var(--r-full); background: var(--c-red); color: #fff; font-size: 0.68rem; display: grid; place-items: center; padding: 0 5px; font-weight: 700; }

/* 浮动 AI 助手 */
.ai-fab {
  position: fixed; right: 28px; bottom: 28px; z-index: 90;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--grad-ink); color: var(--c-gold);
  display: grid; place-items: center; box-shadow: var(--sh-lg), var(--sh-gold);
  transition: transform var(--t-base);
  animation: fabPulse 3s infinite;
}
.ai-fab:hover { transform: scale(1.08) rotate(6deg); }
@keyframes fabPulse { 0%, 100% { box-shadow: var(--sh-lg), 0 0 0 0 rgba(201,169,98,0.35); } 50% { box-shadow: var(--sh-lg), 0 0 0 12px rgba(201,169,98,0); } }

/* 页面进入动画 */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-up { animation: fadeUp 0.5s both; }
.fade-in { animation: fadeIn 0.4s both; }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  :root { --header-h: 60px; }
  .menu-toggle {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-md);
    color: var(--c-charcoal); transition: background var(--t-fast);
  }
  .menu-toggle:hover { background: var(--c-gold-soft); }
  .nav {
    position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0;
    background: var(--c-surface); flex-direction: column; align-items: stretch;
    padding: var(--sp-4); gap: 2px; overflow-y: auto;
    transform: translateX(100%); transition: transform var(--t-base);
    box-shadow: var(--sh-lg);
  }
  .nav.open { transform: translateX(0); }
  .nav-link { padding: 14px 16px; font-size: 1rem; border-radius: var(--r-md); }
  .nav-link.active::after { display: none; }
  .nav-link.active { background: var(--c-gold-soft); }
  .brand-sub { display: none; }
  .header-actions .btn-text { display: none; }
  .section { padding: var(--sp-8) 0; }
  .footer-grid { grid-template-columns: 1fr; gap: var(--sp-6); }
  .footer-bottom { flex-direction: column; text-align: center; }
  .ai-fab { right: 18px; bottom: 18px; width: 54px; height: 54px; }
}

@media (max-width: 560px) {
  body { font-size: 14px; }
  .container { padding: 0 var(--sp-4); }
  .card-pad, .card-body { padding: var(--sp-4); }
  .section-title { flex-direction: column; align-items: flex-start; }
}

/* 路由切换进度条：懒加载页面在慢网络下也有明确反馈 */
#routeProgress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--c-gold-dark), var(--c-gold));
  z-index: 9999; opacity: 0; pointer-events: none;
  transition: width 0.25s ease, opacity 0.25s ease;
}
#routeProgress.on { opacity: 1; width: 68%; }
#routeProgress.done { opacity: 0; width: 100%; transition: width 0.18s ease, opacity 0.2s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
