/* ==========================================================
   xmgzxmgz.github.io — base.css
   设计令牌 · 复位 · 全局骨架 · 明暗双主题
   零外部依赖：不使用任何 Web Font，全部走系统字体栈
   ========================================================== */

/* ---------- 亮色令牌（默认） ---------- */
:root {
  color-scheme: light;

  --paper:       #f7f4ee;
  --surface:     #fffdf9;
  --surface-2:   #efeae0;
  --ink:         #23211d;
  --ink-2:       #57513f;
  --ink-3:       #6d6457;
  --rule:        #e4ddcf;
  --rule-strong: #d3c9b6;

  --accent:      #b8483a;
  --accent-ink:  #96382c;
  --accent-wash: rgba(184, 72, 58, .09);
  --moss:        #47634f;
  --moss-wash:   rgba(71, 99, 79, .11);
  --indigo:      #3d5a80;
  --sakura:      #e8a3b6;
  --sakura-wash: rgba(232, 163, 182, .18);

  --shadow-sm: 0 1px 2px rgba(35, 33, 29, .05), 0 2px 8px rgba(35, 33, 29, .04);
  --shadow-md: 0 8px 26px rgba(35, 33, 29, .09);
  --shadow-lg: 0 20px 54px rgba(35, 33, 29, .14);

  --radius:    16px;
  --radius-sm: 10px;
  --maxw:      980px;
  --gutter:    24px;
  --header-h:  60px;

  --serif: "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif SC",
           "Noto Serif CJK SC", Georgia, "Times New Roman", serif;
  --sans:  -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
           "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --mono:  "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- 暗色令牌 ---------- */
[data-theme="dark"] {
  color-scheme: dark;

  --paper:       #14130f;
  --surface:     #1c1a15;
  --surface-2:   #252118;
  --ink:         #ece7dc;
  --ink-2:       #b7ae9e;
  --ink-3:       #8d8475;
  --rule:        #2f2a21;
  --rule-strong: #443d30;

  --accent:      #e2745f;
  --accent-ink:  #f0907c;
  --accent-wash: rgba(226, 116, 95, .14);
  --moss:        #8fb39b;
  --moss-wash:   rgba(143, 179, 155, .13);
  --indigo:      #8fadd6;
  --sakura:      #e8a3b6;
  --sakura-wash: rgba(232, 163, 182, .13);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 10px rgba(0, 0, 0, .3);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, .55);
}

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

html {
  scroll-behavior: smooth;
  /* 锚点定位时留出吸顶导航的高度 */
  scroll-padding-top: calc(var(--header-h) + 20px);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.8;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: background-color .3s ease, color .3s ease;
}

/* 极淡的双色晕染，替代原先的固定背景 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 12% 0%, var(--sakura-wash), transparent 70%),
    radial-gradient(ellipse 50% 40% at 88% 12%, var(--moss-wash), transparent 70%);
}

img, svg { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; transition: color .2s ease; }
a:hover { color: var(--accent-ink); }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* 焦点可见性：键盘导航必须看得见 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection { background: var(--accent-wash); color: var(--ink); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* ---------- 跳转链接（无障碍） ---------- */
.skip-link {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -120%);
  z-index: 200;
  padding: 10px 20px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 0 0 8px 8px;
  font-size: 13px;
  transition: transform .2s ease;
}
.skip-link:focus { transform: translate(-50%, 0); color: var(--paper); }

/* ---------- 布局容器 ---------- */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- 吸顶导航 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease, background-color .3s ease;
}
/* 不支持 color-mix 时的兜底 */
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .site-header { background: var(--paper); }
}
.site-header.is-stuck {
  border-bottom-color: var(--rule);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--ink);
  white-space: nowrap;
}
.brand:hover { color: var(--accent); }
.brand .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.nav a {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-2);
  letter-spacing: .3px;
  transition: color .2s ease, background-color .2s ease;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a.is-active { color: var(--accent); }

.theme-toggle {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1;
  margin-left: 8px;
  flex-shrink: 0;
  transition: border-color .2s ease, color .2s ease, transform .2s ease;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: rotate(-12deg);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .4px;
  border: 1px solid transparent;
  transition: transform .2s ease, background-color .2s ease,
              border-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.btn:active { transform: translateY(0) scale(.985); }

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(184, 72, 58, .22);
}
.btn--primary:hover {
  background: var(--accent-ink);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(184, 72, 58, .3);
}
/* 暗色下 accent 变浅（适合正文链接），但白字压浅红对比度只有 2.5:1，
   主按钮单独用更深一档的红，保持白字与 4.9:1 对比度 */
[data-theme="dark"] .btn--primary {
  background: #c24632;
  color: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .35);
}
[data-theme="dark"] .btn--primary:hover {
  background: #b8483a;
  color: #fff;
}

.btn--ghost {
  border-color: var(--rule-strong);
  color: var(--ink-2);
  background: var(--surface);
}
.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.7;
  letter-spacing: .2px;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag--accent { background: var(--accent-wash); color: var(--accent); }
.tag--live   { background: var(--moss-wash);   color: var(--moss); }

/* ---------- 区块标题 ---------- */
.section { padding: 64px 0; }
.section + .section { border-top: 1px solid var(--rule); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.section-title {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 1.5px;
  line-height: 1.4;
}
.section-title .idx {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-3);
  letter-spacing: 0;
  margin-right: 10px;
  vertical-align: 3px;
}
.section-sub {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 2px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 44px 0 52px;
  text-align: center;
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: .4px;
}
.site-footer .sigil {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink-2);
  letter-spacing: 3px;
  margin-bottom: 10px;
}
.site-footer .quote {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: 18px;
  letter-spacing: 1px;
}
.site-footer .meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.site-footer .meta a { color: var(--ink-3); }
.site-footer .meta a:hover { color: var(--accent); }
.site-footer .sep { opacity: .45; }

/* ---------- 滚动进场 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .6s cubic-bezier(.2, .7, .3, 1),
              transform .6s cubic-bezier(.2, .7, .3, 1);
  will-change: opacity, transform;
}
.reveal.is-visible { opacity: 1; transform: none; }

/* 尊重系统的减少动效设置 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- 小屏 ---------- */
@media (max-width: 720px) {
  :root { --gutter: 18px; }
  body { font-size: 14.5px; }
  .nav a { padding: 6px 8px; font-size: 12.5px; }
  .brand { font-size: 15px; }
  .section { padding: 48px 0; }
  .section-title { font-size: 20px; }
  .section-sub { display: none; }
}

@media (max-width: 420px) {
  .nav a[data-optional] { display: none; }
}

/* ---------- 打印 ---------- */
@media print {
  .site-header, .theme-toggle, .skip-link, .site-footer .meta { display: none; }
  body { background: #fff; color: #000; }
  body::before { display: none; }
  a { color: #000; text-decoration: underline; }
}
