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

:root {
  --violet: #6514ff;
  --magenta: #bf00ff;
  --ink: #1c1726;
  --paper: #f4efff;
  --white: #ffffff;
  --radius: 18px;
  --head: "Newsreader", "Songti SC", "Noto Serif SC", Georgia, serif;
  --body: "Roboto", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.7;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(101, 20, 255, 0.16) 1.5px, transparent 1.5px);
  background-size: 26px 26px;
  animation: drift 48s linear infinite;
}

@keyframes drift {
  from { background-position: 0 0; }
  to { background-position: 260px 260px; }
}

hr { border: 0; }

a { color: var(--violet); }

:focus-visible { outline: 3px solid var(--magenta); outline-offset: 2px; }

.skip {
  position: fixed;
  left: 10px;
  top: -80px;
  z-index: 60;
  background: var(--white);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 16px;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip:focus { top: 10px; }

/* ---------- 左侧固定竖排导航 ---------- */
.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: 300px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 28px 22px 24px;
  background: var(--ink);
  border-right: 4px solid var(--violet);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--white);
  text-decoration: none;
  font-family: var(--head);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.25;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  background: var(--violet);
  object-fit: cover;
}

.rail ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rail a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  color: #ece6ff;
  text-decoration: none;
  font-size: 16px;
  line-height: 1.35;
  border: 2px solid transparent;
  border-radius: 12px;
  transition: background 0.24s ease, color 0.24s ease, border-color 0.24s ease;
}

.rail a:hover,
.rail a:focus-visible {
  background: var(--violet);
  color: var(--white);
  border-color: var(--white);
}

.n-idx {
  font-family: var(--head);
  font-size: 13px;
  min-width: 20px;
  opacity: 0.7;
}

/* ---------- 主区 ---------- */
main {
  position: relative;
  z-index: 1;
  margin-left: 300px;
  max-width: 1240px;
  padding: 28px 40px 96px;
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(120px, 200px) minmax(0, 1fr);
  align-items: center;
  gap: 48px;
  min-height: 70vh;
  padding: 56px 48px;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: linear-gradient(130deg, var(--violet), var(--magenta) 78%);
  color: var(--white);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.42) 2px, transparent 2px);
  background-size: 22px 22px;
  opacity: 0.5;
  animation: drift 30s linear infinite;
}

.hero > * { position: relative; z-index: 1; }

.hero-copy { text-align: right; }

.hero h1 {
  margin: 0 0 20px;
  font-family: var(--head);
  font-weight: 700;
  font-size: clamp(34px, 5.4vw, 66px);
  line-height: 1.07;
  letter-spacing: -0.01em;
}

.hero-desc {
  margin: 0 0 0 auto;
  max-width: 46ch;
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.7;
  color: #f2e9ff;
}

.hero-art {
  margin: 0;
  display: flex;
  justify-content: center;
}

.hero-art svg {
  width: 100%;
  max-width: 200px;
  height: auto;
  display: block;
}

/* ---------- 侧栏 + 正文 ---------- */
.stage {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
  gap: 48px;
  margin-top: 64px;
}

.toc {
  position: sticky;
  top: 32px;
  padding: 22px 18px;
  background: var(--ink);
  color: var(--white);
  border: 3px solid var(--violet);
  border-radius: var(--radius);
}

.toc h2 {
  margin: 0 0 12px;
  font-family: var(--head);
  font-size: 24px;
  line-height: 1.2;
}

.toc hr {
  width: 48px;
  margin: 0 0 16px;
  border-top: 4px solid var(--magenta);
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  counter-reset: toc;
}

.toc li { counter-increment: toc; }

.toc a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 40px;
  padding: 8px 4px;
  color: #ece5ff;
  text-decoration: none;
  font-size: 16px;
  line-height: 1.4;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  transition: color 0.22s ease;
}

.toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: var(--head);
  font-size: 12px;
  color: var(--magenta);
}

.toc a:hover,
.toc a:focus-visible { color: var(--white); }

.post {
  counter-reset: sec;
  min-width: 0;
  max-width: 70ch;
  overflow-wrap: break-word;
}

.post div {
  counter-increment: sec;
  margin: 0 0 48px;
  padding: 32px 30px;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  scroll-margin-top: 32px;
}

.post div::before {
  content: counter(sec, decimal-leading-zero);
  display: block;
  margin-bottom: 14px;
  font-family: var(--head);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--violet);
}

.post h2 {
  margin: 0 0 12px;
  font-family: var(--head);
  font-weight: 700;
  font-size: clamp(26px, 3.2vw, 38px);
  line-height: 1.16;
}

.post h2 + hr {
  width: 56px;
  margin: 0 0 20px;
  border-top: 4px solid var(--magenta);
}

.post h3 {
  margin: 28px 0 10px;
  font-family: var(--head);
  font-size: 23px;
  line-height: 1.3;
}

.post p,
.post li {
  font-size: 17px;
  line-height: 1.8;
}

.post p { margin: 0 0 16px; }

.post ul,
.post ol { padding-left: 24px; margin: 0 0 18px; }

.post li { margin-bottom: 8px; }

.post a {
  color: var(--violet);
  text-underline-offset: 3px;
}

.post a:hover { color: var(--magenta); }

.post hr {
  margin: 26px 0;
  border-top: 2px solid var(--ink);
}

.post figure { margin: 24px 0; }

.post img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

.post blockquote {
  margin: 24px 0;
  padding: 14px 20px;
  background: var(--paper);
  border-left: 6px solid var(--magenta);
  border-radius: 0 12px 12px 0;
}

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

.post table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 16px;
}

.post th,
.post td {
  border: 2px solid var(--ink);
  padding: 8px 10px;
  text-align: left;
}

.post th { background: var(--paper); }

.post details {
  margin: 20px 0;
  padding: 12px 16px;
  border: 2px solid var(--ink);
  border-radius: 12px;
}

.post summary {
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  display: flex;
  align-items: center;
}

.post code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 15px;
  background: var(--paper);
  padding: 1px 5px;
  border-radius: 6px;
}

/* ---------- 页脚 ---------- */
.foot {
  position: relative;
  z-index: 1;
  margin: 96px 0 0 300px;
  padding: 48px 40px 32px;
  background: var(--ink);
  color: var(--white);
  border-top: 4px solid var(--magenta);
}

.foot-brand {
  margin: 0 0 32px;
  font-family: var(--head);
  font-size: clamp(40px, 7vw, 92px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
}

.foot-cols {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px;
  padding-top: 28px;
  border-top: 2px solid rgba(255, 255, 255, 0.2);
}

.foot dl { margin: 0; }

.foot dt {
  margin-bottom: 8px;
  font-family: var(--head);
  font-size: 18px;
  color: var(--magenta);
}

.foot dd {
  margin: 0;
  font-size: 16px;
  color: #ded6f5;
}

.foot dd ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.foot dd a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: #ded6f5;
  text-decoration: none;
  transition: color 0.22s ease;
}

.foot dd a:hover,
.foot dd a:focus-visible { color: var(--white); }

.foot-copy {
  margin: 28px 0 0;
  text-align: center;
  font-size: 16px;
  color: #b6abd4;
}

/* ---------- 回到顶部 ---------- */
.to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  min-height: 44px;
  padding: 10px 16px;
  font-family: var(--body);
  font-size: 16px;
  color: var(--white);
  background: var(--ink);
  border: 2px solid var(--violet);
  border-radius: 12px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease, background 0.24s ease;
}

.to-top.on { opacity: 1; pointer-events: auto; }

.to-top:hover { background: var(--violet); }

/* ---------- 进场 ---------- */
html.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

html.js .reveal.in {
  opacity: 1;
  transform: none;
}

/* ---------- 窄屏 ---------- */
@media (max-width: 1200px) {
  .stage { grid-template-columns: 1fr; gap: 32px; }
  .toc { position: static; }
  .toc ol { flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .toc a {
    border-bottom: 0;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 10px;
    padding: 8px 10px;
  }
}

@media (max-width: 960px) {
  .rail {
    position: sticky;
    inset: auto;
    top: 0;
    width: auto;
    height: auto;
    gap: 8px;
    padding: 10px 14px 12px;
    border-right: 0;
    border-bottom: 4px solid var(--violet);
    overflow: visible;
  }

  .rail ol {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .rail a {
    white-space: nowrap;
    border-color: rgba(255, 255, 255, 0.22);
  }

  .brand { font-size: 17px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 9px; }

  main { margin-left: 0; padding: 18px 16px 64px; }

  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 22px;
    padding: 30px 20px;
  }

  .hero-copy { order: 1; text-align: left; }
  .hero-desc { margin-left: 0; }
  .hero-art { order: 2; justify-content: flex-end; }
  .hero-art svg { max-width: 120px; }

  .stage { margin-top: 40px; }

  .post div { padding: 24px 18px; scroll-margin-top: 118px; }

  .foot { margin-left: 0; padding: 36px 18px 28px; }
  .foot-cols { grid-template-columns: 1fr; gap: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body::before,
  .hero::after { animation: none; }
  html.js .reveal { opacity: 1; transform: none; transition: none; }
  * { transition-duration: 0.01ms !important; }
}

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