/* ==========================================================================
   闪电的空间 · 品牌样式层
   --------------------------------------------------------------------------
   这一层只做三件事，按优先级排列：
     1. 阅读体验（最重要）：正文 17px / 行高 1.9 / 栏宽 660px ≈ 38 个汉字
     2. 品牌色板与字体：无衬线正文 + 衬线大标题的编辑式混排
     3. 组件外观精修：顶栏、卡片、文章头、引用、代码块、页脚

   设计约束（不要随意改，改了要重测）：
     · 660px ÷ 17px ≈ 38.8 汉字/行 —— 落在 34~40 的舒适区间
     · 正文行高 1.9 让长文有呼吸感；段距用 1.15em 保证段落可分辨
     · 正文用无衬线（屏幕阅读更稳），标题用衬线（有纸感、更耐看）
     · 所有颜色走 CSS 变量，亮/暗两套同时维护，不出现硬编码色

   加载顺序：必须排在 style.css 之后，靠后出现覆盖同优先级规则。
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 色板：纸白 + 墨黑 + 琥珀主色
   与「闪电」品牌同色系，但压暗一档保证 WCAG AA 对比度（正文/链接 ≥ 4.5:1）。
   四个 accent 变体统一成同一套，避免切换配色后与品牌层打架。
   -------------------------------------------------------------------------- */
:root {
  /* 亮色 */
  --bg: #fdfdfc;
  --bg-soft: #f5f4f1;
  --card: #ffffff;
  --fg: #1a1917;
  --muted: #6b6862;
  --border: #e8e5df;
  --accent: #b45309;
  --accent-soft: #fdf3e6;
  --accent-2: #d97706;
  --accent-fg: #ffffff;
  --code-bg: #f6f5f2;

  --shadow: 0 1px 2px rgba(26, 25, 23, 0.04), 0 4px 12px rgba(26, 25, 23, 0.05);
  --shadow-hover: 0 2px 4px rgba(26, 25, 23, 0.05), 0 12px 26px -8px rgba(26, 25, 23, 0.12);
  --shadow-float:
    0 1px 2px rgba(26, 25, 23, 0.04),
    0 8px 20px -6px rgba(26, 25, 23, 0.08),
    0 22px 44px -18px rgba(26, 25, 23, 0.10);

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

  /* 字体：正文无衬线，标题衬线 —— 当下中文独立博客最常见也最耐看的组合 */
  --font: "Inter", "HarmonyOS Sans SC", "PingFang SC", "Source Han Sans SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", "HarmonyOS Sans SC", "PingFang SC", "Source Han Sans SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-heading: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "宋体", serif;
  --font-display: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "宋体", serif;
  /* 引用块原用仿宋（--font-deco）：现代版式里改用正文无衬线 + 主色左线更干净 */
  --font-deco: var(--font-body);

  /* 阅读三要素：字号 / 行高 / 栏宽（改这三个值等于改整站阅读手感） */
  --read-size: 17px;
  --read-lh: 1.9;
  --read-width: 660px;

  --ls-title: -0.01em;
  --ls-body: 0.012em;
}

/* 暗色：不用纯黑，留一点暖调，长时间阅读不刺眼 */
html[data-theme="dark"] {
  --bg: #0f0f11;
  --bg-soft: #17171a;
  --card: #16161a;
  --fg: #e9e6e1;
  --muted: #9b9791;
  --border: #2a2a2f;
  --accent: #f0a65c;
  --accent-soft: #2b2117;
  --accent-2: #f6c48a;
  --accent-fg: #1a1917;
  --code-bg: #1a1a1f;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.45), 0 16px 34px -10px rgba(0, 0, 0, 0.55);
  --shadow-float:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 8px 20px -6px rgba(0, 0, 0, 0.4),
    0 22px 44px -18px rgba(0, 0, 0, 0.5);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 32%, transparent);
}

/* 四个 accent 变体统一（原文件里这些选择器特异性更高，必须逐个列出才压得住） */
:root[data-theme="light"][data-accent="terra"],
:root[data-theme="light"][data-accent="indigo"],
:root[data-theme="light"][data-accent="bamboo"],
:root[data-theme="light"][data-accent="dusk"] {
  --accent: #b45309; --accent-soft: #fdf3e6; --accent-2: #d97706; --accent-fg: #fff;
  --bg: #fdfdfc; --bg-soft: #f5f4f1; --card: #ffffff; --border: #e8e5df;
}
html[data-theme="dark"][data-accent="terra"],
html[data-theme="dark"][data-accent="indigo"],
html[data-theme="dark"][data-accent="bamboo"],
html[data-theme="dark"][data-accent="dusk"] {
  --accent: #f0a65c; --accent-soft: #2b2117; --accent-2: #f6c48a; --accent-fg: #1a1917;
  --bg: #0f0f11; --bg-soft: #17171a; --card: #16161a; --border: #2a2a2f;
}

/* --------------------------------------------------------------------------
   2. 阅读排版 —— 本层的核心
   -------------------------------------------------------------------------- */

/* 正文容器宽度：660px ≈ 38 个汉字。这是"读起来不累"的关键，别为了填满屏幕放宽 */
.post-body {
  max-width: var(--read-width);
  margin-left: auto;
  margin-right: auto;
}

/* 关于页、归档页等长文页沿用同一栏宽，避免不同页面字宽跳变 */
.article,
.md-body {
  font-size: calc(var(--read-size) * var(--reading-scale, 1));
  line-height: var(--read-lh);
  letter-spacing: var(--ls-body);
  color: var(--fg);
  /* 中文标点悬挂：让引号/逗号不占字宽，行首更齐 */
  hanging-punctuation: allow-end;
  text-wrap: pretty;
}

/* 段落：行高已经宽松，段距用 1.15em 足够分辨，再大就散了 */
.article p {
  margin: 1.15em 0;
}

/* 章节标题：去掉原版的下边框（更像杂志正文），靠字重和上间距建立层级 */
.article h1,
.article h2,
.article h3,
.article h4 {
  font-family: var(--font-display);
  letter-spacing: -0.005em;
  line-height: 1.45;
  color: var(--fg);
}
.article h1 { font-size: 1.6em; margin: 2.2em 0 0.75em; }
.article h2 {
  font-size: 1.42em;
  font-weight: 700;
  margin: 2.4em 0 0.85em;
  padding-bottom: 0;
  border-bottom: none;
}
.article h3 { font-size: 1.17em; font-weight: 600; margin: 2em 0 0.7em; }
.article h4 { font-size: 1.04em; font-weight: 600; margin: 1.8em 0 0.6em; }

/* 列表：项间距随行高放大，否则长列表看起来糊成一片 */
.article ul,
.article ol { margin: 1.1em 0; padding-left: 1.45em; }
.article li { margin: 0.5em 0; }
.article li::marker { color: var(--muted); }

/* 引用：细左线 + 极浅底色，不用重阴影（原版的浮起阴影在长文里很抢眼） */
.article blockquote {
  margin: 1.6em 0;
  padding: 4px 0 4px 20px;
  border-left: 3px solid color-mix(in srgb, var(--accent) 70%, transparent);
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--font-body);
  font-size: 1em;
  color: var(--muted);
}
.article blockquote p { margin: 0.7em 0; }
.article blockquote strong { color: var(--fg); }

/* 代码：圆角略收、内边距更大，读代码时不挤 */
.article pre.code-block {
  border-radius: 10px;
  padding: 16px 18px;
  font-size: 13.5px;
  line-height: 1.72;
  box-shadow: none;
  border: 1px solid var(--border);
}
.article code.inline-code {
  border-radius: 5px;
  padding: 1.5px 6px;
  font-size: 0.88em;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}

/* 图片：居中 + 圆角 + 极轻描边，避免在浅底上"飘" */
.article img {
  border-radius: 10px;
  box-shadow: none;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.article figure { margin: 1.8em 0; }
.article figcaption {
  margin-top: 0.7em;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* 表格：细线、无外框，比原来的满格线更现代 */
.article table {
  font-size: 14.5px;
  border-collapse: collapse;
  margin: 1.6em 0;
}
.article th,
.article td {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}
.article th {
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  border-bottom: 1px solid color-mix(in srgb, var(--fg) 22%, var(--border));
}
.article tbody tr:hover { background: color-mix(in srgb, var(--bg-soft) 70%, transparent); }

/* 分割线：中间短一截更精致 */
.article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.6em auto;
  width: 46%;
}

/* 文章内链接：只给下划线，不换色（正文里满屏彩色链接很吵） */
.article a {
  color: inherit;
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: repeat-x;
  background-position: 0 100%;
  background-size: 100% 1px;
  transition: background-size 0.18s ease, color 0.18s ease;
}
.article a:hover {
  color: var(--accent);
  background-size: 100% 2px;
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   3. 文章页头：左对齐的编辑式版头（居中标题在长文里显旧）
   -------------------------------------------------------------------------- */
.post-header {
  text-align: left;
  border-bottom: none;
  padding-bottom: 0;
  margin: 34px 0 34px;
}
.post-header h1 {
  margin: 0 0 16px;
  max-width: 100%;
  font-size: clamp(26px, 4.2vw, 34px);
  line-height: 1.38;
  font-weight: 700;
  letter-spacing: -0.012em;
  text-align: left;
}
.post-header .meta {
  justify-content: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.01em;
}
/* 元信息之间的分隔点弱化 */
.post-header .meta .meta-dot { opacity: 0.5; }

/* 文章底部操作行分隔线调轻 */
.article-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   4. 首页 magazine 版头精修
   -------------------------------------------------------------------------- */
.magazine-masthead { align-items: end; padding-bottom: 26px; }
.magazine-masthead h1 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.magazine-kicker {
  letter-spacing: 0.16em;
  font-size: 11px;
  color: var(--accent);
}
.magazine-edition strong {
  letter-spacing: -0.06em;
  font-weight: 700;
}

/* 精选卡：圆角加大、去掉重阴影，靠描边和图片撑质感 */
.magazine-feature {
  border-radius: 18px;
  box-shadow: none;
  border: 1px solid var(--border);
}
.magazine-feature:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: color-mix(in srgb, var(--border) 60%, var(--accent) 22%);
}
.magazine-feature-label {
  border-radius: 6px;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--accent);
}
.magazine-card {
  border-radius: 14px;
  box-shadow: none;
}
/* 作者卡：侧栏只有 ~190px 宽，横排会让简介挤成窄条。
   改成头像在上、文字在下，简介用满宽度。 */
.magazine-author-body {
  flex-direction: column;
  align-items: flex-start;
  gap: 11px;
}
.magazine-author-meta { width: 100%; }
.magazine-author-meta strong {
  font-size: 14.5px;
  letter-spacing: 0.01em;
}
.magazine-author-meta p {
  max-width: none;
  font-size: 12.5px;
  line-height: 1.75;
  margin-top: 6px;
}

/* --------------------------------------------------------------------------
   5. 顶栏 / 导航：更细、更轻、字号收小
   -------------------------------------------------------------------------- */
.topbar {
  height: 64px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
}
.topbar-inner { height: 64px; }
.brand {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.main-nav .nav-link {
  font-size: 15px;
  padding: 6px 11px;
  border-radius: 7px;
  letter-spacing: 0.01em;
}
.main-nav .nav-link.active {
  color: var(--fg);
  font-weight: 600;
  background: var(--bg-soft);
}

/* --------------------------------------------------------------------------
   6. 列表卡片：去掉左侧彩色竖条动效，改为描边 + 轻微上浮
   -------------------------------------------------------------------------- */
.post-card {
  border-radius: 14px;
  box-shadow: none;
  border: 1px solid var(--border);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.22s ease,
              box-shadow 0.22s ease;
}
.post-card::after { display: none; }
.post-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--border) 55%, var(--accent) 26%);
  box-shadow: var(--shadow-hover);
  background: var(--card);
}
.post-card h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.006em;
  line-height: 1.45;
}
.post-card .meta { font-size: 12.5px; color: var(--muted); }

/* 按钮：更扁、更安静的圆角 */
.btn { border-radius: 9px; font-weight: 600; }
.btn-primary {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}
.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* --------------------------------------------------------------------------
   7. 页脚
   -------------------------------------------------------------------------- */
.footer, .site-footer {
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   8. 移动端：字号保持 17px，行高略收（窄屏下单行字数少，行高过大会拖慢阅读）
   -------------------------------------------------------------------------- */
@media (max-width: 720px) {
  :root { --read-size: 16.5px; --read-lh: 1.86; }
  .article { letter-spacing: 0.008em; }
  .post-body { max-width: 100%; }
  .post-header { margin: 20px 0 28px; }
  .post-header h1 { font-size: 26px; }
  .article h2 { font-size: 1.32em; margin-top: 2em; }
  .article p { margin: 1.05em 0; }
  .topbar, .topbar-inner { height: 58px; }
}

/* --------------------------------------------------------------------------
   9. 阅读工具栏：按钮多，窄屏必须允许换行
   不换行时 flex 会把「阅读字号」这种中文标签压成一列竖排字，非常难看。
   -------------------------------------------------------------------------- */
.reading-tools {
  flex-wrap: wrap;
  row-gap: 8px;
  margin-bottom: 20px;
}
.reading-tools > * { flex: none; }
.reading-tools .rt-label,
.reading-tools .rt-btn { white-space: nowrap; }
.reading-tools .rt-label {
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* 精选卡标题：均衡断行，避免最后一行只剩一两个字 */
.magazine-feature h2,
.magazine-feature h3,
.magazine-feed-head h2,
.post-card h2 {
  text-wrap: balance;
  word-break: normal;
  overflow-wrap: break-word;
}

/* 首屏加载态：跟随品牌色，避免深色模式白闪 */
.boot-load { background: var(--bg, #fdfdfc); }
.boot-ring::before { border-top-color: var(--accent, #b45309); }
.boot-ring::after { border-top-color: var(--accent-2, #d97706); }
.boot-name { letter-spacing: 0.16em; color: var(--muted, #6b6862); }
