/* =========================================================
   个人主页样式
   想改颜色，只需要动下面这一段变量（--背景色、--文字色、--强调色）
   ========================================================= */
:root {
  --bg: #fdfcfa;
  --surface: #ffffff;
  --text: #1c1b19;
  --text-soft: #6b6864;
  --line: #e7e3dd;
  --accent: #1f6f5c;
  --accent-soft: #e6f1ed;
  --radius: 14px;
  --content: 720px;
  --watermark-opacity: 0.22;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1b1e23;
  --text: #ecebe8;
  --text-soft: #9b988f;
  --line: #2c3037;
  --accent: #5fd0ad;
  --accent-soft: #1d2b28;
  --watermark-opacity: 0.14;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #14161a;
    --surface: #1b1e23;
    --text: #ecebe8;
    --text-soft: #9b988f;
    --line: #2c3037;
    --accent: #5fd0ad;
    --accent-soft: #1d2b28;
    --watermark-opacity: 0.14;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

p { margin: 0 0 1.1em; }

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 16px;
  top: 16px;
  z-index: 10;
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 8px;
}

/* ---------------- 背景水印 ---------------- */
.watermark {
  position: fixed;
  inset: 0;
  z-index: -1;                 /* 在页面底色之上、正文之下 */
  pointer-events: none;        /* 不影响任何点击和选中 */
  background-image: url("watermark.webp"); /* 相对于本 CSS 文件所在的 assets/ 目录 */
  background-repeat: no-repeat;
  background-position: right bottom;
  background-size: auto 100vh; /* 高度 = 可视高度，宽度按原比例 */
  opacity: var(--watermark-opacity);
  mix-blend-mode: multiply;    /* 图片是白底无透明通道，用正片叠底让白底融进底色 */
}

html[data-theme="dark"] .watermark {
  mix-blend-mode: screen;
  filter: invert(1) hue-rotate(180deg);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .watermark {
    mix-blend-mode: screen;
    filter: invert(1) hue-rotate(180deg);
  }
}

/* ---------------- 顶部导航 ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: calc(var(--content) + 48px);
  margin: 0 auto;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
}

.brand {
  font-weight: 650;
  color: var(--text);
  letter-spacing: .01em;
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 18px;
  margin-left: auto;
  font-size: 15px;
}

.nav a { color: var(--text-soft); }
.nav a:hover { color: var(--accent); text-decoration: none; }

.nav .is-active {
  color: var(--text);
  font-weight: 600;
}

/* ---------------- 中英文切换 ---------------- */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  line-height: 1;
}

.lang-switch > * {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--text-soft);
  white-space: nowrap;
}

.lang-switch .is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.lang-switch a:hover { color: var(--accent); text-decoration: none; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 15px;
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease;
}
.theme-toggle:hover { transform: rotate(20deg); border-color: var(--accent); }

/* ---------------- 内容容器 ---------------- */
main {
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 24px 40px;
}

/* ---------------- 首屏 ---------------- */
.hero {
  padding: 56px 0 64px;
  border-bottom: 1px solid var(--line);
}

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  margin-bottom: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 44px;
  font-weight: 600;
  overflow: hidden;
}

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

h1 {
  margin: 0 0 18px;
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.accent { color: var(--accent); }

.lede {
  max-width: 34em;
  font-size: 19px;
  color: var(--text-soft);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.btn {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: transform .18s ease, border-color .18s ease, background-color .18s ease;
}

.btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  text-decoration: none;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

html[data-theme="dark"] .btn.primary { color: #0d1512; }

/* ---------------- 通用小节 ---------------- */
.section {
  padding: 52px 0 8px;
  border-bottom: 1px solid var(--line);
}

.section:last-of-type { border-bottom: none; }

h2 {
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-soft);
}

h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.muted { color: var(--text-soft); font-size: 15px; }

/* ---------------- 项目卡片 ---------------- */
.cards {
  list-style: none;
  margin: 0 0 44px;
  padding: 0;
  display: grid;
  gap: 14px;
}

.card {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, .5);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.card p {
  margin: 0 0 10px;
  color: var(--text-soft);
  font-size: 16px;
}

.card-links { font-size: 15px; }

.card-links .dot {
  margin: 0 6px;
  color: var(--text-soft);
}

.paper-title { font-size: 17px; line-height: 1.5; }
.paper-title a { color: var(--text); }
.paper-title a:hover { color: var(--accent); }

/* 带主图的卡片（论文、项目）：标题占整行，文字在左，主图在右 */
.card-media {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  grid-template-areas:
    "head head"
    "text figure";
  gap: 20px 26px;
  align-items: start;
}

.card-media .card-head { grid-area: head; margin-bottom: 0; }
.card-media .card-text { grid-area: text; }
.card-media .card-figure { grid-area: figure; }

.card-figure { margin: 0; }

.card-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.card-figure figcaption {
  margin-top: 8px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

@media (max-width: 720px) {
  .card-media {
    grid-template-columns: 1fr;
    grid-template-areas: "head" "text" "figure";
    gap: 18px;
  }
}

.authors {
  font-size: 15px !important;
  color: var(--text-soft);
}

.tag {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  white-space: nowrap;
}

html[data-theme="dark"] .btn.primary { color: #0d1512; }

/* 跟随系统深色、但用户还没手动切过主题的情况 */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .btn.primary { color: #0d1512; }
}

/* ---------------- 列表 ---------------- */
.list {
  list-style: none;
  margin: 0 0 40px;
  padding: 0;
}

.list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
}

.list li:last-child { border-bottom: none; }

.list .meta,
.list .label {
  margin-left: auto;
  color: var(--text-soft);
  font-size: 14px;
  white-space: nowrap;
}

.list .label { margin-left: 0; min-width: 68px; }
.list .label + a { margin-left: auto; }

/* ---------------- 页脚 ---------------- */
.site-footer {
  max-width: var(--content);
  margin: 0 auto;
  padding: 28px 24px 48px;
  color: var(--text-soft);
  font-size: 14px;
}

.site-footer p { margin: 0; }

/* ---------------- 博客文章页 ---------------- */
.post { padding: 56px 0 24px; }

.post-date {
  margin: 0 0 36px;
  color: var(--text-soft);
  font-size: 15px;
}

.post-back {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 15px;
}

/* 正文里的小标题不用页面上那种小节标签样式 */
.post-body h2 {
  margin: 1.8em 0 .6em;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--text);
}

.post-body h3 {
  margin: 1.5em 0 .5em;
  font-size: 18px;
  font-weight: 650;
}

.post-body ul,
.post-body ol { margin: 0 0 1.2em; padding-left: 1.4em; }
.post-body li { margin-bottom: .4em; }

.post-body code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  font-size: .92em;
}

.post-body blockquote {
  margin: 0 0 1.2em;
  padding-left: 16px;
  border-left: 3px solid var(--line);
  color: var(--text-soft);
}

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* ---------------- 滚动出现动画 ---------------- */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .6s ease, transform .6s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .btn:hover, .card:hover { transform: none; }
}

/* ---------------- 手机适配 ---------------- */
@media (max-width: 640px) {
  /* 手机屏幕窄，水印和正文几乎重叠，压淡一点保证可读性 */
  :root { --watermark-opacity: 0.12; }

  body { font-size: 16px; }

  .site-header {
    flex-wrap: wrap;          /* 站名 + 语言 + 主题一行，导航单独一行 */
    row-gap: 6px;
    padding: 10px 18px 8px;
    gap: 12px;
  }

  .nav {
    order: 3;                 /* 导航排到第二行 */
    width: 100%;
    margin-left: 0;
    gap: 12px;
    font-size: 14px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; }

  .lang-switch { margin-left: auto; }

  .avatar {
    width: 92px;
    height: 92px;
    font-size: 36px;
  }

  main, .site-footer { padding-left: 18px; padding-right: 18px; }
  .hero { padding: 36px 0 44px; }
  .section { padding: 40px 0 8px; }
}
