/* Keel · 司元 — legal pages
   单一样式表，四篇文档 + 首页共用。无外部依赖，无字体请求。 */

:root {
  color-scheme: light dark;

  --bg: #fbfbfc;
  --surface: #ffffff;
  --surface-subtle: #f4f6f8;
  --text: #16202b;
  --text-muted: #5a6773;
  --text-faint: #8b96a2;
  --border: #e4e8ed;
  --border-strong: #cbd3dc;
  --accent: #0e6b68;
  --accent-text: #0a5350;
  --accent-soft: #e7f2f1;
  --shadow-sm: 0 1px 2px rgba(16, 24, 32, .05);
  --shadow-md: 0 1px 2px rgba(16, 24, 32, .04), 0 10px 28px rgba(16, 24, 32, .06);

  --measure: 43rem;
  --radius: 12px;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418;
    --surface: #161c22;
    --surface-subtle: #1b232a;
    --text: #e6ebf0;
    --text-muted: #a2aeb9;
    --text-faint: #7c8894;
    --border: #263039;
    --border-strong: #354250;
    --accent: #4fb3ad;
    --accent-text: #6ec8c2;
    --accent-soft: #16302f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 28px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

/* ---------- 语言显隐 ----------
   <html> 上的 .lang-zh / .lang-en 由 <head> 里的内联脚本在首帧前写入。
   没有 JS 时两个 class 都不存在，于是**两种语言都显示**（中文在前，英文在后）——
   法律文档在脚本挂掉时也必须完整可读，这条比「不重复」优先。 */

html.lang-zh [data-lang="en"] { display: none; }
html.lang-en [data-lang="zh"] { display: none; }

/* 无 JS 时两篇之间需要一道分隔，否则中文正文直接顶着英文标题。 */
html:not(.lang-zh):not(.lang-en) article[data-lang="en"] {
  margin-top: 3.5rem;
  padding-top: 3rem;
  border-top: 1px solid var(--border);
}

/* 行内标签（导航、页脚、卡片标题、hero 徽标）无 JS 时只留中文：它们是 inline，
   两种语言会直接黏成「即将上架 App StoreComing to the App Store」。
   正文用的是块级元素（article / p / h2 / div / table-wrap），不受这条影响，仍双语并存。 */
span[data-lang="en"] { display: none; }
html.lang-en span[data-lang="en"] { display: inline; }
html.lang-en span[data-lang="zh"] { display: none; }

/* 切换按钮由 JS 摘掉 hidden；没有 JS 就不该出现一个点了没反应的按钮。
   !important 是必需的：下面 .lang-toggle 的 display 会盖掉 UA 的 [hidden]。 */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- 页头 ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .75rem clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-weight: 600;
  font-size: .98rem;
  letter-spacing: .01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

/* logo.svg 自带浅色方底，按 app 图标的 ~22% 比例切圆角，免得在页头是个硬方块 */
.brand-mark {
  display: block;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 5px;
}

.brand .brand-sub {
  color: var(--text-faint);
  font-weight: 400;
}

/* margin-left:auto (rather than a spacer element) keeps the nav and the language
   toggle glued together as one right-aligned group — including when they wrap
   onto a second row on narrow screens. */
.doc-nav {
  display: flex;
  margin-left: auto;
  gap: .25rem;
  padding: 3px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.doc-nav a {
  padding: .3rem .8rem;
  border-radius: 999px;
  font-size: .84rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}

.doc-nav a:hover { color: var(--text); }

.doc-nav a[aria-current="page"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  min-width: 3.4rem;                 /* "EN" 与 "中文" 宽度不同，钉死免得按钮在切换时跳一下 */
  justify-content: center;
  padding: .3rem .75rem;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s ease, color .15s ease;
}

.lang-toggle:hover { color: var(--accent-text); border-color: var(--accent); }

.lang-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 3.75rem) clamp(1.1rem, 5vw, 2rem) 4rem;
}

.doc-title {
  margin: 0 0 .4rem;
  font-size: clamp(1.75rem, 5vw, 2.3rem);
  line-height: 1.25;
  letter-spacing: -.015em;
  font-weight: 680;
}

.doc-meta {
  margin: 0 0 2rem;
  font-size: .87rem;
  color: var(--text-faint);
}

.doc-meta span + span::before {
  content: "·";
  margin: 0 .5rem;
}

h2 {
  margin: 2.75rem 0 .85rem;
  padding-top: .35rem;
  font-size: 1.2rem;
  line-height: 1.4;
  letter-spacing: -.005em;
  font-weight: 640;
  scroll-margin-top: 5.5rem;
}

h3 {
  margin: 1.9rem 0 .6rem;
  font-size: 1.02rem;
  font-weight: 620;
  color: var(--text);
}

p { margin: 0 0 1.05rem; }

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

strong { font-weight: 640; }

ul, ol { margin: 0 0 1.05rem; padding-left: 1.35rem; }
li { margin-bottom: .45rem; }
li > ul, li > ol { margin-top: .45rem; }

hr {
  margin: 3rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

code {
  padding: .1em .35em;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: .86em;
  word-break: break-word;
}

/* ---------- 摘要卡 ---------- */

.callout {
  margin: 0 0 2.5rem;
  padding: 1.25rem 1.4rem .35rem;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--radius);
}

.callout .callout-title {
  margin: 0 0 .6rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.callout ul { padding-left: 1.2rem; }
.callout > :last-child { margin-bottom: 1rem; }

.note {
  margin: 1.5rem 0;
  padding: 1rem 1.2rem .1rem;
  background: var(--surface-subtle);
  border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .95rem;
  color: var(--text-muted);
}

.note > :last-child { margin-bottom: 1rem; }

/* ---------- 目录 ---------- */

.toc {
  margin: 0 0 3rem;
  padding: 1.15rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.toc h2 {
  margin: 0 0 .7rem;
  padding: 0;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 2;
  column-gap: 1.75rem;
}

.toc li {
  margin: 0 0 .3rem;
  break-inside: avoid;
  font-size: .91rem;
}

.toc a { color: var(--text-muted); text-decoration: none; }
.toc a:hover { color: var(--accent-text); text-decoration: underline; }

@media (max-width: 34rem) {
  .toc ol { columns: 1; }
}

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

.table-wrap {
  margin: 0 0 1.5rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}

th, td {
  padding: .7rem .95rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 620;
  white-space: nowrap;
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: .84rem;
  letter-spacing: .01em;
}

/* 第一列是标签列。min-width 要连 .95rem 的左右内边距一起算进去，否则 5~6 字的
   中文标签仍会掉下一个孤字。表格整体由 .table-wrap 横向滚动兜底。 */
tbody td:first-child { min-width: 8.5em; }

tbody tr:last-child td { border-bottom: 0; }

/* 窄屏放开表头 nowrap 并收窄首列下限，让三列表能收进容器——否则英文表头
   （"Where the data goes"）会把表撑到 412px，逼出一条本可避免的横向滚动。
   真收不进时仍由 .table-wrap 横向滚动兜底，页面本体永远不横滚。 */
@media (max-width: 34rem) {
  th { white-space: normal; }
  tbody td:first-child { min-width: 7em; }
}

/* ---------- 首页 ---------- */

.hero {
  text-align: center;
  padding: clamp(1rem, 6vw, 3rem) 0 2.5rem;
}

.hero-mark {
  display: block;
  width: 62px;
  height: 62px;
  margin: 0 auto 1.35rem;
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}

.hero h1 {
  margin: 0 0 .5rem;
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  letter-spacing: -.02em;
  font-weight: 680;
}

.hero p {
  max-width: 34rem;
  margin: 0 auto;
  color: var(--text-muted);
}

.hero-alt { color: var(--text-faint); font-weight: 400; }

.hero-badge {
  margin-top: 1.35rem !important;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--accent-text) !important;
}

/* 首页分节：h2 在文档页是「第 N 条」，在首页是版块标题，需要更大的上间距 */
main > section { margin-top: 3.5rem; }
main > section > h2 { margin-top: 0; }

/* 首页比法律文档宽：三张卡要排得下一行，否则 2+1 落单。
   但正文不跟着变宽——43rem 的阅读行宽是刻意的，只有卡片网格该占满。 */
body.home main { max-width: 54rem; }
body.home main > section > p,
body.home main > section > .table-wrap { max-width: 43rem; }

.lang-block {
  margin-bottom: 2.25rem;
}

.lang-block h2 {
  margin: 0 0 .9rem;
  padding: 0;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: .85rem;
}

.card {
  display: block;
  padding: 1.15rem 1.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* 不是链接的卡片：别给悬停反馈与箭头，否则用户会去点一个点不动的东西。
   选择器写成 .card.card-static 是必需的——箭头规则 .card .card-title::after
   在下方，同特异度下后写的赢，不加这一级就压不住。 */
.card.card-static { cursor: default; }
.card.card-static:hover { border-color: var(--border); transform: none; box-shadow: var(--shadow-sm); }
.card.card-static .card-title::after { content: none; }

.card .card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  font-weight: 620;
  font-size: 1.02rem;
  margin-bottom: .2rem;
}

.card .card-title::after {
  content: "→";
  color: var(--text-faint);
  font-weight: 400;
  transition: transform .16s ease, color .16s ease;
}

.card:hover .card-title::after { color: var(--accent); transform: translateX(2px); }

.card .card-desc {
  font-size: .9rem;
  line-height: 1.55;
  color: var(--text-muted);
}

/* 落地页卡片上的英文副本压一档，让中文先被读到，但不至于灰到读不清。 */
.card .card-alt {
  display: inline-block;
  margin-top: .3rem;
  font-size: .84rem;
  color: var(--text-faint);
}

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

.site-footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.75rem clamp(1.1rem, 5vw, 2rem) 3.5rem;
  border-top: 1px solid var(--border);
  font-size: .85rem;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  align-items: center;
}

.site-footer a { color: var(--text-muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent-text); text-decoration: underline; }
.site-footer .footer-spacer { flex: 1 1 auto; }

/* ---------- 打印 ---------- */

@media print {
  .site-header, .toc, .site-footer { display: none !important; }
  body { font-size: 11pt; line-height: 1.55; background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  h2 { page-break-after: avoid; }
  .callout, .note, .table-wrap { break-inside: avoid; border: 1px solid #bbb; background: #fff; }
  a { color: #000; text-decoration: none; }
}
