/*
 * Createc · 基线 (base.css)
 * reset、排版基线、焦点环、选区、页面转场、reduced-motion 降级、.sr-only、.skip
 */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
  scrollbar-gutter: stable;           /* 锁滚动时不跳动；请勿使用 100vw 做宽度 */
  background: var(--paper);
}
html.is-locked { overflow: hidden; }

body {
  margin: 0;
  padding-top: var(--nav-h);          /* 固定导航占位 */
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  font-synthesis: none;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd, ul, ol, pre, hr { margin: 0; }
ul, ol { padding: 0; list-style: none; }

img, svg, video, canvas, picture { display: block; max-width: 100%; }
img, video { height: auto; }
img { font-style: italic; }          /* alt 文本回退时可辨 */

a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; }

table { border-collapse: collapse; border-spacing: 0; }
hr { border: 0; }
summary { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- 排版基线 ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: var(--fw-black);
  text-wrap: balance;
}
h1, .h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); letter-spacing: var(--ls-tight); font-weight: var(--fw-black); }
h2, .h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); letter-spacing: var(--ls-tight); font-weight: var(--fw-black); }
h3, .h3 { font-size: var(--fs-h3); line-height: var(--lh-snug); letter-spacing: -.01em; font-weight: var(--fw-bold); }
h4, .h4 { font-size: var(--fs-lg); line-height: var(--lh-snug); font-weight: var(--fw-bold); }
.h1, .h2, .h3, .h4 { font-family: var(--font-display); text-wrap: balance; }

p { text-wrap: pretty; }
.lede { font-size: var(--fs-lg); line-height: 1.65; color: var(--fg-2, var(--ink-2)); max-width: 46em; }
.small { font-size: var(--fs-sm); line-height: 1.6; }
.muted { color: var(--fg-mute, var(--mute-ink)); }

/* mono 元信息：编号 / 标签 / 参数 */
.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  font-weight: var(--fw-regular);
  letter-spacing: var(--ls-mono);
  text-transform: uppercase;
  line-height: 1.5;
}
.mono--lg { font-size: var(--fs-mono-lg); }

/* 英文/数字大字（Barlow Condensed） */
.num {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-display);
  line-height: .9;
  letter-spacing: -.02em;
  font-variant-numeric: lining-nums;
}

strong, b { font-weight: var(--fw-bold); }
code, kbd, samp { font-family: var(--font-mono); font-size: .92em; }
::placeholder { color: var(--mute-ink); opacity: 1; }

/* ---------- 焦点 / 选区 ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------- 页面转场（跨文档 View Transitions，不支持则无感降级） ---------- */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 260ms;
  animation-timing-function: var(--ease);
}

/* ---------- 无障碍 ---------- */
.nowrap { white-space: nowrap; }   /* 中文标题要控制断行：<span class="nowrap">一站式搞定</span> 或 <br> */

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: var(--z-skip);
  padding: 12px 18px;
  background: var(--ink);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: var(--fs-mono-lg);
  letter-spacing: var(--ls-mono);
  transform: translateY(-200%);
  transition: transform var(--dur-fast) var(--ease);
}
.skip:focus,
.skip:focus-visible { transform: none; outline-offset: 2px; }

/* ---------- 减弱动效：全局降级 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: .001ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }

  @view-transition { navigation: none; }
}
