/* cunedi 2026-07 texture utilities — base.css
 * Consumes the CSS custom properties written by boot.js (the token engine).
 * Self-hosted fonts live in /fonts/. No CDN, no external requests.
 */

/* ---------- Fonts (self-hosted, /fonts/*.woff2) ---------- */

/* ── CunediMetrics:只有度量、没有字形的「基准字」(2026-09-17) ──────────────
 * 为什么需要它:固定行高下,文字基线的位置由字体栈里**第一个可用字体**的
 * ascent 决定(CSS 管这叫 strut)。各套字体 ascent 不同 → 换字体后中文在气泡/
 * 药丸里忽上忽下(铜铜 09-17 报的「宋体的字微微靠上」就是这个)。
 *
 * 本来用 @font-face 的 ascent-override 修最干净,但 **Safari 不认那组描述符**
 * (iOS 18.0 实测被完全忽略,chat-v2/fontcheck.html 可自检)。于是改成这个不挑
 * 浏览器的老办法:造一个 ascent/descent = 1066/300(即 Manrope 的真实度量,也就是
 * 全站"正常"的基准)、cmap 只映射一个私用区码位的空字体,插在每套字体栈**最前面**。
 * 它永远不渲染任何字(真文本里没有 U+E000),但 strut 认它 → 所有字体基线一致。
 *
 * 内联成 data URI 是故意的:344 字节,零额外请求,base.css 一解析就可用,
 * 不会出现"字体没到位 → 基线先错一下再跳"的抖动。
 * 改这里的数值必须同步 /fonts/cjk/*.css 里的 ascent-override(认它的浏览器走那条)。
 */
@font-face {
  font-family: 'CunediMetrics';
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
  src: url(data:font/woff2;base64,d09GMgABAAAAAAFkAAoAAAAAA2wAAAEdAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmAANAoYNgE2AiQDBgsGAAQgBYJZBywbzgJgLgpsG5Y9NQ6Wg/XJT8aLqBq2nrslR/UWslBZaFTUOJ2cCkIj5Cv48o8Fs11ggQ5kMPB0QWBd/XW764LV3CseyARArU4EM2qzHQ+eJ/QkMc50QM/dhRYOZxZoZIGkJ0t25dsTXhTRraqP0oSSvuws1ze1pD80VPt/U/s5BMi4vWMAGjrWdcG6MkApYej/nx+jCIAGCkFhAlCAVOYyKwkQhM/lcY/Zr95H8P116EXQNRAL5D6i/xiruvQRCJoimqib9yYgFijYTFlgt2HdCnuc0J3FpKnUpWbErsuCzaJbdvuerPDMCZM+YtJUX8fBNMVzG/crlTanHKCXleNT18IBk1HwODNcDSxh69y4hjGiDeLYqUapkTZxwQA=) format('woff2');
}

/* 钢笔楷专属基准字:它的字形在 em 里画得偏小偏高(墨迹 -0.090..+0.652,常规中文字是
 * -0.12..+0.88),照通用的 1066/300 排会整体偏低约 1.1px。A+D 仍是 1366(盒高不变),
 * 只把 A-D 调小 0.156em 把基线提上来。数值与 /fonts/cjk/pen.css 的 override 一致 ——
 * 认 override 的浏览器走那条,不认的(Safari)走这条,两条算出同一个基线。
 * 重造:scratchpad/mkmetrics.py CunediMetricsPen 988 -378 <out>
 */
@font-face {
  font-family: 'CunediMetricsPen';
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
  src: url(data:font/woff2;base64,d09GMgABAAAAAAFwAAoAAAAAA4QAAAEnAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmAANAoYNgE2AiQDBgsGAAQgBYJ0Bywb6QJgngXuvr5FdMovHlFji8TD/w+3+/5/OHckJCR03d1SDMmUbPY1siXMmZDTtYq67Sk+lAdDtypiaKJDDvJwfe8mz5dh6UGa7Xi3G0QTepIYZxpY3EXeeRgEG1GiEXaenkyxKzYJDxTRrbJ2o4ZkOmFraatm+t++1ff/+cGAgPgtV2iCgooZVWBGaiKl4FuvJx/jEAAKSAQSDUACImM4hkQEEAhOLrHXuL+BWrvQuX7oIBYCVQFhgUGX+mMIZtFKOBQpQBFKOGJXgDABqtdvQoBqwXxCKYtoqNasj7RURQ4KTZsJijHbqNp2KGUfDX2erY/kLoVhacFznbfBHlNV6y2iwu+XWm1LgoFFFfA4NV0NmA62cAxO7ynI8YSkpa2IohClcdwAAAA=) format('woff2');
}

/* Manrope — sans body, 400/500/600/700/800 */
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/Manrope-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/Manrope-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/Manrope-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/Manrope-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/fonts/Manrope-800.woff2') format('woff2');
}

/* Newsreader — serif toggle + thinking text, regular + italic, 400/600 */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/Newsreader-400.woff2') format('woff2');
  /* 基线对齐:见 /fonts/cjk/ 的同款注释。106.6/30 = Manrope 的真实度量。 */
  ascent-override: 106.6%;
  descent-override: 30%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/Newsreader-400i.woff2') format('woff2');
  /* 基线对齐:见 /fonts/cjk/ 的同款注释。106.6/30 = Manrope 的真实度量。 */
  ascent-override: 106.6%;
  descent-override: 30%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/Newsreader-600.woff2') format('woff2');
  /* 基线对齐:见 /fonts/cjk/ 的同款注释。106.6/30 = Manrope 的真实度量。 */
  ascent-override: 106.6%;
  descent-override: 30%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/Newsreader-600i.woff2') format('woff2');
  /* 基线对齐:见 /fonts/cjk/ 的同款注释。106.6/30 = Manrope 的真实度量。 */
  ascent-override: 106.6%;
  descent-override: 30%;
  line-gap-override: 0%;
}

/* Cormorant Garamond — wordmark fallback only, 600 italic */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/CormorantGaramond-600i.woff2') format('woff2');
}

/* ---------- Body font stacks ----------
   --cn-font 由 boot.js 按 cunedi_look.font 内联写在 <html> 上(字体表也在
   boot.js 里,别在 CSS 里另抄一份栈)。这里的字面量只是「引擎没跑起来」时的兜底。
   --cn-fs 是正文字号倍率(0.85–1.45),正文类样式用 calc(基准px * var(--cn-fs,1))。 */

body {
  font-family: var(--cn-font, 'Manrope', -apple-system, 'PingFang SC', 'Hiragino Sans GB', sans-serif);
}

/* 只有一个字重的中文字库(站酷小薇/快乐体/马善政/志莽行书/钢笔楷)被选中时,
   boot.js 会打 html[data-font-solo]。关掉浏览器的「合成粗体」——它靠给字形
   描边来假装 bold,拉丁字母尚可,中文直接糊成一坨。关掉后加粗落回常规字重,
   强调靠颜色和上下文,比糊字好看得多。斜体合成留着(思考块的 Newsreader
   本来就有真斜体,不受影响)。 */
html[data-font-solo] {
  font-synthesis: style;            /* 老写法:只合成斜体,不合成字重 */
  font-synthesis-weight: none;      /* 新写法:Safari 16.4+ / Chrome 97+ */
}

/* ---------- Aurora wash (full-bleed fixed background layer) ---------- */

.cn-aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--bg);
  background-image: var(--aurora);
  filter: blur(6px);
  animation: auroraDrift 26s ease-in-out infinite;
  will-change: transform;
  pointer-events: none;
}

@keyframes auroraDrift {
  0%   { transform: scale(1.05) translate3d(0, 0, 0); }
  50%  { transform: scale(1.16) translate3d(-1.5%, 1.5%, 0); }
  100% { transform: scale(1.05) translate3d(0, 0, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .cn-aurora { animation: none; }
}

/* ---------- Frosted glass ---------- */

.cn-glass {
  background: var(--glass-surface);
  -webkit-backdrop-filter: blur(var(--glass-blur, 20px)) saturate(1.2);
  backdrop-filter: blur(var(--glass-blur, 20px)) saturate(1.2);
}

/* ---------- Glass card (glow hairline + drop shadow) ---------- */

.cn-card {
  background: var(--glass-surface);
  -webkit-backdrop-filter: blur(var(--glass-blur, 20px)) saturate(1.2);
  backdrop-filter: blur(var(--glass-blur, 20px)) saturate(1.2);
  border: 1px solid var(--glow-border);
  box-shadow: var(--glow-shadow), 0 8px 30px rgba(0, 0, 0, .34);
  border-radius: 20px;
}

/* ---------- Metallic hairline ring ----------
 * Host must be position:relative; the ring is a masked ::before so it frames
 * without blocking any backdrop-filter behind it. */

.cn-metal-ring {
  position: relative;
}
.cn-metal-ring::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 1.5px;
  background: var(--metal-grad);
  border-radius: inherit;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* ---------- Small generic pieces ---------- */

.cn-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--text-mute);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.cn-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ── 全站壁纸(cunedi_home_bg,boot.js 置 data-wall + --cn-wall)──
 * 观感与主页完全一致:清晰原图(壁纸替代晕染,禁掉晕染的 blur/漂移动画,
 * 否则壁纸会跟着糊跟着晃)+ 官方 --chat-scrim 压字渐变。
 * 页面自带背景系统(chat 壁纸/音乐封面氛围/玄学壁纸)层级在其上,自动优先。 */
html[data-wall] .cn-aurora {
  filter: none;
  animation: none;
  background-image: none;
}
html[data-wall] .cn-aurora::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--chat-scrim), var(--cn-wall);
  background-size: cover;
  background-position: center;
}
