/* ============================================================
   全站 UI 微调（ui-tweaks）
   收录经实测发现的问题，以「可用性 / 可读性」为主，不改变视觉语言。
   每项均注明成因与依据，便于日后维护。
   注意：注释正文里不得再出现注释结束标记，否则会提前闭合注释块、吃掉紧随其后
   的第一条规则（本次改动曾因此丢失 .tag-cloud-list a 规则）。
   ============================================================ */

/* ---------- 1. 标签云配色修复 ----------
   成因：Hexo tagcloud() 生成内联 style 写死随机 RGB，完全不感知深浅色主题。
   实测对比度：浅色约 2.4:1，深色低至 1.06:1，远低于 WCAG AA 的 4.5:1。
   处理：统一为语义文本色，字号层级保留，hover 切品牌链接色。
   两个容器需分别覆盖：tags 页用 .tag-cloud-list，侧栏卡片用 .card-tag-cloud。
   需 !important 才能压过内联样式。 */
.tag-cloud-list a,
#aside-content .card-tag-cloud a {
  color: var(--font-color) !important;
  transition: color .25s ease;
}

.tag-cloud-list a:hover,
#aside-content .card-tag-cloud a:hover {
  color: #7c3aed !important;
}

html[data-theme="dark"] .tag-cloud-list a:hover,
html[data-theme="dark"] #aside-content .card-tag-cloud a:hover {
  color: #a855f7 !important;
}

/* ---------- 2. 行内代码对比度（仅浅色模式） ----------
   成因：theme_color.code_foreground 为 #F47466，落在浅底上实测仅 2.53:1。
   深色模式当前达标，故不动，避免反向劣化。
   选择器限定 p / li / blockquote 内的 code，不波及代码块语法高亮。 */
html[data-theme="light"] #article-container p code,
html[data-theme="light"] #article-container li code,
html[data-theme="light"] #article-container blockquote code {
  color: #a8332b;
}

/* ---------- 3. 图片 / 头图背景上的文字 ----------
   成因：页脚与文章头图均为照片背景，主题用 70% 白字，实测约 2.88:1。
   单纯调颜色无法适配任意照片，故加投影以在保证可读性的同时保底。 */
#footer-wrap {
  color: #f2f2f2;
}

/* 注意：文章头图内的 meta 容器是 #post-meta（ID），不是 .post-meta。 */
#footer-wrap,
#footer-wrap a,
#page-header #post-info #post-meta,
#page-header #post-info #post-meta span,
#page-header #post-info #post-meta time,
#page-header #post-info #post-meta a {
  text-shadow: 0 1px 3px rgba(0, 0, 0, .55);
}

#page-header #post-info #post-meta,
#page-header #post-info #post-meta span,
#page-header #post-info #post-meta time,
#page-header #post-info #post-meta a {
  color: rgba(255, 255, 255, .95);
}

/* ---------- 4. 锚点跳转不被固定导航遮挡 ----------
   点击目录或带锚点链接后，标题会被顶部固定导航盖住一小截。 */
#article-container :is(h1, h2, h3, h4, h5, h6) {
  scroll-margin-top: 76px;
}

/* ---------- 5. 键盘可达：全站焦点环 ----------
   此前除作品集外全站无 :focus-visible 样式，键盘 Tab 时缺少可见反馈。 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #8b5cf6;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- 6. 移动端触控目标 ----------
   实测社交图标 20x26、19x26、17x26，分类链接 50x17，均低于建议的 44x44。
   仅放大侧栏与页脚图标，导航栏空间紧张维持原样（汉堡入口已达 44px）。 */
@media (max-width: 768px) {
  #aside-content .social-icon,
  #footer-wrap .social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
  }

  #article-container .article-meta__categories,
  #recent-posts .article-meta .article-meta__categories {
    display: inline-block;
    padding: 4px 2px;
  }

  #article-container .sp-btn,
  #article-container .filter-chip {
    min-height: 44px;
  }
}

/* ---------- 7. 降低动效偏好 ----------
   系统开启减弱动效时统一收敛，避免与 showcase / 404 的局部规则打架。 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 8. 文章头图遮罩加强 ----------
   成因：文章页标题与元信息直接压在封面截图上（如像素对话截图，文字密集、
   明暗混杂），主题 mask 仅提供 30% 黑色平涂（--mark-bg），不足以保证可读性。
   处理：仅对文章页（.post-bg）把平涂遮罩换成上浅下深的渐变，其他页面不动。
   主题同名规则是 #page-header:not(.not-top-img):before，此处多一个 .post-bg
   类提高特异性，可稳定覆盖。 */
#page-header.post-bg:not(.not-top-img)::before {
  background: linear-gradient(180deg, rgba(0, 0, 0, .38) 0%, rgba(0, 0, 0, .62) 100%);
}

/* ---------- 9. 社交图标单色化 ----------
   成因：图标写死品牌色（GitHub #24292e 近黑），在首页深色横幅上直接隐形；
   侧栏多色图标也与紫色主题争抢注意力。品牌色只保留 hover 瞬间。
   注意：主题把 .social-icon 类也用在导航搜索按钮上，故全部按容器限定。 */
#site-info .social-icon i {
  color: rgba(255, 255, 255, .92) !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

#site-info .social-icon:hover i {
  color: #c4b5fd !important;
}

#aside-content .social-icon i {
  color: var(--font-color);
  opacity: .8;
  transition: color .25s ease, opacity .25s ease;
}

#aside-content .social-icon:hover i {
  color: #7c3aed;
  opacity: 1;
}

html[data-theme="dark"] #aside-content .social-icon:hover i {
  color: #a855f7;
}

#footer-wrap .social-icon i {
  color: rgba(255, 255, 255, .85);
  transition: color .25s ease;
}

#footer-wrap .social-icon:hover i {
  color: #c4b5fd;
}

/* ---------- 10. 移动端页脚避让浮动按钮 ----------
   成因：右下角固定按钮组（设置 + 阅读进度，主题固定在 bottom:40px，
   两枚叠放高约 90px）在移动端直接压住页脚最后一行文字。
   处理：仅窄屏给页脚加底部安全边距，让最后一行文字抬离按钮区。 */
@media (max-width: 900px) {
  #footer-wrap {
    padding-bottom: 96px;
  }
}

/* ---------- 11. 深色模式图片降亮 ----------
   成因：白底截图 / 白底图表在暗色界面里是刺眼的大白块。
   处理：仅暗色模式对正文图片、首页列表封面、归档缩略图、侧栏最新文章
   缩略图降亮；头像（.avatar-img）与友链头像不处理，避免整体发灰。 */
html[data-theme="dark"] #article-container img,
html[data-theme="dark"] .recent-post-item .post_cover img,
html[data-theme="dark"] .article-sort-item-img img,
html[data-theme="dark"] .aside-list-item img {
  filter: brightness(.85) contrast(.95);
}
