/* ============================================
   beautiBlog — Base Theme
   统一品牌级设计变量 & 基础排版
   每篇文章在此基础上叠加个性样式
   ============================================ */

/* --- Design Tokens --- */
:root {
  /* 品牌色系 */
  --color-primary: #2d3436;
  --color-primary-light: #636e72;
  --color-accent: #6c5ce7;
  --color-accent-light: #a29bfe;
  --color-accent-subtle: rgba(108, 92, 231, 0.08);

  /* 文字层级 */
  --color-text: #1a1a2e;
  --color-text-secondary: #4a4a68;
  --color-text-tertiary: #8888a0;
  --color-text-inverse: #fafafa;

  /* 背景 */
  --color-bg: #fefefe;
  --color-bg-secondary: #f8f9fa;
  --color-bg-tertiary: #f1f3f4;
  --color-bg-elevated: #ffffff;

  /* 边框 & 分隔 */
  --color-border: #e8e8ee;
  --color-border-light: #f0f0f5;
  --color-divider: #eaeaf0;

  /* 字体栈 */
  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont,
    'Segoe UI', sans-serif;
  --font-serif: 'Noto Serif SC', 'Source Serif Pro', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  --font-display: 'Inter', var(--font-sans);

  /* 字号 */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1.0625rem;
  --text-lg: 1.1875rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;
  --text-4xl: 3rem;
  --text-5xl: 4rem;

  /* 行高 */
  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.7;
  --leading-relaxed: 1.85;

  /* 间距 */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;
  --space-3xl: 6rem;
  --space-4xl: 10rem;

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

  /* 阴影 */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.12), 0 8px 20px rgba(0, 0, 0, 0.06);

  /* 过渡 */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 200ms;
  --duration-normal: 400ms;
  --duration-slow: 700ms;

  /* 布局 */
  --content-width: 720px;
  --wide-width: 960px;
  --full-width: 1200px;
  --side-padding: clamp(1rem, 5vw, 3rem);
}

/* --- 暗色模式 --- */
@media (prefers-color-scheme: dark) {
  :root {
    --color-text: #e8e8f0;
    --color-text-secondary: #a0a0b8;
    --color-text-tertiary: #6a6a80;
    --color-text-inverse: #1a1a2e;

    --color-bg: #0f0f1a;
    --color-bg-secondary: #161625;
    --color-bg-tertiary: #1e1e30;
    --color-bg-elevated: #1a1a2e;

    --color-border: #2a2a40;
    --color-border-light: #222238;
    --color-divider: #252540;

    --color-accent: #a29bfe;
    --color-accent-light: #6c5ce7;
    --color-accent-subtle: rgba(162, 155, 254, 0.1);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.5);
  }
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  overflow-x: hidden;
}

/* --- 排版 --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  color: var(--color-text);
  letter-spacing: -0.02em;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }

p {
  margin-bottom: var(--space-lg);
  line-height: var(--leading-normal);
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

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

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

/* --- 代码块 --- */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-bg-tertiary);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
}

pre {
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  overflow-x: auto;
  margin-bottom: var(--space-xl);
  border: 1px solid var(--color-border-light);
}

pre code {
  background: none;
  padding: 0;
  font-size: var(--text-sm);
  line-height: 1.6;
}

/* --- 引用 --- */
blockquote {
  border-left: 3px solid var(--color-accent);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-xl) 0;
  background: var(--color-accent-subtle);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-style: italic;
  color: var(--color-text-secondary);
}

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

/* --- 列表 --- */
ul, ol {
  padding-left: var(--space-lg);
  margin-bottom: var(--space-lg);
}

li {
  margin-bottom: var(--space-sm);
  line-height: var(--leading-normal);
}

/* --- 分隔线 --- */
hr {
  border: none;
  height: 1px;
  background: var(--color-divider);
  margin: var(--space-2xl) 0;
}

/* --- 选中样式 --- */
::selection {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

/* ============================================
   滚动动画基础类
   配合 Intersection Observer 使用
   ============================================ */

/* 淡入上浮 */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* 左侧滑入 */
.reveal-left {
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.reveal-left.visible {
  opacity: 1;
  transform: translateX(0);
}

/* 右侧滑入 */
.reveal-right {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.reveal-right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* 缩放淡入 */
.reveal-scale {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.reveal-scale.visible {
  opacity: 1;
  transform: scale(1);
}

/* 延迟递增（用于列表/网格项） */
.reveal-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}

.reveal-stagger.visible > *:nth-child(1) { transition-delay: 0ms; opacity: 1; transform: translateY(0); }
.reveal-stagger.visible > *:nth-child(2) { transition-delay: 80ms; opacity: 1; transform: translateY(0); }
.reveal-stagger.visible > *:nth-child(3) { transition-delay: 160ms; opacity: 1; transform: translateY(0); }
.reveal-stagger.visible > *:nth-child(4) { transition-delay: 240ms; opacity: 1; transform: translateY(0); }
.reveal-stagger.visible > *:nth-child(5) { transition-delay: 320ms; opacity: 1; transform: translateY(0); }
.reveal-stagger.visible > *:nth-child(6) { transition-delay: 400ms; opacity: 1; transform: translateY(0); }
