/* ============================================================
   Axtrivc's Blog — Theme System v7 (Panel UI + overrides)
   Color changes: JS direct DOM manipulation (theme-system.js)
   ============================================================ */

/* CRITICAL: Override Butterfly's inline-style background on #web_bg */
#web_bg,
.bg-animation#web_bg {
  background-color: #FFFFFF !important;
  background-image: none !important;
}

/* CRITICAL: Override #page-header brown bg + dark overlay
   修复 2026-06-26：hexo-butterfly 5.x 默认 #page-header { background-color: #8b6f47 } (棕色)
   主题切换后 nav 仍是黄色就是这个没覆盖。
   加 full_page + post-bg 两个变体（post-bg 是文章页）。 */
#page-header,
#page-header.full_page,
#page-header.post-bg {
  background-color: transparent !important;
  background-image: none !important;
  background-attachment: scroll !important;
}
#page-header::before,
#page-header.full_page::before,
#page-header.post-bg::before {
  background-color: transparent !important;
  opacity: 0 !important;
}

/* 2026-06-26 修复：文章页（非主页，无 hero-page-active）默认 post-bg 高度 400px，
   但没 top_img 时显示成 400px 白色空白。压缩为自适应 + 最小 220px 放标题。 */
body:not(.hero-page-active) #page-header.post-bg {
  height: auto !important;
  min-height: 220px !important;
}

/* 2026-07-22 修复：文章页标题/meta 隐形
   header 背景已在上方改透明，但 Butterfly 的 #post-info 仍是为深色 top_img
   设计的白字标题(#FFFFFF) + 浅灰 meta(#EEEEEE)，白底页面上完全/几乎看不见。
   改为跟随主题的深色系（标题 --theme-heading，meta --theme-secondary-current）。 */
#page-header.post-bg #post-info .post-title {
  color: var(--theme-heading, #1a1a1a) !important;
  text-shadow: none !important;
}
#page-header.post-bg #post-info #post-meta,
#page-header.post-bg #post-info #post-meta span,
#page-header.post-bg #post-info #post-meta time,
#page-header.post-bg #post-info #post-meta i {
  color: var(--theme-secondary-current, #7A7A7A) !important;
  text-shadow: none !important;
}
#page-header.post-bg #post-info #post-meta a {
  color: var(--theme-accent-current, #07C160) !important;
}

/* Hide Butterfly dark mode toggle */
#toggle-sidebar,
#darkmode_button,
.darkmode_toggle { display: none !important; }

/* Theme nav item highlight - 跟随主题主色 + 强制居中下划线 */
#nav-theme-trigger {
  position: relative;
  color: #333333 !important;
}
#nav-theme-trigger::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 50% !important;
  transform: translateX(-50%) !important;
  width: 0; height: 2px;
  background: var(--theme-accent-current, #07C160) !important;
  border-radius: 1px;
  transition: width 0.25s ease, background 0.45s ease;
}
#nav-theme-trigger:hover::after { width: 80% !important; }

/* 全局导航菜单下划线 - 跟随主题主色，但排除 Theme 按钮（避免覆盖其居中定位）
   注：使用 --theme-accent-current（不是 --theme-accent legacy），
   保证 CSS 解析初期 JS 尚未 setProperty 时 fallback 到 #07C160 也至少等于
   旧 var 的语义；JS 跑完后会平滑切换到当前主题色。 */
#menus .menus_item a:not(#nav-theme-trigger),
#nav a.site-page:not(#nav-theme-trigger),
.menus_items a:not(#nav-theme-trigger) {
  position: relative;
}
#menus .menus_item a:not(#nav-theme-trigger)::after,
#nav a.site-page:not(#nav-theme-trigger)::after,
.menus_items a:not(#nav-theme-trigger)::after {
  background: var(--theme-accent-current, #07C160) !important;
  transition: background 0.45s ease;
}
/* Butterfly 原生下划线选择器兼容 */
#menus .menus_item:hover > a:not(#nav-theme-trigger)::after,
.menus_item:hover > a.site-page:not(#nav-theme-trigger)::after {
  background: var(--theme-accent-current, #07C160) !important;
}

/* ═══ 2026-06-27 修复：active menu 下划线不跟主题 ═══
   根因 1：上面 --theme-accent → --theme-accent-current 改完，JS 未跑时 underline
            颜色 fallback 到 #07C160，但 JS 一跑就 OK，理论上不应持久绿。
   根因 2（真正的）：Butterfly 默认 underline 是 hover 触发 + 渐变色 brown，
            theme-system.css 之前的覆盖虽然 specificty 够，但用了 legacy --theme-accent
            （仅在 applyTheme 内设置），CSS 解析初期变量未定义 → fallback #07C160。
            如果 JS 异步加载慢或 theme 切换瞬态，underline 会"卡"在绿色。
   修复：
     a) 上面已把 --theme-accent 改 --theme-accent-current（更早 setProperty）
     b) 这里加 body 前缀的更高优先级兜底，覆盖所有可能的 active/select 类
     c) 用 ID 选择器升一级 specificity，确保压过 Butterfly 原生规则 */
body #page-header #nav #menus .menus_item a::after,
body #page-header #nav #menus .menus_items a::after,
body #page-header #nav a.site-page::after,
body #nav .menus_item a::after,
body #nav a.site-page::after {
  background-color: var(--theme-accent-current, #07C160) !important;
  transition: background-color 0.45s ease !important;
}
body #page-header #nav #menus .menus_item:hover a::after,
body #page-header #nav #menus .menus_items a:hover::after,
body #page-header #nav a.site-page:hover::after,
body #nav .menus_item:hover a::after,
body #nav a.site-page:hover::after {
  background-color: var(--theme-accent-current, #07C160) !important;
}
/* 防御：覆盖 Butterfly 未来版本可能引入的 .select_parent / .select-child / .menus_item.select
   即使本仓库 5.5.4 没有这些类，提前兜底避免升级后回归 */
body #nav .select_parent > a::after,
body #nav .select-child a::after,
body #nav .menus_item.select a::after,
body #nav .menus_item.select > a::after {
  background: var(--theme-accent-current, #07C160) !important;
  background-color: var(--theme-accent-current, #07C160) !important;
  border-color: var(--theme-accent-current, #07C160) !important;
}

/* Panel overlay */
#theme-overlay {
  position: fixed; top:0; left:0; width:100%; height:100%;
  background: rgba(0,0,0,0.18);
  z-index: 10005; opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease; backdrop-filter: blur(3px);
}
#theme-overlay.show { opacity: 1; pointer-events: auto; }

/* Main panel */
#theme-panel {
  position: fixed; top: 60px; right: 20px;
  width: 320px; max-height: 80vh; overflow-y: auto;
  background: var(--theme-surface-current, #fff);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.15);
  z-index: 10006;
  transform: translateY(-10px) scale(0.97);
  opacity: 0; pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.18) transparent;
}
#theme-panel::-webkit-scrollbar { width: 6px; }
#theme-panel::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 3px; }
#theme-panel::-webkit-scrollbar-track { background: transparent; }
#theme-panel.show {
  transform: translateY(0) scale(1);
  opacity: 1; pointer-events: auto;
}

/* Header */
#theme-panel .panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--theme-border-current, rgba(0,0,0,0.06));
}
#theme-panel .panel-header .panel-title {
  font-size: 14px; font-weight: 700;
  color: var(--theme-heading, #222);
  display: flex; align-items: center; gap: 8px;
}
#theme-panel .panel-header .icon { font-size: 16px; }
#theme-panel .panel-close {
  width:28px; height:28px; border-radius:50%; border:none;
  background: rgba(0,0,0,0.05);
  color: var(--theme-secondary-current, #888);
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  font-size:14px; transition:all 0.2s;
}
#theme-panel .panel-close:hover {
  background:rgba(0,0,0,0.12);
  color: var(--theme-heading, #333);
}

/* Section labels */
.panel-section-label {
  padding: 14px 18px 6px;
  font-size: 11px; font-weight: 700;
  color: var(--theme-secondary-current, #aaa);
  text-transform: uppercase; letter-spacing: 1.2px;
}
.panel-section-sub {
  padding: 0 18px 8px;
  font-size: 10px;
  color: var(--theme-secondary-current, #bbb);
  letter-spacing: 0.5px;
}

/* Theme grid */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 18px 8px;
}
.theme-option {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 6px; border-radius: 12px; border: 2px solid transparent;
  cursor: pointer; transition: all 0.22s ease;
}
.theme-option:hover {
  border-color: var(--theme-border-current, rgba(0,0,0,0.08));
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.05);
}
.theme-option.active {
  border-color: var(--theme-accent-current, #07C160);
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.015);
}
/* Check mark on active */
.theme-option.active .theme-name::before {
  content: '✓';
  margin-right: 4px;
  color: var(--theme-accent-current, #07C160);
  font-weight: 700;
}
.theme-name {
  font-size: 11px; font-weight:600;
  color: var(--theme-text-current, #333);
  white-space:nowrap;
}

/* Swatches */
.theme-swatch { display: flex; gap: 3px; }
.swatch-dot {
  width:16px; height:16px; border-radius:50%;
  border: 1.5px solid rgba(255,255,255,0.6); box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Background section styles removed — feature deleted */

/* Responsive */
@media(max-width:768px){
  #theme-panel{ width:calc(100vw - 32px); right:16px; left:16px; top:56px; }
}

/* ============================================================
   Global theme overrides — elements often missed by JS applyTheme
   Uses CSS custom properties set by theme-system.js
   ============================================================ */

/* Footer — 完全融入背景（不单独拎出来，与背景同色） */
#footer-wrap,
#footer,
footer {
  background-color: var(--theme-body-current, transparent) !important;
  background: transparent !important;
  color: var(--theme-secondary-current, #666666) !important;
  border-top: none !important;
  box-shadow: none !important;
  transition: color 0.45s ease;
}
#footer .footer-other {
  padding: 10px 20px !important;
}
/* © 2026 By xxx 这行字跟随主题副标题同色（--theme-heading） */
#footer .copyright {
  color: var(--theme-heading, #07C160) !important;
  font-weight: 600 !important;
}
#footer a {
  color: var(--theme-secondary-current, #666666) !important;
}
#footer a:hover {
  color: var(--theme-accent-current, #07C160) !important;
}

/* 隐藏框架信息行 "框架 Hexo 7.3.0 | 主题 Butterfly 5.5.4" */
#footer .framework-info {
  display: none !important;
}

/* Right-side floating buttons 已通过 hide-rightside.css 完全隐藏，这里不再处理 */

/* Pagination buttons */
#pagination .page-number,
.pagination .page-number {
  background-color: var(--theme-card-current, #FFFFFF) !important;
  border-color: var(--theme-border-current, #E5E7EB) !important;
  color: var(--theme-text-current, #222222) !important;
  transition: all 0.25s ease !important;
}
#pagination .page-number:hover,
.pagination .page-number:hover {
  border-color: var(--theme-accent-current, #07C160) !important;
}
/* Current page number */
#pagination .page-number.current,
.pagination .page-number.current,
#pagination .current,
#page-current {
  background-color: var(--theme-accent-current, #07C160) !important;
  border-color: var(--theme-accent-current, #07C160) !important;
  color: #FFFFFF !important;
}
/* Pagination arrows (next/prev) */
#pagination .extend,
#pagination .extend.next,
#pagination .extend.prev,
.pagination a.extend {
  background-color: var(--theme-card-current, #FFFFFF) !important;
  border-color: var(--theme-border-current, #E5E7EB) !important;
  color: var(--theme-text-current, #222222) !important;
}

/* ══ v3.1 修复: 上一篇/下一篇 + 相关推荐 背景色 ══
 * butterfly 默认 .pagination-related 用 $dark-black (#000000) 纯黑底
 * 内部 .cover div 用 var(--default-bg-color) = #8b6f47 棕灰色 (主题色)
 * 没有封面图时两层叠加 → 丑棕灰底
 * 改为白底 + 主题色文字,跟文章卡片风格一致 */
.pagination-related,
#pagination .pagination-related {
  background: var(--theme-card-current, #FFFFFF) !important;
}
/* 关键: 覆盖 .cover div 的棕灰背景 */
.pagination-related .cover {
  background: var(--theme-card-current, #FFFFFF) !important;
  opacity: 0 !important;
}
.pagination-related .info,
.pagination-related .info-1,
.pagination-related .info-2 {
  color: var(--theme-text-current, #222222) !important;
}
.pagination-related .info-1 .info-item-1 {
  color: var(--theme-secondary-current, #7A7A7A) !important;
}
.pagination-related .info-1 .info-item-2 {
  color: var(--theme-text-current, #222222) !important;
}
/* 相关推荐卡片: 白底 + 主题色文字 */
.relatedPosts-list > a {
  background: var(--theme-card-current, #FFFFFF) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
}
.relatedPosts-list > a .cover {
  background: var(--theme-card-current, #FFFFFF) !important;
  opacity: 0 !important;
}
.relatedPosts-list > a .info,
.relatedPosts-list > a .info-1,
.relatedPosts-list > a .info-2 {
  color: var(--theme-text-current, #222222) !important;
}
.relatedPosts-list > a .info-1 .info-item-1 {
  color: var(--theme-secondary-current, #7A7A7A) !important;
}
/* 相关推荐标题 */
.relatedPosts > .headline {
  color: var(--theme-text-current, #222222) !important;
}

/* Sidebar Follow Me button — actual DOM id: #card-info-btn */
#card-info-btn,
a[id="card-info-btn"] {
  background-color: var(--theme-accent-current, #07C160) !important;
  color: #FFFFFF !important;
  transition: background-color 0.45s ease !important;
}

/* ============================================================
   2026-06-20: 副标题（打字机效果）改为柔和绿色
   原 Butterfly 默认 var(--light-grey) #EEEEEE，在亮色背景下太浅且灰
   注：Footer 保持 Butterfly 默认黑色，不改动
   ============================================================ */

/* 站点副标题：跟随主题 heading 色（深色稳重，避免荧光感）
   原 Butterfly 默认 var(--light-grey) #EEEEEE 太浅
   原方案用 --theme-accent 会导致亮色主题（如湖蓝）副标题发荧光
   现改用 --theme-heading（每个主题的深色变体），自动适配
   注：Footer 保持 Butterfly 默认黑色，不改动 */
#site-subtitle,
#subtitle {
  color: var(--theme-heading, #07C160) !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.08) !important;
  font-weight: 600 !important;
  transition: color 0.45s ease !important;
}

/* 站点主标题 "Axtrivc's Blog" — 强制黑色（不跟随主题） */
#site-title {
  color: #1a1a1a !important;
  text-shadow: none !important;
}

/* ============================================================
   2026-06-20: 侧边栏 widget hover 跟随主题色
   原问题：Butterfly 用 Stylus 编译期变量 $theme-color (#8B6F47)
   硬编码到 hover 规则，运行时 CSS 变量改不了，必须 !important 覆盖
   ============================================================ */

/* 标签云 hover 文字色 */
#aside-content .card-tag-cloud a:hover {
  color: var(--theme-accent-current, #07C160) !important;
}

/* 最新评论/最近文章列表 hover 文字色 */
#aside-content .aside-list-item .content > .title:hover,
#aside-content .aside-list-item .content > .comment:hover {
  color: var(--theme-accent-current, #07C160) !important;
}

/* 归档 / 分类列表 hover 背景 + 文字色（原 rgba(139,111,71,.7)） */
#aside-content .card-archives .card-archive-list-item a:hover,
#aside-content .card-categories .card-category-list-item a:hover {
  background-color: var(--theme-accent-current, #07C160) !important;
  color: #FFFFFF !important;
}

/* 目录（TOC）hover 文字色 */
#aside-content #card-toc .toc-link:hover {
  color: var(--theme-accent-current, #07C160) !important;
}

/* 站点数据（文章数/分类数/标签数）hover 文字色 */
.site-data > a:hover div {
  color: var(--theme-accent-current, #07C160) !important;
}

/* Follow 按钮 hover 背景（原 --btn-hover-color #C4A96A） */
#aside-content #card-info-btn:hover {
  background-color: var(--theme-heading, #0A3D2A) !important;
}

/* 全局覆盖 Butterfly 的 hover 变量，给其他未捕获的规则兜底 */
:root {
  --btn-hover-color: var(--theme-heading, #07C160);
  --text-bg-hover: var(--theme-accent-current, rgba(7,193,96,0.7));
}

/* ============================================================
   头像悬停效果：去掉 Butterfly 默认的 rotate(360deg)（会导致横跳）
   改为轻微放大 + 柔和阴影，更专业
   ============================================================ */
.avatar-img img {
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              filter 0.35s ease !important;
}
.avatar-img img:hover {
  transform: scale(1.08) !important;
  filter: brightness(1.05) !important;
}

/* ============================================================
   2026-07-22: 首页文章列表 masonry → 对齐双列网格
   Butterfly index_layout:6 用 MasonryInfiniteGrid 绝对定位、逐列堆叠,
   左右两列高度各自累计 → 同一视觉行的卡片顶边错位(如 7-21 早报/晚报)。
   覆盖为 CSS grid: 行内卡片顶边对齐, 行高取该行最高卡片。
   !important 压过 InfiniteGrid 写入的内联 width/transform/position/height。
   gap 与 masonry 配置一致(horizontal 10 / vertical 20)。
   ============================================================ */
#recent-posts.masonry .recent-post-items {
  display: grid !important;
  grid-template-columns: 1fr;
  gap: 20px 10px;
  height: auto !important;
}
#recent-posts.masonry .recent-post-item {
  position: static !important;
  transform: none !important;
  width: auto !important;
  left: auto !important;
  top: auto !important;
  margin-bottom: 0 !important;
}
@media (min-width: 768px) {
  #recent-posts.masonry .recent-post-items {
    grid-template-columns: repeat(2, 1fr);
  }
}
