/*
 * Copyright (c) 2026 poboll · 花生片 Peanup 设计令牌
 * SPDX-License-Identifier: LicenseRef-Poboll-NonCommercial
 *
 * 两套纸：
 *   1. 站点纸（首页 / 页头 / 页脚）——与产品网站 pean.caiths.com 的 base.css 完全同一组令牌：
 *      纯白纸底 #fff、近黑墨 #141414、冷灰细线 #d9d9d3，强调色就是墨色本身。
 *   2. 工作纸（工作台 / 设备工具）——参考薯饼实验室 m8mi6m.top 的麻色特种纸：
 *      浅灰桌面 #ececec 上铺一张 #f7f7f2 的特种纸，卡片是半透明白，细线用黑色低透明度。
 *      不是黄的、不是米色的，是平整的冷白；纸感靠柔和阴影和细线，不靠纹理。
 * 六色颜料与相纸色不随主题变化。本文件必须是每个页面的第一张样式表，其余样式只引用这里的变量。
 */

@font-face {
  font-family: "Huiwen Mincho";
  src: url("../fonts/huiwen-mincho.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
}

:root {
  /* ---- 站点纸（= pean.caiths.com base.css） ---- */
  --paper: #fff;
  --surface: #fff;
  --surface-soft: #f8f8f8;
  --surface-hover: #f4f4f4;
  --surface-raised: #fff;
  --chrome-bg: rgba(255, 255, 255, .92);
  --menu-bg: rgba(255, 255, 255, .98);
  --hardware-back: #ecece8;

  /* 墨 */
  --ink: #141414;
  --ink-secondary: #6d6d67;
  --ink-faint: #a3a3a3;
  --muted: #6d6d67;
  --line: #d9d9d3;
  --ghost-line: #e8e8e8;
  --hairline: #d9d9d3;
  --hairline-strong: #c4c4bd;
  --shadow: rgba(20, 20, 20, .1);
  --shadow-ink: rgba(20, 20, 20, .16);

  /* 强调色就是墨：黑底白字按钮、黑色选中态，与产品网站一致 */
  --accent: #141414;
  --accent-hover: #2b2b2b;
  --accent-soft: rgba(20, 20, 20, .06);
  --accent-shadow: rgba(20, 20, 20, .18);
  --on-accent: #fff;
  --accent-ink: #fff;

  /* 语义色（蓝 / 红 / 黄 / 绿 与产品网站同值） */
  --blue: #4779bc;
  --red: #d64e3e;
  --yellow: #e6b930;
  --green: #6d9666;
  --connected: #18a739;
  --connected-ink: #157a2f;
  --information: #4779bc;
  --information-ink: #365f97;
  --warning: #e6b930;
  --warning-ink: #806200;
  --yellow-ink: #806200;
  --failure: #d64e3e;

  /* ---- 工作纸（= m8mi6m.top 麻色特种纸） ---- */
  --desk: #ececec;
  --sheet: #f7f7f7;
  --sheet-white: #fcfcfc;
  --sheet-glass: rgba(255, 255, 255, .78);
  --sheet-line: rgba(0, 0, 0, .14);
  --sheet-line-strong: rgba(0, 0, 0, .24);
  --sheet-ink: #171714;
  --sheet-ink-soft: #555550;
  --sheet-shadow: 0 22px 70px rgba(15, 23, 42, .08);
  --sheet-shadow-soft: 0 12px 36px rgba(0, 0, 0, .06);
  --sheet-fibre: none;

  /* 相纸色（不随主题变） */
  --photo-paper: #f9f9f9;
  --photo-ink: #141412;
  --photo-ink-secondary: #525957;
  --photo-hairline: #d6d8d8;
  --photo-accent: #ab382e;

  /* 六色物理颜料（不随主题变） */
  --pigment-black: #141412;
  --pigment-white: #f9f9f9;
  --pigment-yellow: #d4ad31;
  --pigment-red: #ab382e;
  --pigment-blue: #334f8f;
  --pigment-green: #4f7c52;

  /* 几何 */
  --radius: 6px;
  --radius-lg: 10px;
  --radius-pill: 999px;
  --pad: clamp(24px, 5vw, 76px);
  --max: 1440px;
  --header-h: 64px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --transition-theme: 320ms;
  --paper-offset: 2px 2px 0 var(--hairline);

  /* 字体：正文系统栈；大标题宋体（两个参考站都用宋体做展示字） */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Segoe UI", sans-serif;
  --font-display: "Songti SC", "STSong", serif;
  --font-mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;

  /* 旧变量别名（保留给尚在引用的脚本 / 内联样式） */
  --peanup-paper-ivory: var(--sheet);
  --paper-bright: var(--surface);
  --ink-soft: var(--ink-secondary);
  --quiet: var(--ink-secondary);
  --serif: var(--font-display);
  --sans: var(--font-ui);
  --mono: var(--font-mono);

  color-scheme: light;
}

/* 暗色主题：= pean.caiths.com base.css 的 data-theme="dark" */
html[data-theme="dark"] {
  --paper: #10110f;
  --surface: #131412;
  --surface-soft: #171816;
  --surface-hover: #262724;
  --surface-raised: #1d1e1b;
  --chrome-bg: rgba(16, 17, 15, .9);
  --menu-bg: rgba(25, 26, 23, .98);
  --hardware-back: #292a26;

  --ink: #f2f2ed;
  --ink-secondary: #a6a7a0;
  --ink-faint: #6e6f69;
  --muted: #a6a7a0;
  --line: #30312d;
  --ghost-line: #2a2b27;
  --hairline: #30312d;
  --hairline-strong: #3d3e39;
  --shadow: rgba(0, 0, 0, .5);
  --shadow-ink: rgba(0, 0, 0, .6);

  --accent: #f2f2ed;
  --accent-hover: #ffffff;
  --accent-soft: rgba(242, 242, 237, .08);
  --accent-shadow: rgba(0, 0, 0, .4);
  --on-accent: #10110f;
  --accent-ink: #10110f;

  --blue: #7c9fc9;
  --red: #ce6d62;
  --yellow: #c8a64d;
  --green: #82a07b;
  --connected: #4fc46a;
  --connected-ink: #7fd792;
  --information: #7c9fc9;
  --information-ink: #9db8d9;
  --warning: #c8a64d;
  --warning-ink: #e0c26a;
  --yellow-ink: #e0c26a;
  --failure: #ce6d62;

  --desk: #0c0c0b;
  --sheet: #161615;
  --sheet-white: #1c1c1a;
  --sheet-glass: rgba(28, 28, 26, .82);
  --sheet-line: rgba(255, 255, 255, .12);
  --sheet-line-strong: rgba(255, 255, 255, .22);
  --sheet-ink: #f2f2ed;
  --sheet-ink-soft: #b1b1aa;
  --sheet-shadow: 0 22px 70px rgba(0, 0, 0, .45);
  --sheet-shadow-soft: 0 12px 36px rgba(0, 0, 0, .35);
  --sheet-fibre: none;

  color-scheme: dark;
}

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

html {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

html.theme-switching, html.theme-switching * {
  transition: background-color var(--transition-theme) ease, color var(--transition-theme) ease, border-color var(--transition-theme) ease, box-shadow var(--transition-theme) ease !important;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.16;
  margin: 0;
  text-wrap: balance;
}

h3, h4, h5, h6 {
  font-family: var(--font-ui);
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
}

p { margin: 0; }
small { font-size: 12px; }
b, strong { font-weight: 600; }
img, svg, canvas, video { display: block; max-width: 100%; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { padding: 0; }
ol, ul { margin: 0; padding: 0; }
code, kbd { font-family: var(--font-mono); font-size: .92em; }
[hidden] { display: none !important; }

button, input, select, textarea {
  font-family: var(--font-ui);
  font-size: inherit;
  color: inherit;
  letter-spacing: 0;
}
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

::selection { color: #fff; background: var(--blue); }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

/* ---- 六色装饰线（2px，六色 flex） ---- */
.color-strip,
.site-header-strip {
  display: flex;
  height: 2px;
  overflow: hidden;
  border-radius: 1px;
}
.color-strip i, .site-header-strip i { flex: 1 1 0; display: block; }
.color-strip i:nth-child(1), .site-header-strip i:nth-child(1) { background: var(--pigment-black); }
.color-strip i:nth-child(2), .site-header-strip i:nth-child(2) { background: var(--pigment-white); }
.color-strip i:nth-child(3), .site-header-strip i:nth-child(3) { background: var(--pigment-yellow); }
.color-strip i:nth-child(4), .site-header-strip i:nth-child(4) { background: var(--pigment-red); }
.color-strip i:nth-child(5), .site-header-strip i:nth-child(5) { background: var(--pigment-blue); }
.color-strip i:nth-child(6), .site-header-strip i:nth-child(6) { background: var(--pigment-green); }

/* ---- 等宽小标签 ---- */
.mono-label,
.eyebrow,
.section-kicker,
.preview-kicker {
  margin: 0;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  line-height: 1.4;
}

/* ---- 主题切换按钮（与产品网站同一只圆钮） ---- */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--chrome-bg);
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(20, 20, 18, .06);
  transition: border-color .25s ease, background-color .3s ease, transform .35s var(--ease);
}
.theme-toggle:hover { border-color: var(--muted); transform: rotate(8deg); }
.theme-toggle:active { transform: scale(.96); }
.theme-toggle .theme-toggle-glyph { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
html[data-theme="light"] .theme-toggle-moon { display: block; }
html[data-theme="light"] .theme-toggle-sun { display: none; }
html[data-theme="dark"] .theme-toggle-moon { display: none; }
html[data-theme="dark"] .theme-toggle-sun { display: block; }
html[data-theme="dark"] .theme-toggle { box-shadow: 0 5px 16px rgba(0, 0, 0, .28); }

/* ---- 麻色特种纸纤维（只给工作纸用，极低对比） ---- */
.paper-texture { position: relative; }
.paper-texture::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background-image: var(--sheet-fibre);
}

/* ---- 渐入（story.js 给 [data-reveal] 加 .is-visible；无 JS 时直接可见） ---- */
html.js [data-reveal] { opacity: 0; transform: translateY(8px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
html.js [data-reveal].is-visible { opacity: 1; transform: none; }

@media (max-width: 680px) {
  :root { --pad: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  html.js [data-reveal] { opacity: 1; transform: none; }
}
