/* Chrono Bee 共享基座（landing / privacy / support 三页都加载）
   规格：docs/design-system.md

   ⚠️ 这里的 token 层是 src/styles/_variables.css 的镜像。
   Chrono Bee 页面是构建时静态输出、从 /css/ 直接加载的，
   走不到 Vite 的 CSS 管道，所以必须自带一份。
   两份的一致性由 src/styles/token-parity.test.js 守护——改一边必须改另一边。 */

/* ============================================
   L1 · 原语色板
   ============================================ */
:root {
  --swatch-slate-dark: #141413;
  --swatch-slate-medium: #3d3d3a;
  --swatch-slate-light: #5e5d59;
  --swatch-slate-a10: rgba(20, 20, 19, 0.1);
  --swatch-slate-a20: rgba(20, 20, 19, 0.2);

  --swatch-ivory-light: #faf9f5;
  --swatch-ivory-medium: #f0eee6;
  --swatch-ivory-dark: #e8e6dc;
  --swatch-ivory-a10: rgba(250, 249, 245, 0.1);
  --swatch-ivory-a20: rgba(250, 249, 245, 0.2);

  --swatch-cloud-light: #d1cfc5;
  --swatch-cloud-medium: #b0aea5;
  --swatch-cloud-dark: #87867f;

  --swatch-clay: #d97757;
  --swatch-accent: #c6613f;
  --swatch-kraft: #d4a27f;
  --swatch-oat: #e3dacc;
  --swatch-manilla: #ebdbbc;

  --swatch-white: #fff;
  --swatch-transparent: transparent;

  /* ---- 排印 ---- */
  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-serif: 'Source Serif 4', 'Noto Serif SC', 'Songti SC', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, 'Fira Code', monospace;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --fs-display-xxl: clamp(2.75rem, 2.2142857143rem + 2.2857142857vw, 4.5rem);
  --fs-display-xl: clamp(2.5rem, 2.0408163265rem + 1.9591836735vw, 4rem);
  --fs-display-l: clamp(2.25rem, 2.0204081633rem + 0.9795918367vw, 3rem);
  --fs-display-m: clamp(1.75rem, 1.6734693878rem + 0.3265306122vw, 2rem);
  --fs-display-s: 1.5rem;
  --fs-display-xs: 1.25rem;

  --fs-para-l: 1.5rem;
  --fs-para-m: 1.25rem;
  --fs-para-s: 1.125rem;
  --fs-para-xs: 1rem;

  --fs-detail-xl: 1.25rem;
  --fs-detail-l: 1.125rem;
  --fs-detail-m: 1rem;
  --fs-detail-s: 0.875rem;
  --fs-detail-xs: 0.75rem;

  --fs-mono: 1.125rem;

  --lh-flat: 1;
  --lh-tight: 1.1;
  --lh-snug: 1.3;
  --lh-normal: 1.4;
  --lh-loose: 1.5;

  --ls-none: 0;
  --ls-tight: -0.005em;
  --ls-tighter: -0.02em;
  --ls-caps: 0.08em;

  /* ---- 间距 ---- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: clamp(1.75rem, 1.6734693878rem + 0.3265306122vw, 2rem);
  --space-7: clamp(2rem, 1.8469387755rem + 0.6530612245vw, 2.5rem);
  --space-8: clamp(2.25rem, 2.0204081633rem + 0.9795918367vw, 3rem);
  --space-9: clamp(2.5rem, 2.0408163265rem + 1.9591836735vw, 4rem);
  --space-10: clamp(3rem, 2.387755102rem + 2.612244898vw, 5rem);
  --space-11: clamp(3.5rem, 2.7346938776rem + 3.2653061224vw, 6rem);

  --section-sm: clamp(2.5rem, 2.0408163265rem + 1.9591836735vw, 4rem);
  --section-md: clamp(3.5rem, 2.7346938776rem + 3.2653061224vw, 6rem);

  /* ---- 固定档尺寸原语（供圆角引用，与主文件保持同构） ---- */
  --size-0: 0rem;
  --size-0-125: 0.125rem;
  --size-0-25: 0.25rem;
  --size-0-375: 0.375rem;
  --size-0-5: 0.5rem;
  --size-0-75: 0.75rem;
  --size-0-875: 0.875rem;
  --size-1: 1rem;
  --size-1-125: 1.125rem;
  --size-1-25: 1.25rem;
  --size-1-5: 1.5rem;

  /* ---- 形状 ---- */
  --border-w: 1px;
  --radius-sm: var(--size-0-25);
  --radius-md: var(--size-0-5);
  --radius-lg: var(--size-1);
  --radius-round: 100vw;
  --focus-w: 0.125rem;
  --focus-offset: 0.25rem;

  /* ---- 动效 ---- */
  --dur-base: 0.2s;
  --dur-slow: 0.3s;
  --dur-reveal: 0.7s;
  --ease: ease;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  /* ---- Chrono Bee 专有 ---- */
  --rail: 1.35rem;
  --shell: 52rem;
}

/* ============================================
   L2 · 语义层（浅色）
   ============================================ */
:root,
.theme-light {
  --background: var(--swatch-ivory-medium);
  --surface: var(--swatch-ivory-dark);
  --surface-hover: var(--swatch-cloud-light);

  --card: var(--swatch-white);
  --card-faded: var(--swatch-slate-a10);
  --card-faded-hover: var(--swatch-slate-a20);

  --text: var(--swatch-slate-dark);
  --text-muted: var(--swatch-slate-light);

  --border: var(--swatch-slate-a10);
  --border-hover: var(--swatch-slate-a20);

  --link: var(--swatch-slate-dark);
  --link-hover: var(--swatch-slate-light);

  --accent: var(--swatch-clay);
  --accent-strong: var(--swatch-accent);

  --button-primary-bg: var(--swatch-slate-dark);
  --button-primary-border: var(--swatch-slate-dark);
  --button-primary-text: var(--swatch-ivory-light);
  --button-primary-bg-hover: var(--swatch-slate-medium);
  --button-primary-border-hover: var(--swatch-slate-medium);
  --button-primary-text-hover: var(--swatch-ivory-light);

  --button-secondary-bg: var(--swatch-transparent);
  --button-secondary-border: var(--swatch-slate-dark);
  --button-secondary-text: var(--swatch-slate-dark);
  --button-secondary-bg-hover: var(--swatch-slate-dark);
  --button-secondary-border-hover: var(--swatch-slate-dark);
  --button-secondary-text-hover: var(--swatch-ivory-light);
}

/* 深色反转 —— 挂在任意容器上即可整段换肤（.cb-pro 用它） */
.theme-dark {
  --background: var(--swatch-slate-dark);
  --surface: var(--swatch-slate-medium);
  --surface-hover: var(--swatch-slate-light);

  --card: var(--swatch-slate-medium);
  --card-faded: var(--swatch-ivory-a10);
  --card-faded-hover: var(--swatch-ivory-a20);

  --text: var(--swatch-ivory-light);
  --text-muted: var(--swatch-cloud-light);

  --border: var(--swatch-ivory-a10);
  --border-hover: var(--swatch-ivory-a20);

  --link: var(--swatch-ivory-light);
  --link-hover: var(--swatch-kraft);

  --accent: var(--swatch-clay);
  --accent-strong: var(--swatch-kraft);

  --button-primary-bg: var(--swatch-ivory-light);
  --button-primary-border: var(--swatch-ivory-light);
  --button-primary-text: var(--swatch-slate-dark);
  --button-primary-bg-hover: var(--swatch-ivory-medium);
  --button-primary-border-hover: var(--swatch-ivory-medium);
  --button-primary-text-hover: var(--swatch-slate-dark);

  --button-secondary-bg: var(--swatch-transparent);
  --button-secondary-border: var(--swatch-ivory-light);
  --button-secondary-text: var(--swatch-ivory-light);
  --button-secondary-bg-hover: var(--swatch-ivory-light);
  --button-secondary-border-hover: var(--swatch-ivory-light);
  --button-secondary-text-hover: var(--swatch-slate-dark);
}

/* ============================================
   L2 · 中文排印修正
   负字距会让汉字相撞，中文一律归零；汉字撑满字身，需要更松的行高。
   完整说明见 src/styles/_variables.css。
   :lang(zh) 与 :root 同特异性，必须后置。
   ============================================ */
:lang(zh) {
  --lh-tight: 1.25;
  --lh-snug: 1.45;
  --lh-normal: 1.65;
  --lh-loose: 1.8;

  --ls-tight: 0;
  --ls-tighter: 0;

  --measure-title: 14em;
  --measure-body: 36em;
  --measure-hero: 36em;

  text-spacing-trim: trim-start;
  text-autospace: normal;
  line-break: strict;
}

/* ============================================
   L2 · 繁体字形 —— zh-TW 页面单独加载 TC 字族
   ============================================ */
html[lang="zh-TW"] {
  --font-sans: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --font-serif: 'Source Serif 4', 'Noto Serif TC', 'Songti TC', Georgia, serif;
}

/* ============================================
   基础
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-serif);
  font-size: var(--fs-para-s);
  line-height: var(--lh-loose);
  color: var(--text);
  background-color: var(--background);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--dur-base) var(--ease);
}

a:hover {
  color: var(--link-hover);
}

:focus-visible {
  outline: var(--focus-w) solid var(--text);
  outline-offset: var(--focus-offset);
}

/* ============================================
   顶栏 — 实底 + 底部细线
   ============================================ */
.doc-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--background);
  border-bottom: var(--border-w) solid var(--border);
}

.doc-topbar-inner {
  max-width: calc(var(--shell) + 2.5rem);
  margin: 0 auto;
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.doc-topbar .lang-switcher {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-detail-s);
}

.doc-topbar .lang-switcher-link {
  color: var(--text-muted);
  text-decoration: none;
}

.doc-topbar .lang-switcher-link:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.doc-topbar .lang-switcher-link[aria-current="true"] {
  color: var(--text);
  font-weight: var(--fw-semibold);
}

.doc-topbar .lang-switcher-sep {
  color: var(--border-hover);
  user-select: none;
}

.doc-brand-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.doc-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-weight: var(--fw-bold);
  font-size: var(--fs-display-xs);
  letter-spacing: var(--ls-tight);
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.doc-brand-mark {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}

.doc-brand:hover {
  color: var(--link-hover);
}

.doc-product {
  font-family: var(--font-mono);
  font-size: var(--fs-detail-xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}

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

.doc-product::before {
  content: '';
  display: inline-block;
  width: var(--border-w);
  height: 0.85em;
  margin-right: var(--space-3);
  vertical-align: -0.05em;
  background: var(--border-hover);
}

.doc-top-nav {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  font-family: var(--font-sans);
  font-size: var(--fs-detail-s);
}

.doc-top-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: background-color var(--dur-base) var(--ease),
              color var(--dur-base) var(--ease);
}

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

.doc-top-nav a[aria-current='page'] {
  color: var(--text);
  background: var(--surface);
  font-weight: var(--fw-semibold);
}

/* ============================================
   外壳
   ============================================ */
.doc-shell {
  max-width: calc(var(--shell) + 2.5rem);
  margin: 0 auto;
  padding: var(--space-9) var(--space-5) var(--space-11);
}

@keyframes doc-enter {
  from {
    opacity: 0;
    transform: translateY(0.6rem);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .doc-shell {
    animation: doc-enter 0.55s var(--ease-out-expo) both;
  }
}

/* ============================================
   页头
   ============================================ */
.doc-header {
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: var(--border-w) solid var(--border);
}

.doc-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--fs-detail-xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--text-muted);
}

.doc-eyebrow::before {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-round);
  background: var(--accent);
}

.doc-header h1 {
  margin: 0 0 var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--fs-display-l);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tighter);
  color: var(--text);
  text-wrap: balance;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  margin: 0 0 var(--space-5);
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--fs-detail-xs);
  color: var(--text-muted);
}

.doc-meta li {
  display: flex;
  gap: var(--space-2);
  align-items: baseline;
}

.doc-meta strong {
  font-weight: var(--fw-medium);
  color: var(--text);
}

.doc-lead {
  margin: 0 0 var(--space-3);
  max-width: 38rem;
  color: var(--text);
  font-size: var(--fs-para-s);
  text-wrap: pretty;
}

.doc-lead:last-child {
  margin-bottom: 0;
}

.doc-lead strong {
  color: var(--text);
  font-weight: var(--fw-semibold);
}

/* ============================================
   正文 + 时间轴导轨（Chrono Bee 标志性结构）
   ============================================ */
.doc-content {
  position: relative;
  padding-left: calc(var(--rail) + 0.85rem);
}

.doc-content::before {
  content: '';
  position: absolute;
  top: 0.35rem;
  bottom: 0.35rem;
  left: calc(var(--rail) / 2 - 0.5px);
  width: var(--border-w);
  background: var(--border-hover);
}

.doc-content h2 {
  position: relative;
  margin: var(--space-8) 0 var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--fs-display-s);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  letter-spacing: var(--ls-tight);
  color: var(--text);
  text-wrap: balance;
}

.doc-content h2:first-child {
  margin-top: 0;
}

.doc-content h2::before {
  content: '';
  position: absolute;
  left: calc(-1 * (var(--rail) + 0.85rem) + var(--rail) / 2 - 4px);
  top: 0.45em;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-round);
  background: var(--background);
  border: 2px solid var(--accent);
}

.doc-content h3 {
  margin: var(--space-6) 0 var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--fs-detail-l);
  font-weight: var(--fw-semibold);
  color: var(--text);
  line-height: var(--lh-snug);
}

.doc-content p,
.doc-content ul,
.doc-content ol {
  margin: 0 0 var(--space-4);
  color: var(--text-muted);
  text-wrap: pretty;
}

.doc-content ul,
.doc-content ol {
  padding-left: var(--space-5);
}

.doc-content li {
  margin-bottom: var(--space-2);
}

.doc-content li::marker {
  color: var(--accent);
}

.doc-content strong {
  color: var(--text);
  font-weight: var(--fw-semibold);
}

.doc-content a {
  font-weight: var(--fw-medium);
}

/* ============================================
   页脚（三页共用）
   ============================================ */
.doc-footer,
.cb-page-footer {
  margin-top: var(--space-10);
  padding: var(--space-5) 0 var(--space-2);
  border-top: var(--border-w) solid var(--border);
  text-align: center;
  font-family: var(--font-sans);
  color: var(--text-muted);
  font-size: var(--fs-detail-s);
}

.doc-footer nav,
.cb-page-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3) var(--space-5);
  margin-bottom: var(--space-3);
}

.doc-footer nav a,
.cb-page-footer nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: var(--fw-medium);
}

.doc-footer nav a:hover,
.cb-page-footer nav a:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.doc-footer p,
.cb-page-footer p {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-detail-xs);
  letter-spacing: var(--ls-caps);
}

/* ============================================
   FAQ 折叠
   ============================================ */
.doc-faq details {
  border-bottom: var(--border-w) solid var(--border);
  padding: var(--space-4) 0;
}

.doc-faq details:first-of-type {
  border-top: var(--border-w) solid var(--border);
  margin-top: var(--space-2);
}

.doc-faq summary {
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--fs-detail-l);
  font-weight: var(--fw-semibold);
  color: var(--text);
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: center;
}

.doc-faq summary::-webkit-details-marker {
  display: none;
}

.doc-faq summary::after {
  content: '+';
  font-family: var(--font-mono);
  font-weight: var(--fw-regular);
  color: var(--text-muted);
  font-size: var(--fs-detail-l);
  flex-shrink: 0;
}

.doc-faq details[open] summary::after {
  content: '−';
}

.doc-faq details > *:not(summary) {
  margin-top: var(--space-3);
}

.doc-faq details p,
.doc-faq details ul,
.doc-faq details ol {
  color: var(--text-muted);
  max-width: 38rem;
}

.doc-contact {
  margin-top: var(--space-2);
  padding: var(--space-5);
  background: var(--card-faded);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-lg);
}

.doc-contact a.cb-mail {
  color: var(--text);
  font-weight: var(--fw-semibold);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.doc-contact a.cb-mail:hover {
  color: var(--link-hover);
}

/* ============================================
   响应式 — 只做布局重排
   ============================================ */
@media (max-width: 575.98px) {
  .doc-topbar-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .doc-top-nav {
    width: 100%;
  }

  .doc-top-nav a {
    flex: 1;
    text-align: center;
  }

  .doc-content {
    padding-left: calc(var(--rail) + 0.55rem);
  }

  .doc-content h2::before {
    left: calc(-1 * (var(--rail) + 0.55rem) + var(--rail) / 2 - 4px);
  }
}
