/* ============================================================
   JINER Blog — Design System
   Tokens · Base · Utilities · Shared Components
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  --color-bg: #f6f5fb;
  --color-surface: #ffffff;
  --color-surface-alt: #efedf8;
  --color-primary: #221c3a;
  --color-text: #221c3a;
  --color-text-secondary: #57517a;
  --color-text-muted: #6b6688;
  --color-accent: #6d28d9;
  --color-accent-soft: rgba(109, 40, 217, 0.08);
  --color-border-light: rgba(34, 28, 58, 0.08);
  --color-border: rgba(34, 28, 58, 0.13);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", Consolas,
    "Courier New", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(34, 28, 58, 0.06);
  --shadow-md: 0 8px 24px rgba(34, 28, 58, 0.08);
  --shadow-lg: 0 20px 48px rgba(34, 28, 58, 0.12);

  --nav-height: 60px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --transition: 0.25s var(--ease);
}

[data-theme="dark"] {
  --color-bg: #0f0d1a;
  --color-surface: #181526;
  --color-surface-alt: #221d3a;
  --color-primary: #ece9f7;
  --color-text: #e6e3f2;
  --color-text-secondary: #b1abcd;
  --color-text-muted: #8d87b4;
  --color-accent: #a78bfa;
  --color-accent-soft: rgba(167, 139, 250, 0.12);
  --color-border-light: rgba(230, 227, 242, 0.08);
  --color-border: rgba(230, 227, 242, 0.15);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);
}

/* 无 JS / auto 模式：跟随系统 */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --color-bg: #0f0d1a;
    --color-surface: #181526;
    --color-surface-alt: #221d3a;
    --color-primary: #ece9f7;
    --color-text: #e6e3f2;
    --color-text-secondary: #b1abcd;
    --color-text-muted: #8d87b4;
    --color-accent: #a78bfa;
    --color-accent-soft: rgba(167, 139, 250, 0.12);
    --color-border-light: rgba(230, 227, 242, 0.08);
    --color-border: rgba(230, 227, 242, 0.15);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);
  }
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .3s ease, color .3s ease;
}

img, svg, video { max-width: 100%; height: auto; display: inline-block; }
a { color: var(--color-accent); }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
p { margin: 0; }
::selection { background: var(--color-accent); color: var(--color-bg); }

/* 键盘焦点可见性 */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 工具类：布局 ---------- */
.max-w-4xl { max-width: 56rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.container { max-width: 720px; margin: 0 auto; padding: 5rem 1.5rem 4rem; }

.grid { display: grid; }
.md\:grid-cols-2, .lg\:grid-cols-3 { grid-template-columns: 1fr; }
.gap-2 { gap: 0.5rem; }
.gap-5 { gap: 1.25rem; }
.col-span-full { grid-column: 1 / -1; }
.items-center { align-items: center; }
.inline-flex { display: inline-flex; }
.block { display: block; }
.inline-block { display: inline-block; }

.hidden { display: none !important; }
[hidden] { display: none !important; }

/* 间距 */
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-16 { padding-top: 4rem; padding-bottom: 4rem; }
.py-24 { padding-top: 6rem; padding-bottom: 6rem; }
.p-6 { padding: 1.5rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-10 { margin-top: 2.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-10 { margin-bottom: 2.5rem; }
.w-4 { width: 1rem; }
.h-4 { height: 1rem; }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.border { border: 1px solid var(--color-border-light); }
.border-slate-100 { border-color: rgba(226, 232, 240, 1); }

/* ---------- 工具类：文字 ---------- */
.font-sans { font-family: var(--font-sans); }
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.tracking-tight { letter-spacing: -0.025em; }
.antialiased { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.text-center { text-align: center; }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }
.text-3xl { font-size: var(--text-3xl); }
.text-4xl { font-size: var(--text-4xl); }
.text-accent { color: var(--color-accent); }
.text-muted { color: var(--color-text-muted); }
.text-ink { color: var(--color-primary); }
.text-white { color: #fff; }
.leading-relaxed { line-height: 1.7; }
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hover-underline:hover { text-decoration: underline; }

/* 颜色 */
.bg-paper { background: var(--color-bg); }
.bg-white { background: var(--color-surface); }
.bg-ink { background: var(--color-primary); }
.hover-bg-ink:hover { background: var(--color-primary); opacity: .92; }

/* ---------- 按钮 ---------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-bg);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity .2s ease;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background-color var(--transition);
}
.btn-ghost:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

/* ---------- 代码注释风格（首页"最近文章"小标签） ---------- */
.code-comment {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-accent);
  background: var(--color-accent-soft);
}

/* ---------- 滚动入场动画 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .6s ease, transform .6s var(--ease);
}
.reveal.visible {
  opacity: 1;
  transform: none;
}

/* ---------- 文章列表卡片补充动效 ---------- */
.card-lift {
  text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.card-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent);
}
.group:hover .group-hover-text-accent { color: var(--color-accent); }
.link-underline { position: relative; }
.link-underline::after {
  content: '';
  position: absolute;
  left: 0; bottom: -2px;
  width: 0; height: 1px;
  background: currentColor;
  transition: width var(--transition);
}
.card-lift:hover .link-underline::after { width: 100%; }

/* ---------- 文章页：标题区约束 + 移动端避让固定导航 ---------- */
main .posts-hero { max-width: 960px; margin-left: auto; margin-right: auto; }
@media (max-width: 767px) {
  main .posts-hero { padding-top: clamp(4.5rem, 12vw, 7rem); }
}

/* ---------- 空状态 ---------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--color-text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; display: block; }
.empty-state p { font-size: var(--text-lg); margin-bottom: 0.75rem; }
.empty-state a { font-weight: 500; }

/* ---------- 页脚 ---------- */
.site-footer {
  background: var(--color-surface-alt);
  border-top: 1px solid var(--color-border-light);
  box-shadow: inset 0 1px 0 var(--color-accent-soft);
  margin-top: clamp(3rem, 6vw, 4.5rem);
}
.footer-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 4rem 20px 2.5rem;
}
.footer-brand { margin-bottom: 1.5rem; }
.footer-logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: 0.01em;
}
.footer-dot { color: var(--color-accent); }
.footer-desc {
  margin-top: 6px;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 1.5rem;
}
.footer-links a {
  padding: 6px 12px;
  margin: -6px -12px;
  border-radius: 999px;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color .2s ease, background-color .2s ease;
}
.footer-links a:hover {
  color: var(--color-accent);
  background: var(--color-accent-soft);
}
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border-light);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.footer-bottom a { color: var(--color-text-secondary); text-decoration: none; }
.footer-bottom a:hover { color: var(--color-accent); }
.footer-dot-sep { opacity: .5; }

/* ---------- 页面头部通用 ---------- */
.page-hero, .posts-hero, .gallery-hero, .tools-hero, .about-hero {
  text-align: center;
}
.page-hero-divider {
  width: 48px;
  height: 3px;
  margin: 1.5rem auto 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--color-accent), #8b5cf6);
}

/* ---------- 响应式 ---------- */
@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
  .md\:py-32 { padding-top: 8rem; padding-bottom: 8rem; }
  .md\:text-4xl { font-size: var(--text-4xl); }
  .md\:flex { display: flex !important; }
  .md\:block { display: block !important; }
  .md\:inline-flex { display: inline-flex !important; }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
  .px-5 { padding-left: 1rem; padding-right: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after { animation-duration: .01ms !important; }
}
