/* ==========================================================
 * 文件: shared/public-story.css
 * 版本: 0.1.0 · 更新: 2026-10-24 · 作者: Claude（为李泓锐）
 * 用途: Public 内容页的「主页往下滑」外壳（<body class="ps-page">）。
 *   - 视觉语言跟 landing.html 一致：深海蓝 → 近黑底 + 很弱的星云图和径向光（纯 CSS + nebula-fallback.png，不跑 Three.js）、
 *     Satoshi / General Sans / Inter / Geist Mono、冰蓝强调、大号 section 标题、大留白
 *   - 第一屏 .ps-hero：页面标题 + 一句话 + 2–4 个关键数字（渲染器的第一行 KPI 由 public.js 搬进来）
 *   - 往下 .ps-sec：渲染器的每个区块包成一屏，滑到时淡入（public.js 的 IntersectionObserver）；自由滚动，不吸附
 *   - 长表格 / 长卡片列表默认折叠（.ps-fold），只露前几行，「展开全部」按钮在下面
 *   - 冰蓝：只在 .ps-page 作用域里把已有 token 换成落地页同款的值（不新增 token 名），组件不用改
 *   - Public 品牌页和落地页一样保持深色，不跟随浅色主题（同 ADR-017）
 * ========================================================== */

/* Geist Mono：与 landing-story.css 同一个固定版本 */
@font-face {
  font-family: "Geist Mono";
  src: url("https://cdn.jsdelivr.net/npm/geist@1.8.2/dist/fonts/geist-mono/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* ---------- 作用域内的 token：冰蓝 + 深海蓝，深色固定 ---------- */
.ps-page,
:root[data-theme="light"] .ps-page {
  --font-display: "Satoshi", "Inter", -apple-system, "PingFang SC", sans-serif;
  --font-heading: "General Sans", "Inter", -apple-system, "PingFang SC", sans-serif;
  --font-body: "Inter", -apple-system, "PingFang SC", "Noto Sans SC", sans-serif;
  --font-num: "Geist Mono", "SF Mono", ui-monospace, monospace;
  --font-zh: "PingFang SC", "Noto Sans SC", "Noto Sans CJK SC", sans-serif;
  --font-ui: var(--font-body);
  --font-mono: var(--font-num);

  --bg-base: #030617;
  --bg-surface: rgba(14, 24, 60, 0.42);
  --bg-elevated: rgba(16, 28, 70, 0.92);
  --bg-sunken: rgba(2, 5, 18, 0.55);
  --bg-solid: #081033;
  --surface-hover: rgba(143, 184, 255, 0.06);
  --border-subtle: rgba(143, 184, 255, 0.12);
  --border-strong: rgba(143, 184, 255, 0.28);
  --glass-highlight: rgba(255, 255, 255, 0.06);
  --accent-primary: #3d6bff;
  --accent-glow: #8fb8ff;
  --accent-text: #8fb8ff;
  --accent-contrast: #ffffff;
  --accent-2: #8fb8ff;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.66);
  --text-dim: rgba(255, 255, 255, 0.4);
  --red: #ff8a8a;
  --green: #4ade80;
  --amber: #fbbf24;
  --red-fill: #f87171;
  --green-fill: #22c55e;
  --chart-1: #8fb8ff;
  --chart-2: #3d6bff;
  --chart-bench: rgba(255, 255, 255, 0.45);
  --chart-grid: rgba(255, 255, 255, 0.05);
  --chart-text: rgba(255, 255, 255, 0.6);
  --shadow-glow: 0 0 60px rgba(61, 107, 255, 0.35);
  --shadow-glow-sm: 0 0 24px rgba(61, 107, 255, 0.3);
  --text-glow: 0 0 24px rgba(143, 184, 255, 0.45);
  --focus-ring: #8fb8ff;
  --selection: rgba(61, 107, 255, 0.45);
  /* 涨跌色是从 --red / --green 派生的，要在同一作用域里重新派生一次（同 landing-s39.css） */
  --color-rise: var(--red);
  --color-fall: var(--green);
  --fill-rise: var(--red-fill);
  --fill-fall: var(--green-fill);

  --ps-gutter: clamp(16px, 6vw, 96px);
  --ps-ease: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: dark;
  font-family: var(--font-body);
  font-size: 16px;
  letter-spacing: -0.006em;
  color: var(--text-primary);
  /* 往下滑的各屏：顶部深蓝 → 往下近黑（同落地页）；跟着页面滚，不 fixed */
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(1100px 640px at 72% -12%, rgba(61, 107, 255, 0.22), transparent 62%),
    radial-gradient(900px 620px at -12% 38%, rgba(143, 184, 255, 0.06), transparent 62%),
    linear-gradient(180deg, #050b2c 0, #030617 1600px) #030617;
}

html[lang="zh-CN"] .ps-page { letter-spacing: 0; }

:root[data-market="us"] .ps-page {
  --color-rise: var(--green);
  --color-fall: var(--red);
  --fill-rise: var(--green-fill);
  --fill-fall: var(--red-fill);
}

/* 很弱的星云：预渲染图 18%，只在页面顶部，往下渐隐；纯装饰 */
.ps-page::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: min(140vh, 100%);
  z-index: -2;
  pointer-events: none;
  background: url("nebula-fallback.png") 70% 0 / cover no-repeat;
  opacity: 0.18;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 75%);
  mask-image: linear-gradient(180deg, #000 0%, transparent 75%);
}

/* theme.css 给 body 的是 fixed 紫色顶光；这里改成跟着页面滚的冰蓝底 */
body.ps-page { background-attachment: scroll; }

/* theme.css 的 fixed 噪点层不用（落地页同样关掉了，见 landing-story.css） */
.ps-page::before { display: none; }

/* ---------- 主体：去掉内容页原来的居中窄栏，改为整屏 section ---------- */
.ps-main.pub-main {
  max-width: none;
  margin: 0;
  padding: 0;
}

.ps-main.pub-main > * + * { margin-top: 0; }
.ps-main [data-ps-body] { display: block; }

/* ---------- 第一屏 ---------- */
.ps-hero {
  position: relative;
  display: grid;
  align-content: end;
  min-height: 100vh;
  min-height: 100svh;
  padding: calc(44px + 14vh) var(--ps-gutter) 16vh;
  isolation: isolate;
}

/* 登录页这类「要马上操作」的页面：第一屏不占满，表单紧跟在下面 */
.ps-hero--compact {
  min-height: 0;
  padding-bottom: 4vh;
}

.ps-hero--compact .ps-kpis { margin-top: 5vh; }
.ps-hero--compact .ps-hint { display: none; }
.ps-hero--compact + * .ps-sec:first-child,
.ps-hero--compact ~ [data-ps-body] > .ps-sec:first-child { padding-top: 6vh; }

.ps-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(55% 45% at 30% 60%, rgba(61, 107, 255, 0.1), transparent 70%);
}

.ps-hero__inner,
.ps-sec__inner {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.ps-hero .pub-head { gap: 0; }

.ps-hero .pub-head h1 {
  max-width: 14ch;
  font-family: var(--font-display);
  font-size: clamp(52px, 8vw, 128px);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: -0.045em;
  color: #fff;
}

/* 标题很长的页面（回测页：策略名 · 标的）：小一号 */
.ps-hero .pub-head h1.ps-h1--md {
  max-width: 18ch;
  font-size: clamp(40px, 5.6vw, 88px);
}

.ps-hero__actions { margin-top: 32px; }

html[lang="zh-CN"] .ps-hero .pub-head h1 {
  max-width: 10em;
  font-family: var(--font-zh);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.02em;
  font-size: clamp(44px, 6.4vw, 104px);
}

.ps-hero .pub-head p {
  max-width: 34em;
  margin-top: 28px;
  font-size: clamp(17px, 1.3vw, 20px);
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.66);
}

.ps-hero .pub-head__meta {
  order: -1;
  margin-bottom: 28px;
  font-family: var(--font-num);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.5);
}

.ps-hero .pub-head { display: flex; flex-direction: column; }
.ps-hero .pub-head__meta .badge { font-size: 12px; }

/* 2–4 个关键数字：大号 Geist Mono，上面一道细线，不用卡片 */
.ps-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  margin-top: 9vh;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.ps-kpis:empty { display: none; }

.ps-kpis .metric {
  gap: 6px;
  padding: 24px 24px 0 0;
  border: 0;
  border-radius: 0;
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

.ps-kpis .metric__label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}

.ps-kpis .metric__value {
  font-family: var(--font-num);
  font-size: clamp(34px, 3.8vw, 60px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.ps-kpis .metric__foot {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.45);
}

/* 第 5 个及以后的数字：小一号，排在下面一行 */
.ps-kpis--minor {
  margin-top: 0;
  border-top: 0;
}

.ps-kpis--minor .metric__value { font-size: clamp(22px, 2vw, 30px); }

.ps-hero .when-loading { margin-top: 9vh; }

/* 往下滑提示 */
.ps-hint {
  position: absolute;
  left: 50%;
  bottom: 4vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-family: var(--font-num);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  transform: translateX(-50%);
}

.ps-hint::after {
  content: "";
  width: 1px;
  height: 36px;
  background: linear-gradient(rgba(255, 255, 255, 0.12), #8fb8ff);
  animation: ps-hint 2s cubic-bezier(0.65, 0, 0.35, 1) infinite;
  transform-origin: top;
}

@keyframes ps-hint {
  0% { transform: scaleY(0); opacity: 1; }
  60% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 0; }
}

/* ---------- 往下的每一屏 ---------- */
.ps-sec {
  position: relative;
  display: grid;
  align-content: center;
  padding: clamp(88px, 13vh, 160px) var(--ps-gutter);
  isolation: isolate;
  scroll-margin-top: 44px;
}

.ps-sec::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(60% 50% at 50% 50%, rgba(61, 107, 255, 0.06), transparent 70%);
}

.ps-sec__inner {
  display: grid;
  gap: 28px;
}

.ps-sec__index {
  font-family: var(--font-num);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
}

/* 区块里原来的 section 不再要额外间距 */
.ps-sec__inner > .pub-section,
.ps-sec__inner > section:not([class]) { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }

/* 网格里的子元素默认 min-width: auto，宽表格 / 图表会把整屏撑出横向滚动；这里统一允许收缩 */
.ps-sec__inner { grid-template-columns: minmax(0, 1fr); }
.ps-sec__inner > *,
.ps-sec__inner > section > *,
.ps-sec .pub-section > * { min-width: 0; }

/* 大号 section 标题（同落地页 .story__title--md 的气质，小一号） */
.ps-sec .section-title,
.ps-sec__inner > section > h2,
.ps-sec__inner > .card > .card__title:first-child {
  max-width: 20ch;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(32px, 4.2vw, 68px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.035em;
  color: #fff;
}

html[lang="zh-CN"] .ps-sec .section-title,
html[lang="zh-CN"] .ps-sec__inner > section > h2,
html[lang="zh-CN"] .ps-sec__inner > .card > .card__title:first-child {
  max-width: 14em;
  font-family: var(--font-zh);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-size: clamp(28px, 3.4vw, 56px);
}

.ps-sec .pub-section__head { align-items: flex-end; gap: 16px 24px; }

/* 一屏就是一张卡片的（回测页的图表、明细）：卡片标题放大一档，承担这一屏的标题 */
.ps-sec__inner > .card > .card__head .card__title,
.ps-sec__inner > section.card > .card__head .card__title,
.ps-sec__inner > .grid .card__title {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.2vw, 34px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

html[lang="zh-CN"] .ps-sec__inner .card__head .card__title { font-family: var(--font-zh); letter-spacing: 0; }
.ps-sec .pub-section__hint { font-size: clamp(15px, 1.1vw, 17px); line-height: 1.6; }

/* 卡片：更透一点、圆角更大，接近落地页的数据面板 */
.ps-page .card {
  border-color: rgba(143, 184, 255, 0.12);
  background: rgba(10, 18, 48, 0.5);
}

.ps-page .card__title { font-family: var(--font-heading); }

/* 表格：数字列用 Geist Mono */
.ps-page .table td.num,
.ps-page .table td.mono { font-family: var(--font-num); }

/* ---------- 滑到时淡入（只动 inner，section 本身不加 transform，免得影响 fixed 子元素） ---------- */
.js .ps-sec__inner {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 600ms var(--ps-ease), transform 900ms var(--ps-ease);
}

.js .ps-sec.is-in .ps-sec__inner { opacity: 1; transform: none; }

/* ---------- 长表格 / 长列表默认折叠 ---------- */
.ps-fold:not(.is-open) .ps-row-more { display: none !important; }

.ps-fold-btn {
  justify-self: center;
  align-self: center;
  margin: 16px auto 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid rgba(143, 184, 255, 0.35);
  background: rgba(61, 107, 255, 0.08);
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: border-color 200ms, box-shadow 200ms;
}

.ps-fold-btn:hover { border-color: #8fb8ff; box-shadow: 0 0 24px rgba(143, 184, 255, 0.25); }
.ps-fold-btn[hidden] { display: none; }

/* 原生 details（FAQ、参数说明）：统一外观 */
.ps-page details > summary { cursor: pointer; }

/* 三态：错误 / 空 的卡片放在第一屏下面居中 */
.ps-state {
  padding: 0 var(--ps-gutter) 12vh;
}

.ps-state > .card { max-width: 720px; margin: 0 auto; }
.ps-state .when-loading { max-width: 1280px; margin: 0 auto; }

/* ---------- 手机 ---------- */
@media (max-width: 767px) {
  .ps-hero { padding-top: calc(44px + 10vh); padding-bottom: 12vh; }
  .ps-sec { padding-block: 72px; }
  .ps-kpis .metric { padding-right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .js .ps-sec__inner { opacity: 1; transform: none; transition: none; }
  .ps-hint::after { animation: none; }
}

/* 数据到了：状态区不占位置 */
.ps-main[data-state="ready"] .ps-state { display: none; }

/* 渲染器刚写进来、还没被 public.js 包成 .ps-sec 的区块：先给它和包好之后一样的宽度，
   这样图表（lightweight-charts 按创建时容器宽度定尺寸）不会按整屏宽度画出来再被挤出横向滚动 */
.ps-main [data-ps-body] > :not(.ps-sec) {
  width: min(1280px, 100% - 2 * var(--ps-gutter));
  margin-inline: auto;
}

/* 分享门：自带 40% 亮度的星云和居中卡片（public-ui.css），这里只让出顶栏高度、关掉重复的星云层 */
.ps-page.gate { padding-top: calc(44px + var(--space-5)); }
.ps-page.gate::after { display: none; }
