@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&family=Share+Tech+Mono&display=swap');

:root {
  --ink: #000000;
  --paper: #ffffff;
  --hair: rgba(0, 0, 0, 0.16);
  --rail: 15rem;
  --bar: 2.6rem;
  --pad: clamp(18px, 4vw, 52px);
  --hud: "Share Tech Mono", "Fira Code", ui-monospace, monospace;
  --text: "Fira Code", ui-monospace, "Songti SC", "Noto Serif CJK SC", Georgia, serif;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.75 var(--text);
  letter-spacing: 0.01em;
  overflow-x: hidden;
}

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

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

/* ---------- 顶部细条 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--bar);
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
}

.mark {
  display: grid;
  place-items: center;
  height: 100%;
  aspect-ratio: 1;
  border-right: 1px solid var(--ink);
  text-decoration: none;
  color: var(--ink);
  font-family: var(--hud);
  font-size: 18px;
  line-height: 1;
}

.mark img {
  display: block;
  filter: grayscale(1);
}

.mast {
  font-family: var(--hud);
  font-size: 16px;
  letter-spacing: 0.42em;
  line-height: 1;
  padding-left: 0.1rem;
}

.bar-rule {
  flex: 1;
  height: 1px;
  margin-right: var(--pad);
  background: repeating-linear-gradient(
    90deg,
    var(--ink) 0 6px,
    transparent 6px 12px
  );
  opacity: 0.5;
}

/* ---------- 左侧竖排导航 ---------- */

.rail {
  position: fixed;
  left: 0;
  top: var(--bar);
  z-index: 30;
  width: var(--rail);
  height: calc(100vh - var(--bar));
  overflow-y: auto;
  border-right: 1px solid var(--ink);
  background: var(--paper);
  padding: 1.1rem 0.9rem 2rem;
}

.rail ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: rn;
}

.rail li {
  counter-increment: rn;
}

.rail li + li {
  border-top: 1px solid var(--hair);
}

.rail a {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  min-height: 44px;
  padding: 0.85rem 0.2rem;
  font-size: 16px;
  line-height: 1.5;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.18s ease, color 0.18s ease, padding-left 0.18s ease;
}

.rail a::before {
  content: counter(rn, decimal-leading-zero);
  font-family: var(--hud);
  letter-spacing: 0.08em;
  opacity: 0.45;
}

.rail a:hover,
.rail a:focus-visible {
  background: var(--ink);
  color: var(--paper);
  padding-left: 0.6rem;
}

.rail a:hover::before,
.rail a:focus-visible::before {
  opacity: 0.9;
}

/* ---------- 主区 ---------- */

main {
  margin-left: var(--rail);
}

.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  align-content: start;
  gap: 1rem;
  min-height: 45vh;
  padding: clamp(18px, 3.6vw, 44px) var(--pad) clamp(26px, 4.5vw, 54px);
  border-bottom: 1px solid var(--ink);
  overflow: hidden;
  background: var(--paper);
}

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

.hero-fig img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.12);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(
    100deg,
    #ffffff 34%,
    rgba(255, 255, 255, 0.78) 58%,
    rgba(255, 255, 255, 0.34) 100%
  );
}

.hero[data-ghost]::before {
  content: attr(data-ghost);
  position: absolute;
  right: -1vw;
  bottom: -0.28em;
  z-index: 3;
  font-family: var(--hud);
  font-size: clamp(62px, 14vw, 168px);
  line-height: 0.8;
  letter-spacing: -0.03em;
  white-space: nowrap;
  color: transparent;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.24);
  pointer-events: none;
}

.hero-in {
  position: relative;
  z-index: 4;
  max-width: 60rem;
}

.hero h1 {
  margin: 0;
  font-family: var(--hud);
  font-size: clamp(34px, 6.4vw, 86px);
  line-height: 1.06;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.lead {
  max-width: 44ch;
  margin: clamp(14px, 2vw, 22px) 0 0;
  padding-left: 1rem;
  border-left: 3px solid var(--ink);
  font-size: 17px;
  line-height: 1.65;
}

/* ---------- 正文与右侧索引 ---------- */

.body-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18rem;
  gap: clamp(20px, 3vw, 44px);
  align-items: start;
  padding: clamp(24px, 4vw, 52px) var(--pad) clamp(28px, 5vw, 64px);
}

.stream {
  min-width: 0;
  max-width: 74ch;
}

.stream > section {
  border: 1px solid var(--ink);
  border-radius: 18px;
  padding: clamp(18px, 3vw, 34px);
  margin: 0 0 clamp(22px, 3.4vw, 40px);
  scroll-margin-top: calc(var(--bar) + 16px);
  background: var(--paper);
}

.stream > section:nth-child(even) {
  margin-left: clamp(0px, 4vw, 54px);
}

.stream h2,
.stream h3 {
  font-family: var(--hud);
  letter-spacing: -0.01em;
  line-height: 1.24;
  margin: 0.1em 0 0.55em;
}

.stream h2 {
  font-size: clamp(23px, 2.7vw, 36px);
}

.stream h3 {
  font-size: clamp(19px, 2vw, 24px);
}

.stream p {
  margin: 0 0 1em;
}

.stream ul,
.stream ol {
  padding-left: 1.35em;
  margin: 0 0 1em;
}

.stream li {
  margin-bottom: 0.4em;
}

.stream a {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.stream a:hover {
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}

.stream blockquote {
  margin: 1.3em 0;
  padding: 0.15em 0 0.15em 1.1em;
  border-left: 3px solid var(--ink);
  font-size: 1.05em;
  line-height: 1.65;
}

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

.stream figure {
  margin: 1.3em 0;
}

.stream figure img {
  border-radius: 18px;
  border: 1px solid var(--ink);
}

.stream figcaption {
  margin-top: 0.45em;
  font-size: 16px;
  opacity: 0.62;
}

.stream hr {
  border: 0;
  border-top: 1px solid var(--hair);
  margin: 1.6em 0;
}

.stream img {
  border-radius: 18px;
}

.stream > section:first-child > p:first-of-type::first-letter {
  float: left;
  font-family: var(--hud);
  font-size: 3.3em;
  line-height: 0.82;
  padding: 0.06em 0.12em 0 0;
}

/* 眉题 */
small {
  display: block;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0.22em;
  color: rgba(0, 0, 0, 0.62);
  margin-bottom: 0.4rem;
}

small::before {
  content: "";
  display: inline-block;
  width: 1.5rem;
  height: 1px;
  margin-right: 0.6rem;
  vertical-align: 0.32em;
  background: currentColor;
}

/* 右侧索引 */
.side {
  position: sticky;
  top: calc(var(--bar) + 16px);
  align-self: start;
  border: 1px solid var(--ink);
  border-radius: 18px;
  padding: 1rem 1rem 1.3rem;
  background: var(--paper);
}

.side h2 {
  margin: 0 0 0.7rem;
  font-family: var(--hud);
  font-size: 20px;
  letter-spacing: 0.1em;
  line-height: 1.3;
}

.side ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: sn;
}

.side li {
  counter-increment: sn;
  border-top: 1px solid var(--hair);
}

.side a {
  display: block;
  min-height: 42px;
  padding: 0.65rem 0;
  font-size: 16px;
  line-height: 1.5;
  text-decoration: none;
  color: var(--ink);
  transition: padding-left 0.18s ease;
}

.side a::before {
  content: counter(sn, decimal-leading-zero);
  margin-right: 0.6em;
  font-family: var(--hud);
  opacity: 0.45;
}

.side a:hover,
.side a:focus-visible {
  padding-left: 0.4rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

footer {
  margin-left: var(--rail);
  border-top: 1px solid var(--ink);
  padding: clamp(24px, 4vw, 46px) var(--pad) 1.5rem;
  background: var(--paper);
}

.foot-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(18px, 3vw, 40px);
  align-items: start;
}

footer address {
  font-style: normal;
  font-family: var(--hud);
  font-size: 19px;
  letter-spacing: 0.18em;
  line-height: 1.5;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid var(--ink);
}

footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.1rem;
}

footer ul a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0.5rem 0;
  font-size: 16px;
  line-height: 1.5;
  text-decoration: none;
  border-bottom: 1px solid var(--hair);
}

footer ul a:hover,
footer ul a:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

.foot-brand {
  margin: clamp(20px, 4vw, 42px) 0 0;
  font-family: var(--hud);
  font-size: clamp(46px, 12vw, 138px);
  line-height: 0.86;
  letter-spacing: -0.03em;
  word-break: break-word;
}

.to-top {
  margin: 1.1rem 0 0;
  text-align: center;
}

.to-top a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 1.1rem;
  font-size: 16px;
  text-decoration: none;
  border: 1px solid var(--ink);
  border-radius: 999px;
}

.to-top a:hover,
.to-top a:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

.copy {
  margin: 1.1rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--hair);
  text-align: center;
  font-size: 16px;
  line-height: 1.6;
  opacity: 0.7;
}

/* ---------- 入场 ---------- */

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

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

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

@media (max-width: 880px) {
  .rail {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--ink);
    padding: 0.4rem 0.8rem 1rem;
  }

  .rail ol {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 0.7rem;
  }

  .rail li + li {
    border-top: 0;
  }

  .rail a {
    border-bottom: 1px solid var(--hair);
    padding: 0.8rem 0.2rem;
  }

  main,
  footer {
    margin-left: 0;
  }

  .body-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .side {
    position: static;
  }

  .foot-top {
    grid-template-columns: minmax(0, 1fr);
  }

  .stream > section:nth-child(even) {
    margin-left: 0;
  }

  .hero {
    min-height: 40vh;
  }
}

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

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .rail a,
  .side a {
    transition: none;
  }
}

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