@import url('https://fonts.googleapis.com/css2?family=Lora:wght@400;500;600;700&family=Raleway:wght@300;400;500;600;700&display=swap');

/* ===== 基础变量 ===== */
:root {
  --c-bg: #fafaf8;
  --c-mid: #4a4a4a;
  --c-ink: #1a1a1a;
  --c-border: #c8c4bc;
  --c-accent: #2e2e2e;
  --c-paper: #f0ede6;
  --c-line: #d4d0c8;
  --ff-serif: 'Lora', 'Georgia', serif;
  --ff-sans: 'Raleway', 'Helvetica Neue', sans-serif;
  --nav-h: 64px;
  --sticky-h: 40px;
  --aside-w: 220px;
  --content-max: 820px;
  --radius-sm: 4px;
  --shadow-sketch: 2px 3px 0 rgba(26,26,26,0.12);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  font-size: 16px;
  background: var(--c-bg);
  color: var(--c-ink);
}
body {
  font-family: var(--ff-sans);
  font-size: 1rem;
  line-height: 1.7;
  background: var(--c-bg);
  color: var(--c-ink);
  overflow-x: hidden;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ===== 纸张肌理背景 ===== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 28px,
      rgba(26,26,26,0.03) 28px,
      rgba(26,26,26,0.03) 29px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 40px,
      rgba(26,26,26,0.015) 40px,
      rgba(26,26,26,0.015) 41px
    );
  mix-blend-mode: multiply;
}

/* ===== page-wrapper ===== */
.page-wrapper {
  position: relative;
  min-height: 100vh;
}

/* ===== ASIDE 导航 ===== */
.site-aside {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--nav-h);
  background: var(--c-bg);
  border-bottom: 2px solid var(--c-ink);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1.5rem;
}

/* 手绘感边框底线 */
.site-aside::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    var(--c-ink) 0px,
    var(--c-ink) 6px,
    transparent 6px,
    transparent 9px
  );
  opacity: 0.35;
}

.aside-brand {
  flex-shrink: 0;
}

.brand-logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 2px solid var(--c-ink);
  border-radius: var(--radius-sm);
  transform: rotate(-1.5deg);
  transition: none;
  background: var(--c-paper);
  box-shadow: var(--shadow-sketch);
}

.brand-logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.brand-logo-text {
  font-family: var(--ff-serif);
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-ink);
  line-height: 1;
}

.aside-nav {
  flex: 1;
}

.aside-nav > ul {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.aside-nav > ul > li {
  display: flex;
}

.nav-link {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 0.85rem;
  font-family: var(--ff-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--c-ink);
  letter-spacing: 0.02em;
  border-radius: var(--radius-sm);
  transition: none;
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 0.85rem;
  right: 0.85rem;
  height: 1.5px;
  background: var(--c-ink);
  transform: scaleX(0);
  transform-origin: left;
}

.nav-link:hover::after {
  transform: scaleX(1);
}

.nav-link:hover {
  background: var(--c-paper);
}

.nav-cta-item {
  margin-left: auto;
}

.nav-cta-btn {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 1.2rem;
  font-family: var(--ff-sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--c-bg);
  background: var(--c-ink);
  border-radius: var(--radius-sm);
  border: 2px solid var(--c-ink);
  transform: rotate(0.5deg);
  box-shadow: 3px 3px 0 var(--c-mid);
  letter-spacing: 0.04em;
}

.nav-cta-btn:hover {
  background: var(--c-mid);
  box-shadow: 1px 1px 0 var(--c-mid);
  transform: rotate(0.5deg) translate(1px, 1px);
}

/* ===== 粘性锚点条 ===== */
.sticky-anchor-bar {
  position: sticky;
  top: var(--nav-h);
  z-index: 90;
  background: var(--c-paper);
  border-bottom: 1.5px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 1.25rem;
  height: var(--sticky-h);
}

.sticky-anchor-bar::-webkit-scrollbar { display: none; }

.sticky-anchor-bar::before {
  content: '—';
  font-family: var(--ff-serif);
  font-size: 0.75rem;
  color: var(--c-border);
  margin-right: 0.75rem;
  flex-shrink: 0;
}

.sticky-link {
  display: flex;
  align-items: center;
  height: var(--sticky-h);
  padding: 0 0.75rem;
  font-size: 0.78rem;
  font-family: var(--ff-sans);
  font-weight: 500;
  color: var(--c-mid);
  white-space: nowrap;
  border-right: 1px dashed var(--c-line);
  flex-shrink: 0;
}

.sticky-link:last-child { border-right: none; }

.sticky-link:hover {
  color: var(--c-ink);
  background: rgba(26,26,26,0.05);
}

/* ===== MAIN ===== */
.site-main {
  padding-top: var(--nav-h);
}

/* article 共用 scroll-margin */
article[id] {
  scroll-margin-top: calc(var(--nav-h) + var(--sticky-h) + 8px);
}

/* ===== HERO ===== */
.hero-section {
  width: 100%;
  min-height: 70vh;
  position: relative;
  overflow: hidden;
  background: var(--c-ink);
}

.hero-figure {
  position: relative;
  width: 100%;
  min-height: 70vh;
  display: flex;
  align-items: flex-end;
  margin: 0;
}

.hero-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.45;
  filter: grayscale(30%) contrast(1.1);
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    160deg,
    rgba(26,26,26,0.65) 0%,
    rgba(26,26,26,0.3) 60%,
    rgba(26,26,26,0.7) 100%
  );
}

/* 超大背景文字 */
.hero-bg-text {
  position: absolute;
  right: -0.05em;
  bottom: -0.15em;
  font-family: var(--ff-serif);
  font-size: clamp(8rem, 22vw, 18rem);
  font-weight: 700;
  color: transparent;
  -webkit-text-stroke: 1.5px rgba(250,250,248,0.12);
  line-height: 1;
  user-select: none;
  pointer-events: none;
  letter-spacing: -0.04em;
}

.hero-caption {
  position: relative;
  z-index: 2;
  padding: 3.5rem 2.5rem 3.5rem clamp(1.25rem, 6vw, 4rem);
  max-width: 640px;
  text-align: left;
}

.hero-eyebrow {
  display: inline-block;
  font-family: var(--ff-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: rgba(250,250,248,0.65);
  text-transform: uppercase;
  margin-bottom: 1rem;
  border-left: 3px solid rgba(250,250,248,0.4);
  padding-left: 0.75rem;
}

.hero-h1 {
  font-family: var(--ff-serif);
  font-size: clamp(2.25rem, 6vw, 4.5rem);
  font-weight: 700;
  color: var(--c-bg);
  line-height: 1.15;
  margin-bottom: 1.25rem;
  letter-spacing: -0.01em;
}

.hero-sub {
  font-family: var(--ff-sans);
  font-size: 1.05rem;
  font-weight: 400;
  color: rgba(250,250,248,0.8);
  line-height: 1.7;
  margin-bottom: 2rem;
  max-width: 480px;
}

.hero-cta-btn {
  display: inline-flex;
  align-items: center;
  height: 48px;
  padding: 0 2rem;
  font-family: var(--ff-sans);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--c-ink);
  background: var(--c-bg);
  border: 2px solid var(--c-bg);
  border-radius: var(--radius-sm);
  transform: rotate(-0.8deg);
  box-shadow: 4px 4px 0 rgba(250,250,248,0.25);
}

.hero-cta-btn:hover {
  background: var(--c-paper);
  transform: rotate(-0.8deg) translate(2px, 2px);
  box-shadow: 2px 2px 0 rgba(250,250,248,0.25);
}

/* ===== 内容区 布局 ===== */
.content-section {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  max-width: calc(var(--content-max) + var(--aside-w) + 3rem);
  margin: 3rem auto 0;
  padding: 0 1.5rem 4rem;
}

/* ===== 左侧侧边栏 aside ===== */
.content-aside {
  flex-shrink: 0;
  width: var(--aside-w);
  position: sticky;
  top: calc(var(--nav-h) + var(--sticky-h) + 16px);
  align-self: flex-start;
}

.aside-toc {
  background: var(--c-paper);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 1.25rem 1rem;
  box-shadow: var(--shadow-sketch);
  transform: rotate(0.4deg);
  position: relative;
}

.aside-toc::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 6px;
  right: -6px;
  bottom: -6px;
  border: 1.5px dashed var(--c-border);
  border-radius: var(--radius-sm);
  z-index: -1;
}

.aside-toc-title {
  font-family: var(--ff-serif);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-ink);
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1.5px solid var(--c-border);
  letter-spacing: 0.05em;
}

.aside-toc-title > span {
  display: inline-block;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.toc-link {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--c-mid);
  padding: 0.35rem 0.5rem;
  border-radius: 2px;
  line-height: 1.4;
  border-left: 2px solid transparent;
}

.toc-link:hover {
  color: var(--c-ink);
  border-left-color: var(--c-ink);
  background: rgba(26,26,26,0.05);
}

/* ===== 正文区 ===== */
.content-body {
  flex: 1;
  min-width: 0;
  max-width: var(--content-max);
}

/* page.content 内部样式 */
.content-body h2 {
  font-family: var(--ff-serif);
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 700;
  color: var(--c-ink);
  margin: 2.5rem 0 1rem;
  line-height: 1.25;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--c-ink);
  position: relative;
}

.content-body h2 > span {
  display: inline-block;
}

.content-body h3 {
  font-family: var(--ff-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--c-ink);
  margin: 1.75rem 0 0.75rem;
}

.content-body h3 > span {
  display: inline-block;
}

.content-body p {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--c-ink);
  margin-bottom: 1.1rem;
}

.content-body ul,
.content-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1.1rem;
}

.content-body li {
  margin-bottom: 0.4rem;
  line-height: 1.7;
}

.content-body a {
  color: var(--c-ink);
  border-bottom: 1.5px solid var(--c-border);
  padding-bottom: 1px;
}

.content-body a:hover {
  border-bottom-color: var(--c-ink);
}

.content-body blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: var(--c-paper);
  border-left: 4px solid var(--c-ink);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--c-mid);
}

.content-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.content-body th,
.content-body td {
  border: 1px solid var(--c-border);
  padding: 0.6rem 0.85rem;
  text-align: left;
}

.content-body th {
  background: var(--c-paper);
  font-weight: 600;
}

/* content-body 内的 article (page.content 七栏) */
.content-body article {
  margin-bottom: 3.5rem;
  padding-top: 1rem;
  position: relative;
}

.content-body article::before {
  content: '';
  display: block;
  height: 3px;
  background: repeating-linear-gradient(
    90deg,
    var(--c-ink) 0px,
    var(--c-ink) 8px,
    transparent 8px,
    transparent 14px
  );
  margin-bottom: 1.5rem;
  opacity: 0.25;
}

/* ===== 卡片（如正文内有） ===== */
.content-body .card {
  background: var(--c-paper);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sketch);
  border-bottom: 3px solid var(--c-ink);
  position: relative;
  transform: rotate(0.2deg);
}

/* ===== FOOTER ===== */
.site-footer {
  background: var(--c-ink);
  color: var(--c-bg);
  padding: 3rem 1.5rem 1.5rem;
  position: relative;
}

.site-footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: repeating-linear-gradient(
    90deg,
    var(--c-bg) 0px,
    var(--c-bg) 10px,
    var(--c-ink) 10px,
    var(--c-ink) 16px
  );
  opacity: 0.3;
}

.footer-inner {
  max-width: calc(var(--content-max) + var(--aside-w) + 3rem);
  margin: 0 auto 2rem;
  display: flex;
  gap: 2.5rem;
  flex-wrap: wrap;
}

.footer-inner dl {
  flex: 1;
  min-width: 160px;
}

.footer-inner dt {
  font-family: var(--ff-serif);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--c-bg);
  margin-bottom: 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px dashed rgba(250,250,248,0.25);
  letter-spacing: 0.05em;
}

.footer-inner dd {
  font-size: 0.85rem;
  color: rgba(250,250,248,0.7);
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.footer-inner dd a {
  color: rgba(250,250,248,0.7);
  display: block;
  padding: 0.2rem 0;
}

.footer-inner dd a:hover {
  color: var(--c-bg);
}

.footer-bottom {
  max-width: calc(var(--content-max) + var(--aside-w) + 3rem);
  margin: 0 auto;
  border-top: 1px solid rgba(250,250,248,0.15);
  padding-top: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.footer-copy,
.footer-note {
  font-size: 0.78rem;
  color: rgba(250,250,248,0.45);
  font-family: var(--ff-sans);
}

/* ===== 滚动显现动效 ===== */
@media (prefers-reduced-motion: no-preference) {
  .content-body article {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.55s cubic-bezier(.22,.68,0,1.2), transform 0.55s cubic-bezier(.22,.68,0,1.2);
  }
  .content-body article.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
  /* stagger */
  .content-body article:nth-child(1) { transition-delay: 0s; }
  .content-body article:nth-child(2) { transition-delay: 0.08s; }
  .content-body article:nth-child(3) { transition-delay: 0.16s; }
  .content-body article:nth-child(4) { transition-delay: 0.24s; }
  .content-body article:nth-child(5) { transition-delay: 0.32s; }
  .content-body article:nth-child(6) { transition-delay: 0.40s; }
  .content-body article:nth-child(7) { transition-delay: 0.48s; }

  .hero-caption > * {
    opacity: 0;
    transform: translateX(-18px);
    animation: heroReveal 0.6s cubic-bezier(.22,.68,0,1.2) forwards;
  }
  .hero-eyebrow { animation-delay: 0.1s; }
  .hero-h1     { animation-delay: 0.22s; }
  .hero-sub    { animation-delay: 0.36s; }
  .hero-cta-btn{ animation-delay: 0.48s; }

  @keyframes heroReveal {
    to { opacity: 1; transform: translateX(0); }
  }

  /* 粘性栏目条吸顶时高亮 */
  .sticky-link.is-active {
    color: var(--c-ink);
    background: rgba(26,26,26,0.08);
    border-bottom: 2px solid var(--c-ink);
  }
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  :root {
    --aside-w: 180px;
  }
  .site-aside {
    padding: 0 1rem;
    gap: 0.75rem;
  }
  .nav-link {
    padding: 0 0.6rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 700px) {
  :root {
    --nav-h: 56px;
  }

  .site-aside {
    padding: 0 1rem;
  }

  .aside-nav > ul {
    display: none;
  }

  .sticky-anchor-bar {
    padding: 0 0.75rem;
  }

  .content-section {
    flex-direction: column;
    padding: 0 1rem 3rem;
    gap: 1.5rem;
    margin-top: 2rem;
  }

  .content-aside {
    width: 100%;
    position: static;
  }

  .aside-toc {
    transform: none;
  }

  .toc-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .toc-link {
    border-left: none;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.6rem;
    font-size: 0.78rem;
  }

  .hero-caption {
    padding: 2.5rem 1.25rem;
  }

  .hero-bg-text {
    font-size: 6rem;
    opacity: 0.5;
  }

  .hero-h1 {
    font-size: 2rem;
  }

  .footer-inner {
    flex-direction: column;
    gap: 1.5rem;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 0.4rem;
  }

  .nav-cta-btn {
    font-size: 0.78rem;
    padding: 0 0.85rem;
  }
}

@media (max-width: 420px) {
  .hero-section {
    min-height: 60vh;
  }
  .hero-figure {
    min-height: 60vh;
  }
  .hero-h1 {
    font-size: 1.75rem;
  }
  .content-body h2 {
    font-size: 1.25rem;
  }
}
