/* ============================================================
   全球文明史门户网站 — base.css
   基础样式：CSS Reset、自定义属性、排版、工具类、响应式断点
   ============================================================ */

/* ---------- Google Fonts 导入 ---------- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&family=Noto+Serif+SC:wght@400;500;700&display=swap');

/* ============================================================
   CSS Reset
   ============================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

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

img {
  height: auto;
  vertical-align: middle;
}

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

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

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* ============================================================
   CSS 自定义属性 — 基础变量
   ============================================================ */

:root {
  /* ---- 颜色 ---- */
  --color-bg:             #F4EDDD;
  --color-card-bg:        #FAF5E6;
  --color-card-hover-bg:  #FFFEF7;
  --color-text-primary:   #2C1810;
  --color-text-secondary: #665544;
  --color-text-tertiary:  #998877;
  --color-text-muted:     #BBAA99;
  --color-border:         #D9CFBE;
  --color-white:          #FFFFFF;
  --color-black:          #1A0E08;
  --color-footer-bg:      #2C1810;
  --color-footer-text:    #C4B5A5;

  /* ---- 排版 ---- */
  --font-heading: 'Noto Serif SC', 'SimSun', 'STSong', serif;
  --font-body:    'Noto Sans SC', 'Microsoft YaHei', 'PingFang SC', sans-serif;

  --font-size-xs:   12px;
  --font-size-sm:   13px;
  --font-size-base: 15px;
  --font-size-md:   16px;
  --font-size-lg:   18px;
  --font-size-xl:   22px;
  --font-size-2xl:  32px;
  --font-size-3xl:  40px;

  --line-height-body:   1.8;
  --line-height-heading: 1.35;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-bold:   700;

  /* ---- 间距 ---- */
  --spacing-xs:  4px;
  --spacing-sm:  8px;
  --spacing-md:  16px;
  --spacing-lg:  24px;
  --spacing-xl:  32px;
  --spacing-2xl: 48px;
  --spacing-3xl: 64px;

  /* ---- 布局 ---- */
  --max-content-width: 1344px;
  --padding-desktop:   48px;
  --padding-tablet:    24px;
  --padding-mobile:    16px;

  --header-height: 72px;

  /* ---- 圆角 ---- */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   16px;
  --radius-full: 9999px;

  /* ---- 阴影 ---- */
  --shadow-sm:   0 1px 3px rgba(44, 24, 16, 0.06);
  --shadow-md:   0 4px 12px rgba(44, 24, 16, 0.08);
  --shadow-lg:   0 8px 24px rgba(44, 24, 16, 0.12);
  --shadow-xl:   0 16px 48px rgba(44, 24, 16, 0.15);

  /* ---- 过渡 ---- */
  --transition-base: 0.3s ease;

  /* ---- 默认主题色 (中文) ---- */
  --accent:        #9D2933;
  --accent-dark:   #6B1E22;
  --tag-bg:        #F0E8D8;
  --tag-text:      #9D2933;
  --gradient-from: #9D2933;
  --gradient-to:   #C23E45;
}

/* ============================================================
   排版
   ============================================================ */

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-body);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  position: relative;
}

/* ============================================================
   页面大背景图 — .page-background
   固定定位，顶部展示文明风格元素，中下部渐变透明
   ============================================================ */
.page-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  background-image: var(--page-bg-image, none);
  background-size: cover;
  background-position: top center;
  background-repeat: no-repeat;
  opacity: 0.82;

  /* 顶部完全可见 → 中部渐隐 → 底部完全透明 */
  -webkit-mask-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 0.95) 25%,
    rgba(0, 0, 0, 0.6) 45%,
    rgba(0, 0, 0, 0.25) 62%,
    rgba(0, 0, 0, 0.05) 75%,
    rgba(0, 0, 0, 0) 85%
  );
  mask-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 0.95) 25%,
    rgba(0, 0, 0, 0.6) 45%,
    rgba(0, 0, 0, 0.25) 62%,
    rgba(0, 0, 0, 0.05) 75%,
    rgba(0, 0, 0, 0) 85%
  );
}

/* 确保 main 内容在背景图之上 */
.site-header,
main,
footer {
  position: relative;
  z-index: 1;
}

/* 平板端：背景图适度降低不透明度 */
@media (max-width: 1024px) {
  .page-background {
    opacity: 0.75;
  }
}

/* 手机端：进一步降低，避免干扰内容 */
@media (max-width: 768px) {
  .page-background {
    opacity: 0.6;
    -webkit-mask-image: linear-gradient(
      to bottom,
      rgba(0, 0, 0, 1) 0%,
      rgba(0, 0, 0, 0.7) 20%,
      rgba(0, 0, 0, 0.3) 40%,
      rgba(0, 0, 0, 0) 60%
    );
    mask-image: linear-gradient(
      to bottom,
      rgba(0, 0, 0, 1) 0%,
      rgba(0, 0, 0, 0.7) 20%,
      rgba(0, 0, 0, 0.3) 40%,
      rgba(0, 0, 0, 0) 60%
    );
  }
}

/* ---- 标题 ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-heading);
  color: var(--color-text-primary);
}

h1 {
  font-size: var(--font-size-2xl);
  letter-spacing: 0.02em;
}

h2 {
  font-size: var(--font-size-xl);
  letter-spacing: 0.01em;
}

h3 {
  font-size: var(--font-size-lg);
}

h4 {
  font-size: var(--font-size-md);
}

/* ---- 段落 ---- */
p {
  margin-bottom: 1.2em;
}

p:last-child {
  margin-bottom: 0;
}

/* ---- 链接 ---- */
a {
  color: var(--accent);
  transition: color var(--transition-base);
}

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

/* ---- 引用 ---- */
blockquote {
  margin: var(--spacing-lg) 0;
  padding: var(--spacing-md) var(--spacing-lg);
  border-left: 3px solid var(--accent);
  background-color: rgba(157, 41, 51, 0.04);
  font-family: var(--font-heading);
  font-style: italic;
  color: var(--color-text-secondary);
}

/* ---- 列表 ---- */
ul:not([class]),
ol:not([class]) {
  padding-left: 1.5em;
  margin-bottom: 1em;
}

ul:not([class]) {
  list-style: disc;
}

ol:not([class]) {
  list-style: decimal;
}

/* ---- 分割线 ---- */
hr {
  border: none;
  height: 1px;
  background-color: var(--color-border);
  margin: var(--spacing-xl) 0;
}

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

/* ---- 滚动条 ---- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

/* ---- 焦点轮廓 ---- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   工具类
   ============================================================ */

/* ---- 容器 ---- */
.container {
  width: 100%;
  max-width: var(--max-content-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--padding-desktop);
  padding-right: var(--padding-desktop);
}

/* ---- 屏幕阅读器专用 ---- */
.sr-only,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- 文本截断 ---- */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- 文本对齐 ---- */
.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }

/* ---- 浮动清除 ---- */
.clearfix::after {
  content: '';
  display: table;
  clear: both;
}

/* ---- 弹性布局快捷类 ---- */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap    { flex-wrap: wrap; }

/* ---- 间距快捷类 ---- */
.mt-0  { margin-top: 0; }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }
.mt-2xl { margin-top: var(--spacing-2xl); }

.mb-0  { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }
.mb-2xl { margin-bottom: var(--spacing-2xl); }

/* ---- 隐藏工具 ---- */
.hidden {
  display: none !important;
}

/* ---- 粘性元素 ---- */
.sticky {
  position: -webkit-sticky;
  position: sticky;
  top: calc(var(--header-height) + var(--spacing-lg));
}

/* ============================================================
   响应式断点
   ============================================================ */

/* 平板 (≤1024px) */
@media (max-width: 1024px) {
  :root {
    --padding-desktop: var(--padding-tablet);
  }

  .container {
    padding-left: var(--padding-tablet);
    padding-right: var(--padding-tablet);
  }

  h1 { font-size: 28px; }
  h2 { font-size: 20px; }
  h3 { font-size: 17px; }
}

/* 手机 (≤768px) */
@media (max-width: 768px) {
  :root {
    --padding-desktop: var(--padding-mobile);
    --font-size-base: 14px;
  }

  .container {
    padding-left: var(--padding-mobile);
    padding-right: var(--padding-mobile);
  }

  h1 { font-size: 24px; }
  h2 { font-size: 19px; }
  h3 { font-size: 17px; }

  .sticky {
    position: relative;
    top: auto;
  }
}

/* 小手机 (≤480px) */
@media (max-width: 480px) {
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
}
