/* =========================================================================
 * base.css — 重置 + 基础排版
 * ========================================================================= */

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* 防止 iOS Safari 横向弹性滚动 */
  overscroll-behavior-x: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

/* 通用排版 */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  color: var(--color-ink);
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4, h5, h6 { font-family: var(--font-sans); font-size: var(--fs-body); font-weight: var(--fw-semibold); }

p { margin: 0; }

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--color-line-soft);
  transition: border-color var(--dur-base) var(--ease-out);
}
a:hover { border-bottom-color: var(--color-line); }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: transparent;
  padding: 0;
}

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

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

/* SVG 图标尺寸约束（防止裸 SVG 撑爆布局） */
svg {
  flex-shrink: 0;
  /* 没有 width/height 属性的 svg 默认走 viewBox 比例，这里兜底约束 */
  max-width: 100%;
  max-height: 100%;
}
/* 显式图标容器约束 */
.icon-btn svg,
.btn svg,
.btn__icon,
.sidenav__icon,
.accordion-chevron,
.entry-card__icon,
.empty__icon,
.toast__icon,
.chip__remove svg,
.gen-nav__chevron,
.detail-section__num + svg,
.tabs__item svg {
  width: auto;
  height: auto;
  max-width: 24px;
  max-height: 24px;
}
/* 极端兜底：所有 svg 不允许超过 64px（除非显式覆盖） */
svg:not([width]):not([height]) {
  width: 1em;
  height: 1em;
}

/* 列表重置 */
ul, ol { list-style: none; margin: 0; padding: 0; }

/* 滚动条（细、克制） */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-line-medium); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--color-line); }

/* 文本选中 */
::selection {
  background: var(--color-ink);
  color: var(--color-bg);
}

/* 隐藏但保留可访问性 */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 数字编号样式（EDITORIAL 风） */
.num-tag {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  color: var(--color-ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* 通用分隔 */
.divider {
  border: 0;
  border-top: var(--border-thin);
  margin: var(--space-8) 0;
}
.divider--strong { border-top: 2px solid var(--color-line); }

/* 文本省略 */
.ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 两行省略 */
.ellipsis-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* flex/grid 工具类 */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* 文本工具 */
.text-center { text-align: center; }
.text-muted { color: var(--color-ink-muted); }
.text-soft { color: var(--color-ink-soft); }
.font-serif { font-family: var(--font-serif); }
.font-mono { font-family: var(--font-mono); }
.uppercase { text-transform: uppercase; letter-spacing: 0.08em; }

/* 移动端 tap 高亮禁用（避免灰色背景闪烁） */
* {
  -webkit-tap-highlight-color: transparent;
}
