/* ============================================================
   新中式皮肤 v4 —— 淡雅左栏
   - 去掉顶部跑马灯；底部导航条改为常驻左侧竖排侧边栏
   - 全局字号缩小，浓墨硬块退为淡墨细线
   - 点缀色改回朱砂暖红，整体配色淡而不陋
   - 字体 / 全部类名与业务结构不变
   ============================================================ */

/* 字体：内置 MiSans 可变字体 —— JP 版优先（覆盖日文），基础版次之
   可变字重 100-900：默认 500，bold 即 900 (Heavy) */
@font-face {
  font-family: "MiSansJP";
  src: url("../fonts/MiSansJapaneseVF.ttf") format("truetype-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "MiSans";
  src: url("../fonts/MiSansVF.ttf") format("truetype-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ---- 背景：宣纸暖白 ---- */
  --bg: #f6f3ec;
  --surface: #fbf9f4;
  --inset: #efeadf;
  --dot: rgba(58, 53, 46, 0.04);

  /* ---- 文字：淡墨三阶 ---- */
  --ink: #38332c;
  --ink-soft: #6b6457;
  --ink-faint: #a59c8c;
  --headline-color: #38332c;

  /* ---- 朱砂暖红：全局唯一点缀色 ---- */
  --seal: #b3543f;
  --seal-tint: rgba(179, 84, 63, 0.08);

  /* ---- 卡片循环底色：宣纸四阶 ---- */
  --a1: #f8f5ee;
  --a2: #f2ede2;
  --a3: #ece5d6;
  --a4: #e5dcc9;

  /* ---- 博客左缘四阶（含一阶朱砂） ---- */
  --edge1: #cdc4b2;
  --edge2: #a89d89;
  --edge3: var(--seal);
  --edge4: #8d8474;

  /* ---- 界线与投影 ---- */
  --line: #ddd5c6;
  --line-strong: #6b6457;
  --border: 1px solid var(--line);
  --border-sm: 1px solid var(--line);
  --shadow: 0 2px 10px rgba(56, 51, 44, 0.06);
  --shadow-sm: 0 1px 6px rgba(56, 51, 44, 0.05);
  --shadow-hover: 0 5px 16px rgba(56, 51, 44, 0.10);

  --sidebar-w: clamp(68px, 7vw, 104px);
  --font-main: "MiSansJP", "MiSans", "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Source Han Sans SC",
    "Microsoft YaHei", sans-serif;
}

/* ==================== 暗色模式：暖调墨夜 ==================== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191713;
    --surface: #211e19;
    --inset: #14120e;
    --dot: rgba(236, 229, 216, 0.035);

    --ink: #e8e2d4;
    --ink-soft: #b0a898;
    --ink-faint: #6d6558;
    --headline-color: #e8e2d4;

    --seal: #d08a72;
    --seal-tint: rgba(208, 138, 114, 0.12);

    --a1: #221f1a;
    --a2: #28241e;
    --a3: #2e2921;
    --a4: #342e25;

    --edge1: #4a443a;
    --edge2: #5c5548;
    --edge3: var(--seal);
    --edge4: #7a7161;

    --line: #3f3a31;
    --line-strong: #b0a898;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* 全局字号整体下调一档 */
html { font-size: 15px; }

::selection { background: var(--seal); color: #fbf9f4; }

body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: var(--font-main);
  font-weight: 500;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ---- bold = Heavy(900)：可变字体直接给真字重 ---- */
.headline, .page-title, .article-title,
.card-name, .card-nick, .card-glyph, .post-item-title,
.article-body h1, .article-body h2, .article-body h3, .article-body h4,
.site-nav a, .reader-title, .intro-name, strong, b {
  font-weight: 900;
}

.container {
  width: 100%;
  padding-left: clamp(1.25rem, 3vw, 3rem);
  padding-right: clamp(1.25rem, 3vw, 3rem);
}

/* ---------- 主区域：避让左侧边栏 ---------- */

#app {
  flex: 1;
  width: auto;
  position: relative;
  z-index: 1;
  margin-left: var(--sidebar-w);
  padding: clamp(1.5rem, 4vh, 2.5rem) clamp(1.25rem, 4vw, 4rem) 5rem;
}

/* ---------- 朱砂小方块 ---------- */

.red-sq {
  display: inline-block;
  width: 0.3em;
  height: 0.3em;
  background: var(--seal);
  margin-left: 0.12em;
  vertical-align: baseline;
}

/* ---------- 主页 ---------- */

.headline {
  font-size: clamp(1.9rem, 5.5vw, 3.2rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.03em;
  text-align: left;
  margin-top: clamp(0.8rem, 4vh, 2rem);
  color: var(--headline-color);
}

.headline .red-sq { width: 0.2em; height: 0.2em; }

.headline-vert-space { height: 1em; }

/* 引言：淡墨面板 + 朱砂左缘 */
.home-intro {
  margin-top: 2.2rem;
  color: var(--ink-soft);
  font-size: clamp(0.85rem, 1.4vw, 0.98rem);
  line-height: 2.1;
  letter-spacing: 0.03em;
  max-width: 44em;
  background: var(--surface);
  border: var(--border);
  border-left: 3px solid var(--seal);
  box-shadow: var(--shadow-sm);
  padding: 1.3rem 1.5rem;
}

.home-intro .intro-name {
  color: var(--seal);
  font-weight: 900;
}

.home-intro .lang {
  display: inline-block;
  margin-right: 1.8em;
  color: var(--ink-faint);
}

/* ---------- 各版块页标题：通栏出血 + 文武线 ---------- */

.page-head {
  margin: 0 calc(-1 * clamp(1.25rem, 4vw, 4rem)) 1.8rem;   /* 向两侧出血 */
  padding: 0 clamp(1.25rem, 4vw, 4rem) 5px;
  background-image:
    linear-gradient(var(--line-strong), var(--line-strong)),
    linear-gradient(var(--line-strong), var(--line-strong));
  background-repeat: no-repeat;
  background-size: 100% 1.5px, 100% 1px;
  background-position: left bottom, left calc(100% - 4px);
}

.page-title {
  display: block;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1.1;
  color: var(--ink);
  padding-bottom: 0.12em;
}

.page-title .red-sq { width: 0.2em; height: 0.2em; }

/* ---------- 卡片网格 ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.3rem;
}

.card-cell {
  display: contents;
}

.card {
  display: block;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  padding: 1rem 1.05rem 1.05rem;
  border: var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

/* 逐张循环：宣纸四阶 */
.card-cell:nth-child(4n+1) .card { background: var(--a1); }
.card-cell:nth-child(4n+2) .card { background: var(--a2); }
.card-cell:nth-child(4n+3) .card { background: var(--a3); }
.card-cell:nth-child(4n+4) .card { background: var(--a4); }

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--edge2);
  position: relative;
  z-index: 2;
}

.card:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* 项目卡：文件夹图标 + 名称 行 */
.card--project .card-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.55rem;
}

.card--project .card-ico {
  flex: 0 0 auto;
  width: 1.15em;
  height: 1.15em;
  color: var(--ink-soft);
}

.card--project .card-ico svg { width: 100%; height: 100%; display: block; }

/* 社交卡 / 友链卡：左媒体 + 右文字 */
.card--social,
.card--link {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.card-media,
.card-avatar {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  overflow: hidden;
  background: var(--surface);
  border: var(--border-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}

.card-media img,
.card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-glyph {
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.card-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-body .card-desc { margin-top: 0.25rem; }

/* 项目卡：标签 chips —— 淡墨描边款 */
.chip-row {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--edge2);
  padding: 0.15em 0.6em;
  white-space: nowrap;
}

.card-name {
  font-size: 0.98rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.card-nick {
  margin-top: 0.12rem;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}

.card-name::after {
  content: "";
  display: inline-block;
  width: 0.28em;
  height: 0.28em;
  background: var(--seal);
  margin-left: 0.4em;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.card:hover .card-name::after { opacity: 1; }

.card-desc {
  margin-top: 0.45rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.8;
}

.empty-note {
  color: var(--ink-faint);
  letter-spacing: 0.2em;
  font-size: 0.85rem;
  padding: 3rem 0;
}

/* ---------- 博客列表：通栏条目 + 左缘四阶 ---------- */

.post-list {
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}

.post-item {
  display: flex;
  gap: 1.8rem;
  align-items: flex-start;
  padding: 1.2rem 1.4rem;
  background: var(--surface);
  border: var(--border);
  border-left-width: 3px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.post-item:nth-child(4n+1) { border-left-color: var(--edge1); }
.post-item:nth-child(4n+2) { border-left-color: var(--edge2); }
.post-item:nth-child(4n+3) { border-left-color: var(--edge3); }
.post-item:nth-child(4n+4) { border-left-color: var(--edge4); }

.post-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.post-cover {
  flex: 0 0 160px;
  aspect-ratio: 16 / 10;
  background: var(--inset);
  border: var(--border);
  overflow: hidden;
}

.post-cover img { width: 100%; height: 100%; object-fit: cover; }

.post-cover .img-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}

.post-cover .img-placeholder svg { width: 32px; height: 32px; color: var(--ink-faint); }

.post-item-body { flex: 1; min-width: 0; }

.post-item-title {
  font-size: 1.12rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 1.45;
}

.post-item:hover .post-item-title { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 1px; }

.post-meta {
  margin-top: 0.6rem;
  color: var(--ink-faint);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
}

/* 标签：淡墨描边款 */
.tag {
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--edge2);
  padding: 0.1em 0.6em;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
}

/* ---------- 博客文章页 ---------- */

.article-head { margin-bottom: 2rem; }

.article-title {
  display: block;
  font-size: clamp(1.4rem, 3.5vw, 2.1rem);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: var(--ink);
  margin: 0 calc(-1 * clamp(1.25rem, 4vw, 4rem));
  padding: 0.1em clamp(1.25rem, 4vw, 4rem) 0.22em;
  /* 文武线：粗线在下、细线在上 */
  background-image:
    linear-gradient(var(--line-strong), var(--line-strong)),
    linear-gradient(var(--line-strong), var(--line-strong));
  background-repeat: no-repeat;
  background-size: 100% 1.5px, 100% 1px;
  background-position: left bottom, left calc(100% - 4px);
}

.article-title .red-sq { width: 0.2em; height: 0.2em; }

.article-head .post-meta {
  margin-top: 1.2rem;
}

.article-cover {
  margin: 1.8rem 0 0;
  background: var(--inset);
  border: var(--border);
  box-shadow: var(--shadow);
  padding: 4px;
}

.article-cover img { width: 100%; display: block; }

/* ---------- 阅读栏：贴底的淡墨浮条（从侧边栏右侧起排） ---------- */
.reader-bar {
  position: fixed;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 0.6rem clamp(1.25rem, 3vw, 3rem);
  background: var(--surface);
  color: var(--ink);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgba(56, 51, 44, 0.05);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.reader-bar.show { transform: translateY(0); }

/* 返回钮：描边款，朱砂悬停 */
.reader-back {
  flex: 0 0 auto;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  white-space: nowrap;
  background: transparent;
  border: 1px solid var(--edge2);
  padding: 0.3em 0.8em;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.reader-back:hover { color: var(--seal); border-color: var(--seal); }
.reader-back:active { color: var(--ink); border-color: var(--ink); }

.reader-title {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-progress {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.reader-track {
  position: relative;
  width: 90px;
  height: 12px;
  background: var(--inset);
  border: 1px solid var(--line);
  overflow: hidden;
}

.reader-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  background: var(--seal);
}

.reader-pct {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  min-width: 2.2em;
  text-align: right;
}

/* 窄屏 */
@media (max-width: 560px) {
  .reader-bar { gap: 1rem; padding: 0.55rem 1rem; }
  .reader-title { display: none; }
  .reader-track { width: 64px; }
}

.article-body {
  font-size: 0.95rem;
  line-height: 2.15;
  letter-spacing: 0.03em;
  padding-top: 2.2rem;
  margin-top: 2.2rem;
  border-top: var(--border);
}

.article-body h1, .article-body h2, .article-body h3, .article-body h4 {
  font-weight: 900;
  line-height: 1.5;
  margin: 2em 0 0.8em;
}

/* 正文标题：朱砂左缘 + 淡朱底 */
.article-body h2, .article-body h3 {
  display: inline-block;
  background: var(--seal-tint);
  border-left: 3px solid var(--seal);
  color: var(--ink);
  padding: 0.08em 0.55em;
}

.article-body h1 { font-size: 1.45rem; }
.article-body h2 { font-size: 1.2rem; }
.article-body h3 { font-size: 1.02rem; }

.article-body p { margin: 1em 0; }

.article-body a { color: var(--ink); text-underline-offset: 4px; text-decoration-thickness: 1px; }
.article-body a:hover { color: var(--seal); background: var(--seal-tint); text-decoration: none; }

.article-body code {
  font-family: var(--font-main);
  font-size: 0.86em;
  background: var(--inset);
  border: var(--border-sm);
  padding: 0.12em 0.4em;
}

.article-body pre {
  background: var(--inset);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.3rem;
  overflow-x: auto;
  margin: 1.4em 0;
}

.article-body pre code { background: none; border: none; padding: 0; }

.article-body blockquote {
  border-left: 3px solid var(--seal);
  background: var(--seal-tint);
  color: var(--ink-soft);
  padding: 0.75rem 1.2rem;
  margin: 1.4em 0;
}

.article-body ul, .article-body ol { padding-left: 1.6em; margin: 1em 0; }

.article-body hr {
  border: none;
  border-top: var(--border);
  margin: 2.5em 0;
}

.article-body img { max-width: 100%; }

.back-link {
  display: inline-block;
  margin-bottom: 2.2rem;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  background: transparent;
  border: 1px solid var(--edge2);
  padding: 0.4em 0.9em;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.back-link:hover { color: var(--seal); border-color: var(--seal); }
.back-link:active { color: var(--ink); border-color: var(--ink); }

/* ---------- 左侧边栏：常驻竖排导航（原底部导航条） ---------- */

.site-footer {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-w);
  z-index: 50;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.footer-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 0 1.4rem;
}

/* 侧边栏内清空 .container 的左右留白，避免挤占窄栏 */
.site-footer .container { padding-left: 0; padding-right: 0; }

/* 主页图标按钮：宣纸印章 */
.site-icon {
  display: block;
  width: 42px;
  height: 42px;
  background: var(--bg);
  border: var(--border);
  position: relative;
  transition: border-color 0.2s ease;
}

.site-icon::after {
  content: "";
  position: absolute;
  inset: 6px;
  background-color: var(--ink);
  -webkit-mask: url("../seirai.svg") no-repeat center / contain;
  mask: url("../seirai.svg") no-repeat center / contain;
  transition: background-color 0.2s ease;
}

.site-icon:hover { border-color: var(--seal); }
.site-icon:hover::after { background-color: var(--seal); }
.site-icon:active { transform: translateY(1px); }

/* 竖排文字导航：居中分布于剩余高度 */
.site-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin: auto 0;   /* 上下留白之间垂直居中 */
}

.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  padding: 0.4em 0.75em 0.6em;
  position: relative;
  border: 1px solid transparent;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.site-nav a:hover {
  color: var(--ink);
  background: var(--inset);
}

/* 活动态 = 朱砂 */
.site-nav a.active { color: var(--seal); }

/* 菜单项文字右下角序号 */
.site-nav a::before {
  position: absolute;
  right: 0.25em;
  bottom: 0.05em;
  font-size: 0.42rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
}

.site-nav a:nth-child(1)::before { content: "01"; }
.site-nav a:nth-child(2)::before { content: "02"; }
.site-nav a:nth-child(3)::before { content: "03"; }
.site-nav a:nth-child(4)::before { content: "04"; }
.site-nav a:nth-child(5)::before { content: "05"; }

.site-nav a:hover::before { color: var(--ink-soft); }
.site-nav a.active::before { color: var(--seal); }

/* ---------- 错误提示 ---------- */

.load-error {
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 2;
  padding: 3rem 0;
  letter-spacing: 0.05em;
}

.load-error code {
  background: var(--inset);
  border: var(--border-sm);
  padding: 0.12em 0.5em;
  font-size: 0.85em;
}

/* ---------- 素雅滚动条 ---------- */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background-color: var(--inset);
}

::-webkit-scrollbar-thumb {
  background-color: var(--edge1);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--edge2);
}

::-webkit-scrollbar-corner {
  background-color: var(--inset);
}

* {
  scrollbar-width: auto;
  scrollbar-color: var(--edge1) var(--inset);
}

/* ---------- 响应式 ---------- */

@media (max-width: 640px) {
  /* 移动端：侧边栏改为底部横向导航条 */
  :root { --sidebar-w: 0px; }

  #app {
    margin-left: 0;
    padding-bottom: 4.6rem;   /* 给底部导航栏让位 */
  }

  .site-footer {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    border-right: none;
    border-top: 1px solid var(--line);
  }

  .footer-inner {
    height: auto;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.8rem 0.5rem;
  }

  .site-icon { width: 36px; height: 36px; }

  .site-nav {
    flex-direction: row;
    gap: 0.3rem;
    margin: 0;
  }

  .site-nav a {
    padding: 0.28em 0.5em 0.45em;
    font-size: 0.92rem;
  }

  .site-nav a::before { font-size: 0.38rem; }

  /* 移动端阅读栏：贴于导航条之上 */
  .reader-bar { left: 0; }

  .post-item { flex-direction: column; gap: 1.1rem; }
  .post-cover { flex: none; width: 100%; }
}
