/* ==========================================================================
   sp.submenu.css — SolarPress 通用二级菜单（主题无关）
   颜色全部走 --spm-* 变量，主题可在自己的 :root/暗色域覆盖。
   ========================================================================== */
:root {
  --spm-bg: #ffffff;
  --spm-ink: #1f2328;
  --spm-muted: #6b7280;
  --spm-faint: #9aa1ab;
  --spm-line: #e5e7eb;
  --spm-accent: #e6533c;
  --spm-accent-soft: rgba(230, 83, 60, 0.1);
  --spm-shadow: 0 18px 44px -16px rgba(30, 25, 20, 0.28);
  --spm-radius: 6px;
}
/* 常见暗色钩子（主题也可用自己的变量覆盖） */
html.dark, html[data-theme="dark"], html[data-theme="black"],
body.dark, [data-theme="dark"], [data-layout="dark"] {
  --spm-bg: #1c1c1e;
  --spm-ink: #e8e6e1;
  --spm-muted: #a8a49c;
  --spm-faint: #76736c;
  --spm-line: #34322f;
  --spm-shadow: 0 20px 48px -16px rgba(0, 0, 0, 0.7);
}

[data-spm] { display: none !important; }

/* ---- 桌面 ---- */
.spm-has { position: relative; }
.spm-parent { display: inline-flex; align-items: center; }
.spm-caret {
  width: 22px; height: 100%;
  min-height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--spm-muted);
  padding: 0; cursor: pointer;
  border-radius: 4px;
  transition: color 0.18s ease;
}
.spm-caret:hover { color: var(--spm-accent); }
.spm-chevron { transition: transform 0.24s ease; }
.spm-has.spm-open .spm-chevron { transform: rotate(180deg); }

.spm-panel-down {
  position: absolute; top: calc(100% + 6px); left: 0;
  /* 子分类同一行横排：显式 max-content 宽度，避免绝对定位 shrink-to-fit 导致子项各自换行 */
  display: flex; align-items: center; gap: 2px;
  width: max-content;
  padding: 6px;
  background: var(--spm-bg);
  border: 1px solid var(--spm-line);
  border-radius: var(--spm-radius);
  box-shadow: var(--spm-shadow);
  opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  z-index: 1000;
}
.spm-has.spm-open .spm-panel-down { opacity: 1; visibility: visible; transform: none; }
.spm-panel-down.spm-flip { left: auto; right: 0; }

.spm-sub {
  flex: 0 0 auto;
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 11px;
  font-size: 0.84rem; line-height: 1.5;
  color: var(--spm-muted);
  border-radius: calc(var(--spm-radius) - 2px);
  white-space: nowrap;
}
.spm-sub::before { content: "·"; color: var(--spm-faint); }
.spm-sub:hover { color: var(--spm-accent); background: var(--spm-accent-soft); }
.spm-sub.active { color: var(--spm-accent); font-weight: 600; background: var(--spm-accent-soft); }
.spm-sub.active::before { content: "●"; font-size: 0.58rem; }
a.spm-parent-active { color: var(--spm-accent) !important; }

/* ---- 父链接上的子级文章总数徽章（桌面/移动通用） ---- */
.spm-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  margin-left: 6px;
  font-size: 0.68rem; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: 0;
  color: var(--spm-muted);
  background: var(--spm-accent-soft);
  border-radius: 999px;
  vertical-align: middle;
  white-space: nowrap;
  transition: color 0.18s ease;
}
.spm-has:hover > a:not(.spm-sub) .spm-count,
.spm-m-has:hover > a:not(.spm-sub) .spm-count,
a.spm-parent-active .spm-count { color: var(--spm-accent); }

/* ---- 移动手风琴（li 或自建 wrapper 均为弹性换行容器） ---- */
.spm-m-has { display: flex; flex-wrap: wrap; align-items: center; }
.spm-m-has > a:not(.spm-sub) { flex: 1 1 auto; min-width: 0; }
.spm-m-parent { width: 100%; }
.spm-m-caret {
  flex-shrink: 0; width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--spm-radius);
  background: transparent; color: var(--spm-muted); cursor: pointer;
}
.spm-m-caret:hover { color: var(--spm-accent); background: var(--spm-accent-soft); }
.spm-m-has.spm-m-open > .spm-m-caret .spm-chevron { transform: rotate(180deg); }
.spm-panel-acc {
  display: grid; grid-template-rows: 0fr;
  flex: 0 0 100%; width: 100%;
  transition: grid-template-rows 0.28s ease;
}
.spm-m-has.spm-m-open > .spm-panel-acc { grid-template-rows: 1fr; }
.spm-panel-acc > * { overflow: hidden; min-height: 0; }
.spm-panel-acc .spm-sub {
  white-space: normal;
  padding-left: 24px;
  font-size: 0.86rem;
}
.spm-panel-acc .spm-sub::before { content: "—"; }

/* 窄屏兜底：即便是桌面 nav 变成竖排，下拉也改为静态展开，避免绝对定位溢出 */
@media (max-width: 920px) {
  .spm-has { position: static; }
  .spm-panel-down {
    position: static;
    width: 100%; max-width: none; min-width: 0;
    margin: 2px 0 4px;
    box-shadow: none;
    transform: none;
    display: none;
  }
  .spm-has.spm-open .spm-panel-down { display: block; opacity: 1; visibility: visible; }
}
