/*
 * report-apple.css
 * Apple-minimalist design system for AI Insight research reports.
 * Used by views that opt-in via <link rel="stylesheet" href="/css/report-apple.css">.
 */

:root {
  /* 暖白系 — 偏离纯白的 #fafaf8 让卡片白能立起来,贴合中文阅读站惯例 */
  --bg: #fafaf8;
  --card: #ffffff;
  --text: #1c1c1e;
  --text-2: #3c3c43;
  --text-3: #6b6b70;
  --text-4: #8e8e93;
  --rule: #cfcfd4;
  --rule-2: #e9e8e4;
  --rule-3: #f1f0ec;       /* 极淡线，用于斑马底 */
  --accent: #0066cc;
  --accent-rgb: 0, 102, 204;
  --warn: #b8350a;
  --good: #1d6f42;
  --tint-accent: rgba(0, 102, 204, 0.05);
  --tint-warm: rgba(196, 149, 106, 0.1);   /* 站点琥珀色微染 */
  --tint-warm-strong: rgba(196, 149, 106, 0.16);
}

@media (prefers-color-scheme: dark) {
  /* Light-only by design — apple-minimal works best on white. Skip dark mode. */
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body.report-apple {
  margin: 0;
  /* PingFang SC 在 SF Pro 之前——让中文字符走 PingFang，西文走 SF Pro */
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "SF Pro Display", "SF Pro Text", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans CN", system-ui, sans-serif;
  font-size: 17px;            /* 17.5 → 17, 中文略紧 */
  line-height: 1.72;          /* 1.7 → 1.72, 中文不太松 */
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* palt = proportional alternates for CJK punctuation tightening */
  font-feature-settings: "kern" 1, "liga" 1, "palt" 1;
  text-rendering: optimizeLegibility;
}

/* Reading-progress hairline */
.ra-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 200;
  background: transparent;
}
.ra-progress > span {
  display: block; height: 100%;
  background: var(--accent);
  width: 0%; transform-origin: left;
  transition: width 0.08s linear;
}

/* Sticky thin nav */
.ra-nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(251, 251, 253, 0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--rule-2);
}
.ra-nav-inner {
  max-width: 980px; margin: 0 auto;
  padding: 14px 24px;
  display: flex; justify-content: space-between; align-items: center;
}
.ra-brand {
  font-size: 14px; font-weight: 600; color: var(--text);
  text-decoration: none; letter-spacing: -0.01em;
}
.ra-back {
  font-size: 13px; color: var(--text-3);
  text-decoration: none;
  transition: color 0.15s;
}
.ra-back:hover { color: var(--accent); }

/* Hero */
.ra-hero {
  padding: clamp(72px, 12vh, 132px) 24px clamp(56px, 8vh, 96px);
  max-width: 800px; margin: 0 auto;     /* 880 → 800, 与 body 760 落差更小 */
  text-align: center;
}
.ra-eyebrow {
  font-size: 12px; font-weight: 600;
  /* 0.18em + uppercase 太 cosplay 美式英文媒体；中文环境收到 0.06em + sentence-case */
  letter-spacing: 0.06em;
  text-transform: none;
  color: var(--accent);
  margin-bottom: 22px;
}
.ra-hero h1 {
  /* 上限 72 → 56；中文 12+ 字标题再大就很难看的换行 */
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 700;          /* 800 在 PingFang SC 上等于 bold；用 700 更稳 */
  letter-spacing: -0.01em;   /* 中文不能压太紧 */
  line-height: 1.2;
  color: var(--text);
  margin: 0 auto 24px;
  max-width: 22ch;           /* 限定标题宽度,避免过宽换行难看 */
}
.ra-hero h1 .accent { color: var(--accent); }
.ra-deck {
  font-size: clamp(17px, 1.6vw, 20px);
  color: var(--text-3);
  line-height: 1.6;
  font-weight: 400;
  letter-spacing: -0.005em;
  margin: 0 auto 36px;
  max-width: 640px;
}
.ra-meta {
  display: inline-flex; gap: 0; flex-wrap: wrap; justify-content: center;
  font-size: 13px; color: var(--text-4);
  padding-top: 24px;
  margin-top: 8px;
  position: relative;
}
.ra-meta::before {
  content: "";
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 32px; height: 1px;
  background: var(--rule);
}
.ra-meta > * { white-space: nowrap; padding: 0 14px; }
.ra-meta > * + * { border-left: 1px solid var(--rule-2); }

/* Body container */
.ra-body {
  max-width: 760px;             /* 720 → 760, 减小 hero/body 落差 */
  margin: 0 auto;
  padding: 16px 24px 120px;
}

.ra-body p {
  margin: 0 0 1.4em;
  color: var(--text-2);
  line-height: 1.78;            /* 段落保留较松,正文阅读核心 */
}
.ra-body p strong { color: var(--text); font-weight: 600; }
.ra-body li { line-height: 1.78; }

.ra-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(var(--accent-rgb), 0.32);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  border-bottom: none;
  transition: text-decoration-color 0.15s;
}
.ra-body a:hover { text-decoration-color: var(--accent); }
.ra-body ul, .ra-body ol { margin: 0 0 1.4em; }
.ra-body ul li::marker { color: var(--accent); }
.ra-body ol li::marker { color: var(--text-4); font-variant-numeric: tabular-nums; }

/* Section eyebrow + heading */
.ra-section { margin: clamp(64px, 8vh, 88px) 0 0; }
.ra-section:first-of-type { margin-top: 48px; }
.ra-section-eyebrow {
  font-size: 11.5px; font-weight: 600;
  /* 中文环境减弱字间距 + 不做 uppercase（数字/英文 attr 自然显示） */
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--text-4);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ra-section-eyebrow::before {
  content: "";
  display: inline-block;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
/* 上限 40 → 32, 中文章节标题不需要那么大；尤其首个 section H2 是大标题的复述 */
.ra-section h2 {
  font-size: clamp(24px, 2.8vw, 32px);
  font-weight: 600;          /* PingFang Semibold (600) — 700 在 PingFang 是 bold，太粗 */
  letter-spacing: -0.005em;
  line-height: 1.3;
  color: var(--text);
  margin: 0 0 24px;
}
/* 第一个 section 的 H2 通常是大标题的复述,再次缩一档 */
.ra-section:first-of-type h2 {
  font-size: clamp(20px, 2.2vw, 26px);
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--rule-2);
  color: var(--text-2);
  font-weight: 600;
}
/* 首个 section 不需要 eyebrow 圆点(避免与 hero 距离太近重复元素) */
.ra-section:first-of-type .ra-section-eyebrow::before { display: none; }
.ra-section:first-of-type .ra-section-eyebrow { display: block; padding-left: 0; }

/* 段落组之间的呼吸节奏 — H3 前轻微减压 */
.ra-section h3 + p,
.ra-section h3 + ul,
.ra-section h3 + ol { margin-top: 0; }
.ra-section p + h3 { margin-top: 32px; }
.ra-section h3 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.003em;
  color: var(--text);
  margin: 36px 0 12px;
}

/* Hero stat strip (tabular nums, no card) */
.ra-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0;
  margin: 48px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.ra-stat {
  padding: 26px 18px;
  text-align: left;
  border-right: 1px solid var(--rule-2);
}
.ra-stat:last-child { border-right: none; }
/* 数字 44 太大让相邻 stat 贴得近;36 在中文上下文更协调 */
.ra-stat .num {
  font-size: clamp(28px, 3.2vw, 38px);
  font-weight: 700;
  letter-spacing: -0.018em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-bottom: 8px;
}
.ra-stat .num.warn { color: var(--warn); }
.ra-stat .num.good { color: var(--good); }
.ra-stat .lab {
  font-size: 12.5px;
  color: var(--text-4);
  letter-spacing: 0.01em;
  line-height: 1.5;
}

/* Inline lede stat (single big number anywhere in body) */
.ra-lede {
  font-size: clamp(40px, 5.6vw, 64px);
  font-weight: 700;
  letter-spacing: -0.024em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  margin: 0.4em 0 0.3em;
}
.ra-lede + .ra-lede-cap {
  font-size: 13.5px; color: var(--text-3); margin: 0 0 1.4em; line-height: 1.6;
}

/* Pull quote */
.ra-pull {
  margin: 48px 0;
  padding: 24px 0;
  text-align: center;
  position: relative;
}
.ra-pull::before {
  content: """;
  position: absolute;
  top: -12px; left: 50%;
  transform: translateX(-50%);
  font-size: 56px;
  color: var(--rule);
  font-family: Georgia, "Source Han Serif", serif;
  line-height: 1;
  font-weight: 400;
}
.ra-pull blockquote {
  font-size: clamp(20px, 2.4vw, 26px);
  font-weight: 500;
  font-style: normal;
  letter-spacing: -0.008em;
  line-height: 1.42;
  color: var(--text);
  margin: 18px auto 14px;
  max-width: 600px;
}
.ra-pull cite {
  display: block;
  font-size: 13px; font-style: normal;
  color: var(--text-4);
  letter-spacing: 0.02em;
}

/* Verbatim quote — bilingual, more compact than pull quote */
.ra-quote {
  margin: 24px 0;
  padding: 24px 0;
  border-top: 1px solid var(--rule-2);
}
.ra-quote .en {
  font-size: 18px;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 8px;
  font-weight: 400;
  letter-spacing: -0.005em;
}
.ra-quote .zh {
  font-size: 15px;
  color: var(--text-3);
  margin: 0 0 10px;
  line-height: 1.7;
}
.ra-quote .src {
  font-size: 12px;
  color: var(--text-4);
  letter-spacing: 0.02em;
}

/* Hairline table */
.ra-table-wrap { margin: 32px 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ra-table-wrap > .ra-table { margin: 0; min-width: 100%; }
.ra-table {
  width: 100%;
  border-collapse: collapse;
  margin: 32px 0;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.ra-table th, .ra-table td {
  padding: 13px 16px;
  text-align: left;
  border-bottom: 1px solid var(--rule-2);
  vertical-align: top;
}
.ra-table thead th {
  font-size: 12px;
  font-weight: 600;
  /* 表头不再 uppercase（中文表头会被吃掉,英文表头依旧识别） */
  text-transform: none;
  letter-spacing: 0.04em;
  color: var(--text-3);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 12px;
  background: transparent;
}
/* 第一列加重(行头),便于扫读 */
.ra-table tbody td:first-child {
  font-weight: 500;
  color: var(--text);
}
/* 隔行轻底,提高扫读性。比 hover-only 更严肃刊物感 */
.ra-table tbody tr:nth-child(even) td {
  background: var(--rule-3);
}
.ra-table tbody tr:hover td {
  background: var(--tint-accent);
}
.ra-table .num-col { text-align: right; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.ra-table .row-em td { font-weight: 600; color: var(--text); background: var(--tint-warm-strong) !important; }
.ra-table caption {
  caption-side: bottom;
  font-size: 12.5px;
  color: var(--text-3);
  text-align: left;
  padding-top: 12px;
  letter-spacing: 0.01em;
  line-height: 1.6;
}

/* Scenario row — replaces card grid */
.ra-scenario {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 28px;
  padding: 26px 0;
  border-top: 1px solid var(--rule-2);
}
.ra-scenario:last-of-type { border-bottom: 1px solid var(--rule-2); }
.ra-scenario .verdict {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  padding-top: 4px;
}
.ra-scenario .verdict.yes { color: var(--good); }
.ra-scenario .verdict.no { color: var(--warn); }
.ra-scenario .verdict.maybe { color: var(--text-3); }
.ra-scenario h3 {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.4;
}
.ra-scenario p {
  margin: 0 0 10px;
  color: var(--text-2);
  font-size: 15.5px;
  line-height: 1.72;
}
.ra-scenario p:last-child { margin-bottom: 0; }
.ra-scenario .basis {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--rule-2);
  font-size: 13.5px;
  color: var(--text-3);
  line-height: 1.7;
}

/* Code inline */
code {
  font-family: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92em;
  padding: 2px 6px;
  background: var(--rule-2);
  border-radius: 4px;
  color: var(--text-2);
}

/* Refs */
.ra-refs ol {
  list-style: none; padding: 0; margin: 0;
  counter-reset: refs;
}
.ra-refs li {
  counter-increment: refs;
  position: relative;
  padding: 14px 0 14px 36px;
  border-bottom: 1px solid var(--rule-2);
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.65;
}
.ra-refs li:last-child { border-bottom: none; }
.ra-refs li::before {
  content: counter(refs);
  position: absolute; left: 0; top: 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  min-width: 24px;
}
.ra-refs a { color: var(--accent); border-bottom-color: transparent; }
.ra-refs a:hover { border-bottom-color: var(--accent); }

/* Editor's note — 严肃刊物感 left-stripe 处理, 类似 NYT */
.ra-editor {
  margin: 64px 0 0;
  padding: 28px 28px 28px 28px;
  border-left: 3px solid var(--accent);
  border-top: none;
  background: var(--tint-warm);
  border-radius: 0 6px 6px 0;
}
.ra-editor::before {
  content: "编者按";
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 12px;
}
.ra-editor p {
  font-size: 15.5px;
  color: var(--text-2);
  line-height: 1.78;
  margin: 0 0 1.1em;
}
.ra-editor p:last-child { margin-bottom: 0; }
.ra-editor a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(var(--accent-rgb), 0.4);
  text-underline-offset: 3px;
}

/* Footnote sup */
sup {
  font-size: 0.7em;
  margin-left: 1px;
}
sup a {
  color: var(--accent);
  border-bottom: none;
  text-decoration: none;
}

/* Paywall — 严肃刊物的"订阅墙",非促销卡片 */
.ra-paywall {
  margin: 64px 0 24px;
  padding: 36px 36px;
  background: linear-gradient(180deg, #fff 0%, #faf9f6 100%);
  border: 1px solid var(--rule-2);
  border-radius: 14px;
  text-align: center;
  position: relative;
}
.ra-paywall::before {
  content: "";
  position: absolute;
  top: -1px; left: 50%;
  transform: translateX(-50%);
  width: 56px; height: 3px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
}
.ra-paywall-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 0 0 12px;
  text-transform: none;
}
.ra-paywall-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  margin: 0 0 10px;
  line-height: 1.4;
}
.ra-paywall-msg {
  font-size: 14.5px;
  color: var(--text-3);
  line-height: 1.7;
  margin: 0 auto 24px;
  max-width: 480px;
}
.ra-paywall-cta {
  display: inline-block;
  padding: 12px 32px;
  background: #1c1c1e;
  color: #fff;
  border-radius: 980px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none !important;
  border: none;
  transition: background 0.15s, transform 0.15s;
}
.ra-paywall-cta:hover {
  background: #000;
  transform: translateY(-1px);
}
@media (max-width: 640px) {
  .ra-paywall { padding: 28px 22px; margin: 48px 0 16px; }
  .ra-paywall-title { font-size: 18px; }
  .ra-paywall-msg { font-size: 14px; }
}

/* Footer */
.ra-foot {
  text-align: center;
  padding: 64px 24px 96px;
  font-size: 13px;
  color: var(--text-4);
  border-top: 1px solid var(--rule-2);
}
.ra-foot a { color: var(--text-3); border-bottom: none; margin: 0 8px; }
.ra-foot a:hover { color: var(--accent); }

/* Mobile */
@media (max-width: 640px) {
  body.report-apple { font-size: 16px; line-height: 1.74; }
  .ra-body { padding: 8px 22px 72px; }
  .ra-hero { padding: 56px 22px 44px; }
  .ra-hero h1 { font-size: clamp(28px, 7vw, 36px); line-height: 1.28; max-width: 18ch; }
  .ra-deck { font-size: 15.5px; line-height: 1.62; max-width: 100%; }
  .ra-eyebrow { font-size: 11.5px; margin-bottom: 16px; }
  .ra-meta { gap: 14px; font-size: 12px; padding-top: 24px; margin-top: 20px; }
  .ra-stats { grid-template-columns: 1fr 1fr; margin: 36px 0; }
  .ra-stat { border-right: none; border-bottom: 1px solid var(--rule-2); padding: 20px 14px; }
  .ra-stat:nth-last-child(-n+2) { border-bottom: none; }
  .ra-stat:nth-child(2n) { border-left: 1px solid var(--rule-2); }
  .ra-stat .num { font-size: 26px; }
  .ra-section { margin-top: 56px; }
  .ra-section h2 { font-size: 22px; line-height: 1.32; margin-bottom: 18px; }
  .ra-section:first-of-type h2 { font-size: 18px; padding-bottom: 18px; margin-bottom: 22px; }
  .ra-section h3 { font-size: 17px; margin: 28px 0 10px; }
  .ra-scenario { grid-template-columns: 1fr; gap: 10px; padding: 22px 0; }
  .ra-scenario .verdict { font-size: 11.5px; padding-top: 0; }
  .ra-scenario h3 { font-size: 17px; }
  .ra-pull blockquote { font-size: 20px; line-height: 1.42; }
  .ra-editor { margin-top: 56px; padding: 22px 0 22px 18px; }

  /* === Mobile table → stack each row as a card === */
  /* JS attaches data-label="<column header>" to each td; CSS picks it up. */
  .ra-table { display: block; font-size: 14.5px; margin: 24px 0; }
  .ra-table thead { display: none; }
  .ra-table tbody { display: block; }
  .ra-table tbody tr {
    display: block;
    border: 1px solid var(--rule-2);
    border-radius: 10px;
    background: var(--card);
    padding: 14px 16px;
    margin: 0 0 10px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
  }
  .ra-table tbody tr:nth-child(even) td { background: transparent; }  /* 关闭 desktop 斑马 */
  .ra-table tbody tr.row-em {
    border-color: rgba(196, 149, 106, 0.4);
    background: var(--tint-warm);
  }
  .ra-table tbody tr.row-em td { background: transparent !important; }
  .ra-table tbody td {
    display: grid;
    grid-template-columns: minmax(72px, 0.4fr) 1fr;
    gap: 12px;
    align-items: baseline;
    padding: 7px 0;
    border-bottom: 1px solid var(--rule-3);
    text-align: left !important;
    line-height: 1.6;
    color: var(--text-2);
  }
  .ra-table tbody td:last-child { border-bottom: none; padding-bottom: 0; }
  .ra-table tbody td:first-child {
    /* Row label (first column) — display as card title (full row) */
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    padding: 0 0 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--rule-2);
    letter-spacing: -0.005em;
  }
  /* Remaining cells — show their column header as a small label aligned left */
  .ra-table tbody td:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-transform: none;       /* 中英文 attr 都自然显示 */
    color: var(--text-4);
    line-height: 1.5;
  }
  /* If the table only has 2 columns, drop the label (it'd just say the column header) */
  .ra-table.cols-2 tbody td:not(:first-child) {
    display: block;
  }
  .ra-table.cols-2 tbody td:not(:first-child)::before { display: none; }
  .ra-table tbody td.num-col,
  .ra-table tbody td[class*="num-col"] {
    text-align: left !important;
    font-weight: 500;
  }
  /* num value 加重以便扫读 */
  .ra-table tbody td.num-col {
    font-variant-numeric: tabular-nums;
    color: var(--text);
  }
  .ra-table caption {
    display: block;
    margin: 4px 4px 0;
    padding: 0;
  }
}
