/**
 * ============================================================
 * bitmall 黑白模式对比度修复
 * ============================================================
 *
 * 根因：
 *   assets/css/apple-theme.css 第 396-405 行有一个【全局】 body 规则：
 *     body { color: var(--apple-text-primary); background-color: var(--apple-background); }
 *   它在 [data-bs-theme="dark"] 下把整页背景变黑(--apple-background:#000)，
 *   但主题 90% 的核心组件/正文文字来自 main.min.css，是【写死深色】且不引用
 *   --apple-* 变量。于是 dark 模式下，所有透明背景区域（文章正文、侧边栏、
 *   用户中心、各类区块）呈现「黑底 + 深色文字」，对比度崩溃，大量内容看不清。
 *   light 模式下 body 本身可读，但某些次要文字使用了过浅的 --apple-text-* 变量，
 *   对比度也不足。
 *
 * 修复策略：
 *   对【默认主题(非 Apple 风格)】在 dark 模式下做系统性高对比覆盖（深底浅字、
 *   卡片/表单/表格/导航均显式高对比）；light 模式补一条次要文字对比度保险。
 *   使用 html[data-bs-theme=...]:not(.apple-style-enabled) 限定，避免影响 Apple
 *   风格主题自身已用变量实现的暗色表现；全部用 !important 压过 main.min.css 写死色。
 * ============================================================ */

/* ===== 深色模式：默认主题系统性高对比 ===== */

/* 变量兜底（供引用变量的少数组件） */
html[data-bs-theme="dark"]:not(.apple-style-enabled) {
    --apple-text-primary: #ECECEE;
    --apple-text-secondary: #B9B9C0;
    --apple-text-tertiary: #9A9AA3;
    --apple-background: #14141C;
    --ri-body-color-rgb: 236, 236, 238;
    --ri-body-bg-rgb: 20, 20, 28;
}

/* 页面底色与默认文字 */
html[data-bs-theme="dark"]:not(.apple-style-enabled) body {
    background-color: #14141C !important;
    color: #ECECEE !important;
}

/* 正文排版 */
html[data-bs-theme="dark"]:not(.apple-style-enabled) .site-content,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .entry-content,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .entry-summary,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .post-content,
html[data-bs-theme="dark"]:not(.apple-style-enabled) article,
html[data-bs-theme="dark"]:not(.apple-style-enabled) p,
html[data-bs-theme="dark"]:not(.apple-style-enabled) li,
html[data-bs-theme="dark"]:not(.apple-style-enabled) dd,
html[data-bs-theme="dark"]:not(.apple-style-enabled) dt,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .desc,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .excerpt {
    color: #D9D9E0 !important;
}

/* 标题 */
html[data-bs-theme="dark"]:not(.apple-style-enabled) h1,
html[data-bs-theme="dark"]:not(.apple-style-enabled) h2,
html[data-bs-theme="dark"]:not(.apple-style-enabled) h3,
html[data-bs-theme="dark"]:not(.apple-style-enabled) h4,
html[data-bs-theme="dark"]:not(.apple-style-enabled) h5,
html[data-bs-theme="dark"]:not(.apple-style-enabled) h6,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .entry-title,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .entry-title a,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .post-title a,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .widget-title {
    color: #F2F2F6 !important;
}

/* 链接 */
html[data-bs-theme="dark"]:not(.apple-style-enabled) a { color: #6FB1FF; }
html[data-bs-theme="dark"]:not(.apple-style-enabled) a:hover { color: #93C4FF; }

/* 卡片 / 容器 / 侧边栏 / 用户中心 */
html[data-bs-theme="dark"]:not(.apple-style-enabled) .card,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .post-item,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .sidebar .widget,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .widget,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .panel,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .user-box,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .uc-card,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .author-card,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .tag-cloud a,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .list-group-item {
    background-color: #1E1E28 !important;
    color: #D9D9E0 !important;
    border-color: #2E2E3A !important;
}

/* 表单控件 */
html[data-bs-theme="dark"]:not(.apple-style-enabled) input[type="text"],
html[data-bs-theme="dark"]:not(.apple-style-enabled) input[type="email"],
html[data-bs-theme="dark"]:not(.apple-style-enabled) input[type="password"],
html[data-bs-theme="dark"]:not(.apple-style-enabled) input[type="search"],
html[data-bs-theme="dark"]:not(.apple-style-enabled) input[type="url"],
html[data-bs-theme="dark"]:not(.apple-style-enabled) input[type="number"],
html[data-bs-theme="dark"]:not(.apple-style-enabled) textarea,
html[data-bs-theme="dark"]:not(.apple-style-enabled) select {
    background-color: #191922 !important;
    color: #ECECEE !important;
    border-color: #3A3A48 !important;
}
html[data-bs-theme="dark"]:not(.apple-style-enabled) ::placeholder { color: #8A8A94 !important; }

/* 表格 */
html[data-bs-theme="dark"]:not(.apple-style-enabled) table { border-color: #2E2E3A !important; color: #D9D9E0 !important; }
html[data-bs-theme="dark"]:not(.apple-style-enabled) table th,
html[data-bs-theme="dark"]:not(.apple-style-enabled) table td { border-color: #2E2E3A !important; color: #D9D9E0 !important; }
html[data-bs-theme="dark"]:not(.apple-style-enabled) thead th { background-color: #262630 !important; color: #ECECEE !important; }

/* 次要 / 静默文字 */
html[data-bs-theme="dark"]:not(.apple-style-enabled) .text-muted,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .small,
html[data-bs-theme="dark"]:not(.apple-style-enabled) small,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .meta,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .post-meta {
    color: #A9A9B4 !important;
}

/* 头部 / 导航 */
html[data-bs-theme="dark"]:not(.apple-style-enabled) .navbar,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .header,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .site-header {
    background-color: #1A1A24 !important;
}
html[data-bs-theme="dark"]:not(.apple-style-enabled) .navbar a,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .header a,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .menu a,
html[data-bs-theme="dark"]:not(.apple-style-enabled) .main-menu a {
    color: #D9D9E0 !important;
}

/* 按钮在深色下保持可读 */
html[data-bs-theme="dark"]:not(.apple-style-enabled) .btn { color: #fff; }
html[data-bs-theme="dark"]:not(.apple-style-enabled) .btn-dark {
    background-color: #2E2E3A !important;
    border-color: #3A3A48 !important;
    color: #ECECEE !important;
}
html[data-bs-theme="dark"]:not(.apple-style-enabled) .btn-outline-dark {
    color: #ECECEE !important;
    border-color: #3A3A48 !important;
}

/* 代码块 / 引用 */
html[data-bs-theme="dark"]:not(.apple-style-enabled) pre,
html[data-bs-theme="dark"]:not(.apple-style-enabled) code,
html[data-bs-theme="dark"]:not(.apple-style-enabled) blockquote {
    background-color: #1B1B25 !important;
    color: #D9D9E0 !important;
    border-color: #2E2E3A !important;
}

/* ===== 浅色模式：次要文字对比度保险（默认主题） ===== */
html:not(.apple-style-enabled) .text-muted { color: #5A5A72 !important; }
html:not(.apple-style-enabled) .text-secondary { color: #4A4A60 !important; }

/* ============================================================
 * 追加修复 1：文章页标题模块（.archive-hero.post-hero）黑白模式均高对比
 * 原 main.min.css：.post-title 写死 #fff；.article-meta 写死 #a1a1a8（灰）；
 * 英雄遮罩渐变顶部 rgba(0,0,0,.55)、底部 rgba(255,255,255,.25)（浅）。
 * 浅色页下白字/灰字在浅色照片区对比崩溃；深色页下灰字也偏暗。
 * 修复：把遮罩统一加暗（黑白两模式都保证深色底），标题白字+阴影，
 *      meta 提到浅灰白，确保「无论黑白都能看清」。
 * ============================================================ */
html:not(.apple-style-enabled) .archive-hero.post-hero .archive-hero-bg::before {
    background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,.72)), to(rgba(0,0,0,.55))) !important;
    background-image: linear-gradient(180deg, rgba(0,0,0,.72), rgba(0,0,0,.55)) !important;
}
html:not(.apple-style-enabled) .archive-hero.post-hero .post-title {
    color: #ffffff !important;
    text-shadow: 0 1px 4px rgba(0,0,0,.55);
}
html:not(.apple-style-enabled) .archive-hero.post-hero .article-meta a,
html:not(.apple-style-enabled) .archive-hero.post-hero .article-meta span {
    color: #E6E6EE !important;
}

/* ============================================================
 * 追加修复 2：顶部菜单栏 浅色模式「白字白底」看不见
 * 原 main.min.css 把 .nav-list>.menu-item>a 与 .action-btn 写死
 * color:#fff!important（本意是透明头覆盖在深色英雄区），但无
 * .header-transparent 限定，于是浅色模式的实心/吸顶头部也变白字→看不见。
 * 策略：浅色模式默认把实心头部菜单/图标改为深色；仅「透明头部且未吸顶」
 *      （覆盖在深色英雄区）保持白字。
 * ============================================================ */
/* 浅色模式：实心/吸顶头部菜单与图标 → 深色可读 */
html[data-bs-theme="light"]:not(.apple-style-enabled) .site-header .nav-list > .menu-item > a,
html[data-bs-theme="light"]:not(.apple-style-enabled) .site-header .navbar .nav-list a,
html[data-bs-theme="light"]:not(.apple-style-enabled) .site-header .action-btn,
html[data-bs-theme="light"]:not(.apple-style-enabled) .site-header .actions .action-btn,
html[data-bs-theme="light"]:not(.apple-style-enabled) .site-header .action-hover-menu .avatar-warp,
html[data-bs-theme="light"]:not(.apple-style-enabled) .site-header .actions a {
    color: #1F1F29 !important;
}
/* 浅色模式：透明头部且未吸顶（覆盖在深色英雄区）→ 保持白字 */
html[data-bs-theme="light"]:not(.apple-style-enabled) .header-transparent .site-header:not(.navbar-sticky) .nav-list > .menu-item > a,
html[data-bs-theme="light"]:not(.apple-style-enabled) .header-transparent .site-header:not(.navbar-sticky) .action-btn,
html[data-bs-theme="light"]:not(.apple-style-enabled) .header-transparent .site-header:not(.navbar-sticky) .actions .action-btn,
html[data-bs-theme="light"]:not(.apple-style-enabled) .header-transparent .site-header:not(.navbar-sticky) .actions a {
    color: #FFFFFF !important;
}
