/**
 * Quartz Features Styles for Hexo Butterfly
 * 
 * 包含：Explorer 文件树 + Backlinks 反向链接 + Popover Previews
 * 灵感来源：Quartz v4 (https://github.com/jackyzha0/quartz)
 */

/* ================================================================
   📂 Explorer 文件树
   ================================================================ */

.q-explorer-widget {
  overflow: hidden;
}

.q-explorer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.q-explorer-title {
  font-size: 0.9em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.q-explorer-title i {
  color: var(--btn-color, #49B1F5);
  font-size: 0.85em;
}

.q-explorer-collapse-all {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--font-color, #4c4948);
  opacity: 0.5;
  transition: all 0.2s ease;
  font-size: 0.8em;
}

.q-explorer-collapse-all:hover {
  opacity: 1;
  background: var(--btn-hover-color, rgba(73,177,245,0.1));
  color: var(--btn-color, #49B1F5);
}

.q-explorer-tree {
  max-height: 420px;
  overflow-y: auto;
  padding: 6px 8px 8px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(128,128,128,0.2) transparent;
}

.q-explorer-tree::-webkit-scrollbar {
  width: 4px;
}

.q-explorer-tree::-webkit-scrollbar-thumb {
  background: rgba(128,128,128,0.2);
  border-radius: 2px;
}

/* 文件夹 */
.q-tree-folder-header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.85em;
  user-select: none;
}

.q-tree-folder-header:hover {
  background: var(--btn-hover-color, rgba(73,177,245,0.08));
}

.q-tree-arrow {
  font-size: 0.65em;
  transition: transform 0.2s ease;
  color: var(--font-color, #4c4948);
  opacity: 0.5;
  width: 12px;
  text-align: center;
}

.q-tree-arrow.open {
  transform: rotate(90deg);
}

.q-tree-icon {
  font-size: 0.85em;
  width: 16px;
  text-align: center;
}

.q-tree-folder-header .q-tree-icon {
  color: #F0C866;
}

.q-tree-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.q-tree-folder-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  padding-left: 10px;
}

.q-tree-folder-content.open {
  max-height: 2000px;
  transition: max-height 0.5s ease;
}

/* 上下文感知：非相关文件夹半透明 */
.q-tree-folder.q-tree-dimmed {
  opacity: 0.4;
  transition: opacity 0.3s ease;
}
.q-tree-folder.q-tree-dimmed:hover {
  opacity: 1;
}

/* 上下文感知：非相关文件条目半透明 */
.q-tree-file.q-tree-file-dimmed {
  opacity: 0.35;
}
.q-tree-file.q-tree-file-dimmed:hover {
  opacity: 1;
}

/* 文件条目 */
.q-tree-file {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none !important;
  color: var(--font-color, #4c4948) !important;
  font-size: 0.82em;
}

.q-tree-file:hover {
  background: var(--btn-hover-color, rgba(73,177,245,0.08));
  color: var(--btn-color, #49B1F5) !important;
}

.q-tree-file.active {
  background: var(--btn-hover-color, rgba(73,177,245,0.12));
  color: var(--btn-color, #49B1F5) !important;
  font-weight: 600;
}

.q-tree-file.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--btn-color, #49B1F5);
  border-radius: 0 3px 3px 0;
}

.q-tree-file .q-tree-icon {
  color: var(--font-color, #4c4948);
  opacity: 0.6;
}

.q-tree-file.active .q-tree-icon {
  color: var(--btn-color, #49B1F5);
  opacity: 1;
}

.q-tree-date {
  font-size: 0.75em;
  opacity: 0.4;
  margin-left: auto;
  flex-shrink: 0;
}

/* ================================================================
   🔗 Backlinks 反向链接
   ================================================================ */

.q-backlinks-section {
  clear: both;
}

.q-backlink-card {
  /* 基础卡片样式在 JS 内联中定义 */
}

.q-backlink-card:hover {
  text-decoration: none !important;
}

/* ================================================================
   🔍 Popover Previews
   ================================================================ */

.q-popover {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ---- 悬浮预览卡片 ----
   2026-09-03 从 quartz-features.js 的行内样式搬过来。三个要点：
   1) 字号一律用 rem。原来用 em，卡片挂在 #article-container 里会继承
      放大后的基准字号，实际比设计意图大一号。
   2) 摘要截 3 行。后端截 200 字，320px 宽下能排 10 行，卡片会高到挡住整个列表。
   3) 不用图标和 emoji。列表行本身没有图标，日期沿用列表里同一套等宽数字，
      卡片才像这一页的一部分。 */

.q-popover-card {
  padding: 13px 15px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  /* 两层阴影：近处一层交代边缘，远处一层交代浮起高度 */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 10px 28px rgba(0, 0, 0, 0.11);
}

.q-popover-title {
  color: #1f2328;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.45;
  /* 标题最多两行，再长就省略，不让卡片被一个长标题撑开 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.q-popover-excerpt {
  margin: 7px 0 0;
  color: rgba(0, 0, 0, 0.56);
  font-size: 0.78rem;
  line-height: 1.62;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.q-popover-date {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.36);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

[data-theme="dark"] .q-popover-card {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(28, 28, 28, 0.97);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.45);
}
[data-theme="dark"] .q-popover-title {
  color: rgba(255, 255, 255, 0.92);
}
[data-theme="dark"] .q-popover-excerpt {
  color: rgba(255, 255, 255, 0.62);
}
[data-theme="dark"] .q-popover-date {
  border-top-color: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.38);
}

/* ================================================================
   暗色模式适配
   ================================================================ */

[data-theme="dark"] .q-explorer-tree {
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

[data-theme="dark"] .q-explorer-collapse-all {
  color: rgba(255,255,255,0.7);
}

[data-theme="dark"] .q-explorer-collapse-all:hover {
  color: var(--btn-color, #49B1F5);
  background: rgba(73,177,245,0.1);
}

[data-theme="dark"] .q-tree-folder-header:hover {
  background: rgba(255,255,255,0.05);
}

[data-theme="dark"] .q-tree-file {
  color: rgba(255,255,255,0.75) !important;
}

[data-theme="dark"] .q-tree-file:hover,
[data-theme="dark"] .q-tree-file.active {
  color: var(--btn-color, #49B1F5) !important;
  background: rgba(73,177,245,0.08);
}

[data-theme="dark"] .q-tree-arrow {
  color: rgba(255,255,255,0.5);
}

/* ================================================================
   响应式
   ================================================================ */

@media (max-width: 768px) {
  .q-explorer-tree {
    max-height: 300px;
  }
  
  .q-backlinks-grid {
    grid-template-columns: 1fr !important;
  }
}
