/* =====================================================
   calnav.css — 栏目页「更新日历 + 两栏布局」& 文章页「上下篇导航」
   2026-10-21
   作用域全部是新类名（cat-bar / cat-layout / today-card / hist-* /
   datecal-* / postnav-*），不影响首页与其他既有页面。
   放在 base.html 最后加载：需要覆盖 theme-v1.css 对 .cat-* 的通用规则。
   ===================================================== */

/* ================= 栏目页：标题横栏 ================= */
.cat-bar {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 2px 0 13px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.cat-bar-ic {
  width: 38px; height: 38px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 15px; line-height: 1;
}
.cat-bar-main { flex: 1 1 auto; min-width: 0; }
.cat-bar-title { font: 800 20px/1.3 var(--serif); letter-spacing: .02em; color: var(--ink); }
.cat-bar-desc { font-size: 12.5px; color: var(--mute); margin-top: 1px; }
.cat-bar-stats {
  flex: none; display: flex; align-items: baseline; gap: 7px;
  font-size: 12.5px; color: var(--sub); white-space: nowrap;
}
.cat-bar-stats b { font: 700 14px var(--mono); color: var(--ink); }
.cat-bar-dot { color: var(--line-2); }
.cat-bar-latest { font-family: var(--mono); color: var(--sub); }

/* ================= 栏目页：两栏 ================= */
.cat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 306px;
  gap: 26px;
  align-items: start;
}
.cat-main { min-width: 0; }
.cat-side { position: sticky; top: 74px; }

/* ================= 最新一篇（整卡可点） ================= */
.today-card {
  display: block; text-decoration: none; color: inherit;
  background: linear-gradient(135deg, #fff 0%, #fdf7f1 100%);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 17px 20px 14px;
  margin-bottom: 22px;
  box-shadow: 0 2px 10px rgba(40, 30, 15, .05);
  transition: box-shadow .18s, transform .18s, border-color .18s;
}
.today-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(40, 30, 15, .1);
  border-color: rgba(214, 58, 48, .35);
  color: inherit;
}
.today-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.today-tag {
  font: 700 11.5px var(--sans); letter-spacing: .12em;
  color: #fff; background: var(--red); border-radius: 4px; padding: 2px 8px;
}
.today-date { font: 600 12.5px var(--mono); color: var(--mute); }
.today-go { margin-left: auto; font: 700 13px var(--sans); color: var(--red); }
.today-card:hover .today-go { color: var(--red-deep); }
.today-title { font: 800 22px/1.4 var(--serif); color: var(--ink); letter-spacing: .01em; }
.today-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 13px; }
.today-num {
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 4px; text-align: center;
}
.today-num b { display: block; font: 700 20px/1.25 var(--mono); color: var(--red); }
.today-num span { font-size: 11.5px; color: var(--sub); }
.today-quote { font: 400 15.5px/1.8 var(--serif); color: var(--ink); margin-top: 8px; }
.today-teaser { font-size: 13px; color: var(--sub); line-height: 1.7; margin-top: 7px; }
.today-foot {
  display: flex; align-items: center; gap: 12px;
  margin-top: 12px; font-size: 12px; color: var(--mute);
}
.today-teaser-inline { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-meta { margin-left: auto; flex: none; display: flex; gap: 12px; }

/* ================= 历史记录：两列紧凑行 ================= */
.hist-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.hist-head h2 { font: 800 15px var(--serif); letter-spacing: .05em; color: var(--ink); }
.hist-head span {
  flex: 0 1 auto; min-width: 0;
  font-size: 12px; color: var(--mute);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hist-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.hist-row {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 12px; text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.hist-row:hover {
  border-color: rgba(214, 58, 48, .38);
  box-shadow: 0 4px 14px rgba(40, 30, 15, .07);
  transform: translateX(2px);
  color: inherit;
}
.hist-date { flex: none; font: 600 11px var(--mono); color: var(--red); letter-spacing: -.03em; }
.hist-title {
  flex: 1 1 auto; min-width: 0; font-size: 12.5px; color: var(--ink);
  letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hist-go { flex: none; font-size: 13px; color: var(--line-2); transition: color .15s, transform .15s; }
.hist-row:hover .hist-go { color: var(--red); transform: translateX(2px); }

/* ================= 更新日历 ================= */
.datecal {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(40, 30, 15, .05);
  overflow: hidden;
}
.datecal-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 13px 14px 11px;
  border-bottom: 1px solid var(--line);
  cursor: default;
  list-style: none;
}
.datecal-head::-webkit-details-marker { display: none; }
.datecal-h-title { font: 800 14.5px var(--serif); letter-spacing: .06em; color: var(--ink); }
.datecal-h-note { margin-left: auto; font-size: 11px; color: var(--mute); }
.datecal-h-caret { display: none; font-size: 11px; color: var(--mute); transition: transform .2s; }

.datecal-body { padding: 4px 12px 12px; }

.datecal-month { padding-top: 6px; }
.datecal-mlabel {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 6px 2px 5px;
  font: 700 12.5px var(--mono); color: var(--ink); letter-spacing: .02em;
}
.datecal-mcount { font: 400 11px var(--sans); color: var(--mute); }
.datecal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; padding-bottom: 4px; }
.datecal-dow span { text-align: center; font-size: 10.5px; color: var(--mute); }
.datecal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }

.dc {
  display: flex; align-items: center; justify-content: center;
  min-height: 27px; border-radius: 6px;
  font: 600 11.5px var(--mono); color: #b6b0a4;
  background: transparent;
  text-decoration: none;
}
.dc-out { visibility: hidden; }
.dc-future { color: #dcd6ca; }
.dc-has {
  background: rgba(214, 58, 48, .1);
  color: var(--red-deep); font-weight: 700;
  cursor: pointer;
  transition: background .15s, color .15s, transform .12s, box-shadow .15s;
}
.dc-has:hover {
  background: var(--red-deep); color: #fff;
  transform: translateY(-1px) scale(1.08);
  box-shadow: 0 4px 10px rgba(214, 58, 48, .35);
}
/* 最新一篇所在日：唯一实心红，把视线直接钉在"最后一次更新"上 */
.dc-latest { background: var(--red); color: #fff; }
.dc-has:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
/* 今天：金色描边，红格/灰格上都能认出来，且不改变布局 */
.dc-today { outline: 1.5px solid #b08a2e; outline-offset: -1px; }

.datecal-legend {
  display: flex; align-items: center; gap: 6px;
  margin: 10px 2px 0; padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: 11px; color: var(--mute);
}
.dc-mini {
  width: 12px; height: 12px; min-height: 0;
  border-radius: 4px; background: var(--bg-sunken);
  font-size: 0; text-indent: -99px; overflow: hidden;
}
/* 图例小方块比格子小，浅红会看不清，单独加深一档 */
.dc-mini.dc-has { background: rgba(214, 58, 48, .42); }
.dc-mini.dc-latest { background: var(--red); }
.dc-mini + .dc-mini { margin-left: 8px; }
/* 更早的月份：折叠区，点开才渲染显示（HTML 一次渲染完，只是视觉隐藏） */
.cal-older { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.cal-older > summary {
  list-style: none; cursor: pointer; text-align: center;
  padding: 5px 0; border-radius: 6px;
  font-size: 11.5px; color: var(--sub);
}
.cal-older > summary::-webkit-details-marker { display: none; }
.cal-older > summary:hover { color: var(--red); background: var(--bg-soft); }
.cal-older[open] > summary { margin-bottom: 2px; }

/* ================= 文章页：上下篇导航 ================= */
.postnav-top {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0 14px; font-size: 12.5px;
  flex-wrap: wrap;
}
.postnav-back { font-weight: 650; color: var(--sub); }
.postnav-back:hover { color: var(--red); }
.postnav-mini { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.postnav-mini > a,
.postnav-mini > .is-off {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 4px 11px; border-radius: 20px;
  border: 1px solid var(--line); background: #fff;
  color: var(--sub); text-decoration: none;
  transition: border-color .15s, color .15s, background .15s;
}
.postnav-mini > a:hover { border-color: var(--red); color: var(--red); background: #fffdfb; }
.postnav-mini .pm-date { font: 600 11px var(--mono); color: var(--mute); }
.postnav-mini .pm-dir { font-size: 12px; font-weight: 650; }
.postnav-mini > .is-off {
  color: var(--line-2); border-style: dashed; cursor: default; pointer-events: none;
}

.postnav-bottom {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin: 18px 0 4px;
}
.postnav-card {
  display: flex; flex-direction: column; gap: 5px;
  min-width: 0; padding: 13px 16px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  text-decoration: none; color: inherit;
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.postnav-card:hover {
  border-color: rgba(214, 58, 48, .4);
  box-shadow: 0 8px 20px rgba(40, 30, 15, .08);
  transform: translateY(-1px);
  color: inherit;
}
.postnav-card.next { text-align: right; }
.postnav-kicker {
  display: flex; align-items: baseline; gap: 7px;
  font: 700 11px var(--sans); letter-spacing: .1em; color: var(--red);
}
.postnav-card.next .postnav-kicker { justify-content: flex-end; }
.postnav-date { font: 600 11.5px var(--mono); color: var(--mute); letter-spacing: 0; }
.postnav-title {
  font-size: 13.5px; font-weight: 650; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.postnav-card.is-empty {
  border-style: dashed; background: transparent;
  color: var(--mute); pointer-events: none; justify-content: center;
}
.postnav-card.is-empty .postnav-kicker { color: var(--line-2); }
.postnav-card.is-empty .postnav-title { color: var(--mute); font-weight: 400; }

/* ================= 响应式 ================= */
@media (max-width: 900px) {
  /* 顺带修一个既有问题：手机端顶部导航是「横向滚动条」，但 flex 项的自动最小尺寸
     等于其 nowrap 内容宽度，会把 header 撑到 512px（视口 430px），整页横向溢出、
     右侧内容被切。给滚动容器与 header 显式 min-width:0 即可解决。 */
  .header-inner { min-width: 0; }
  .main-nav { min-width: 0; max-width: 100%; }

  .cat-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .cat-side { position: static; order: -1; }
  /* 手机上日历默认收起：首屏先给内容，点标题栏再展开（脚本按断点设置 open） */
  .datecal-head { cursor: pointer; background: var(--bg-soft); }
  .datecal-h-caret { display: block; }
  .datecal[open] .datecal-h-caret { transform: rotate(180deg); }
  .datecal[open] .datecal-head { border-bottom: 1px solid var(--line); }
  .datecal:not([open]) .datecal-head { border-bottom: 0; }
  /* 展开后也只给近两个月，第三个月交给「看完整更新记录」 */
  .datecal-month-extra { display: none; }
}
@media (max-width: 700px) {
  .cat-bar { flex-wrap: wrap; gap: 10px; }
  .cat-bar-stats { width: 100%; padding-left: 51px; }
  .today-card { padding: 15px 15px 12px; }
  .today-title { font-size: 19px; }
  .today-nums { grid-template-columns: repeat(2, 1fr); }
  .hist-grid { grid-template-columns: minmax(0, 1fr); }
  /* 手机上「共 N 篇 · 按日期倒序…」这行说明会把标题挤掉，直接不显示 */
  .hist-head > span { display: none; }
  .postnav-mini { width: 100%; margin-left: 0; }
  .postnav-mini > a,
  .postnav-mini > .is-off { flex: 1 1 0; justify-content: center; }
  .postnav-bottom { grid-template-columns: 1fr; }
  .postnav-card.next { text-align: left; }
  .postnav-card.next .postnav-kicker { justify-content: flex-start; }
}
