/* ==========================================================================
   base.css · 重置、排版基线与通用工具
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1.5rem);
}

body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  letter-spacing: var(--ls-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis-weight: none;
}

/* 标题一律衬线、紧字距、字重单一 */
h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: var(--ls-head);
  line-height: var(--lh-snug);
  text-wrap: balance;
  overflow-wrap: break-word;
  min-width: 0;
}

h1 {
  font-size: var(--fs-display);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-display);
}

h2 {
  font-size: var(--fs-3xl);
}

h3 {
  font-size: var(--fs-xl);
  font-weight: 600;
}

p {
  margin: 0;
  overflow-wrap: break-word;
}

a {
  color: inherit;
  text-decoration-color: color-mix(in oklab, var(--accent) 55%, transparent);
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration-color: var(--accent);
}

img,
svg {
  display: block;
  max-width: 100%;
}

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;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

li {
  list-style: none;
}

hr {
  border: 0;
  border-top: var(--border);
  margin: 0;
}

/* ---- 焦点：始终可见、即刻出现 ------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

:focus:not(:focus-visible) {
  outline: none;
}

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

/* ---- 滚动条：与主题同步 ------------------------------------------------ */
:root {
  scrollbar-color: color-mix(in oklab, var(--ink-soft) 60%, var(--bg)) var(--bg);
  scrollbar-width: thin;
}

@supports not (scrollbar-color: auto) {
  :root {
    scrollbar-width: auto;
  }
  ::-webkit-scrollbar {
    width: 12px;
    height: 12px;
  }
  ::-webkit-scrollbar-thumb {
    background: var(--ink-faint);
    border: 3px solid var(--bg);
    border-radius: 999px;
  }
  ::-webkit-scrollbar-track {
    background: var(--bg);
  }
}

/* ---- 布局容器 ---------------------------------------------------------- */
.shell {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---- 正文区块 ---------------------------------------------------------- */
.prose {
  max-width: var(--measure);
  color: var(--ink-soft);
  font-size: var(--fs-md);
}

.prose > * + * {
  margin-top: 1.1em;
}

.prose strong {
  color: var(--ink);
  font-weight: 600;
}

.prose h3 {
  color: var(--ink);
  margin-top: 2.2rem;
  max-width: 34ch;
}

.prose a {
  color: var(--accent);
}

/* ---- 数字：等宽、表格数字 ---------------------------------------------- */
.num,
.readout {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums slashed-zero;
  letter-spacing: var(--ls-mono);
  font-feature-settings: "tnum" 1, "zero" 1;
}

.label {
  font-size: var(--fs-xs);
  line-height: 1.4;
  color: var(--ink-faint);
  letter-spacing: 0;
}

/* ---- 无障碍工具 -------------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 50%;
  top: 0.5rem;
  transform: translate(-50%, -150%);
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--bg);
  font-size: var(--fs-sm);
  text-decoration: none;
}

.skip:focus-visible {
  transform: translate(-50%, 0);
}

[hidden] {
  display: none !important;
}

/* ---- 动效降级：保留颜色变化，去掉位移与缩放 ---------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
