/**
 * 「松烟」基础样式 (Base Styles)
 * 包含通用 Reset、全局排版规范、打印样式与无障碍降级
 */

@import "./tokens.css";

/* 基础盒模型与排版重置 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 100%;
  line-height: var(--leading-body);
  background-color: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  color-scheme: light;
}

body {
  min-height: 100vh;
  font-family: var(--font-serif);
  background-color: var(--paper);
  background-image: var(--paper-texture);
  background-repeat: repeat;
  color: var(--ink);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* 链接规范：烟青墨色，悬停转浓；朱砂留给每屏唯一的一点 */
a {
  color: var(--celadon-deep);
  text-decoration: none;
  transition: color var(--dur-feedback) var(--ease-ink), border-color var(--dur-feedback) var(--ease-ink), background-size var(--dur-feedback) var(--ease-ink);
}

a:hover, a:focus-visible {
  color: var(--ink);
}

a:focus-visible,
button:focus-visible {
  /* 焦点环须满足 WCAG 2.2 SC 1.4.11 非文本对比 ≥ 3:1：
     --ochre 2.77:1 不达标，改用朱砂悬停色 7.47:1，与站点色系同源 */
  outline: 2px solid var(--celadon-deep);
  outline-offset: 2px;
}

::-moz-selection {
  background: var(--line);
  color: var(--ink);
}

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

/* 标题规范（默认选用文楷/宋体） */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-title);
  color: var(--ink);
  line-height: var(--leading-title);
  font-weight: 400;
  letter-spacing: var(--tracking-title);
  text-wrap: balance;
}

h1 { font-size: var(--text-page-title); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5, h6 { font-size: var(--text-body); font-weight: 600; }

p {
  margin-bottom: var(--space-4);
  line-height: var(--leading-body);
}

/* 强调与引用 */
em, i {
  font-style: normal;
  color: var(--ink-light);
}

strong, b {
  font-weight: 700;
  color: var(--ink);
}

blockquote {
  margin: var(--space-8) 0;
  padding: var(--space-1) 0 var(--space-1) var(--space-6);
  border-left: 1px solid transparent;
  -o-border-image: var(--rain-thread-v) 1;
     border-image: var(--rain-thread-v) 1;
  color: var(--ink-light);
  font-family: var(--font-title);
  font-style: normal;
}

hr {
  border: none;
  height: 1px;
  /* 古籍刊本式行气留白：两端透明淡出、中央微显淡墨，严禁灰色实线 */
  background: var(--rain-thread);
  margin: var(--space-12) auto;
  max-width: 50%;
}

ul, ol {
  padding-left: var(--space-6);
  margin-bottom: var(--space-4);
}

li {
  margin-bottom: var(--space-2);
}

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

/* 跳过链接：键盘用户越过页头直达正文 */
.skip-link {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-4);
  transform: translateY(-200%);
  z-index: 101;
  padding: var(--space-2) var(--space-4);
  background: var(--paper);
}

.skip-link:focus {
  transform: none;
}

/* 全站唯一入场动效：「落墨」——只动透明度与位移，交由合成层完成 */
@keyframes luo-mo {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.enter {
  animation: luo-mo var(--dur-enter) var(--ease-ink) both;
}

/* 首页唯一印章盖下：自上轻落、微放即收（400ms，仅一次） */
@keyframes gai-yin {
  from {
    opacity: 0;
    transform: scale(1.35);
  }
  60% {
    opacity: 1;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.seal--stamp {
  animation: gai-yin var(--dur-stamp) var(--ease-ink) 120ms both;
}

/* 场景稳定时保留原生吸附；仅程序过渡与逐列阅读临时让出控制权。 */
html.cover-scroll-enabled:root {
  overflow-anchor: none;
}
html.story-transitioning:root,
html.story-flow:root,
html.ci-columns-locked:root {
  scroll-snap-type: none;
}

/* 尊重减弱动效偏好：动效时长全部经 tokens 归零，入场直接落定 */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-enter: 0.01ms;
    --dur-feedback: 0.01ms;
    --dur-unfold: 0.01ms;
    --dur-stamp: 0.01ms;
  }
  html {
    scroll-behavior: auto;
  }
  .enter,
  .seal--stamp {
    animation: none;
  }
}

/* 打印样式：素白纸面、去除页头页脚与纸纹 */
@media print {
  html,
  body {
    background: var(--print-paper);
    color: var(--print-ink);
  }

  .site-header,
  .site-footer,
  .skip-link {
    display: none;
  }

  .site-main,
  .reading-page .site-main {
    max-width: none;
  }

  a,
  .reading-body a {
    color: var(--print-ink);
    text-decoration: underline;
  }
}


/* 微湿宣纸远光晕：低饱和天青/赭石，不抢正文 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 45% at 12% 18%, var(--paper-glow-celadon), transparent 70%),
    radial-gradient(ellipse 60% 40% at 88% 78%, var(--paper-glow-ochre), transparent 72%);
}
