/* ============================================================
   a.journey — 温暖杂志风样式表
   Light / Dark 双主题，通过 <html data-theme="…"> 切换
   ============================================================ */

:root {
  /* —— 暖色调浅色主题 —— */
  --bg:        #f6f1e7;   /* 暖米白底 */
  --bg-soft:   #efe7d8;   /* 略深的暖底（页眉/分区） */
  --card:      #fffdf8;   /* 卡片纸张色 */
  --card-soft: #faf5ea;
  --ink:       #2c2620;   /* 暖墨色正文标题 */
  --ink-soft:  #574e44;   /* 次级正文 */
  --muted:     #9b9082;   /* 弱化文字 */
  --accent:    #b9542d;   /* 赤陶/铁锈红 主强调色 */
  --accent-2:  #a8451f;
  --accent-soft: rgba(185, 84, 45, 0.10);
  --gold:      #b58a36;   /* 点缀金 */
  --border:    #e6dcc9;   /* 暖色描边 */
  --border-strong: #d8cab0;

  --diff-easy-bg: #e9f1e3; --diff-easy-fg: #4e7a32;
  --diff-mid-bg:  #f6ecd6; --diff-mid-fg:  #9a6b16;
  --diff-hard-bg: #f4e0d8; --diff-hard-fg: #a8452a;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 2px rgba(60,45,25,0.04), 0 6px 20px rgba(60,45,25,0.05);
  --shadow-lg: 0 8px 34px rgba(120,70,30,0.13);
  --transition: 0.22s ease;

  --serif: 'Noto Serif SC', 'Songti SC', 'Source Han Serif SC', Georgia, 'Times New Roman', serif;
  --sans:  -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  --maxw: 760px;
}

html[data-theme="dark"] {
  --bg:        #1b1714;
  --bg-soft:   #221d18;
  --card:      #24201a;
  --card-soft: #2a251e;
  --ink:       #ece4d6;
  --ink-soft:  #b8ad9c;
  --muted:     #897e6e;
  --accent:    #e08a5c;
  --accent-2:  #ec9869;
  --accent-soft: rgba(224, 138, 92, 0.14);
  --gold:      #d6b15e;
  --border:    #38312a;
  --border-strong: #463d33;

  --diff-easy-bg: #21301e; --diff-easy-fg: #9ccb83;
  --diff-mid-bg:  #322a16; --diff-mid-fg:  #d8b35e;
  --diff-hard-bg: #34201a; --diff-hard-fg: #e89677;

  --shadow:    0 1px 2px rgba(0,0,0,0.3), 0 6px 22px rgba(0,0,0,0.32);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.75;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

::selection { background: var(--accent-soft); }

/* ===== 阅读进度条 ===== */
.reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  z-index: 200;
  transition: width 0.1s linear;
}

/* ===== MASTHEAD（报头） ===== */
.masthead {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  padding: 26px 20px 0;
}
.masthead-inner { max-width: var(--maxw); margin: 0 auto; }
.masthead-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-family: var(--serif);
  font-size: 2em;
  font-weight: 700;
  letter-spacing: -0.5px;
  text-decoration: none;
  color: var(--ink);
}
.brand-mark { color: var(--accent); }
.brand-name { color: var(--ink); }
.masthead-tagline {
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  font-size: 0.95em;
  margin-top: 6px;
}

/* 主题切换按钮 */
.theme-toggle {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 1.1em;
  display: grid;
  place-items: center;
  transition: var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: inline; }

/* ===== TAB 导航 ===== */
.tab-bar {
  display: flex;
  gap: 26px;
  margin-top: 18px;
}
.tab-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 1.05em;
  font-weight: 600;
  padding: 8px 2px 14px;
  cursor: pointer;
  transition: color var(--transition);
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--accent); }
.tab-btn.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

/* ===== 容器 ===== */
.container { max-width: var(--maxw); margin: 0 auto; padding: 28px 20px 10px; }

/* ===== TAB 内容 ===== */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeUp 0.3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== 工具栏（搜索 + 计数） ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 14px;
  color: var(--muted);
  font-size: 1.1em;
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 11px 16px 11px 40px;
  border: 1px solid var(--border);
  border-radius: 30px;
  background: var(--card);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.95em;
  transition: var(--transition);
}
.search-box input::placeholder { color: var(--muted); }
.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.count { color: var(--muted); font-size: 0.85em; white-space: nowrap; }

/* ===== 筛选 chips ===== */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.filter-btn {
  padding: 5px 15px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.82em;
  cursor: pointer;
  transition: var(--transition);
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.filter-btn.filter-more {
  border-style: dashed;
  color: var(--muted);
  background: transparent;
}
.filter-btn.filter-more:hover { color: var(--accent); border-color: var(--accent); }

/* ===== 卡片列表 ===== */
.card-grid { display: flex; flex-direction: column; gap: 4px; }
.card {
  background: transparent;
  padding: 22px 4px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
  position: relative;
}
.card:hover { padding-left: 14px; }
.card:hover .card-title { color: var(--accent); }
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title {
  font-family: var(--serif);
  font-size: 1.28em;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
  flex: 1;
  transition: color var(--transition);
}
.card-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.72em;
  font-weight: 600;
  white-space: nowrap;
}
.badge-tag { background: var(--accent-soft); color: var(--accent); }
.badge-cat { background: var(--bg-soft); color: var(--ink-soft); border: 1px solid var(--border); }
.badge-diff-easy { background: var(--diff-easy-bg); color: var(--diff-easy-fg); }
.badge-diff-mid  { background: var(--diff-mid-bg);  color: var(--diff-mid-fg); }
.badge-diff-hard { background: var(--diff-hard-bg); color: var(--diff-hard-fg); }
.card-desc {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 0.92em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.65;
}
.card-bottom {
  margin-top: 12px;
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 0.8em;
  color: var(--muted);
}
.card-source { display: inline-flex; align-items: center; gap: 4px; }

/* ===== 滚动加载哨兵 ===== */
.load-sentinel {
  text-align: center;
  padding: 22px 0 6px;
  color: var(--muted);
  font-size: 0.82em;
  letter-spacing: 0.5px;
  min-height: 1px;
}
.load-sentinel.active { cursor: pointer; }
.load-sentinel.active:hover { color: var(--accent); }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-state .icon { font-size: 2.6em; margin-bottom: 12px; opacity: 0.7; }

/* ===== 详情视图 ===== */
.detail-view { display: none; }
.detail-view.active { display: block; animation: fadeUp 0.3s ease; }
.list-view.hidden { display: none; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  margin-bottom: 18px;
  transition: var(--transition);
}
.back:hover { opacity: 0.7; }

.detail-layout { display: block; position: relative; }
.detail-main { min-width: 0; }

.detail-header { margin-bottom: 26px; }
.detail-header h1 {
  font-family: var(--serif);
  font-size: 2.1em;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.5px;
  color: var(--ink);
}
.detail-header .meta {
  font-size: 0.84em;
  color: var(--muted);
  margin-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.detail-header .meta .dot { opacity: 0.5; }

/* ===== 正文（杂志排版） ===== */
.detail-body { font-size: 1.08em; line-height: 1.9; color: var(--ink-soft); }
.detail-body > *:first-child { margin-top: 0; }
.detail-body h1, .detail-body h2, .detail-body h3, .detail-body h4 {
  font-family: var(--serif);
  color: var(--ink);
  margin-top: 1.8em;
  margin-bottom: 0.6em;
  line-height: 1.4;
  scroll-margin-top: 80px;
}
.detail-body h1 { font-size: 1.55em; }
.detail-body h2 {
  font-size: 1.34em;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}
.detail-body h3 { font-size: 1.16em; }
.detail-body h4 { font-size: 1.02em; }
.detail-body p { margin-bottom: 1.1em; }
.detail-body ul, .detail-body ol { margin: 0 0 1.1em 1.4em; }
.detail-body li { margin-bottom: 0.4em; }
.detail-body code {
  background: var(--bg-soft);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.86em;
  font-family: 'SF Mono', 'Cascadia Code', Consolas, Menlo, monospace;
  color: var(--accent-2);
}
.detail-body pre {
  background: #211d18;
  color: #ece4d6;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-bottom: 1.2em;
  font-size: 0.88em;
  line-height: 1.65;
  border: 1px solid var(--border-strong);
}
.detail-body pre code { background: none; padding: 0; color: inherit; font-size: 1em; }
.detail-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 6px 20px;
  margin: 1.4em 0;
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
  font-family: var(--serif);
}
.detail-body blockquote p:last-child { margin-bottom: 0; }
.detail-body img { max-width: 100%; border-radius: var(--radius-sm); margin: 1.2em 0; }
.detail-body a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
.detail-body a:hover { border-bottom-color: var(--accent); }
.detail-body table { width: 100%; border-collapse: collapse; margin: 1.4em 0; font-size: 0.92em; }
.detail-body th, .detail-body td { padding: 10px 14px; border: 1px solid var(--border); text-align: left; }
.detail-body th { background: var(--bg-soft); font-weight: 700; color: var(--ink); }
.detail-body hr { margin: 2.4em 0; border: none; border-top: 1px solid var(--border); }
.detail-body strong { color: var(--ink); font-weight: 700; }
/* 首字下沉（杂志感，仅博客首段） */
.detail-body.dropcap > p:first-of-type::first-letter {
  font-family: var(--serif);
  float: left;
  font-size: 3.1em;
  line-height: 0.82;
  font-weight: 800;
  color: var(--accent);
  margin: 0.05em 0.12em 0 0;
}

/* ===== 目录 TOC ===== */
.toc { display: none; }
.toc-title {
  font-family: var(--serif);
  font-size: 0.78em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-bottom: 12px;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a {
  display: block;
  padding: 4px 0 4px 12px;
  border-left: 2px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.84em;
  line-height: 1.5;
  transition: var(--transition);
}
.toc a:hover { color: var(--accent); }
.toc a.toc-h3 { padding-left: 24px; font-size: 0.8em; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }

@media (min-width: 1180px) {
  .container { max-width: 960px; }
  .detail-layout { display: grid; grid-template-columns: 1fr 220px; gap: 48px; align-items: start; }
  .toc {
    display: block;
    position: sticky;
    top: 30px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }
  .toc:empty { display: none; }
}

/* ===== 加载 ===== */
.loading { text-align: center; padding: 60px; color: var(--muted); }
.spinner {
  display: inline-block;
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 返回顶部 ===== */
.to-top {
  position: fixed;
  bottom: 26px; right: 26px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--accent);
  font-size: 1.2em;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: var(--transition);
  z-index: 150;
}
.to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== 外链资源框 ===== */
.resource-link-box {
  padding: 18px 22px;
  background: var(--card-soft);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent);
  margin-top: 8px;
}
.resource-link-box .label { margin: 0 0 8px; font-size: 0.85em; color: var(--muted); }
.resource-link-box a { font-weight: 700; font-size: 1.05em; color: var(--accent); text-decoration: none; }

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 40px 20px;
  margin-top: 40px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82em;
}
.footer a { color: var(--accent); text-decoration: none; }

/* ===== giscus ===== */
.giscus-wrapper { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.giscus { min-height: 150px; }

.hidden { display: none !important; }

/* ===== 响应式 ===== */
@media (max-width: 640px) {
  .brand { font-size: 1.7em; }
  .container { padding: 22px 16px 10px; }
  .detail-header h1 { font-size: 1.55em; }
  .detail-body { font-size: 1.02em; }
  .card-title { font-size: 1.14em; }
  .detail-body.dropcap > p:first-of-type::first-letter { font-size: 2.6em; }
  .tab-bar { gap: 20px; }
}
