/* ============================================================
   成分复杂 · 个人主页 v2 —— 纸面志 × 印章红
   中性纸底 / 墨黑字 / 卡塞尔红点睛
   ============================================================ */

:root {
  /* 色彩 tokens（中性纸底，质感靠纹理与排版，非暖色） */
  --paper: #F5F5F3;
  --paper-deep: #ECECEA;
  --card: #FBFBFA;
  --ink: #201E1B;            /* 墨黑 */
  --ink-soft: #55524B;       /* 次级 */
  --ink-faint: #756F66;      /* 弱化（≥4.5:1，正文级小字可用） */
  --accent: #B0212A;         /* 卡塞尔红/印章红 */
  --accent-deep: #8F1A22;
  --line: #DDDCD7;           /* 发丝分隔线 */
  --surface-hover: rgba(255,255,255,.55);
  --wm-ink: rgba(33,31,26,.07);        /* 水印描边 */
  --hero-glow: rgba(176,33,42,.05);    /* 顶部红晕 */

  /* 排版 */
  --font-display: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* 间距 8pt */
  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 40px; --s5: 64px; --s6: 96px;

  --maxw: 820px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; color-scheme: light; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-color: var(--paper);
  /* 纸面颗粒（内联 SVG 噪点，极低透明度） */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.32'/%3E%3C/svg%3E");
  background-size: 140px 140px;
}
/* 噪点只做质感，不压文字 */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(1200px 500px at 50% -8%, var(--hero-glow), transparent 70%);
}

/* ---------- 可访问性 ---------- */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 10px 16px;
}
.skip-link:focus { left: 0; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---------- 头部 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  border-bottom: 1px solid var(--line);
}
.nav {
  max-width: var(--maxw); margin: 0 auto; padding: 14px var(--s3);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
}
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-seal {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  background: var(--accent); color: var(--paper);
  font-family: var(--font-display); font-size: 15px; font-weight: 700;
  border-radius: 3px;
}
.brand-name { font-family: var(--font-display); font-weight: 700; letter-spacing: .06em; }
.nav-links { display: flex; gap: var(--s3); font-size: 15px; }
.nav-links a { color: var(--ink-soft); position: relative; }
.nav-links a:hover { color: var(--ink); }
.nav-links a::after {
  content: ""; position: absolute; left: 0; bottom: -3px; height: 1px; width: 0;
  background: var(--accent); transition: width .25s var(--ease);
}
.nav-links a:hover::after { width: 100%; }

/* ---------- 明暗切换按钮 ---------- */
.theme-toggle {
  width: 36px; height: 36px;
  position: relative;
  display: inline-grid; place-items: center;
  padding: 0; margin-left: 4px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent; color: var(--ink-soft);
  cursor: pointer;
  transition: color .25s var(--ease), border-color .25s var(--ease), background .25s var(--ease);
}
.theme-toggle:hover {
  color: var(--accent); border-color: var(--accent);
  background: var(--surface-hover);
}
.theme-toggle .ic {
  position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px;
  transition: opacity .4s ease, transform .6s var(--ease);
}
.ic-sun  { opacity: 0; transform: rotate(-120deg) scale(.35); }
.ic-moon { opacity: 1; transform: rotate(0) scale(1); }
:root[data-theme="dark"] .ic-sun { opacity: 1; transform: rotate(0) scale(1); }
:root[data-theme="dark"] .ic-moon { opacity: 0; transform: rotate(130deg) scale(.35); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ic-sun { opacity: 1; transform: rotate(0) scale(1); }
  :root:not([data-theme="light"]) .ic-moon { opacity: 0; transform: rotate(130deg) scale(.35); }
}

/* ---------- Hero ---------- */
main, .site-footer { position: relative; z-index: 1; }

.hero {
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--s3);
  scroll-margin-top: 70px;
  position: relative;
}
.hero-inner {
  text-align: center;
  padding: var(--s5) 0 var(--s4);
  border-bottom: 1px solid var(--line);
  position: relative;
}
/* 巨大水印字 */
.hero-watermark {
  position: absolute; right: -18px; top: 10px;
  font-family: var(--font-display);
  font-size: clamp(120px, 22vw, 230px);
  line-height: 1; color: transparent;
  -webkit-text-stroke: 1px var(--wm-ink);
  user-select: none; pointer-events: none;
  z-index: 0;
}
.hero-inner > * { position: relative; z-index: 1; }

.hero-seal { margin: 0 0 var(--s3); }
.hero-avatar {
  width: 96px; height: 96px; border-radius: 50%;
  object-fit: cover; object-position: top center;
  display: inline-block;
  /* 印章双圈 */
  border: 2px solid var(--accent);
  outline: 1px solid var(--accent);
  outline-offset: 5px;
  box-shadow: 0 0 0 6px var(--paper), 0 0 0 7px var(--line);
}
.hero-seal-caption {
  margin-top: 14px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .42em;
  color: var(--ink-faint); text-transform: uppercase;
}

.kicker {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--accent);
  margin: 0 0 var(--s3);
}
.hero-name {
  font-family: var(--font-display);
  font-size: clamp(54px, 12vw, 96px);
  font-weight: 700; line-height: 1.02; letter-spacing: .02em;
  margin: 0 0 14px;
}
.hero-alias {
  font-size: 18px; color: var(--ink-soft); letter-spacing: .3em;
  margin: 0 0 var(--s4);
}
.hero-intro {
  max-width: 30em; margin: 0 auto var(--s4);
  font-size: 17px; line-height: 2;
}
.hero-meta {
  list-style: none; padding: 0; margin: 0 0 var(--s4);
  display: flex; justify-content: center; flex-wrap: wrap; gap: var(--s2) var(--s5);
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); letter-spacing: .08em;
}
.meta-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; }
.hero-rule {
  width: 44px; height: 2px; margin: 0 auto; background: var(--accent);
  position: relative;
}
.hero-rule::after {
  content: ""; position: absolute; left: 50%; top: -2px; width: 6px; height: 6px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--paper); border: 1px solid var(--accent);
}

/* ---------- 通用 section ---------- */
.section { max-width: var(--maxw); margin: 0 auto; padding: var(--s5) var(--s3) 0; scroll-margin-top: 70px; }
.section-head { margin-bottom: var(--s4); }
.section-index {
  font-family: var(--font-mono); font-size: 12px; color: var(--accent);
  letter-spacing: .2em; margin: 0 0 6px;
}
.section-title {
  font-family: var(--font-display); font-size: clamp(28px, 4.6vw, 40px);
  font-weight: 700; margin: 0 0 8px; letter-spacing: .02em;
}
.section-sub { color: var(--ink-faint); font-size: 15px; margin: 0; }

/* ---------- 作品：编号目录 ---------- */
.work-list { list-style: none; margin: 0; padding: 0; counter-reset: work; }
.work { border-top: 1px solid var(--line); }
.work:last-child { border-bottom: 1px solid var(--line); }
.work-link {
  display: grid;
  grid-template-columns: 56px 1fr auto 30px;
  align-items: center; gap: var(--s2) var(--s3);
  padding: var(--s3) 6px;
  transition: background .25s var(--ease), padding-left .25s var(--ease);
}
.work:hover { background: var(--surface-hover); padding-left: 14px; }
.work-num {
  font-family: var(--font-mono); font-size: 13px; color: var(--accent);
}
.work-body { display: flex; flex-direction: column; min-width: 0; }
.work-en {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .3em;
  color: var(--ink-faint); text-transform: uppercase; margin-bottom: 2px;
}
.work-name { font-family: var(--font-display); font-size: 22px; font-weight: 700; margin-bottom: 2px; }
.work-desc { color: var(--ink-soft); font-size: 14.5px; line-height: 1.7; }
.work-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.work-tags i {
  font-style: normal; font-size: 11.5px; color: var(--ink-soft);
  border: 1px solid var(--line); padding: 2px 9px; border-radius: 99px;
  background: var(--card);
}
.work-arrow { font-size: 18px; color: var(--ink-faint); transition: color .2s, transform .25s var(--ease); }
.work-link:hover .work-arrow { color: var(--accent); transform: translate(2px,-2px); }

/* ---------- 小工具 ---------- */
.tool-list { list-style: none; margin: 0; padding: 0; }
.tool-list li {
  display: flex; align-items: baseline; gap: var(--s3);
  padding: 14px 4px; border-bottom: 1px dashed var(--line);
}
.tool-list a { font-size: 16.5px; font-weight: 600; }
.tool-list a::before { content: "·"; color: var(--accent); margin-right: 8px; }
.tool-list a:hover { color: var(--accent); }
.tool-desc { margin-left: auto; color: var(--ink-faint); font-size: 13.5px; white-space: nowrap; }

/* ---------- 链接 ---------- */
.social-list { list-style: none; margin: 0; padding: 0; }
.social-list li { border-top: 1px solid var(--line); }
.social-list li:last-child { border-bottom: 1px solid var(--line); }
.social-list a {
  display: flex; align-items: baseline; gap: var(--s3);
  padding: var(--s2) 6px;
  transition: background .25s var(--ease), padding-left .25s var(--ease);
}
.social-list a:hover { background: var(--surface-hover); padding-left: 14px; }
.social-name { font-family: var(--font-display); font-size: 21px; font-weight: 700; }
.social-name::before { content: "↳ "; color: var(--accent); font-size: 17px; }
.social-desc { color: var(--ink-faint); font-size: 14px; }
.social-list .work-arrow { margin-left: auto; }
.social-list a:hover .work-arrow { color: var(--accent); transform: translate(2px,-2px); }

/* ---------- Footer ---------- */
.site-footer {
  max-width: var(--maxw); margin: var(--s5) auto 0; padding: var(--s4) var(--s3) var(--s5);
  text-align: center;
}
.footer-line { font-family: var(--font-display); font-size: 18px; margin: 0 0 6px; }
.footer-sub { font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; color: var(--ink-faint); margin: 0; }
.footer-domain { font-family: var(--font-mono); font-size: 11px; letter-spacing: .18em; color: var(--ink-faint); opacity: .7; margin: 14px 0 0; }
/* 页脚印章落款 */
.footer-seal {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; margin-bottom: 14px;
  border: 1.5px solid var(--accent); border-radius: 50%;
  color: var(--accent);
  font-family: var(--font-display); font-size: 15px; font-weight: 700; line-height: 1;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

/* 丝滑切换：仅切换瞬间挂 class，避免常驻 transition 干扰 */
html.theme-switching, html.theme-switching *,
html.theme-switching *::before, html.theme-switching *::after {
  transition: background-color .5s ease, color .5s ease, border-color .5s ease,
              box-shadow .5s ease, opacity .5s ease, fill .5s ease !important;
}

/* ---------- 入场（尊重 reduced-motion）---------- */
.js-fade { opacity: 0; transform: translateY(14px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.js-fade.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js-fade { opacity: 1; transform: none; transition: none; }
  .work, .social-list a, .nav-links a::after, .theme-toggle, .theme-toggle .ic,
  html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after {
    transition: none !important;
  }
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .work-link { grid-template-columns: 40px 1fr 24px; }
  .work-tags { display: none; }
  .nav-links { gap: var(--s2); font-size: 14px; }
  .tool-list li { flex-direction: column; gap: 2px; }
  .tool-desc { margin-left: 24px; white-space: normal; }
  .hero-watermark { right: 0; }
}

/* ---------- 墨本模式：手动按钮优先，否则跟随系统 ---------- */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #191814;
  --paper-deep: #21201B;
  --card: #24221C;
  --ink: #EAE4D7;
  --ink-soft: #BFB7A6;
  --ink-faint: #9A9182;
  --accent: #E0564D;
  --accent-deep: #B83C35;
  --line: #34322A;
  --surface-hover: rgba(255,255,255,.05);
  --wm-ink: rgba(234,228,215,.10);
  --hero-glow: rgba(224,86,77,.09);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #191814;
    --paper-deep: #21201B;
    --card: #24221C;
    --ink: #EAE4D7;
    --ink-soft: #BFB7A6;
    --ink-faint: #9A9182;
    --accent: #E0564D;
    --accent-deep: #B83C35;
    --line: #34322A;
    --surface-hover: rgba(255,255,255,.05);
    --wm-ink: rgba(234,228,215,.10);
    --hero-glow: rgba(224,86,77,.09);
  }
}

/* ---------- 未上线条目标注（线上版） ---------- */
.proto-name, .tool-name { font-weight: 600; }
.proto-desc, .tool-desc { color: var(--ink-faint); }


/* ---------- 导航头像 ---------- */
.brand {
  display: inline-flex; align-items: center; gap: 10px;
}
.brand-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  border: 1px solid var(--line);
}

/* ---------- 原型 · 未上线区 ---------- */
.proto-head {
  margin: var(--s5) 0 var(--s2);
  display: flex; align-items: baseline; gap: var(--s2);
  font-family: var(--font-mono); font-size: 13px;
  color: var(--ink-faint); letter-spacing: 0.08em;
}
.proto-head::before { content: ""; flex: 1; height: 1px; background: var(--line); }
.proto-head::after { content: "LAB · ONLINE"; }

.proto-list { list-style: none; margin: 0; padding: 0; }
.proto-list li {
  display: flex; align-items: baseline; gap: var(--s2);
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 16px;
}
.proto-list li:last-child { border-bottom: none; }
.proto-list a {
  color: var(--ink);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, color .2s ease;
}
.proto-list a:hover { color: var(--accent); border-color: var(--accent); }
.proto-desc { color: var(--ink-soft); font-size: 14px; }
@media (max-width: 640px) {
  .proto-list li { flex-direction: column; gap: 2px; }
  .proto-desc { font-size: 13px; }
}
