/* ==========================================================================
   缘梦 YuanMoon · 基础层
   字体声明、重置、排版基线、焦点与降级动效。
   ========================================================================== */

/* --------------------------------------------------------------------------
   自托管展示字（latin 子集，共约 92KB）
   刻意不走 Google Fonts —— 国内访问 Google Fonts 不稳定，
   字体是首屏渲染的关键路径，必须握在自己手里。
   -------------------------------------------------------------------------- */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/cormorant-garamond-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../assets/fonts/cormorant-garamond-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../assets/fonts/cormorant-garamond-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/cormorant-garamond-latin-400-italic.woff2") format("woff2");
}

/* ============================== 重置 ==================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body,
h1, h2, h3, h4,
p, figure, blockquote,
dl, dd,
ul, ol {
  margin: 0;
}

ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

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

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

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

/* ============================== 排版基线 ================================ */
html,
body {
  height: 100%;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.75;
  letter-spacing: 0.015em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  /* 首屏以外的地方不晃眼：底部略压暗，模拟望向深空的渐隐 */
  background-image: linear-gradient(180deg, var(--ink-950) 0%, var(--ink-900) 42%, var(--ink-950) 100%);
}

/* 中文标题用宋体栈时，笔画细，需要多给一点行高与字距才不显局促 */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 { font-size: var(--fs-display); }
h2 { font-size: var(--fs-section); }
h3 { font-size: var(--fs-lg); line-height: 1.25; }

p {
  /* 中文正文行长控制在 28–40 字 */
  max-width: 40em;
  text-wrap: pretty;
}

/* 拉丁小节标签：等宽 + 大字距，像观测记录上的字段名 */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--color-muted);
}

/* 展示字里的拉丁部分单独放大、收字距，让 "YuanMoon" 站得住 */
.display-latin {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.03em;
  font-feature-settings: "liga" 1, "kern" 1;
}

/* ============================== 焦点与选中 ============================== */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

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

/* ============================== 行内代码 ================================
   正文里提到文件名、命令这类东西时用 <code>。不加样式的话浏览器会
   给它默认等宽体，在深空底上和一整套衬线正文打架。 */
code {
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--moon-300) 12%, transparent);
  font-family: var(--font-mono);
  font-size: 0.86em;
  letter-spacing: 0.02em;
  color: var(--color-accent);
  word-break: break-all;
}

/* ============================== 滚动条 ================================== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--ink-950);
}
::-webkit-scrollbar-thumb {
  background: var(--ink-600);
  border-radius: var(--radius-full);
  border: 2px solid var(--ink-950);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ink-500);
}

/* ========================= 视觉隐藏（仅屏幕阅读器） ===================== */
.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;
}

/* ============================== 跳转链接 ================================ */
.skip-link {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 999;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  transform: translateY(-200%);
  transition: transform var(--dur-fast) var(--ease-out);
}
.skip-link:focus-visible {
  transform: translateY(0);
}

/* ======================================================================
   降级：用户要求减少动效时，关掉一切动画与过渡。
   这不是可选项 —— 前庭功能敏感的用户会因视差和脉动产生不适。
   ====================================================================== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
