@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: #1c1726;
  --violet: #6514ff;
  --magenta: #bf00ff;
  --paper: #f8f4ff;
  --dim: #c3b8de;
  --line: rgba(248, 244, 255, .18);
  --head: 70px;
  --rail: 56px;
  --pad: clamp(16px, 4.5vw, 44px);
  --font: "Noto Sans Arabic", "Noto Naskh Arabic", system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --t: .24s ease;
}

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

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

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

body::before {
  content: "";
  position: fixed;
  inset: -25% -25% -25% -25%;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(115deg, rgba(101, 20, 255, .16) 0 2px, transparent 2px 72px),
    radial-gradient(52vw 52vw at 92% 3%, rgba(191, 0, 255, .24), transparent 62%),
    radial-gradient(48vw 48vw at 3% 97%, rgba(101, 20, 255, .22), transparent 62%);
  animation: slide 26s linear infinite;
}

@keyframes slide {
  to { transform: translate3d(-72px, 36px, 0); }
}

header,
.rail,
main,
.foot { position: relative; z-index: 1; }

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

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

::selection {
  background: var(--magenta);
  color: #fff;
}

/* ---------- 顶栏 ---------- */
.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(28, 23, 38, .94);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--violet);
}

.head-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "nav-a brand nav-b";
  align-items: center;
  gap: 8px 10px;
  padding: 9px var(--pad);
}

.nav-a { grid-area: nav-a; }
.nav-b { grid-area: nav-b; }
.brand { grid-area: brand; }

.nav-a p,
.nav-b p {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
}

.nav-b p { justify-content: flex-end; }

.masthead nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--paper);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t), color var(--t), transform var(--t);
}

.masthead nav a:hover {
  background: var(--violet);
  color: #fff;
  transform: translateY(-2px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 10px;
  color: var(--paper);
  font-size: 19px;
  font-weight: 700;
  text-decoration: none;
}

.glyph {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--violet), var(--magenta));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  transform: rotate(-6deg);
}

/* ---------- 锚点条 ---------- */
.rail {
  position: sticky;
  top: var(--head);
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px var(--pad);
  background: linear-gradient(90deg, var(--violet), var(--magenta));
  border-bottom: 2px solid var(--ink);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

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

.search {
  flex: 0 0 auto;
  margin: 0;
  scroll-snap-align: start;
}

.search input {
  width: min(200px, 44vw);
  min-height: 42px;
  padding: 0 12px;
  border: 2px solid rgba(28, 23, 38, .4);
  border-radius: 10px;
  background: rgba(28, 23, 38, .55);
  color: #fff;
  font: inherit;
  font-size: 16px;
}

.search input::placeholder { color: rgba(248, 244, 255, .72); }

.chips {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  margin: 0;
}

.chips a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 2px solid rgba(28, 23, 38, .38);
  border-radius: 10px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  scroll-snap-align: start;
  transition: background var(--t), border-color var(--t);
}

.chips a:hover {
  background: var(--ink);
  border-color: var(--ink);
}

.totop {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 42px;
  margin-left: auto;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(28, 23, 38, .78);
  color: #fff;
  font-size: 16px;
  text-decoration: none;
  white-space: nowrap;
}

/* ---------- 首屏 ---------- */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 100vh;
  padding: calc(var(--head) + var(--rail) + 30px) var(--pad) 96px;
  overflow: hidden;
  isolation: isolate;
  border-bottom: 3px solid var(--ink);
}

.hero::before {
  content: "";
  position: absolute;
  top: -140px;
  right: -120px;
  z-index: -1;
  width: 420px;
  height: 420px;
  background: conic-gradient(from 0deg, var(--violet), var(--magenta), transparent 70%);
  opacity: .55;
  border-radius: 44% 56% 62% 38% / 48% 42% 58% 52%;
  animation: spin 20s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hero-media {
  position: absolute;
  inset: 0;
  z-index: -3;
  margin: 0;
  background:
    linear-gradient(120deg, rgba(28, 23, 38, .96), rgba(101, 20, 255, .7) 55%, rgba(191, 0, 255, .45));
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(.3) contrast(1.08);
}

.hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(102deg, rgba(28, 23, 38, .95) 0%, rgba(28, 23, 38, .7) 46%, rgba(191, 0, 255, .28) 100%),
    linear-gradient(to top, rgba(28, 23, 38, .95), transparent 55%);
}

.hero-copy {
  position: relative;
  z-index: 2;
  max-width: 780px;
}

.hero h1 {
  margin: 0 0 18px;
  font-size: clamp(36px, 8vw, 72px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -.02em;
  text-wrap: balance;
}

.lede {
  max-width: 44ch;
  margin: 0;
  padding-left: 16px;
  border-left: 5px solid var(--magenta);
  color: #ecdeff;
  font-size: clamp(17px, 2.2vw, 20px);
}

.wedge {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  height: 70px;
  background: linear-gradient(90deg, var(--magenta), var(--violet));
  clip-path: polygon(0 62%, 100% 0, 100% 100%, 0 100%);
  opacity: .92;
}

/* ---------- 主体 ---------- */
.body-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: start;
  gap: clamp(26px, 4vw, 52px);
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 68px) var(--pad) 80px;
}

.prose { min-width: 0; }

.sec-h,
.side-h {
  margin: 0 0 8px;
  font-size: clamp(24px, 3.2vw, 32px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.01em;
}

.sec-h span,
.side-h span {
  display: inline-block;
  padding: 0 .16em;
  background: linear-gradient(transparent 62%, rgba(191, 0, 255, .55) 62%);
}

.sec-h { margin-bottom: 26px; }

.prose section {
  position: relative;
  margin: 0 0 clamp(24px, 4vw, 44px);
  padding: clamp(20px, 3vw, 32px);
  border: 2px solid var(--line);
  border-radius: 10px;
  background: rgba(248, 244, 255, .035);
  scroll-margin-top: calc(var(--head) + var(--rail) + 22px);
  counter-increment: blk;
}

.prose {
  counter-reset: blk;
}

.prose section::before {
  content: "";
  position: absolute;
  top: 24px;
  left: -2px;
  width: 6px;
  height: 36px;
  border-radius: 0 6px 6px 0;
  background: linear-gradient(var(--violet), var(--magenta));
}

.prose section::after {
  content: counter(blk, decimal-leading-zero);
  position: absolute;
  top: 14px;
  right: 18px;
  color: var(--magenta);
  font-size: 20px;
  font-weight: 700;
  opacity: .5;
  letter-spacing: .08em;
}

.prose section:nth-of-type(even) {
  border-color: rgba(191, 0, 255, .42);
  background: rgba(101, 20, 255, .1);
}

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

.prose h2,
.prose h3 {
  margin: 0 0 .55em;
  font-size: clamp(22px, 2.8vw, 30px);
  line-height: 1.3;
  letter-spacing: -.01em;
  padding-right: 48px;
}

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

.prose h2 span,
.prose h3 span {
  display: inline-block;
  padding: 0 .14em;
  background: linear-gradient(transparent 64%, rgba(101, 20, 255, .8) 64%);
}

.prose p {
  max-width: 68ch;
  margin: 0 0 1em;
  color: #ece6f8;
}

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

.prose ul,
.prose ol {
  max-width: 66ch;
  margin: 0 0 1em;
  padding-left: 1.3em;
}

.prose li { margin-bottom: .4em; }

.prose li::marker { color: var(--magenta); }

.prose a {
  color: #d9c2ff;
  text-decoration-color: var(--magenta);
  text-underline-offset: 3px;
  transition: color var(--t);
}

.prose a:hover { color: #fff; }

.prose strong { color: #fff; }

.prose blockquote {
  margin: 0 0 1em;
  padding: 12px 18px;
  border-left: 5px solid var(--violet);
  background: rgba(191, 0, 255, .12);
  border-radius: 0 10px 10px 0;
}

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

.prose figure { margin: 0 0 1em; }

.prose img,
.side-fig img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 2px solid rgba(191, 0, 255, .4);
}

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

.prose th,
.prose td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-align: left;
}

.prose th { background: rgba(101, 20, 255, .28); }

/* ---------- 侧栏 ---------- */
.side {
  position: sticky;
  top: calc(var(--head) + var(--rail) + 20px);
  padding: 18px;
  border: 2px solid rgba(101, 20, 255, .65);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(101, 20, 255, .2), rgba(28, 23, 38, .92));
}

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

.toc a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--paper);
  font-size: 16px;
  text-decoration: none;
  transition: background var(--t), border-color var(--t), transform var(--t);
}

.toc a:hover {
  border-color: var(--magenta);
  background: rgba(191, 0, 255, .26);
  transform: translateX(3px);
}

.side-fig { margin: 16px 0 0; }

/* ---------- 页脚 ---------- */
.foot {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "brand cta"
    "copy links";
  gap: 18px 24px;
  padding: clamp(32px, 6vw, 60px) var(--pad);
  border-top: 4px solid var(--ink);
  background: linear-gradient(120deg, var(--violet), var(--magenta));
  color: #fff;
}

.foot-brand {
  display: flex;
  grid-area: brand;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.foot-brand .glyph {
  background: rgba(28, 23, 38, .85);
}

.foot-cta {
  grid-area: cta;
  align-self: center;
  margin: 0;
}

.foot-cta a {
  display: inline-block;
  padding-bottom: 2px;
  border-bottom: 3px solid rgba(255, 255, 255, .65);
  color: #fff;
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 700;
  text-decoration: none;
  transition: border-color var(--t), letter-spacing var(--t);
}

.foot-cta a:hover {
  border-color: #fff;
  letter-spacing: .04em;
}

.foot-copy,
.foot-links {
  align-self: end;
  font-size: 16px;
}

.foot-copy { grid-area: copy; opacity: .92; }

.foot-links {
  grid-area: links;
  justify-self: end;
}

.foot-links a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 6px;
  color: #fff;
  text-decoration: none;
}

.foot-links a:hover { text-decoration: underline; }

/* ---------- 动效 ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .5s ease, transform .5s ease;
}

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

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

/* ---------- 窄屏 ---------- */
@media (max-width: 860px) {
  :root {
    --head: 122px;
    --rail: 52px;
  }

  .head-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "brand brand"
      "nav-a nav-b";
    padding: 8px var(--pad);
  }

  .brand { justify-self: center; }

  .nav-a,
  .nav-b {
    width: 100%;
    min-width: 0;
  }

  .nav-a p,
  .nav-b p {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .nav-a p::-webkit-scrollbar,
  .nav-b p::-webkit-scrollbar { display: none; }

  .masthead nav a {
    padding: 0 10px;
    font-size: 16px;
  }

  .hero { padding-bottom: 80px; }

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

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

  .wedge { height: 52px; }

  .foot {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "cta"
      "copy"
      "links";
  }

  .foot-links { justify-self: start; }
}

@media (max-width: 420px) {
  .search input { width: 130px; }
  .hero h1 { font-size: 34px; }
}

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