/* ==========================================================================
   base.css — reset, typography, layout primitives
   零字面量：色值 / 间距 / 字号 / 圆角 / 边框 / 阴影一律取 tokens.css 变量
   唯三例外（design-spec §12.0）：Grid 列数整数、组件 min-height、媒体查询断点值
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--color-bg-page);
  color: var(--color-text-body);
  font-family: var(--font-family-base);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  scroll-behavior: smooth;
}

body {
  margin: var(--space-0);
  background: var(--color-bg-page);
  color: var(--color-text-body);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
ul,
ol,
dl,
figure,
blockquote,
pre {
  margin: var(--space-0);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--color-text-heading);
  font-weight: var(--font-weight-bold);
  text-wrap: balance;
}

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

h2 {
  font-size: var(--font-size-h2);
  line-height: var(--line-height-heading);
  letter-spacing: var(--letter-spacing-snug);
}

h3 {
  font-size: var(--font-size-h3);
  line-height: var(--line-height-subheading);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-snug);
}

h4 {
  font-size: var(--font-size-h4);
  line-height: var(--line-height-subheading);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-normal);
}

p {
  max-width: var(--container-prose);
}

ul,
ol {
  padding-inline-start: var(--space-6);
}

li + li {
  margin-top: var(--space-2);
}

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: var(--space-1);
  transition: color var(--transition-base) var(--transition-easing);
}

a:hover {
  color: var(--color-primary-hover);
}

strong,
b {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-heading);
}

small {
  font-size: var(--font-size-small);
  line-height: var(--line-height-caption);
}

code,
kbd,
samp,
pre {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-caption);
}

hr {
  border: 0;
  border-top: var(--border-width-thin) solid var(--color-border);
  margin-block: var(--space-8);
}

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

img {
  height: auto;
}

figure {
  margin: var(--space-0);
}

figcaption {
  margin-top: var(--space-2);
  font-size: var(--font-size-caption);
  line-height: var(--line-height-caption);
  color: var(--color-text-helper);
}

/* --------------------------------------------------------------------------
   Focus — 全站统一 3px 主色环 + 2px offset（design-spec §6.0）
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-focus-ring);
  outline-offset: var(--focus-ring-offset);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-focus-ring);
  outline-offset: var(--focus-ring-offset);
}

/* --------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--page-padding);
}

.container--wide {
  max-width: var(--container-wide);
}

.container--prose {
  max-width: var(--container-prose);
  margin-inline: auto;
  padding-inline: var(--page-padding);
}

.section {
  padding-block: var(--section-gap);
}

.section--subtle {
  background: var(--color-bg-subtle);
}

.section--tight {
  padding-block: var(--space-12);
}

.section__head {
  margin-bottom: var(--space-8);
}

.section__head p {
  margin-top: var(--space-4);
  font-size: var(--font-size-body-lg);
  line-height: var(--line-height-body);
  color: var(--color-text-secondary);
}

.eyebrow {
  display: block;
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-3);
}

.lead {
  font-size: var(--font-size-body-lg);
  line-height: var(--line-height-body);
  color: var(--color-text-secondary);
  max-width: var(--container-prose);
}

.prose > * + * {
  margin-top: var(--space-4);
}

.prose h2 {
  margin-top: var(--space-10);
}

.prose h3 {
  margin-top: var(--space-8);
}

.prose ul,
.prose ol {
  color: var(--color-text-body);
}

.stack > * + * {
  margin-top: var(--space-4);
}

.stack--loose > * + * {
  margin-top: var(--space-6);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.mono {
  font-family: var(--font-family-mono);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-normal);
}

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

.text-secondary {
  color: var(--color-text-secondary);
}

.visually-hidden {
  position: absolute;
  width: var(--border-width-thin);
  height: var(--border-width-thin);
  padding: var(--space-0);
  margin: calc(-1 * var(--border-width-thin));
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-skip);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-surface);
  color: var(--color-primary);
  font-weight: var(--font-weight-semibold);
  border: var(--border-width-input) solid var(--color-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transform: translateY(calc(-1 * var(--space-32)));
}

.skip-link:focus {
  transform: translateY(var(--space-0));
}

/* --------------------------------------------------------------------------
   Responsive helpers（断点与 tokens.css 的变量覆盖块分离，见 design-spec §8.1）
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  .md-up\:hidden {
    display: none;
  }
}

@media (max-width: 767px) {
  .md-down\:hidden {
    display: none;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0ms;
    animation-iteration-count: 1;
    transition-duration: 0ms;
  }
}
