/**
 * base.css —— 第 3 层：重置、排版基线、可访问性工具
 * 规则：本文件及以下组件层只允许引用 style.css 第 2 层语义 token，禁止裸色值。
 */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* 头部是 sticky：锚点跳转留出高度，避免标题被盖住 */
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* 阿语等 RTL 语言由 <html dir="rtl"> 驱动，这里不写死方向 */
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--s-3);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }

p { margin: 0 0 var(--s-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--text-brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--accent-brand-hover); }

img, svg, video { max-width: 100%; height: auto; display: block; }
img { background-color: var(--bg-inset); }   /* 图未加载时的底色，避免白闪 */

ul, ol { margin: 0 0 var(--s-4); padding-inline-start: 1.25em; }
li + li { margin-top: var(--s-1); }

hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: var(--s-6) 0;
}

blockquote {
  margin: var(--s-5) 0;
  padding-inline-start: var(--s-4);
  border-inline-start: 3px solid var(--accent-brand);
  color: var(--text-secondary);
}

code, pre, kbd { font-family: var(--font-mono); font-size: .9em; }

table { border-collapse: collapse; width: 100%; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* ---- 焦点环：任何底色上都可见，键盘操作用 ---- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}
:focus:not(:focus-visible) { outline: none; }

/* ---- 无障碍工具类 ---- */
.sr-only {  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  inset-block-start: -100px;
  inset-inline-start: var(--s-4);
  z-index: var(--z-skip);
  padding: var(--s-3) var(--s-4);
  background: var(--text-primary);
  color: var(--text-inverse);
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: inset-block-start var(--dur) var(--ease);
}
.skip-link:focus-visible { inset-block-start: var(--s-4); }

/* 屏幕阅读器友好的当前页标记 */
[aria-current="page"] { font-weight: 600; }

/* RTL 下图标（箭头类）自动翻转；带 .no-flip 的除外 */
[dir="rtl"] .ico--flip { transform: scaleX(-1); }

/* 数字/代码在 RTL 段落里保持 LTR 排列 */
bdi, [dir="ltr"] { unicode-bidi: isolate; }

/* 减少动态偏好：全站关掉过渡与动画（motion.css 里还有 3D 降级） */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* WordPress 核心类：对齐/图注，保持前台不塌 */
.alignleft { float: inline-start; margin: 0 var(--s-4) var(--s-4) 0; }
.alignright { float: inline-end; margin: 0 0 var(--s-4) var(--s-4); }
.aligncenter { margin-inline: auto; }
.wp-caption { max-width: 100%; }
.wp-caption-text, .wp-block-image figcaption {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: var(--s-2);
}
.sticky, .bypostauthor, .screen-reader-text { /* 保留核心类，不做视觉处理 */ }
.screen-reader-text {
  position: absolute !important;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* [hidden] 必须压过组件自身的 display：
   .pcard / .grid 都写了 display，浏览器默认的 [hidden]{display:none}
   优先级不够，前端筛选「隐藏卡片」会失效。 */
[hidden] { display: none !important; }
