/* ============================================================================
   织书 TypeWeaver · 官网 —— 设计系统 / Design System
   气质：精工 · 创造 · 澄澈（工匠精度 × 创作愉悦 × 清晰高效）
   视觉母题：纸张肌理 + 活字暖金 + 高饱和创造靛（工具 × 成品的双重身份）
   ----------------------------------------------------------------------------
   本表提供设计令牌 + 可复用组件类 + 响应式栅格 + 无障碍规则。
   运行期 Settings（外观预设 / 字号 / 字体 / 版心 / 动效）通过覆盖
   :root CSS 变量生效（见 app-core.jsx 的 PRESETS / applyCfg）。
   —— 新增一套外观预设 = 在 PRESETS 增一个键；本表无需改动。
   ========================================================================== */

:root {
  /* —— 字体（Settings 可覆盖）—— */
  --serif: 'Noto Serif SC', 'Songti SC', serif;
  --sans: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --mono: 'Roboto Mono', ui-monospace, 'SFMono-Regular', monospace;

  /* —— 外观预设令牌（默认：minimal 极简·冷调；由 Settings 覆盖）—— */
  --bg: #f5f6f7;             /* 页面底 */
  --bg-alt: #eceef0;         /* 分区带 */
  --bg-alt2: #e2e5e8;        /* 深一档底 / 骨架线条 */
  --text: #1a1c22;           /* 标题深墨 */
  --text-soft: #5a5f6b;      /* 正文 */
  --text-faint: #8b909c;     /* 辅助 / 注释 */
  --gold: #8f8574;           /* 活字暖金（极简预设下为冷调灰金） */
  --gold-soft: #e7e4dd;
  --gold-deep: #6e6555;
  --accent: #3457d5;         /* 创造靛（工具与 CTA） */
  --accent-soft: #e8ecfb;
  --accent-deep: #22409e;
  --line: rgba(20,22,30,0.08);
  --line-strong: rgba(20,22,30,0.16);
  --card: #ffffff;
  --shadow: 0 16px 40px rgba(20,22,30,0.08);
  --on-accent: #ffffff;      /* accent 实底上的文字 */
  --on-dark: #ffffff;        /* text 渐变实底上的文字 */

  /* —— 版心与动效（Settings 可覆盖）—— */
  --measure: 1280px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html {
  font-size: 16px;               /* Settings 大字模式覆盖 */
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-soft);
  font-family: var(--sans);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .35s ease, color .35s ease;
}

::selection { background: var(--gold-soft); color: var(--gold-deep); }
button { font-family: inherit; }
img { max-width: 100%; }

/* 键盘可达焦点环（无障碍） */
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ============================ 动效 ============================ */
@keyframes twRevealUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes twFadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes twFloat    { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes twNavFade  { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes twGrowLine { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
/* Settings「关闭入场动效」 */
html[data-rm] * { animation: none !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }

.tw-reveal { animation: twRevealUp .8s var(--ease-out) both; }
.tw-fade   { animation: twFadeIn .5s ease both; }

/* ============================ 布局容器 ============================ */
.tw-container { max-width: var(--measure); margin: 0 auto; padding: 0 32px; }
.tw-narrow    { max-width: 1100px; margin: 0 auto; padding: 0 32px; }
.tw-prose     { max-width: 900px;  margin: 0 auto; padding: 0 32px; }
.tw-band      { background: var(--bg-alt); }

/* ============================ 排版原子 ============================ */
.tw-kicker {
  font-size: .8rem; letter-spacing: .1em; font-weight: 700;
  text-transform: uppercase; margin-bottom: 14px; color: var(--gold);
}
.tw-kicker--accent { color: var(--accent); }
.tw-h1 { font-family: var(--serif); font-weight: 700; color: var(--text); line-height: 1.22; letter-spacing: .01em; margin: 0 0 20px; font-size: clamp(2rem, 4.4vw, 3.4rem); }
.tw-h2 { font-family: var(--serif); font-weight: 700; color: var(--text); line-height: 1.32; margin: 0; font-size: clamp(1.55rem, 3vw, 2.1rem); }
.tw-h3 { font-family: var(--serif); font-weight: 700; color: var(--text); margin: 0; }
.tw-serif { font-family: var(--serif); }
.tw-mono  { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tw-lead  { font-size: 1.02rem; color: var(--text-soft); line-height: 1.8; }

/* ============================ 按钮 ============================ */
.tw-btn {
  appearance: none; border: none; cursor: pointer; font-family: inherit;
  border-radius: 10px; font-weight: 600; letter-spacing: .02em; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .2s var(--ease-out), box-shadow .2s, background .2s, border-color .2s, color .2s;
}
.tw-btn-primary { background: var(--accent); color: var(--on-accent); padding: 15px 28px; font-size: .97rem; box-shadow: 0 12px 28px var(--accent-soft); }
.tw-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 34px var(--accent-soft); }
.tw-btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line-strong); padding: 14px 26px; font-size: .97rem; }
.tw-btn-ghost:hover { background: var(--bg-alt); }
.tw-btn-gold { background: var(--gold); color: var(--bg); padding: 14px 30px; font-size: .95rem; font-weight: 700; }
.tw-btn-gold:hover { transform: translateY(-2px); }
.tw-btn-dark { background: var(--text); color: var(--bg); padding: 14px 30px; font-size: .92rem; }
.tw-btn-dark:hover { transform: translateY(-2px); }
.tw-btn-sm { padding: 10px 20px; font-size: .88rem; border-radius: 9px; }

/* ============================ 卡片 ============================ */
.tw-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  transition: background .35s ease, border-color .35s ease;
}
.tw-card-hover { transition: transform .3s var(--ease-out), box-shadow .3s; }
.tw-card-hover:hover { transform: translateY(-4px); box-shadow: var(--shadow); }

/* 深色实底卡（CTA 带 / 引擎枢纽），令牌随预设联动 */
.tw-dark-panel {
  background: linear-gradient(120deg, var(--text), var(--text-soft));
  color: var(--on-dark); border-radius: 24px; box-shadow: var(--shadow);
}

/* ============================ 栅格（响应式）============================ */
.tw-grid { display: grid; gap: 20px; }
.tw-g2 { grid-template-columns: repeat(2, 1fr); }
.tw-g3 { grid-template-columns: repeat(3, 1fr); }
.tw-g4 { grid-template-columns: repeat(4, 1fr); }
.tw-auto-fit-200 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tw-auto-fit-240 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.tw-auto-fill-180 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 26px; }
.tw-auto-fill-220 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tw-hero2 { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: clamp(32px, 5vw, 64px); align-items: center; }

@media (max-width: 960px) {
  .tw-g3, .tw-g4 { grid-template-columns: repeat(2, 1fr); }
  .tw-hero2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tw-container, .tw-narrow, .tw-prose { padding: 0 18px; }
  .tw-g2, .tw-g3, .tw-g4 { grid-template-columns: 1fr; }
}

/* ============================ 导航 ============================ */
.tw-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .tw-header { background: var(--bg); }
}
.tw-nav { max-width: var(--measure); margin: 0 auto; padding: 0 32px; height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.tw-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; flex: none; background: none; border: none; cursor: pointer; padding: 0; }
.tw-brand-mark {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: linear-gradient(155deg, var(--text), var(--text-soft));
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.tw-brand-glyph { width: 15px; height: 15px; border-radius: 3px; border: 2px solid var(--gold); }
.tw-navlinks { display: flex; align-items: center; gap: 4px; flex: 1; justify-content: center; }
.tw-navlink {
  appearance: none; border: none; background: none; cursor: pointer; font-family: inherit;
  padding: 9px 15px; font-size: .9rem; font-weight: 500; border-radius: 8px;
  color: var(--text-soft); transition: background .15s ease, color .15s ease; white-space: nowrap; text-decoration: none;
}
.tw-navlink:hover { background: var(--bg-alt); color: var(--text); }
.tw-navlink.is-active { color: var(--accent); background: var(--bg-alt); font-weight: 600; }
.tw-menu-btn { display: none; }
.tw-mobile-menu { display: none; }

@media (max-width: 920px) {
  .tw-navlinks { display: none; }
  .tw-nav-cta-desktop { display: none !important; }
  .tw-menu-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    width: 40px; height: 40px; border-radius: 9px; border: 1px solid var(--line);
    background: var(--bg-alt); cursor: pointer;
  }
  .tw-menu-btn i { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; }
  .tw-mobile-menu { display: block; border-top: 1px solid var(--line); padding: 8px 20px 20px; animation: twNavFade .16s ease; }
  .tw-mobile-menu .tw-navlink { display: block; width: 100%; text-align: left; padding: 12px 10px; font-size: 1rem; }
}

/* 预设快速切换（导航调色盘） */
.tw-preset-pop {
  position: absolute; top: 48px; right: 0; width: 260px; z-index: 120;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 14px; animation: twNavFade .16s ease;
}
.tw-preset-row {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 8px;
  border-radius: 10px; border: none; background: transparent; cursor: pointer; text-align: left; margin-bottom: 2px;
}
.tw-preset-row:hover, .tw-preset-row.is-on { background: var(--bg-alt); }
.tw-swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); margin-left: -4px; flex: none; }

/* ============================ 徽章 / 芯片 ============================ */
.tw-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px;
  border-radius: 100px; background: var(--accent-soft); color: var(--accent-deep);
  font-size: .8rem; font-weight: 600;
}
.tw-pill-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.tw-chip {
  padding: 8px 17px; border-radius: 100px; border: 1px solid var(--line);
  background: transparent; color: var(--text-soft); font-size: .85rem; font-weight: 600; cursor: pointer;
  transition: all .18s ease;
}
.tw-chip:hover { border-color: var(--line-strong); color: var(--text); }
.tw-chip.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-deep); }
.tw-tag { font-size: .69rem; font-weight: 700; padding: 4px 10px; border-radius: 100px; white-space: nowrap; }

/* ============================ 书封 ============================ */
.tw-bookcover {
  position: relative; border-radius: 8px; overflow: hidden;
  box-shadow: 0 16px 32px rgba(0,0,0,0.16);
  display: flex; flex-direction: column; justify-content: space-between; padding: 20px;
  transition: transform .2s ease;
}
.tw-bookcover::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 9px;
  background: rgba(0,0,0,0.16);
}
button:hover > .tw-bookcover { transform: translateY(-6px); }

/* ============================ 弹层 ============================ */
.tw-modal-mask {
  position: fixed; inset: 0; background: rgba(10,10,14,0.6); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 28px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: twFadeIn .2s ease;
}
.tw-modal {
  width: 100%; max-width: 880px; max-height: 88vh; overflow: auto;
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow); animation: twRevealUp .3s var(--ease-out);
}

/* ============================ 设置面板 ============================ */
.tw-settings-fab {
  width: 52px; height: 52px; flex: none; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 12px 30px var(--accent-soft);
  display: flex; align-items: center; justify-content: center; transition: transform .35s var(--ease-out);
}
.tw-settings-fab:hover { transform: rotate(35deg) scale(1.06); }
.tw-settings-panel {
  width: 330px; max-width: calc(100vw - 40px); max-height: calc(100vh - 120px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); padding: 20px 20px 22px; animation: twRevealUp .3s ease both;
}
.tw-seg { display: flex; gap: 7px; flex-wrap: wrap; }
.tw-seg-btn {
  flex: 1; min-width: 72px; appearance: none; cursor: pointer; font-family: inherit;
  border-radius: 9px; padding: 9px 4px; font-size: .84rem; font-weight: 600; transition: all .2s;
  border: 1px solid var(--line-strong); background: transparent; color: var(--text-soft);
}
.tw-seg-btn.is-on { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.tw-set-label { font-size: .72rem; font-weight: 700; letter-spacing: .08em; color: var(--text-faint); text-transform: uppercase; margin: 16px 0 8px; }

/* ============================ 表格化行（规范样本） ============================ */
.tw-spec-row { display: flex; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--line); gap: 20px; }
.tw-spec-row:last-child { border-bottom: none; }
@media (max-width: 640px) { .tw-spec-row { flex-wrap: wrap; gap: 8px; } }

/* ============================ 新闻列表行 ============================ */
.tw-news-row { display: flex; gap: 24px; padding: 22px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; text-align: left; width: 100%; background: none; border-left: none; border-right: none; border-top: none; cursor: pointer; font: inherit; color: inherit; }
.tw-news-row:hover h3 { color: var(--accent); }

/* ============================ 法务两栏 ============================ */
.tw-legal-grid { display: grid; grid-template-columns: 240px 1fr; gap: 40px; align-items: start; }
.tw-legal-toc { position: sticky; top: 92px; }
@media (max-width: 820px) {
  .tw-legal-grid { grid-template-columns: 1fr; gap: 12px; }
  .tw-legal-toc { position: static; }
}

/* ============================ 杂项 ============================ */
.tw-arrow-r { width: 0; height: 0; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 12px solid var(--gold); flex: none; }
.tw-hr-gold { position: relative; white-space: nowrap; color: var(--gold); }
.tw-scroll-x { display: flex; gap: 20px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: thin; }
.tw-input {
  padding: 11px 16px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--text); font-size: .88rem; font-family: inherit;
}
.tw-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.tw-link:hover { text-decoration: underline; }
.tw-footlink { font-size: .86rem; color: var(--text-soft); text-decoration: none; background: none; border: none; cursor: pointer; padding: 0; text-align: left; font-family: inherit; }
.tw-footlink:hover { color: var(--accent); }
