/* Wesala 官网样式表。
   配色直接取自 app 的设计令牌 lib/core/theme/tokens.dart —— 深青主色、
   琥珀金辅色、暖白底 —— 这样网站和 app 内看到的是同一套颜色。 */

:root {
  --brand: #0B6E5B;        /* T.primary */
  --brand-deep: #0B3A31;   /* 导航与页脚通栏用的更深一档 */
  --brand-ink: #062621;
  --gold: #D49B32;         /* T.secondary */
  --paper: #F7F8F6;        /* T.bg */
  --card: #FFFFFF;         /* T.surface */
  --ink: #18201E;          /* T.text */
  --muted: #66716D;        /* T.textSecondary */
  --line: #DCE3DF;         /* T.border */
  --soft: #EFF2F0;         /* T.neutralSoft */

  /* 霓虹四色直接采样自 App 图标（tool/app_icon_source.png）。
     图标是蓝→紫→粉→橙的渐变气泡，和深青主色不是一路，所以它们只在
     光晕、渐变描边、标题高亮这些「发光」的地方出现，不参与版式配色。 */
  --n-blue: #3C63FF;
  --n-violet: #7B3BF5;
  --n-pink: #FA3D86;
  --n-orange: #FD8143;
  --aurora: linear-gradient(100deg, var(--n-blue), var(--n-violet) 34%,
                            var(--n-pink) 68%, var(--n-orange));
  /* 提亮版，用于压在深青底上的文字 —— 原色在深底上读不清 */
  --aurora-lit: linear-gradient(100deg, #8FB8FF, #C79BFF 34%,
                                #FF8FBC 68%, #FFC089);

  --r: 12px;               /* T.rLarge */
  --r-sm: 8px;             /* T.rMedium */
  --shell: 1060px;
  --measure: 70ch;

  --lift: 0 12px 28px rgba(11, 58, 49, 0.10), 0 2px 6px rgba(11, 58, 49, 0.06);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 88px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
    Roboto, "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
}

a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-deep); }

.shell { max-width: var(--shell); margin: 0 auto; padding: 0 24px; }

/* ------------------------------------------------------------ 顶部导航 --
   深青通栏 + 金色底边，滚动时吸顶。 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--brand-deep);
  border-bottom: 2px solid var(--gold);
  transition: box-shadow 0.28s var(--ease), background-color 0.28s var(--ease);
}

/* 滚动离开顶部后加半透明 + 模糊，让正文从导航底下穿过时有层次。
   `is-stuck` 由 wesala.js 挂上，没有 JS 时导航就是原来的实心通栏。 */
.topbar.is-stuck {
  background: color-mix(in srgb, var(--brand-deep) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  box-shadow: 0 10px 30px rgba(6, 38, 33, 0.28);
}

/* 阅读进度条：贴在导航金色底边上，用图标那组霓虹色。
   法务长文里最有用 —— 它同时充当「这份文件还剩多少」的提示。 */
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  height: 2px;
  width: var(--progress, 0%);
  background: var(--aurora);
  transition: width 0.1s linear;
}

.topbar .shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  min-height: 64px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

/* 站标用真正的 App 图标（tool/site_brand.py 从 app_icon_source.png 生成），
   而不是一个抽象色点 —— 网页上的形象要和用户手机桌面上的一致。
   放在伪元素里是为了 16 个页面的 HTML 一行都不用改。 */
.wordmark::before {
  content: "";
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 7px;
  background: url("brand/icon-32.png") center / cover no-repeat;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14),
              0 4px 14px rgba(250, 61, 134, 0.34);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.wordmark:hover::before {
  transform: translateY(-1px) scale(1.06);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2),
              0 6px 20px rgba(250, 61, 134, 0.5);
}

.wordmark .age {
  margin-left: 2px;
  padding: 1px 7px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.topnav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.topnav a {
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  text-decoration: none;
}

.topnav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.topnav a[aria-current="page"] { color: #fff; box-shadow: inset 0 -2px 0 var(--gold); }

.topnav .lang {
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--gold);
  font-weight: 600;
}

.topnav .lang:hover { background: transparent; color: #fff; }

/* --------------------------------------------------------------- 标题区 --
   首页是深色大区块，内页是浅色窄条，二者共用 .masthead。 */

/* 极光：四团霓虹柔光缓慢漂移在深青底上。
   两个关键决定：
   1. `screen` 混合 —— 正常叠加下霓虹压在深青上会调出脏绿和土褐，
      screen 只做提亮，光斑才像光而不像颜料。
   2. 光斑画在 .masthead 自己的 background 里，而不是覆盖一层带
      mix-blend-mode 的伪元素 —— 后者会让浏览器把标题区合成为一个混合层，
      实测在部分视口高度下会把右侧的事实清单整块裁掉。
      background-blend-mode 只在这一个元素的背景内部混合，不参与层合成。 */
.masthead {
  position: relative;
  overflow: hidden;
  color: #fff;
  background-color: var(--brand);
  background-image:
    /* 第一层是压在光斑之上的暗色蒙版，只盖文字所在的左半边，右侧留给光。
       没有它，蓝光漫到正文下面时白字只剩 2.9:1，达不到 AA。 */
    linear-gradient(104deg, rgba(6, 38, 33, 0.74) 0%,
                    rgba(6, 38, 33, 0.5) 44%, rgba(6, 38, 33, 0.34) 100%),
    radial-gradient(42% 52% at 50% 50%, rgba(60, 99, 255, 0.38), transparent 68%),
    radial-gradient(38% 46% at 50% 50%, rgba(123, 59, 245, 0.3), transparent 68%),
    radial-gradient(46% 56% at 50% 50%, rgba(250, 61, 134, 0.3), transparent 70%),
    radial-gradient(40% 50% at 50% 50%, rgba(253, 129, 67, 0.24), transparent 68%);
  background-repeat: no-repeat;
  /* 光斑压在四角：正文和标题落在中间，中间要留住深青底才有对比度 */
  background-size: 100% 100%, 116% 120%, 104% 112%, 124% 118%, 110% 112%;
  background-position: 0 0, -8% -6%, 104% -10%, 108% 104%, 24% 118%;
  /* 蒙版正常叠加，四团光走 screen */
  background-blend-mode: normal, screen, screen, screen, screen;
  animation: drift 30s var(--ease) infinite alternate;
}

/* 只动光斑的位置，蒙版不动。四团各走各的方向，看不出周期。 */
@keyframes drift {
  from { background-position: 0 0, -8% -6%, 104% -10%, 108% 104%, 24% 118%; }
  to   { background-position: 0 0, 2% -14%, 94% 0%, 98% 94%, 36% 108%; }
}

/* 正文压在极光之上 */
.masthead .shell {
  position: relative;
  z-index: 1;
  padding-top: 56px;
  padding-bottom: 56px;
}

.masthead.slim .shell { padding-top: 36px; padding-bottom: 32px; }

.masthead h1 {
  max-width: 22ch;
  margin: 0 0 16px;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.masthead.slim h1 { max-width: none; font-size: clamp(26px, 4vw, 34px); margin-bottom: 8px; }

.masthead p { max-width: var(--measure); color: rgba(255, 255, 255, 0.86); }
.masthead .lede { font-size: 18px; }
.masthead a { color: #fff; }

.kicker {
  display: inline-block;
  margin: 0 0 14px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* 首页标题区右侧的事实清单，替代参考站的纯文字 hero */
.hero-split { display: grid; gap: 32px; }

@media (min-width: 900px) {
  .hero-split { grid-template-columns: 1.35fr 1fr; align-items: start; }
}

/* 首页 h1 里被 <em> 圈住的那半句走霓虹渐变，一屏里只此一处，
   多了就廉价。渐变字在不支持 background-clip 的浏览器上退回白色。
   用的是 --aurora-lit 而不是 --aurora：原色里的靛蓝和品红压在深青上
   偏暗，标题得先能读清楚。 */
.masthead h1 em {
  font-style: normal;
  background: var(--aurora-lit);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: hue 14s linear infinite;
}

@supports not (background-clip: text) {
  .masthead h1 em { color: #fff; }
}

@keyframes hue {
  from { background-position: 0% 50%; }
  to   { background-position: 200% 50%; }
}

/* App 图标本体：站点上唯一一处让霓虹占据大面积的地方 */
.applogo {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 22px;
}

.applogo img {
  width: 76px;
  height: 76px;
  border-radius: 20px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18),
              0 18px 44px rgba(250, 61, 134, 0.42),
              0 6px 18px rgba(60, 99, 255, 0.36);
  animation: float 7s var(--ease) infinite alternate;
}

.applogo b { display: block; font-size: 20px; letter-spacing: -0.01em; }
.applogo span { color: rgba(255, 255, 255, 0.72); font-size: 14px; }

@keyframes float {
  from { transform: translateY(-3px); }
  to   { transform: translateY(3px); }
}

.factsheet {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: var(--r);
  padding: 4px 18px;
}

.factsheet dl { margin: 0; }
.factsheet div { padding: 12px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.16); }
.factsheet div:last-child { border-bottom: 0; }

.factsheet dt {
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.factsheet dd { margin: 2px 0 0; font-size: 15px; }

/* ----------------------------------------------------------------- 正文 --*/

main .shell { padding-top: 48px; padding-bottom: 24px; }

section { margin-bottom: 44px; }
section > p, section > ul, section > ol, section > table { max-width: var(--measure); }

h2 {
  margin: 0 0 14px;
  font-size: 22px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

/* 编号小节：法务页靠它做锚点标题，参考站没有编号 */
h2 .num {
  display: inline-block;
  min-width: 26px;
  margin-right: 10px;
  padding: 1px 0;
  border-bottom: 2px solid var(--gold);
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 700;
}

h3 { margin: 0 0 6px; font-size: 16px; }
p { margin: 0 0 14px; }

.lede { font-size: 18px; }
.muted, .meta, .note { color: var(--muted); font-size: 14px; }
.note { max-width: var(--measure); }

.stamp {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.stamp b { color: #fff; font-weight: 600; }
.stamp span { opacity: 0.5; }

/* ----------------------------------------------------------------- 卡片 --
   左侧金色竖条 + 极淡投影。 */

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(248px, 1fr)); }

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--r);
  padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(24, 32, 30, 0.04);
  transition: transform 0.32s var(--ease), box-shadow 0.32s var(--ease),
              border-left-color 0.32s var(--ease);
}

/* hover 时左侧金条换成霓虹渐变、卡片浮起来。用伪元素铺渐变而不是直接
   改 border-left-color，是因为 border 不吃渐变。 */
.card::before {
  content: "";
  position: absolute;
  left: -3px;
  top: -1px;
  bottom: -1px;
  width: 3px;
  border-radius: 3px 0 0 3px;
  background: var(--aurora);
  opacity: 0;
  transition: opacity 0.32s var(--ease);
}

.card:hover { transform: translateY(-3px); box-shadow: var(--lift); }
.card:hover::before { opacity: 1; }

.card p:last-child { margin-bottom: 0; }
.card p { color: var(--muted); font-size: 15px; }

.slab {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 24px;
}

.slab > :last-child { margin-bottom: 0; }
.slab h2 { margin-top: 0; }

.tinted { background: var(--soft); border-color: transparent; }

/* 强调条：用于 18+ 声明这类需要一眼看到的句子 */
.rulebar {
  border-left: 3px solid var(--brand);
  background: var(--card);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 14px 18px;
  max-width: var(--measure);
  font-weight: 500;
}

/* ------------------------------------------------------------- 列表/表格 --*/

.ticks { list-style: none; margin: 0 0 14px; padding: 0; max-width: var(--measure); }

.ticks li { position: relative; margin-bottom: 10px; padding-left: 26px; }

.ticks li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.62em;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--brand);
}

.terms { margin: 0; max-width: var(--measure); }
.terms dt { margin-top: 14px; font-weight: 600; }
.terms dt:first-child { margin-top: 0; }
.terms dd { margin: 2px 0 0; color: var(--muted); }

.rows { width: 100%; border-collapse: collapse; }

.rows th, .rows td {
  padding: 12px 12px 12px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.rows th {
  width: 38%;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* -------------------------------------------------------------- 文档索引 --*/

.docs { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }

.docs li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px 22px;
  transition: transform 0.32s var(--ease), box-shadow 0.32s var(--ease),
              border-color 0.32s var(--ease);
}

.docs li:hover {
  transform: translateY(-3px);
  border-color: transparent;
  box-shadow: var(--lift), 0 0 0 1px rgba(123, 59, 245, 0.28);
}

.docs a { font-size: 18px; font-weight: 650; text-decoration: none; }
.docs .meta { display: block; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.docs p { margin: 0; color: var(--muted); font-size: 15px; }

/* ------------------------------------------------------ 法务页双栏 + 目录 --
   参考站的法务页是单列长文；这里给宽屏加一个吸顶目录。 */

.withtoc { display: block; }

@media (min-width: 960px) {
  .withtoc { display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 48px; align-items: start; }
  .toc { position: sticky; top: 88px; }
}

.toc { margin-bottom: 32px; }

.toc h2 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }

.toc li { counter-increment: toc; }

.toc a {
  display: block;
  padding: 6px 0 6px 26px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  position: relative;
}

.toc a::before {
  content: counter(toc);
  position: absolute;
  left: 10px;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.toc a { transition: border-left-color 0.24s var(--ease), color 0.24s var(--ease); }
.toc a:hover { border-left-color: var(--gold); color: var(--ink); }

/* 当前正在读的章节。`is-active` 由 wesala.js 按滚动位置挂上，
   没有 JS 时目录仍是一个可点的普通列表。 */
.toc a.is-active {
  border-left-color: transparent;
  color: var(--ink);
  font-weight: 600;
  /* 竖直方向的一小段渐变，横向的 --aurora 在 2px 宽的条上看不出颜色 */
  background: linear-gradient(180deg, var(--n-blue), var(--n-pink))
              left / 2px 100% no-repeat;
}

.toc a.is-active::before { color: var(--n-pink); }

.doc section { scroll-margin-top: 88px; }
.doc section:last-child { margin-bottom: 0; }

/* ----------------------------------------------------------------- 页脚 --*/

footer.sitefoot {
  position: relative;
  overflow: hidden;
  margin-top: 40px;
  background: var(--brand-ink);
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

/* 右下角一枚极淡的图标水印，和顶部站标呼应，不抢正文 */
footer.sitefoot::before {
  content: "";
  position: absolute;
  right: -34px;
  bottom: -46px;
  width: 210px;
  height: 210px;
  background: url("brand/icon-192.png") center / contain no-repeat;
  opacity: 0.07;
  pointer-events: none;
}

footer.sitefoot .shell { position: relative; padding-top: 32px; padding-bottom: 40px; }

footer.sitefoot .rule {
  max-width: var(--measure);
  margin: 0 0 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 500;
}

footer.sitefoot nav { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-bottom: 14px; }
footer.sitefoot a { color: rgba(255, 255, 255, 0.78); text-decoration: none; }
footer.sitefoot a:hover { color: #fff; text-decoration: underline; }
footer.sitefoot .fine { margin: 0; color: rgba(255, 255, 255, 0.45); font-size: 13px; }

/* ----------------------------------------------------------------- 动效 --
   全部动效遵守两条：一是没有 JS 也要能正常读（渐显只在 JS 挂上
   `js` 标记后才生效），二是系统开了「减弱动态效果」就全部关掉。 */

/* 滚动渐显。wesala.js 会给 section / .card / .docs li 打上 data-reveal，
   进入视口时换成 is-in。 */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.js [data-reveal].is-in { opacity: 1; transform: none; }

/* 同一组里的卡片依次进场，差 60ms，够看出先后又不至于让人等 */
.js [data-reveal][style*="--i"] { transition-delay: calc(var(--i) * 60ms); }

/* 编号小节：hover 时下划线走霓虹，呼应卡片 */
h2 .num { transition: color 0.24s var(--ease), border-bottom-color 0.24s var(--ease); }
section:hover > h2 .num { border-bottom-color: var(--n-pink); }

/* 锚点跳转后短暂高亮目标章节，长文里不容易跟丢 */
.doc section:target > h2 .num {
  border-bottom-color: var(--n-pink);
  color: var(--n-violet);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  .masthead,
  .masthead h1 em,
  .applogo img { animation: none; }

  .js [data-reveal] { opacity: 1; transform: none; transition: none; }

  .card:hover,
  .docs li:hover { transform: none; }

  * { transition-duration: 0.01ms !important; }
}

/* --------------------------------------------------------------- 暗色 --*/

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0E1513;
    --card: #17201D;
    --ink: #EDF2EF;
    --muted: #96A39E;
    --line: #26312D;
    --soft: #1C2622;
    --brand: #3E9D86;
    --brand-deep: #0A1C18;
    --brand-ink: #06110F;
  }

  /* 深色底上极光要压得更淡，否则光斑会盖过正文。底色换成更深的一档，
     光斑本身用 --n-* 的低透明度版本重画一遍。 */
  .masthead {
    background-color: #0D2A24;
    background-image:
      radial-gradient(42% 52% at 50% 50%, rgba(60, 99, 255, 0.4), transparent 70%),
      radial-gradient(38% 46% at 50% 50%, rgba(123, 59, 245, 0.34), transparent 70%),
      radial-gradient(46% 56% at 50% 50%, rgba(250, 61, 134, 0.3), transparent 72%),
      radial-gradient(40% 50% at 50% 50%, rgba(253, 129, 67, 0.24), transparent 70%);
  }

  .card { box-shadow: none; }

  :root { --lift: 0 14px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4); }

  .card:hover,
  .docs li:hover { border-color: rgba(123, 59, 245, 0.4); }

  footer.sitefoot::before { opacity: 0.1; }
}
