@import url('https://fonts.googleapis.com/css2?family=Kalam:wght@400;700&family=Patrick+Hand&display=swap');

:root {
  --ink: #1c1726;
  --violet: #6514ff;
  --magenta: #bf00ff;
  --paper: #faf7ff;
  --deep: #151020;
  --muted: #6a5c85;
  --edge: #2a2140;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --hand: "Kalam", "Patrick Hand", var(--font);
}

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

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

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

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(45deg, rgba(101, 20, 255, 0.22) 0 2px, transparent 2px 28px),
    repeating-linear-gradient(-45deg, rgba(191, 0, 255, 0.16) 0 2px, transparent 2px 38px);
  background-size: 220% 220%;
  animation: drift 22s linear infinite;
}

@keyframes drift {
  to {
    background-position: 240px 240px, -240px -240px;
  }
}

a {
  color: inherit;
}

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

img {
  max-width: 100%;
  height: auto;
}

/* ---------- 顶栏 ---------- */
.top {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 16px clamp(14px, 3vw, 34px);
  border-bottom: 3px solid var(--violet);
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.top-nav.left {
  justify-content: flex-start;
}

.top-nav.right {
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 16px;
  border: 2px solid #4b3f66;
  border-radius: 999px;
  color: #efe7ff;
  font-size: 16px;
  text-decoration: none;
  transition: background-color 220ms, border-color 220ms, color 220ms, transform 220ms;
}

.pill:hover,
.pill:focus-visible {
  background: var(--magenta);
  border-color: var(--magenta);
  color: #fff;
  transform: translateY(-2px);
}

.pill-cta {
  background: var(--violet);
  border-color: var(--violet);
  font-weight: 700;
  color: #fff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: #fff;
  text-decoration: none;
}

.mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--violet), var(--magenta));
  color: #fff;
  font-family: var(--hand);
  font-size: 20px;
  font-weight: 700;
  object-fit: cover;
}

.brand-name {
  font-family: var(--hand);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ---------- 粘性章节条 ---------- */
.rail {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(28, 23, 38, 0.95);
  border-bottom: 3px solid var(--magenta);
  backdrop-filter: blur(8px);
}

.rail-nav {
  display: flex;
  gap: 8px;
  padding: 10px clamp(14px, 3vw, 34px);
  overflow-x: auto;
  scrollbar-width: none;
}

.rail-nav::-webkit-scrollbar {
  display: none;
}

.rail-nav a {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 15px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--edge);
  color: #e2d6ff;
  font-size: 16px;
  text-decoration: none;
  transition: background-color 220ms, color 220ms, border-color 220ms;
}

.rail-nav a:hover,
.rail-nav a:focus-visible {
  background: var(--violet);
  border-color: #b79bff;
  color: #fff;
}

/* ---------- 主体骨架 ---------- */
main {
  position: relative;
  z-index: 2;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(14px, 3vw, 38px);
}

.sheet {
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 26px;
}

/* ---------- 首屏 ---------- */
.hero {
  position: relative;
  display: grid;
  place-items: center;
  gap: 22px;
  min-height: clamp(430px, 84svh, 800px);
  padding: 70px 22px 96px;
  overflow: hidden;
  text-align: center;
  color: #fff;
  background: linear-gradient(142deg, var(--violet), var(--magenta) 58%, var(--ink));
  clip-path: polygon(0 0, 100% 0, 100% 91%, 0 100%);
}

.hero-bg {
  position: absolute;
  top: 6%;
  left: -12%;
  right: -12%;
  z-index: 1;
  color: rgba(255, 255, 255, 0.15);
  font-family: var(--hand);
  font-size: clamp(64px, 15vw, 180px);
  line-height: 1;
  letter-spacing: 0.04em;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  will-change: transform;
}

.hero-media {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.34;
  filter: grayscale(0.25) contrast(1.1);
}

.hero h1 {
  position: relative;
  z-index: 2;
  max-width: 20ch;
  margin: 0;
  font-size: clamp(2.05rem, 6.6vw, 4.5rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  text-shadow: 0 4px 0 rgba(28, 23, 38, 0.35);
}

.cta {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  padding: 12px 32px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 240ms, color 240ms, transform 240ms;
}

.cta:hover,
.cta:focus-visible {
  background: #fff;
  color: var(--violet);
  transform: translateY(-3px);
}

/* ---------- 双栏 ---------- */
.cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: clamp(24px, 4vw, 54px);
  padding: clamp(24px, 4vw, 56px);
}

.prose {
  min-width: 0;
  font-size: 17px;
  line-height: 1.85;
  color: #241d31;
}

.prose div {
  padding: clamp(26px, 4vw, 46px) 0;
  border-top: 3px dashed rgba(28, 23, 38, 0.2);
  scroll-margin-top: 112px;
}

.prose div:first-child {
  padding-top: 0;
  border-top: 0;
}

.prose h2 {
  margin: 0 0 16px;
  font-size: clamp(1.45rem, 3.2vw, 2rem);
  line-height: 1.28;
}

.prose h2 > span,
.prose h3 > span {
  display: inline-block;
  position: relative;
  padding-bottom: 4px;
}

.prose h2 > span::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--violet), var(--magenta));
  opacity: 0.35;
}

.prose h3 {
  margin: 26px 0 12px;
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
  line-height: 1.35;
}

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

.prose ul,
.prose ol {
  margin: 0 0 18px;
  padding-left: 1.35em;
}

.prose li {
  margin: 0 0 8px;
}

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

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

.prose blockquote {
  margin: 22px 0;
  padding: 14px 20px;
  border-left: 6px solid var(--magenta);
  border-radius: 0 18px 18px 0;
  background: #f0e6ff;
}

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

.prose figure {
  margin: 22px 0;
}

.prose figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 16px;
}

.prose table {
  width: 100%;
  margin: 22px 0;
  border-collapse: collapse;
  font-size: 16px;
}

.prose th,
.prose td {
  padding: 10px 12px;
  border: 2px solid rgba(28, 23, 38, 0.25);
  text-align: left;
}

.prose th {
  background: #efe4ff;
}

.prose strong {
  color: #150f22;
}

.prose code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #ece2ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
}

/* ---------- 右侧栏 ---------- */
.side {
  position: sticky;
  top: 92px;
  align-self: start;
  padding: 18px 18px 12px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: #efe5ff;
  color: var(--ink);
}

.side-t {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.35;
}

.side-t .dot {
  margin-left: 4px;
  color: var(--magenta);
}

.side-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.side-list a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 4px 10px;
  border: 2px solid transparent;
  border-radius: 12px;
  color: #2a2140;
  font-size: 16px;
  text-decoration: none;
  transition: background-color 200ms, color 200ms, border-color 200ms;
}

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

.side-list li {
  animation: rise 460ms ease both;
}

.side-list li:nth-child(1) { animation-delay: 30ms; }
.side-list li:nth-child(2) { animation-delay: 70ms; }
.side-list li:nth-child(3) { animation-delay: 110ms; }
.side-list li:nth-child(4) { animation-delay: 150ms; }
.side-list li:nth-child(5) { animation-delay: 190ms; }
.side-list li:nth-child(6) { animation-delay: 230ms; }
.side-list li:nth-child(7) { animation-delay: 270ms; }

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 回到顶部 ---------- */
.totop {
  margin: 0;
  padding: 0 clamp(24px, 4vw, 56px) clamp(28px, 4vw, 46px);
}

.totop a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 20px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  transition: background-color 220ms, color 220ms, border-color 220ms;
}

.totop a:hover,
.totop a:focus-visible {
  background: var(--violet);
  border-color: var(--violet);
  color: #fff;
}

/* ---------- 页脚 ---------- */
.foot {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px 34px;
  padding: 26px clamp(16px, 3vw, 34px);
  border-top: 3px solid var(--violet);
  background: var(--deep);
  color: #cbbfe4;
}

.f-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
}

.f-nav dl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  margin: 0;
}

.f-nav dt {
  margin: 0;
  font-weight: 700;
}

.f-nav dd {
  margin: 0;
}

.f-nav dt a,
.f-nav dd a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 4px;
  text-decoration: none;
}

.f-nav dt a {
  color: #fff;
  border-bottom: 2px solid var(--magenta);
}

.f-nav dd a {
  color: #cbbfe4;
}

.f-nav a:hover,
.f-nav a:focus-visible {
  color: var(--magenta);
}

.f-copy p {
  margin: 0;
  color: #a294c0;
  font-size: 16px;
}

/* ---------- 滚动渐显 ---------- */
.js .prose div {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 460ms ease, transform 460ms ease;
}

.js .prose div.in {
  opacity: 1;
  transform: none;
}

/* ---------- 窄屏 ---------- */
@media (max-width: 960px) {
  .cols {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
    order: 2;
  }
}

@media (max-width: 860px) {
  .top {
    grid-template-columns: 1fr;
    gap: 10px;
    padding-bottom: 12px;
  }

  .brand {
    order: -1;
    justify-self: center;
  }

  .top-nav {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .top-nav::-webkit-scrollbar {
    display: none;
  }

  .top-nav .pill {
    flex: 0 0 auto;
  }

  .hero {
    min-height: clamp(360px, 72svh, 620px);
    padding: 56px 18px 84px;
  }

  .foot {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 16px;
  }

  .brand-name {
    font-size: 20px;
  }

  .prose {
    font-size: 16px;
  }

  .sheet {
    border-radius: 20px;
  }
}

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

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

  body::before {
    animation: none;
  }

  .js .prose div {
    opacity: 1;
    transform: none;
  }
}

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