@import url('https://fonts.googleapis.com/css2?family=Cormorant+Infant:wght@300;400;500;600;700&family=Great+Vibes&display=swap');

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

:root {
  --ink: #1c1726;
  --ink-2: #221a31;
  --ink-3: #2a1f3d;
  --edge: #3a2c55;
  --violet: #6514ff;
  --magenta: #bf00ff;
  --paper: #f7f2ff;
  --dim: #b6a8cf;
  --rail: 200px;
  --gutter: 216px;
}

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

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: "Cormorant Infant", "Songti SC", "Noto Serif SC", Georgia, "PingFang SC", serif;
  font-size: 17px;
  line-height: 1.72;
  letter-spacing: .01em;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: 0;
  pointer-events: none;
  opacity: .14;
  background-image: repeating-linear-gradient(45deg, var(--violet) 0 2px, transparent 2px 28px);
  animation: drift 30s linear infinite;
}

@keyframes drift {
  to { transform: translate3d(28px, 28px, 0); }
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-6px) rotate(1.5deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

a { color: #cbaaff; }

img { max-width: 100%; }

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 80;
  padding: 12px 18px;
  background: var(--magenta);
  color: #fff;
  text-decoration: none;
  font-size: 16px;
}

.skip:focus { left: 10px; top: 10px; }

/* ---------- 左侧导轨 ---------- */

.rail {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 30;
  width: var(--rail);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 16px 26px;
  overflow-y: auto;
  background: linear-gradient(180deg, #191026 0%, #1c1726 46%, #1c1726 100%);
  border-right: 1px solid var(--edge);
}

.mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  background: var(--violet);
  color: #fff;
  text-decoration: none;
  transition: background .24s ease, transform .24s ease;
}

.mark:hover { background: var(--magenta); transform: rotate(-4deg); }

.mark img { width: 40px; height: 40px; object-fit: contain; display: block; }

.mark-t {
  font-family: "Great Vibes", "Cormorant Infant", cursive;
  font-size: 30px;
  line-height: 1;
  transform: translateY(-2px);
}

.srch {
  display: flex;
  border: 1px solid var(--edge);
  background: #140e20;
}

.srch-i {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--paper);
  font: inherit;
  font-size: 16px;
}

.srch-i::placeholder { color: var(--dim); }

.srch-i:focus { outline: 2px solid var(--magenta); outline-offset: -2px; }

.srch-b {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  background: var(--magenta);
  color: #fff;
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  transition: background .2s ease;
}

.srch-b:hover { background: var(--violet); }

.srch.miss { animation: shake .3s ease; }

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

.rail-list li { counter-increment: rl; }

.rail-list li:nth-child(2),
.rail-list li:nth-child(4) {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--edge);
}

.rail-list a {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 10px 8px;
  color: var(--paper);
  text-decoration: none;
  font-size: 16px;
  line-height: 1.3;
  border-left: 3px solid transparent;
  transition: background .22s ease, color .22s ease, border-color .22s ease;
}

.rail-list a::before {
  content: counter(rl, decimal-leading-zero);
  font-family: "Cormorant Infant", Georgia, serif;
  font-size: 13px;
  letter-spacing: .06em;
  color: var(--magenta);
  opacity: .85;
}

.rail-list a:hover,
.rail-list a:focus-visible,
.rail-list a.on {
  background: var(--violet);
  border-left-color: var(--magenta);
  color: #fff;
}

/* ---------- 主体骨架 ---------- */

.page {
  position: relative;
  z-index: 1;
  padding-left: var(--gutter);
}

.grid {
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  gap: clamp(20px, 3vw, 44px);
  max-width: 1260px;
  margin: 0 auto;
  padding: 34px clamp(16px, 3vw, 40px) 72px;
}

main { min-width: 0; }

/* ---------- 侧边目录 ---------- */

.toc {
  position: sticky;
  top: 24px;
  align-self: start;
  padding: 16px 14px 18px;
  background: #201830;
  border-top: 6px solid var(--violet);
}

.toc-t {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: .3em;
}

.toc hr {
  width: 46px;
  margin: 10px 0 0;
  border: 0;
  border-top: 3px solid var(--magenta);
}

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

.toc-list a {
  display: block;
  min-height: 40px;
  padding: 9px 6px;
  color: var(--dim);
  text-decoration: none;
  font-size: 16px;
  line-height: 1.4;
  border-bottom: 1px solid #2e2443;
  transition: color .2s ease, padding-left .2s ease, background .2s ease;
}

.toc-list a:hover,
.toc-list a:focus-visible {
  color: #fff;
  padding-left: 13px;
  background: #2c2143;
}

/* ---------- 首屏 ---------- */

.hero {
  position: relative;
  min-height: 70vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .8fr);
  gap: clamp(24px, 4vw, 52px);
  align-items: center;
  padding: clamp(36px, 6vw, 88px) clamp(20px, 4vw, 52px);
  margin-bottom: clamp(24px, 4vw, 48px);
  overflow: hidden;
  background:
    radial-gradient(130% 130% at 0% 0%, #3d0a86 0%, #26123f 46%, var(--ink) 82%);
}

.hero::after {
  content: "";
  position: absolute;
  right: -70px;
  bottom: -90px;
  width: 300px;
  height: 300px;
  background: var(--magenta);
  opacity: .2;
  transform: rotate(16deg);
}

.hero-txt {
  position: relative;
  z-index: 2;
  text-align: left;
}

.badge { margin: 0 0 22px; display: inline-flex; }

.badge a {
  display: inline-block;
  padding: 9px 18px;
  background: var(--magenta);
  color: #fff;
  text-decoration: none;
  font-family: "Great Vibes", "Cormorant Infant", cursive;
  font-size: 24px;
  line-height: 1.25;
  box-shadow: 7px 7px 0 rgba(101, 20, 255, .65);
  animation: bob 6s ease-in-out infinite;
}

.badge a:hover { background: var(--violet); }

h1 {
  margin: 0 0 18px;
  font-size: clamp(34px, 5.4vw, 66px);
  line-height: 1.07;
  font-weight: 600;
  letter-spacing: -.012em;
}

.lede {
  margin: 0;
  max-width: 44ch;
  font-size: clamp(16px, 1.5vw, 19px);
  line-height: 1.65;
  color: #ddcff2;
}

.collage {
  position: relative;
  min-height: clamp(250px, 46vh, 420px);
  z-index: 1;
}

.tile {
  position: absolute;
  margin: 0;
  overflow: hidden;
  background: linear-gradient(140deg, var(--violet), var(--magenta));
}

.tile-a {
  left: 0;
  top: 0;
  width: 60%;
  aspect-ratio: 4 / 5;
  box-shadow: 14px 14px 0 rgba(191, 0, 255, .38);
}

.tile-b {
  right: 0;
  bottom: 0;
  width: 52%;
  aspect-ratio: 3 / 4;
  border: 6px solid var(--ink);
  transform: translateY(12%) rotate(-4deg);
}

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

/* ---------- 正文 ---------- */

section { padding-bottom: 24px; }

section > div {
  position: relative;
  padding: clamp(28px, 4vw, 52px);
  margin-bottom: clamp(20px, 3vw, 34px);
  background: var(--ink-2);
  border-left: 5px solid var(--violet);
  scroll-margin-top: 26px;
}

section > div:nth-of-type(even) {
  background: #281d3c;
  border-left-color: var(--magenta);
}

section > div::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 28px 28px 0;
  border-color: transparent var(--violet) transparent transparent;
}

section > div:nth-of-type(even)::after {
  border-right-color: var(--magenta);
}

section h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: -.008em;
}

section h3 {
  margin: 1.4em 0 .5em;
  font-size: clamp(19px, 2vw, 23px);
  line-height: 1.3;
  color: #ecd9ff;
}

section hr {
  width: 66px;
  margin: 12px 0 24px;
  border: 0;
  border-top: 3px solid var(--magenta);
}

section p {
  margin: 0 0 1.05em;
  max-width: 68ch;
  font-size: 17px;
  line-height: 1.78;
}

section ul,
section ol {
  margin: 0 0 1.1em;
  padding-left: 1.35em;
  max-width: 66ch;
}

section li { margin: 0 0 .45em; }

section a {
  color: #dcbfff;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: background .2s ease, color .2s ease;
}

section a:hover { background: var(--violet); color: #fff; }

section blockquote {
  margin: 0 0 1.2em;
  padding: 14px 20px;
  border-left: 4px solid var(--magenta);
  background: #1a1428;
  color: #e3d5f6;
}

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

section strong { color: #f0e2ff; }

section table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.2em;
  font-size: 16px;
}

section th,
section td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--edge);
  text-align: left;
  vertical-align: top;
}

section th { background: #1a1428; color: #fff; }

/* ---------- 滚动显现 ---------- */

.rv {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .5s ease, transform .5s ease;
}

.rv.in { opacity: 1; transform: none; }

/* ---------- 页脚 ---------- */

footer {
  position: relative;
  z-index: 1;
  margin-left: var(--gutter);
  padding: 46px clamp(16px, 4vw, 56px) 44px;
  border-top: 1px solid var(--edge);
  background: #140e20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "brand copy"
    "brand links";
  gap: 8px 24px;
  align-items: end;
}

.f-brand {
  grid-area: brand;
  margin: 0;
  font-size: clamp(32px, 6.6vw, 74px);
  line-height: .96;
  font-weight: 600;
  letter-spacing: -.02em;
  color: #c49bff;
}

.f-copy,
.f-links {
  font-size: 16px;
  line-height: 1.5;
  color: var(--dim);
}

.f-copy { grid-area: copy; text-align: right; }

.f-links {
  grid-area: links;
  text-align: right;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.f-links a {
  display: inline-block;
  min-height: 40px;
  padding: 8px 6px;
  line-height: 24px;
  color: var(--dim);
  text-decoration: none;
  transition: color .2s ease;
}

.f-links a:hover,
.f-links a:focus-visible { color: #fff; }

.f-links a + a::before {
  content: "·";
  margin-right: 10px;
  color: var(--violet);
}

/* ---------- 窄屏 ---------- */

@media (max-width: 900px) {
  .rail {
    position: sticky;
    top: 0;
    bottom: auto;
    left: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--edge);
    background: #150f21;
  }

  .mark { order: 1; width: 42px; height: 42px; }
  .mark-t { font-size: 25px; }

  .srch { order: 2; flex: 1 1 auto; min-width: 0; }

  .rail-list {
    order: 3;
    flex: 1 0 100%;
    flex-direction: row;
    gap: 4px;
    padding-bottom: 2px;
    overflow-x: auto;
  }

  .rail-list li:nth-child(n) {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .rail-list li { flex: 0 0 auto; }

  .rail-list a {
    min-height: 44px;
    white-space: nowrap;
    border-left: 0;
    border-bottom: 3px solid transparent;
  }

  .rail-list a:hover,
  .rail-list a:focus-visible,
  .rail-list a.on { border-bottom-color: var(--magenta); }

  .page { padding-left: 0; }

  .grid {
    grid-template-columns: 1fr;
    padding: 22px 14px 56px;
  }

  .toc { position: static; padding: 14px 12px; }

  .toc-list {
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
  }

  .toc-list a {
    white-space: nowrap;
    min-height: 40px;
    border-bottom: 0;
    border-right: 1px solid #2e2443;
  }

  .toc-list a:hover { padding-left: 6px; }

  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 34px 20px 40px;
  }

  .collage {
    min-height: 300px;
    margin-top: 26px;
  }

  section > div { scroll-margin-top: 118px; }

  footer { margin-left: 0; }
}

@media (max-width: 520px) {
  .tile-b { transform: translateY(8%) rotate(-3deg); }
  .f-brand { font-size: 34px; }
  footer { gap: 6px 12px; padding: 36px 14px 34px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }

  .rv { opacity: 1; transform: none; }
}

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