/* ==========================================================================
   base.css — 重置、排版基座、栅格与容器
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 108px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-feature-settings: "kern" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--t-fast), background-color var(--t-fast), border-color var(--t-fast);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }

ul, ol { margin: 0; padding: 0; list-style: none; }
p { margin: 0; }
figure, blockquote { margin: 0; }

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

::selection {
  background: var(--mint-3);
  color: var(--ink-deep);
}

/* 图标 sprite：默认实心、随字色 */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

svg:not(.sprite) {
  width: 1em;
  height: 1em;
  fill: currentColor;
  flex-shrink: 0;
}

/* ---------------------------------------------------------------- 标题 */

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink-deep);
  letter-spacing: -.018em;
  line-height: var(--lh-tight);
  text-wrap: balance;
}

.h-hero {
  font-size: var(--fs-hero);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.03em;
}

.h-1 {
  font-size: var(--fs-h1);
  line-height: 1.14;
  letter-spacing: -.024em;
}

.h-2 {
  font-size: var(--fs-h2);
  line-height: 1.18;
  letter-spacing: -.022em;
}

.h-3 {
  font-size: var(--fs-h3);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -.012em;
}

/* 标题里的强调：只换颜色，不加装饰 */
h1 em, h2 em, .h-1 em, .h-2 em {
  font-style: normal;
  color: var(--accent);
}

/* ---------------------------------------------------------------- 正文 */

.lede {
  font-size: clamp(15.5px, 1.16vw, 17px);
  line-height: 1.78;
  color: var(--ink-2);
  max-width: 62ch;
}

.tiny {
  font-size: var(--fs-xs);
  line-height: 1.65;
  color: var(--ink-3);
}

.mono {
  font-family: var(--font-mono);
  font-size: .92em;
  letter-spacing: -.01em;
  color: var(--ink-2);
}

/* 小标签：官网那种窄字距全大写 */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 16px;
}

.eyebrow::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.eyebrow:empty { display: none; }

.inline-code {
  font-family: var(--font-mono);
  font-size: .88em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--paper-3);
  color: var(--ink-deep);
  white-space: nowrap;
}

strong, b { font-weight: 600; color: var(--ink); }

a strong { color: inherit; }

/* ---------------------------------------------------------------- 容器 */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: var(--sec-y); }
.section--tight { padding-block: calc(var(--sec-y) * .56); }
.section--white { background: var(--paper-2); }
.section--paper { background: var(--paper-3); }

.section--line { border-top: 1px solid var(--line); }

/* 区块头：左标题 + 右说明 */
.split {
  display: flex;
  gap: clamp(24px, 4vw, 64px);
  justify-content: space-between;
}

.split > * { min-width: 0; }

/* 正文 + 代码块/侧栏并排时，右侧固定宽度，避免被正文挤扁 */
.split > .code { flex: 0 0 clamp(300px, 33%, 400px); }
.split > .prose { flex: 1 1 auto; min-width: 0; }
.split > .doc-aside { flex: 0 0 260px; }

@media (max-width: 760px) {
  .split > .code,
  .split > .doc-aside { flex: 1 1 auto; width: 100%; }
}

/* ---------------------------------------------------------------- 栅格 */

.grid {
  display: grid;
  gap: var(--gap);
}

.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1080px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .grid--2,
  .grid--3,
  .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .split { flex-direction: column; gap: 18px; }
}

/* ---------------------------------------------------------------- 其它 */

.skip-link {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -120%);
  z-index: 999;
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: var(--fs-sm);
  transition: transform var(--t-fast);
}

.skip-link:focus { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
