/* ============================================================
   布局层：报头（masthead）· 报价条 · 左栏 · 阅读栏
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* 动效默认缓动：transition-* 不继承，只能摊到通配上。
   此后所有没显式写缓动的 transition 都落在 --ease-out，
   不再各自退回浏览器内置的 ease。颜色类的双向过渡在各自规则里
   显式写 --ease-in-out，会覆盖这里的默认。 */
*, *::before, *::after {
  transition-timing-function: var(--ease-out, cubic-bezier(.16, 1, .3, 1));
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

/* 纸纹：极淡的斜向网格，只在大屏出现，模拟账簿纸 */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(22,35,43,.016) 1px, transparent 1px) 0 0 / 46px 46px,
    linear-gradient(rgba(22,35,43,.016) 1px, transparent 1px) 0 0 / 46px 46px;
  opacity: .9;
}
body[data-theme="night"]::before { opacity: .5; }

h1,h2,h3,h4 { color: var(--ink); line-height: var(--lh-title); font-weight: 700; margin: 0; }
p { margin: 0 0 var(--s-3); }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: var(--r-1); }
/* 换页之后焦点会落到 #main 上（读屏用户得知道内容整块换了）。
   但 #main 不是可交互控件——给它画一圈焦点框，版式上就多出一条莫名其妙的金线
   （贴着正文右边缘，从头贯到尾），读者会以为那是什么坏了。
   容器上的焦点框去掉，「换页了」这件事交给 live region 播报。 */
main:focus, main:focus-visible { outline: none; }
::selection { background: var(--gold-soft); color: var(--ink); }

/* ---------- 通用排版件 ---------- */
.eyebrow {
  font-family: var(--font-mono); font-size: var(--t-eyebrow); letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-3); margin: 0 0 var(--s-2);
  display: flex; align-items: center; gap: var(--s-2);
}
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--flat); }
.gold { color: var(--gold-text); } .teal { color: var(--teal); }
.muted { color: var(--ink-3); }
.small { font-size: var(--t-small); }
.micro { font-size: var(--t-micro); }
.hide { display: none !important; }

/* 只给读屏看的东西：页面上看不见，但该念的还得念。
   换页提示、回放器的播报、峰值谷值都靠它。 */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

/* 跳到主内容：平时藏在屏幕外，Tab 到它才露出来。
   键盘用户不用每次都从报头的搜索按钮一路 Tab 到正文。 */
.skip {
  position: fixed; top: var(--s-2); left: var(--s-2); z-index: calc(var(--z-top) + 10);
  transform: translateY(-250%);
  padding: 9px 16px; border-radius: var(--r-2);
  background: var(--ink); color: var(--paper);
  font-size: var(--t-small); text-decoration: none;
  transition: transform var(--dur-1, 140ms) var(--ease-out, cubic-bezier(.16, 1, .3, 1));
}
.skip:focus { transform: translateY(0); text-decoration: none; }

/* ============================================================
   报头 Masthead
   ============================================================ */
.masthead {
  position: sticky; top: 0; z-index: var(--z-top);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.masthead-in {
  max-width: var(--page-max); margin: 0 auto; padding: 0 var(--s-5);
  height: var(--masthead-h);
  display: flex; align-items: center; gap: var(--s-5);
}
.nameplate { display: flex; align-items: baseline; gap: var(--s-3); flex: none; }
.nameplate .zh {
  font-size: 21px; font-weight: 700; color: var(--ink); letter-spacing: .06em; line-height: 1;
}
.nameplate .en {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .18em;
  color: var(--ink-3); text-transform: uppercase; line-height: 1;
}
.masthead-spacer { flex: 1 1 auto; }
.masthead-meta {
  font-family: var(--font-mono); font-size: var(--t-micro); color: var(--ink-3);
  display: flex; align-items: center; gap: var(--s-3); white-space: nowrap;
}
.masthead-meta .sep { color: var(--rule); }
.masthead-meta #mh-sister {
  color: var(--ink-3); text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color var(--dur-1, 140ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1)),
              border-color var(--dur-1, 140ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1));
}
.masthead-meta #mh-sister:hover { color: var(--teal); border-bottom-color: var(--teal-line); }

.mh-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border: 1px solid var(--rule); border-radius: var(--r-2); background: var(--sheet);
  color: var(--ink-2); font-size: var(--t-small);
  transition: border-color var(--dur-1, 140ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1)),
              color var(--dur-1, 140ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1));
  position: relative;
}
/* D-6：触控热区。
   按钮本身只有 30px 高，手指按不准。视觉不动，用一层透明的 ::after
   把热区撑到 44×44（宽高都够），点哪儿都是这个按钮。 */
.mh-btn::after { content: ''; position: absolute; left: -7px; right: -7px; top: -7px; bottom: -7px; }
.mh-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.mh-btn .kbd {
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-3);
  border: 1px solid var(--rule); border-radius: var(--r-1); padding: 0 4px; line-height: 15px;
}
.mh-btn.icon { padding: 0 7px; }
.mh-btn.icon svg { display: block; }

/* 报头下的时间刻度线 —— 全站签名的最小版本 */
.tick-rule { height: 7px; border-bottom: 1px solid var(--rule); position: relative; overflow: hidden; }
.tick-rule i {
  position: absolute; bottom: 0; width: 1px; height: 4px; background: var(--rule);
}
.tick-rule i.major { height: 7px; background: var(--ink-4); }

/* ============================================================
   报价条 Ticker
   ============================================================ */
.ticker {
  background: var(--sheet); border-bottom: 1px solid var(--rule);
  position: sticky; top: var(--masthead-h); z-index: calc(var(--z-top) - 1);
}
.ticker-in {
  max-width: var(--page-max); margin: 0 auto; padding: 0 var(--s-5);
  height: var(--ticker-h); display: flex; align-items: center; gap: var(--s-5);
  overflow-x: auto; scrollbar-width: none;
}
.ticker-in::-webkit-scrollbar { display: none; }
.tk {
  display: inline-flex; align-items: baseline; gap: 7px; flex: none;
  padding-right: var(--s-5); border-right: 1px solid var(--rule-2); cursor: pointer;
}
.tk:last-child { border-right: 0; }
.tk .k { font-size: var(--t-micro); color: var(--ink-3); white-space: nowrap; }
.tk .v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--t-small); color: var(--ink); }
.tk .c { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.tk .spark { width: 34px; height: 12px; display: block; }
.tk:hover .k { color: var(--teal); }
.tk.src-note { margin-left: auto; border: 0; color: var(--ink-4); font-size: 11px; font-family: var(--font-mono); cursor: default; }

/* ============================================================
   主体骨架：左栏 + 阅读栏
   ============================================================ */
.shell {
  max-width: var(--page-max); margin: 0 auto; padding: 0 var(--s-5);
  display: grid; grid-template-columns: var(--rail-w) minmax(0,1fr); gap: var(--s-7);
  align-items: start;
}

.rail {
  position: sticky; top: calc(var(--masthead-h) + var(--ticker-h) + var(--s-4));
  padding: var(--s-6) 0 var(--s-7);
  max-height: calc(100dvh - var(--masthead-h) - var(--ticker-h));
  overflow-y: auto; scrollbar-width: thin;
}
.rail-group + .rail-group { margin-top: var(--s-5); }
.rail-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-4); padding: 0 var(--s-3) var(--s-2);
}
.rail-item {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 6px var(--s-3); border-radius: var(--r-2);
  color: var(--ink-2); font-size: var(--t-small); position: relative;
  transition: background-color var(--dur-1, 140ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1)),
              color var(--dur-1, 140ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1));
}
.rail-item .ri-n {
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-4); width: 16px; flex: none;
}
.rail-item .ri-t { flex: 1 1 auto; }
.rail-item .ri-c { font-family: var(--font-mono); font-size: 10px; color: var(--ink-4); }
.rail-item:hover { background: var(--teal-soft); color: var(--ink); text-decoration: none; }
.rail-item.on { background: var(--teal-soft); color: var(--teal); font-weight: 500; }
.rail-item.on .ri-n { color: var(--teal); }
.rail-item.on::before {
  content: ""; position: absolute; left: -1px; top: 6px; bottom: 6px; width: 2px; background: var(--gold);
}
.rail-item svg { flex: none; opacity: .7; }
.rail-item.on svg { opacity: 1; }

.rail-sister {
  margin-top: var(--s-6); padding: var(--s-3); border: 1px solid var(--rule); border-radius: var(--r-2);
  background: var(--sheet-2);
}
.rail-sister .rs-t { font-size: 12.5px; color: var(--ink); font-weight: 500; margin-bottom: 3px; }
.rail-sister .rs-d { font-size: 11.5px; color: var(--ink-3); line-height: 1.6; margin: 0; }

/* 阅读栏 */
.main { min-width: 0; padding: var(--s-6) 0 var(--s-8); }
.reading { max-width: var(--reading-w); }

/* 换页进场（route-in）定义在 index.html 的动效层，唯一一份：
   容器只纯淡入，位移交给各视图自己的进场动画（fx-page-in /
   terms-body-in 都是 6px），容器再挪一次就叠成 12px。
   这里不写第二份——同特异性下后加载的内联层会静默盖掉本文件，
   两处各改各的等于白改。 */

/* 阅读进度：贴在视口顶的金线。
   游标类指示——linear 是「不缓动、跟手」，刻意不进三档缓动；
   时长仍走 --dur-1。
   宽度常驻 100%，进度由 app.js 写 scaleX（0→1）：transform 过渡走
   合成器；width 过渡在滚动里每帧追帧、每帧 layout，代价太高。 */
.progress {
  position: fixed; top: 0; left: 0; height: 2px; z-index: calc(var(--z-top) + 1);
  background: var(--gold); width: 100%; transform: scaleX(0); transform-origin: left;
  transition: transform var(--dur-1, 140ms) linear;
}

/* ---------- 移动端底部标签栏 ---------- */
.tabbar { display: none; }

/* ============================================================
   响应式
   ============================================================ */
/* ============================================================
   全站页脚：免责声明
   写作指南要求每页页脚都有一处。页脚跟正文列对齐（不是通栏），
   免得宽屏下那两行字飘在页面最左边。
   ============================================================ */
.footer {
  border-top: 1px solid var(--rule);
  margin-top: var(--s-7);
}
.footer-in {
  max-width: var(--page-max); margin: 0 auto; padding: var(--s-5) var(--s-5) calc(var(--s-6) + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: var(--rail-w) minmax(0,1fr); gap: var(--s-7);
}
.footer-text {
  grid-column: 2;
  font-size: var(--t-small); color: var(--ink-3); line-height: 1.75;
}
.footer-text p { margin: 0 0 6px; }
.footer-text p:last-child { margin: 0; }
.footer-text b { color: var(--ink-2); font-weight: 600; }

@media (max-width: 1080px) {
  :root { --rail-w: 176px; --s-7: 32px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0,1fr); gap: 0; padding: 0 var(--s-4); }
  .rail { display: none; }
  .main { padding-bottom: 88px; }
  .masthead-in, .ticker-in { padding: 0 var(--s-4); }
  .masthead-meta .hide-sm { display: none; }

  /* D-1：页头横向溢出。
     报头是 flex，7 个孩子之间有 6 个 22px 的 gap（合计 132px）。
     窄屏下 .masthead-spacer 与 .masthead-meta 宽度虽然变成 0，
     却仍然各占一个 gap；搜索按钮里的「搜索」二字也还在，
     三样加起来把 320px 的屏撑到 407px，页面横向能拖。
     现在：窄屏一律收起英文名、日期、姊妹站链接和搜索文字，
     报头只留站名 + 三个图标按钮。 */
  .masthead-in { gap: 8px; }
  .masthead .hide-sm { display: none !important; }
  .nameplate .en { display: none !important; }
  .masthead-spacer, .masthead-meta { display: none !important; }

  .footer-in { grid-template-columns: minmax(0,1fr); gap: 0; padding-left: var(--s-4); padding-right: var(--s-4); }
  .footer-text { grid-column: 1; }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-rail);
    background: color-mix(in srgb, var(--sheet) 96%, transparent);
    backdrop-filter: blur(12px); border-top: 1px solid var(--rule);
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
  }
  .tabbar button {
    flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
    border: 0; background: none; padding: 5px 2px; color: var(--ink-3); font-size: 10.5px;
    border-radius: var(--r-2); position: relative;
    transition: color var(--dur-1, 140ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1));
  }
  .tabbar button.on { color: var(--teal); }
  .tabbar button.on::before {
    content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 16px; height: 2px; background: var(--gold);
  }
  .tabbar svg { width: 19px; height: 19px; }
}
@media (max-width: 420px) {
  .nameplate .en { display: none; }
}
