/* ============================================================
 * heronk-pc-gadget-article-contents —— 长文目录（TOC）小部件样式
 * 悬浮面板（贴正文卡片左侧、随阅读移动）+ 正文 H2 / H3 标题效果
 * ============================================================ */

/* ---- 悬浮挂载点：fixed 定位，位置由 module.js 按正文卡片几何逐帧计算 ---- */

.heronk-pc-gadget-article-contents {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 80;
  width: 230px; /* 兜底；实际宽度由 JS 按设置写入 */
  font-size: 14px;
  line-height: 1.6;
  color: #444;
  -webkit-font-smoothing: antialiased;
  visibility: visible;
  opacity: 1;
  /* 只过渡显隐；top/left 由 JS 逐帧直写（跟随滚动），加过渡会拖住跟随 */
  transition: opacity 0.25s ease;
  will-change: top, left, opacity;
}

/* 正文卡片离开视口 / 左侧放不下：收起（保留占位尺寸便于继续测量） */
.heronk-pc-gadget-article-contents[data-show="0"] {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

/* 首帧定位前不显示（避免闪在左上角） */
.heronk-pc-gadget-article-contents:not([data-show]) {
  visibility: hidden;
}

/* 窄窗口兜底：JS 会算放不放得下，这一条防脚本缺席时的闪现 */
@media (max-width: 1080px) {
  .heronk-pc-gadget-article-contents {
    display: none !important;
  }
}

/* ---- 悬浮面板（颜色走站点主题变量，主题没定义时用后面的回退值） ---- */

.heronk-pc-gadget-article-contents .hk-toc-box {
  background: var(--ls-card-bg, #fff) !important;
  border: 1px solid var(--ls-border-light, #f3f4f6) !important;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(20, 20, 20, 0.08), 0 10px 28px rgba(20, 20, 20, 0.06);
  padding: 16px 0 8px;
  overflow: hidden;
}

.heronk-pc-gadget-article-contents .hk-toc-head {
  padding: 0 16px 10px;
  border-bottom: 1px solid var(--ls-border-light, #f1f1f1);
}

.heronk-pc-gadget-article-contents .hk-toc-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ls-text, #1f2937) !important;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- 统计 / 提示 ---- */

.heronk-pc-gadget-article-contents .hk-toc-meta {
  margin: 10px 16px 0;
  font-size: 12px;
  color: var(--ls-text-muted, #4b5563) !important;
}

.heronk-pc-gadget-article-contents .hk-toc-intro {
  margin: 4px 16px 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--ls-border-light, #f1f1f1);
  font-size: 12px;
  color: var(--ls-text-muted, #4b5563) !important;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- 目录列表（长列表：限高 + 滚动 + 自定义滚动条） ---- */

.heronk-pc-gadget-article-contents .hk-toc-list {
  list-style: none;
  margin: 8px 16px 6px;
  padding: 0 6px 6px 4px;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  background: var(--ls-bg, #fff) !important;
  scrollbar-width: thin;
  scrollbar-color: var(--ls-primary, #f0c8a8) transparent;
}

.heronk-pc-gadget-article-contents .hk-toc-list::-webkit-scrollbar {
  width: 5px;
}

.heronk-pc-gadget-article-contents .hk-toc-list::-webkit-scrollbar-track {
  background: transparent;
}

.heronk-pc-gadget-article-contents .hk-toc-list::-webkit-scrollbar-thumb {
  background: var(--ls-primary, #f6cfa9);
  border-radius: 999px;
}

.heronk-pc-gadget-article-contents .hk-toc-list::-webkit-scrollbar-thumb:hover {
  background: #f0b071;
}

.heronk-pc-gadget-article-contents .hk-toc-item {
  margin: 2px 0;
}

.heronk-pc-gadget-article-contents .hk-toc-anchor {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ls-text-secondary, #4b5563) !important;
  background: var(--ls-bg, #fff) !important;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
  border-left: 3px solid transparent;
}

/* 悬停 / 激活态同样加 !important，压过上面的基色，保证交互反馈仍在 */
.heronk-pc-gadget-article-contents .hk-toc-anchor:hover {
  background: #fff7ed !important;
  color: #c2610c !important;
}

.heronk-pc-gadget-article-contents .hk-toc-bullet {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 7px;
  background: #e2c9b3;
  transition: all 0.18s ease;
}

/* H3 副标题：缩进 + 小方点 */
.heronk-pc-gadget-article-contents .hk-toc-l3 .hk-toc-anchor {
  padding-left: 26px;
}

.heronk-pc-gadget-article-contents .hk-toc-l3 .hk-toc-bullet {
  width: 5px;
  height: 5px;
  border-radius: 2px;
  background: #e9ddd1;
}

.heronk-pc-gadget-article-contents .hk-toc-text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.heronk-pc-gadget-article-contents .hk-toc-l2 .hk-toc-text {
  font-weight: 500;
}

/* 激活态：左彩条 + 橙底 */
.heronk-pc-gadget-article-contents .hk-toc-item.active .hk-toc-anchor {
  background: #fff3e3 !important;
  border-left-color: #f97316;
  color: #c2610c !important;
}

.heronk-pc-gadget-article-contents .hk-toc-item.active .hk-toc-bullet {
  background: #f97316;
  transform: scale(1.25);
}

.heronk-pc-gadget-article-contents .hk-toc-item.active .hk-toc-text {
  color: #c2610c;
  font-weight: 600;
}

/* ============================================================
 * 正文标题效果（module.js 挂到正文 h2 / h3 上）
 * ============================================================ */

/* H2 标题：左侧渐变彩条 + 底部细线 */
h2.hk-h2 {
  position: relative;
  padding-left: 14px;
  margin-top: 1.6em;
  border-bottom: 1px solid #f3e3d3;
  scroll-behavior: smooth;
}

h2.hk-h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.22em;
  bottom: 0.22em;
  width: 5px;
  border-radius: 3px;
  background: linear-gradient(180deg, #fb923c, #ea580c);
}

h2.hk-h2::after {
  content: "#";
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  color: #fdba74;
  font-size: 0.72em;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.18s ease;
}

h2.hk-h2:hover::after {
  opacity: 1;
}

/* H3 副标题：左侧圆点标记 */
h3.hk-h3 {
  position: relative;
  padding-left: 14px;
}

h3.hk-h3::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 0.62em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fdba74, #f97316);
  box-shadow: 0 0 0 3px #fff3e3;
}

/* 跳转闪动：柔和的橙色高亮渐隐 */
h2.hk-h2.hk-flash,
h3.hk-h3.hk-flash {
  animation: heronk-ac-flash 1.6s ease-out;
}

@keyframes heronk-ac-flash {
  0% {
    background-color: #ffedd5;
    box-shadow: -5px 0 0 0 #f97316;
  }
  60% {
    background-color: #fff7ed;
    box-shadow: -5px 0 0 0 #fdba74;
  }
  100% {
    background-color: transparent;
    box-shadow: -5px 0 0 0 transparent;
  }
}

/* 尊重系统的「减少动态效果」设置 */
@media (prefers-reduced-motion: reduce) {
  .heronk-pc-gadget-article-contents *,
  h2.hk-h2,
  h3.hk-h3 {
    transition: none !important;
    animation: none !important;
  }
}
