@import url('https://fonts.googleapis.com/css2?family=Karla:wght@300;400;500;600;700&family=Playfair+Display+SC:wght@400;700&display=swap');

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

:root {
  --paper: #fafaf8;
  --gray: #4a4a4a;
  --ink: #1a1a1a;
  --rail: 264px;
  --strip: 46px;
  --body: "Karla", "Hiragino Sans GB", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --disp: "Playfair Display SC", "Songti SC", Georgia, "Times New Roman", serif;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  padding: var(--strip) 0 0 var(--rail);
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(0deg, rgba(26, 26, 26, 0.028) 0 1px, transparent 1px 27px),
    repeating-linear-gradient(90deg, rgba(26, 26, 26, 0.02) 0 1px, transparent 1px 27px);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.68;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0.45;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.3'/%3E%3C/svg%3E");
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

/* 顶部细条 */
.strip {
  position: fixed;
  top: 0;
  left: var(--rail);
  right: 0;
  z-index: 30;
  height: var(--strip);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  overflow: hidden;
  border-bottom: 2px solid var(--ink);
  background: rgba(250, 250, 248, 0.94);
}

.strip-mark {
  display: inline-block;
  color: var(--gray);
  font-size: 16px;
  transform: rotate(14deg);
}

.strip-line {
  margin: 0;
  font-size: 16px;
  color: var(--gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 左侧竖排栏 */
.rail {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  width: var(--rail);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 18px;
  border-right: 2px solid var(--ink);
  background: rgba(250, 250, 248, 0.96);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  overflow-y: auto;
}

.brand {
  font-family: var(--disp);
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: 0.07em;
  color: var(--ink);
  text-decoration: none;
  padding-bottom: 8px;
  border-bottom: 3px double var(--ink);
  transform: rotate(-0.8deg);
}

.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 18px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.menu p {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 0;
}

.menu a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.2;
  text-decoration: none;
}

.menu a:nth-child(2n) { transform: rotate(-0.9deg); }
.menu a:nth-child(3n) { transform: rotate(0.8deg); }
.menu a:nth-child(5n) { transform: rotate(-0.4deg); }

.menu a:hover,
.menu a:focus-visible {
  background: var(--ink);
  color: var(--paper);
  transform: rotate(0);
}

/* 首屏堆叠 */
.hero {
  position: relative;
  overflow: hidden;
  max-width: 960px;
  margin: 0 auto;
  padding: 26px 22px 0;
  min-height: 45vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-big {
  position: absolute;
  left: 4px;
  top: 34%;
  margin: 0;
  z-index: 0;
  font-family: var(--disp);
  font-weight: 700;
  font-size: clamp(70px, 15vw, 180px);
  line-height: 0.88;
  letter-spacing: -0.02em;
  color: rgba(26, 26, 26, 0.085);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  will-change: transform;
}

.hero-copy {
  position: relative;
  z-index: 2;
  padding-top: 4px;
}

.hero h1 {
  font-family: var(--disp);
  font-weight: 700;
  font-size: clamp(28px, 4.6vw, 50px);
  line-height: 1.16;
  letter-spacing: -0.005em;
  margin: 0 0 14px;
  max-width: 24ch;
}

.hero-lead {
  max-width: 44ch;
  margin: 0 0 18px;
  color: var(--gray);
  font-size: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-fig {
  position: relative;
  z-index: 1;
  margin: 14px 0 0;
  min-height: 150px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: #efefec;
  transform: rotate(0.5deg);
  box-shadow: 7px 7px 0 rgba(26, 26, 26, 0.1);
}

.hero-fig img {
  display: block;
  width: 100%;
  height: auto;
  filter: grayscale(0.18) contrast(1.06);
}

/* 主体：侧栏在左 */
.shell {
  display: grid;
  grid-template-columns: 198px minmax(0, 1fr);
  gap: 34px;
  max-width: 1010px;
  margin: 44px auto 0;
  padding: 0 22px 64px;
  align-items: start;
}

.toc {
  position: sticky;
  top: calc(var(--strip) + 18px);
  padding: 14px 14px 16px;
  border: 2px dashed rgba(26, 26, 26, 0.42);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 5px 5px 0 rgba(26, 26, 26, 0.07);
  transform: rotate(-0.7deg);
}

.toc-title {
  margin: 0;
  font-family: var(--disp);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.toc-list {
  list-style: none;
  counter-reset: toc;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 10px 0 0;
  padding: 0;
}

.toc-list li { counter-increment: toc; }

.toc-list a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 40px;
  padding: 8px 4px;
  border-bottom: 1px dotted rgba(26, 26, 26, 0.28);
  color: var(--gray);
  font-size: 16px;
  line-height: 1.3;
  text-decoration: none;
}

.toc-list a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: var(--disp);
  font-size: 16px;
  color: rgba(26, 26, 26, 0.45);
}

.toc-list a:hover { color: var(--ink); }

/* 正文 */
.paper { min-width: 0; }

.paper section {
  padding: 30px 0 34px;
  border-top: 2px solid rgba(26, 26, 26, 0.85);
  scroll-margin-top: calc(var(--strip) + 16px);
}

.paper section:first-child {
  border-top: 0;
  padding-top: 4px;
}

.paper h2 {
  position: relative;
  margin: 0 0 16px;
  font-family: var(--disp);
  font-weight: 700;
  font-size: clamp(24px, 3.2vw, 34px);
  line-height: 1.22;
}

.paper h2 span {
  position: relative;
  display: inline-block;
}

.paper h2 span::after {
  content: "";
  position: absolute;
  left: -3%;
  right: -3%;
  bottom: 4px;
  height: 9px;
  z-index: -1;
  background: rgba(74, 74, 74, 0.17);
  transform: skewX(-14deg) rotate(-0.6deg);
}

.paper h3 {
  margin: 26px 0 10px;
  font-family: var(--disp);
  font-weight: 700;
  font-size: 21px;
  line-height: 1.32;
}

.paper h3 span {
  display: inline-block;
  padding-bottom: 2px;
  border-bottom: 2px solid rgba(26, 26, 26, 0.5);
}

.paper p {
  margin: 0 0 1.05em;
  color: #2f2f2f;
}

.paper a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-decoration-color: rgba(26, 26, 26, 0.5);
  text-underline-offset: 3px;
}

.paper a:hover { background: rgba(26, 26, 26, 0.08); }

.paper ul,
.paper ol {
  margin: 0 0 1.1em;
  padding-left: 1.25em;
}

.paper li { margin: 0 0 0.45em; }

.paper img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 18px 0;
  border: 2px solid var(--ink);
  border-radius: 4px;
  filter: grayscale(0.15);
}

.paper blockquote {
  margin: 22px 0;
  padding: 12px 18px;
  border-left: 4px solid var(--ink);
  background: rgba(26, 26, 26, 0.04);
  color: var(--gray);
  transform: rotate(-0.25deg);
}

.paper blockquote p:last-child { margin: 0; }

.paper table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  margin: 0 0 1.2em;
  border-collapse: collapse;
  font-size: 16px;
}

.paper th,
.paper td {
  padding: 8px 12px;
  border: 1.5px solid rgba(26, 26, 26, 0.5);
  text-align: left;
  white-space: nowrap;
}

.paper th { background: rgba(26, 26, 26, 0.07); }

.paper code {
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(26, 26, 26, 0.08);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 15px;
}

.paper pre {
  overflow-x: auto;
  padding: 14px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: rgba(26, 26, 26, 0.05);
}

.paper pre code { padding: 0; background: none; }

.paper figure { margin: 18px 0; }

.paper hr {
  margin: 28px 0;
  border: 0;
  border-top: 2px dashed rgba(26, 26, 26, 0.35);
}

/* 页脚 */
.foot {
  max-width: 1010px;
  margin: 0 auto;
  padding: 22px 22px 40px;
  border-top: 2px solid var(--ink);
  text-align: center;
}

.foot p {
  margin: 0 0 8px;
  font-family: var(--disp);
  font-size: 18px;
  letter-spacing: 0.22em;
}

.foot small {
  display: block;
  color: var(--gray);
  font-size: 16px;
  letter-spacing: 0.04em;
}

/* 进场 */
html.js .paper section {
  opacity: 0;
  transform: translateY(14px);
}

html.js .paper section.in {
  opacity: 1;
  transform: none;
  transition: opacity 0.32s ease, transform 0.34s ease;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  html.js .paper section {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* 移动端 */
@media (max-width: 860px) {
  body { padding: 66px 0 0 0; }

  .strip { display: none; }

  .rail {
    right: 0;
    bottom: auto;
    width: 100%;
    min-height: 62px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    overflow: visible;
    border-right: 0;
    border-bottom: 2px solid var(--ink);
  }

  .brand {
    padding-bottom: 0;
    border-bottom: 0;
    font-size: 22px;
    transform: none;
  }

  .menu-btn { display: inline-flex; }

  .menu {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    max-height: 72vh;
    overflow-y: auto;
    padding: 12px 14px 18px;
    border-bottom: 2px solid var(--ink);
    background: var(--paper);
  }

  .rail.nav-open .menu { display: block; }

  .menu a { background: rgba(255, 255, 255, 0.55); }

  .hero {
    min-height: 0;
    padding: 20px 16px 0;
  }

  .hero-big { font-size: 21vw; top: 30%; }

  .hero h1 { max-width: 20ch; }

  .shell {
    grid-template-columns: 1fr;
    gap: 22px;
    margin-top: 26px;
    padding: 0 16px 44px;
  }

  .toc {
    position: static;
    transform: none;
  }

  .paper section { scroll-margin-top: 84px; }

  .foot { padding: 20px 16px 34px; }
}

button[aria-expanded]{min-width:44px;min-height:44px}
