:root {
  --bg: #FAFAF8;
  --bg-card: #F2F0EB;
  --text: #1A1A18;
  --text-muted: #6B6862;
  --text-faint: #A09D96;
  --accent: #26f7d2;        /* pirate / navy 高亮色 */
  --line: #E2DED6;
  --serif: 'Libre Baskerville', 'Baskerville', Georgia, serif;
  --sans: 'Futura', 'Futura PT', 'Trebuchet MS', sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --nav-glass: rgba(255, 255, 255, 0.28);
  --nav-glass-end: rgba(255, 255, 255, 0.12);
  --nav-highlight: rgba(255, 255, 255, 0.5);
  --title-color: #2A2A28;
}

[data-theme="dark"] {
  --bg: #16161A;
  --bg-card: #1E1E22;
  --text: #E8E6E1;
  --text-muted: #9B9890;
  --text-faint: #6B6862;
  --line: #2A2A2E;
  --accent: #fddd09;        /* 暗色模式下高亮色自动切换为金色 */
  --nav-glass: rgba(30, 30, 34, 0.35);
  --nav-glass-end: rgba(22, 22, 26, 0.18);
  --nav-highlight: rgba(255, 255, 255, 0.08);
  --title-color: #E8E6E1;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  line-break: strict;   /* CJK 避头尾：逗号/句号/叹号等标点不置行首（浏览器原生支持时生效，JS 兜底见 main.js） */
}

a { color: inherit; text-decoration: none; }

/* ===== 导航 ===== */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 24px 48px;
  transition: all 0.4s var(--ease);
}

.nav.scrolled {
  background: linear-gradient(
    to bottom,
    var(--nav-glass),
    var(--nav-glass-end)
  );
  backdrop-filter: blur(40px) saturate(240%) brightness(1.08);
  -webkit-backdrop-filter: blur(40px) saturate(240%) brightness(1.08);
  border-bottom: 1px solid var(--nav-highlight);
  box-shadow:
    inset 0 1px 0 var(--nav-highlight),
    0 6px 24px rgba(0, 0, 0, 0.05);
  padding: 16px 48px;
}

.nav-left { display: none; }

.nav-back {
  font-size: 18px;
  font-weight: 400;
  color: var(--text-muted);
  margin-right: auto;
  transition: color 0.3s var(--ease);
}

.nav-back:hover { color: var(--text); }

.nav-links {
  display: flex;
  gap: 40px;
}

.nav-links a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.3s var(--ease);
  position: relative;
}

.nav-links a:hover, .nav-links a.active { color: var(--text); }

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -4px; left: 0;
  width: 0; height: 1px;
  background: var(--text);
  transition: width 0.3s var(--ease);
}

.nav-links a:hover::after, .nav-links a.active::after { width: 100%; }

.nav-menu {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
  justify-self: end;
}

.nav-menu span {
  width: 22px; height: 1.5px;
  background: var(--text);
}

/* ===== Hero ===== */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 88px 48px 80px;
  max-width: 1400px;
  margin: 0 auto;
  gap: 48px;
  position: relative;
}

.hero-content {
  flex: 1;
  max-width: 900px;
}

.hero-title {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 6.5vw, 5.8rem);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: 0.005em;
  color: var(--title-color);
}

.type-cursor {
  display: inline-block;
  width: 0.06em;
  height: 0.95em;
  background: var(--text);
  margin-right: 0.04em;
  vertical-align: -0.08em;
  animation: blink 0.5s step-end infinite;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.type-text .tc { opacity: 0; }
.type-text .accent-word {
  font-style: italic;
  color: var(--accent);
}

/* 彩色光标 icon — 仅主页右下角，滚动后消失 */
.hero-cursor {
  position: fixed;
  bottom: 56px;
  right: 48px;
  z-index: 90;
  display: block;
  transition: transform 0.4s var(--ease), opacity 0.4s var(--ease);
  cursor: pointer;
}

.hero-cursor:hover { transform: translate(-2px, -2px); }

/* 主页滚动后隐藏 */
.hero-cursor.hidden { opacity: 0; pointer-events: none; }

/* 子页面不显示 icon */
.page-work .hero-cursor,
.page-about .hero-cursor,
.page-contact .hero-cursor { display: none; }

.cursor-icon-img {
  display: block;
  width: 80px;
  height: auto;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.15));
  animation: spin 6s linear infinite;
  transition: width 0.3s var(--ease);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ===== Section 通用 ===== */
section {
  padding: 80px 48px;
  max-width: 1400px;
  margin: 0 auto;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 40px;
  gap: 16px;
  flex-wrap: wrap;
}

.section-title {
  font-family: 'Jost', 'Futura', sans-serif;
  font-size: clamp(2rem, 4vw, 3.4rem);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: 0.005em;
  color: var(--title-color);
}

.section-link {
  font-size: 13px;
  color: var(--text-muted);
  transition: color 0.3s var(--ease);
}

.section-link:hover { color: var(--text); }

/* ===== 主页 1×4 近期项目 ===== */
.recent-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.recent-item {
  display: block;
  cursor: pointer;
}

.recent-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-card);
  border-radius: 16px;
  transition: transform 0.6s var(--ease);
  margin-bottom: 12px;
}

.recent-item:hover .recent-img { transform: scale(0.98); }

.recent-name {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--title-color);
}

/* ===== Work 页面：4列网格 ===== */
.page-header {
  padding: 140px 48px 48px;
  max-width: 1400px;
  margin: 0 auto;
}

.page-title {
  font-family: var(--sans);
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--accent);
}

.page-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 12px;
  white-space: pre-line;
}

.page-body {
  padding: 0 48px calc(80px + env(safe-area-inset-bottom));
  max-width: 1400px;
  margin: 0 auto;
}

.all-work-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px 24px;
}

.work-item {
  display: block;
  cursor: pointer;
}

.work-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-card);
  border-radius: 16px;
  transition: transform 0.6s var(--ease);
  margin-bottom: 12px;
}

.work-item:hover .work-img { transform: scale(0.98); }

.work-name {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--title-color);
  margin-bottom: 4px;
}

.work-meta {
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.5px;
}

/* ===== About 页面 ===== */
.about-columns {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 64px;
}

.about-columns.no-portrait {
  justify-content: center;
}

.about-text {
  flex: 1 1 55%;
  max-width: 720px;
}

.about-portrait {
  flex: 0 1 360px;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--line);
}

.about-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.about-intro {
  margin-bottom: 48px;
}

/* 中文自我介绍：思源宋体 */
.about-intro-cn {
  font-family: 'Noto Serif SC', 'Source Han Serif SC', 'Source Han Serif',
               'Songti SC', 'STSong', 'SimSun', serif;
  font-size: clamp(0.95rem, 1.22vw, 1.1rem);
  font-weight: 400;
  line-height: 1.92;
  letter-spacing: 0.03em;
  color: var(--title-color);
  text-align: justify;
  text-justify: inter-ideograph;
  text-align-last: left;
  hanging-punctuation: allow-end;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

.about-intro-cn p {
  margin-bottom: 20px;
  widows: 2;
  orphans: 2;
}
.about-intro-cn p:last-child { margin-bottom: 0; }

/* 英文自我介绍：Libre Baskerville */
.about-intro-en {
  font-family: var(--serif);
  font-size: clamp(0.92rem, 1.18vw, 1.06rem);
  font-weight: 400;
  line-height: 1.82;
  letter-spacing: 0.005em;
  color: var(--text-muted);
  text-align: justify;
  text-justify: inter-word;
  text-align-last: left;
  text-wrap: pretty;
  hyphens: auto;
  -webkit-hyphens: auto;
  word-break: normal;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

.about-intro-en p {
  margin-bottom: 16px;
  widows: 2;
  orphans: 2;
}
.about-intro-en p:last-child { margin-bottom: 0; }

.about-lead em, .about-body em { font-style: italic; color: var(--accent); }

.about-body {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 40px;
}

.about-skills { display: flex; flex-wrap: wrap; gap: 8px; }

.about-skills span {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--text-muted);
}

/* ===== Contact 页面 ===== */
.contact-content { text-align: center; padding: 40px 0; }

.contact-lead {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 2.8vw, 2rem);
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 48px;
}

.contact-email {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.5rem, 4vw, 3rem);
  font-weight: 400;
  letter-spacing: 0.005em;
  color: var(--accent);
  display: inline-block;
  position: relative;
  padding-bottom: 4px;
  transition: opacity 0.3s var(--ease);
}

.contact-email::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: var(--text);
  transform: scaleX(0.6);
  transform-origin: left;
  transition: all 0.4s var(--ease);
}

.contact-email:hover { opacity: 0.7; }
.contact-email:hover::after { transform: scaleX(1); background: var(--accent); }

.contact-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin-top: 64px;
  flex-wrap: wrap;
}

.contact-links a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.3s var(--ease);
}

.contact-links a:hover { color: var(--text); }

.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-faint); }

/* ===== 页脚 ===== */
.footer {
  border-top: 1px solid var(--line);
  padding: 32px 48px;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-faint);
  flex-wrap: wrap;
  gap: 8px;
}

/* ===== 滚动揭示 ===== */
[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

[data-reveal].revealed { opacity: 1; transform: translateY(0); }

/* ===== 主题切换按钮 ===== */
.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 100px;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.3s var(--ease);
  flex-shrink: 0;
  margin-left: 40px;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: absolute;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

/* 亮色模式：显示月亮（点击切到暗色） */
.theme-toggle .icon-sun { opacity: 0; transform: rotate(-90deg) scale(0.5); }
.theme-toggle .icon-moon { opacity: 1; transform: rotate(0) scale(1); }

/* 暗色模式：显示太阳（点击切到亮色） */
[data-theme="dark"] .theme-toggle .icon-sun { opacity: 1; transform: rotate(0) scale(1); }
[data-theme="dark"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(90deg) scale(0.5); }

/* About 页面 Contact 区块标题 */
.contact-section { padding-top: 20px; }
.contact-heading {
  font-family: 'Jost', 'Futura', sans-serif;
  font-weight: 200;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: 32px;
}

/* About 页 Contact 引导语：配合标题缩小字号（仅 About 页，不影响独立 contact 页） */
.contact-section .contact-lead {
  font-size: clamp(1.1rem, 2vw, 1.5rem);
}

/* About 页 Contact 邮箱：仅缩小字号，其余（衬线斜体/强调色/悬停下划线）保持原样（仅作用于 About 页，不影响独立 contact 页） */
.contact-section .contact-email {
  font-size: clamp(1.1rem, 2.4vw, 1.7rem);
}

/* 暗色模式下的微调 */
[data-theme="dark"] .nav-menu span { background: var(--text); }
[data-theme="dark"] .recent-img,
[data-theme="dark"] .work-img { background-color: var(--bg-card); }

/* ===== 项目详情页 ===== */
.project-header {
  padding: 140px 48px 48px;
  max-width: 1400px;
  margin: 0 auto;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.project-tag {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--accent);
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid var(--accent);
  border-radius: 100px;
}

.project-title {
  font-family: var(--sans);
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--title-color);
  line-height: 1.1;
}

.project-meta {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 12px;
  letter-spacing: 0.02em;
}

.project-body {
  padding: 0 48px 80px;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.project-description {
  font-family: 'Libre Baskerville', 'Noto Sans SC', 'Source Han Sans SC', 'Source Han Sans', sans-serif;
  font-size: clamp(0.95rem, 1.15vw, 1.08rem);
  font-weight: 400;
  line-height: 1.85;
  letter-spacing: 0.005em;
  color: var(--text-muted);
  max-width: none;
  text-align: justify;
  text-align-last: left;
}

/* 画廊 */
.project-gallery {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 56px;
}

.gallery-figure {
  width: 100%;
  margin: 0;
}

.gallery-figure img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 2px;
  background: transparent;
}

/* 视频 */
.project-videos {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 56px;
}
.video-embed, .video-file {
  width: 100%;
  border-radius: 2px;
  overflow: hidden;
  background: transparent;
}
.video-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
}
.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-file video {
  width: 100%;
  height: auto;
  display: block;
}

/* 返回链接 */
.back-link {
  display: inline-block;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.3s var(--ease);
  margin-top: 16px;
}

.back-link:hover { color: var(--text); }

/* 未找到 */
.project-not-found {
  padding: 200px 48px 80px;
  max-width: 1400px;
  margin: 0 auto;
  text-align: center;
}

.project-not-found p {
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* 子页面不显示 hero cursor */
.page-project .hero-cursor { display: none; }

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .nav, .nav.scrolled { padding: 16px 24px; }
  .nav-links { display: none; gap: 0; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 56px; left: 0; right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    padding: 24px;
    gap: 20px;
  }
  .nav-menu { display: flex; margin-left: 18px; }
  .theme-toggle { width: 32px; height: 32px; margin-left: 4px; }

  .hero {
    flex-direction: column;
    align-items: flex-start;
    padding: 100px 24px 60px;
    gap: 40px;
  }

  .hero-cursor { bottom: 32px; right: 24px; }
  .cursor-icon-img { width: 56px; }

  section { padding: 60px 24px; }

  .recent-grid { grid-template-columns: 1fr 1fr; }
  .all-work-grid { grid-template-columns: 1fr 1fr; }

  .page-header { padding: 100px 24px 32px; }
  .page-body { padding: 0 24px calc(100px + env(safe-area-inset-bottom)); }

  .about-columns {
    flex-direction: column-reverse;
    gap: 40px;
  }
  .about-portrait {
    flex: 0 0 auto;
    max-width: 320px;
    margin: 0 auto;
  }
  .about-text {
    min-width: 0;
    width: 100%;
  }

  /* 移动端 About 文字排版优化 */
  .about-intro {
    margin-bottom: 36px;
  }
  .about-intro-cn {
    font-size: 1rem;
    line-height: 2.1;
    letter-spacing: 0.02em;
  }
  .about-intro-cn p {
    margin-bottom: 28px;
  }
  .about-intro-en {
    font-size: 0.98rem;
    line-height: 2.0;
  }
  .about-intro-en p {
    margin-bottom: 24px;
  }

  .project-header { padding: 100px 24px 32px; }
  .project-body { padding: 0 24px 60px; }
  .project-gallery { gap: 16px; }

  .footer-inner { flex-direction: column; text-align: center; }
}

@media (max-width: 600px) {
  .recent-grid, .all-work-grid { grid-template-columns: 1fr; }

  /* 窄屏（手机）：中文/英文自我介绍切回左对齐，避免两端对齐把字距/词距拉松 */
  .about-intro-cn,
  .about-intro-en,
  .project-description {
    text-align: left;
    text-align-last: left;
    word-break: normal;
  }
}
