/* ============================================================
   base.css —— reset / 排版 / 字体 / 容器 / 通用布局
   ============================================================ */

/* ---------- 阿姆哈拉语子集字体 ----------
   unicode-range 限定在 Ethiopic 区段：EN 页面永不触发下载（弱网优化）。
   字体文件由 tools/font-subset.sh 生成后放入 assets/fonts/；
   缺失时浏览器自动回退系统字体，不影响可用性。 */
@font-face {
  font-family: 'Noto Sans Ethiopic Subset';
  src: url('../assets/fonts/noto-sans-ethiopic-subset.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+1200-137F, U+1380-139F, U+2D80-2DDF, U+AB00-AB2F;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html[lang='am'] body {
  font-family: 'Noto Sans Ethiopic Subset', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 底部安全区（刘海屏 / 手势条） */
body {
  padding-bottom: var(--safe-bottom);
}

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--sp-3);
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h1 {
  font-size: var(--fs-2xl);
}
h2 {
  font-size: var(--fs-lg);
}
h3 {
  font-size: var(--fs-md);
}

p {
  margin: 0 0 var(--sp-3);
}

a {
  color: var(--c-brand);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

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

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* 键盘可达性：焦点环 */
:focus-visible {
  outline: 2px solid var(--c-brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------- 容器 ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding-left: calc(var(--sp-4) + var(--safe-left));
  padding-right: calc(var(--sp-4) + var(--safe-right));
}

.page {
  min-height: 60vh;
  padding-top: var(--sp-6);
  padding-bottom: var(--sp-12);
}

/* ---------- 排版工具 ---------- */
.muted {
  color: var(--c-text-3);
}
.small {
  font-size: var(--fs-sm);
}
.strong {
  font-weight: 700;
}
.nowrap {
  white-space: nowrap;
}
.center {
  text-align: center;
}
.hidden {
  display: none !important;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.wrap {
  flex-wrap: wrap;
}
.grow {
  flex: 1 1 auto;
  min-width: 0;
}

/* 屏幕阅读器专用 */
.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;
}

/* ---------- 骨架屏动画（样式内联在 CSP 白名单内） ---------- */
@keyframes egp-pulse {
  0% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.55;
  }
}
@keyframes egp-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes egp-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
