@import url('https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;500;600;700&family=Noto+Sans+Arabic:wght@300;400;500;700&display=swap');

:root {
  --ink: #000;
  --paper: #fff;
  --grey: #6a6a6a;
  --soft: #d8d8d8;
  --r: 4px;
}

*,
*::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-family: 'Noto Sans Arabic', system-ui, -apple-system, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 17px;
  line-height: 1.75;
  letter-spacing: .01em;
}

h1, h2, h3 {
  font-family: 'Noto Naskh Arabic', 'Noto Sans Arabic', system-ui, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  margin: 0;
  line-height: 1.22;
  letter-spacing: -.01em;
}

p { margin: 0 0 1.1em; }
a { color: inherit; }
img { max-width: 100%; height: auto; display: block; }
dl, dd, ol, ul { margin: 0; }

/* ---------- 顶部 ---------- */

.hd {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
  padding: .3rem max(1rem, calc((100% - 1200px) / 2));
}

.hd-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .1rem;
}

.hd-l .hd-nav { justify-content: flex-start; }
.hd-r .hd-nav { justify-content: flex-end; }

.hd-nav a {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 44px;
  padding: .35rem .55rem;
  font-size: 16px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .22s ease, color .22s ease;
}

.gl {
  width: 7px;
  height: 7px;
  display: inline-block;
  background: var(--ink);
  transition: background .22s ease, transform .22s ease;
}

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

.hd-nav a:hover .gl,
.hd-nav a:focus-visible .gl {
  background: var(--paper);
  transform: rotate(45deg);
}

.hd-c { text-align: center; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 44px;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .2em;
  white-space: nowrap;
}

.logo-img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  border-radius: 2px;
}

.hd-r {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .4rem;
}

/* ---------- 骨架 ---------- */

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
  gap: 0 clamp(1.5rem, 4vw, 3.5rem);
  padding: 0 max(1rem, calc((100% - 1200px) / 2));
  align-items: start;
}

.doc { min-width: 0; }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  min-height: 70vh;
  display: grid;
  align-content: end;
  justify-items: end;
  text-align: right;
  padding: clamp(2rem, 5vw, 3.5rem) clamp(1.25rem, 4vw, 3rem);
}

.hero-mark {
  position: absolute;
  top: -.16em;
  left: -.05em;
  font-size: clamp(4.5rem, 15vw, 12rem);
  font-weight: 700;
  line-height: .92;
  letter-spacing: -.05em;
  color: rgba(255, 255, 255, .12);
  pointer-events: none;
  user-select: none;
}

.hero-in {
  position: relative;
  display: grid;
  justify-items: end;
  gap: 1.1rem;
}

.hero-ico {
  display: flex;
  gap: 8px;
}

.hero-ico i {
  display: block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--paper);
}

.hero-ico i:nth-child(2) { background: var(--paper); }

.hero h1 {
  font-size: clamp(1.9rem, 5vw, 3.5rem);
  line-height: 1.14;
  max-width: 22ch;
}

.hero-d {
  margin: 0;
  max-width: 44ch;
  color: #cfcfcf;
  font-size: 16px;
}

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

.doc > section:not(.hero) {
  padding: clamp(2.5rem, 6vw, 4.5rem) 0;
  border-top: 1px solid var(--ink);
  scroll-margin-top: 100px;
}

.doc > section.rv {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .55s ease, transform .55s ease;
}

.doc > section.rv.in {
  opacity: 1;
  transform: none;
}

.doc h2 {
  font-size: clamp(1.4rem, 3.2vw, 2.05rem);
  margin-bottom: 1.1rem;
}

.doc h2 > span {
  display: inline-block;
  border-bottom: 4px solid var(--ink);
  padding-bottom: .2em;
}

.doc h3 {
  font-size: clamp(1.15rem, 2.2vw, 1.4rem);
  margin: 2.2rem 0 .6rem;
}

.doc h3 > span {
  display: inline-block;
  border-bottom: 2px solid var(--ink);
  padding-bottom: .16em;
}

.doc p { max-width: 66ch; }
.doc ul, .doc ol { padding-left: 1.4em; max-width: 66ch; }
.doc li { margin: .35em 0; }

.doc a {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: background .2s ease, color .2s ease;
}

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

.doc blockquote {
  margin: 1.6rem 0;
  padding: .2rem 0 .2rem 1.2rem;
  border-left: 4px solid var(--ink);
  color: #2b2b2b;
}

.doc strong { font-weight: 700; }
.doc hr { border: 0; border-top: 1px solid var(--ink); margin: 2rem 0; }
.doc img { margin: 1.4rem 0; border-radius: var(--r); }
.doc code { font-size: 16px; }

.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.doc th, .doc td {
  border-bottom: 1px solid var(--ink);
  padding: .6rem .5rem;
  text-align: left;
  vertical-align: top;
}

/* ---------- 侧栏 ---------- */

.rail {
  align-self: start;
  position: sticky;
  top: 5.5rem;
  padding: clamp(2rem, 4vw, 3rem) 0 3rem clamp(1rem, 2.5vw, 1.4rem);
  border-left: 1px solid var(--ink);
}

.rail-b + .rail-b { margin-top: 2rem; }

.rail h2 {
  font-size: 1rem;
  letter-spacing: .16em;
  margin-bottom: .7rem;
}

.rail h2 > span {
  display: inline-block;
  border-bottom: 2px solid var(--ink);
  padding-bottom: .3em;
}

.toc {
  list-style: none;
  padding: 0;
  counter-reset: toc;
}

.toc li {
  counter-increment: toc;
  border-bottom: 1px solid var(--soft);
}

.toc a {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 44px;
  padding: .4rem 0;
  font-size: 16px;
  text-decoration: none;
  transition: padding .22s ease, background .22s ease, color .22s ease;
}

.toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-size: 12px;
  letter-spacing: .06em;
  color: var(--grey);
  width: 1.8em;
  flex: none;
}

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

.totop {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 .1rem;
  font-size: 16px;
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
  transition: background .22s ease, color .22s ease;
}

.totop:hover { background: var(--ink); color: var(--paper); }

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

.ft {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem 2.5rem;
  border-top: 1px solid var(--ink);
  margin-top: 3.5rem;
  padding: 2.5rem max(1rem, calc((100% - 1200px) / 2)) 3rem;
}

.ft-b {
  display: flex;
  align-items: center;
  gap: .9rem;
}

.ft-logo { display: block; }
.ft-logo .logo-img { width: 40px; height: 40px; }

.ft-word {
  font-size: clamp(1.6rem, 4.5vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1;
}

.ft-nav dl {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.1rem;
}

.ft-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 16px;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}

.ft-nav a:hover { border-bottom-color: var(--ink); }

.ft-c {
  font-size: 16px;
  color: var(--ink);
}

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

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

.hd-nav a { animation: rise .45s ease both; }
.hd-nav a:nth-child(1) { animation-delay: .02s; }
.hd-nav a:nth-child(2) { animation-delay: .06s; }
.hd-nav a:nth-child(3) { animation-delay: .1s; }
.hd-nav a:nth-child(4) { animation-delay: .14s; }

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

@media (max-width: 980px) {
  .hd {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: .2rem;
    padding-top: .45rem;
    padding-bottom: .45rem;
  }

  .hd-c { order: -1; }

  .hd-l, .hd-r { width: 100%; }

  .hd-nav,
  .hd-l .hd-nav,
  .hd-r .hd-nav { justify-content: center; }

  .hd-nav a { padding: .3rem .45rem; }

  main { grid-template-columns: 1fr; }

  .hero {
    min-height: 0;
    align-content: center;
    padding: 2.2rem 1.1rem 2.6rem;
  }

  .hero-mark {
    font-size: clamp(3.5rem, 22vw, 7rem);
    color: rgba(255, 255, 255, .14);
  }

  .hero-d { max-width: 100%; }

  .rail {
    position: static;
    border-left: 0;
    border-top: 1px solid var(--ink);
    margin-top: 2.5rem;
    padding: 1.8rem 0 2.2rem;
  }

  .toc { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }

  .ft {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.2rem;
    padding-bottom: 2rem;
  }

  .ft-c {
    width: 100%;
    text-align: center;
    border-top: 1px solid var(--ink);
    padding-top: 1rem;
  }
}

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

  .hd-nav a { animation: none; }

  .doc > section.rv {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

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