/**
 * flicker-guard.css — 全局毛玻璃闪屏防护（v1.4.3）
 *
 * v1.4 新增第 1c 节：flat 档常态关闭 .phone-container / .quick-functions 的整屏级
 * translateZ 合成层提升（小米 K70 APK 用户反馈：已选全平化仍闪屏、抖屏；
 * 项目内早有记录「小米输入法弹起时 fixed 输入栏 + translateZ 合成层触发整屏闪烁」，
 * 旧缓解只在键盘态生效且依赖键盘检测成功，现 flat 档下不再依赖）。
 *
 * v1.1 新增第 3 节「轻量毛玻璃档 html.lovemi-lite-glass」与第 4 节 prefers-reduced-motion 兜底：
 * 用户反馈 iPhone 15 Pro Max + Safari 从主屏进入微信聊天/朋友圈/推特等功能页偶发闪屏、卡顿。
 * iOS 合成器对少量静态 backdrop-filter 稳定，但三类高开销负载叠加时同样掉帧：
 *   a) 页面切换是 display:none→flex 硬切换，首帧要一次性栅格化几十个模糊层
 *      （聊天首屏最多 30 条气泡 × blur(10px)、朋友圈每张卡片 blur(18px)）；
 *   b) 微信三栏 ::before 有全屏 18s 无限循环光影动画（wechatLightGlassBg），
 *      聊天心跳图标 1.15s 无限脉冲且光晕用 filter: blur(12px) 逐帧重渲染；
 *   c) 滚动容器内的模糊层（气泡/卡片/私信气泡）滚动时逐帧重采样背后位图。
 * 轻量档只砍掉上述三类，顶栏/底栏/弹窗等「静态镶边」毛玻璃原样保留，iPhone 观感基本不变。
 * iOS 命中 lite；安卓/鸿蒙等 flat 环境同时叠加 lite（flat 只管 backdrop-filter，
 * 管不到 filter:blur 光晕与无限动画，由 lite 补齐）。命中逻辑见 index.html 头部内联脚本。
 *
 * 用户反馈：荣耀 Magic8（Chrome / Edge / Via 均复现）几乎进入任何功能界面都会闪屏几秒，
 * 微信聊天窗口打字过程中甚至持续闪屏；此前华为 麦芒11 + Edge 也在微信聊天页复现过同类问题。
 *
 * 根因：全站累计有约 800 处 backdrop-filter: blur() 毛玻璃层（情侣空间入口卡片 / 各功能
 * 面板 / 弹窗 / 输入栏 / 消息气泡……），它们叠加在带背景图、渐变、动画且持续滚动的内容之上。
 * 安卓 Chromium 内核（Mali / Adreno GPU + 各厂商合成器）在滚动、虚拟键盘弹起收起、
 * CSS 动画重绘时，必须对每个模糊层逐帧重新采样背后位图，GPU 合成与栅格化互相抢帧，
 * 表现为整屏反复闪烁。iOS Safari 对 backdrop-filter 合成稳定，iPhone 不复现。
 *
 * 既有方案 html.lovemi-chat-flat-glass（mobile-real-device-fix.css 第 14 节）只降级了
 * #chat-page 内部，且该文件在多数模块样式表「之前」加载——模块里同为 !important 的
 * backdrop-filter 规则（fullscreen-styles.css / voice-call.css / twitter.css 等）会在
 * 同特异性下按加载顺序反超，导致降级不彻底。
 *
 * 本文件的两个硬性要求：
 *   1. 必须是 index.html <head> 中「最后一个」样式表（在 safe-area-compat.css 之后）；
 *   2. 选择器用 :not(#lovemi-fg) ×3 抬高特异性到 (3,1,1)，压过全站所有
 *      「#id .class { backdrop-filter: ... !important }」级别的规则，
 *      也压过 JS 动态注入的 <style>（wechat-online-chat-beautify 用户自定义气泡等）。
 *
 * 生效条件：index.html 头部内联脚本判定为易闪屏环境（安卓 / 鸿蒙 / 华为 / 荣耀，
 * 或不支持 backdrop-filter 的浏览器）时给 <html> 打 lovemi-flat-glass。
 * iPhone / 桌面端不命中，毛玻璃观感原样保留。
 * 手动覆盖：localStorage.loveMiGlassMode = 'blur'（强制保留毛玻璃）| 'flat'（强制降级）。
 *
 * 安全性：backdrop-filter 纯属视觉特效，移除不影响任何功能逻辑；被降级的表面仍保留
 * 各自的半透明底色（多为 rgba 白 0.4~0.9），观感接近「轻磨砂」。个别透明度过低、
 * 依赖模糊才可读的表面在下方第 2 节做实色补偿。
 */

/* ------------------------------------------------------------------ */
/* 1) 全局压制：易闪屏环境下关闭一切 backdrop-filter（含伪元素），      */
/*    彻底杜绝任何模糊层在滚动 / 键盘回流 / 动画重绘时逐帧重采样。      */
/* ------------------------------------------------------------------ */
/* 每日备忘录与②号屏拍立得是两个静态小组件，按设计分别保留 30px / 25px
   背景模糊；它们不参与聊天或长列表的逐帧重采样，其余层仍全量压平。 */
html.lovemi-flat-glass *:not(.ssdm-card):not(.sub-screen-polaroid):not(#lovemi-fg):not(#lovemi-fg):not(#lovemi-fg),
html.lovemi-flat-glass *:not(.ssdm-card):not(.sub-screen-polaroid):not(#lovemi-fg):not(#lovemi-fg):not(#lovemi-fg)::before,
html.lovemi-flat-glass *:not(.ssdm-card):not(.sub-screen-polaroid):not(#lovemi-fg):not(#lovemi-fg):not(#lovemi-fg)::after {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

/* ------------------------------------------------------------------ */
/* 1b) 桌面分页器（主屏 ↔ 各子屏）在 flat 档的额外压平                  */
/*                                                                    */
/* 用户反馈（OPPO Reno14 / 小米 12 / OPPO A5 / 小米 15 Pro，APK）：      */
/* 已在「主屏幕设置 → 画面特效」选了全平化，横向滑屏仍然卡顿。          */
/* 原因是第 1 节只关掉了 backdrop-filter，而滑屏这条路径上真正昂贵的是   */
/* 另外两类特效：                                                       */
/*   - filter: blur()/drop-shadow()：与 backdrop-filter 不同，它需要把    */
/*     元素自身先离屏渲染再做卷积。滑动中三页全程参与合成，每帧都要重做；*/
/*   - 大范围 box-shadow：模糊半径越大，合成时需要重绘的区域越大。       */
/* 这里只作用于分页器内部，聊天、弹窗等其它界面的观感完全不受影响。      */
/* ------------------------------------------------------------------ */
html.lovemi-flat-glass #home-desktop-pager *:not(#lovemi-fg):not(#lovemi-fg),
html.lovemi-flat-glass #home-desktop-pager *:not(#lovemi-fg):not(#lovemi-fg)::before,
html.lovemi-flat-glass #home-desktop-pager *:not(#lovemi-fg):not(#lovemi-fg)::after {
    filter: none !important;
    -webkit-filter: none !important;
}

/* 有意不在拖动过程中临时关掉 backdrop-filter / box-shadow：
   那样确实能再省一些每帧开销，但手指按下与松手的瞬间界面会「啪」地变一下样，
   观感损失比卡顿更刺眼。想要极致流畅的用户走「画面特效 → 全平化」即可，
   flat 档下这些特效本来就是常态关闭的。 */

/* ------------------------------------------------------------------ */
/* 1c) flat 档常态收敛「整屏级 GPU 合成层提升」                          */
/*                                                                    */
/* 用户反馈（小米 K70，APK）：已选「全平化」仍然闪屏、抖屏。             */
/* mobile-real-device-fix.css 把 .phone-container / .quick-functions    */
/* 常驻提升为 translateZ(0) 合成层，并在注释里记录过「小米/Chrome        */
/* Android 输入法弹起时，fixed 输入栏 + translateZ 合成层容易触发整屏    */
/* 闪烁/黑屏」——因此键盘态已临时取消该提升。但该缓解依赖键盘检测        */
/* （data-mobile-keyboard-open）在各 ROM/输入法上都判定成功，且只覆盖    */
/* 键盘场景；小米合成器在滚动 / 弹窗 / 高刷新率切换时同样可能因这块      */
/* 整屏大层与其余内容层抢显存、反复丢层重建而闪屏。                      */
/* flat 档语义就是「牺牲特效换稳定」：在 flat 下把整屏级提升常态关闭，    */
/* 不再依赖键盘检测。图标等小元素的 translateZ 提升不受影响；            */
/* iPhone / 桌面端不命中 flat，行为不变。                                */
/* ------------------------------------------------------------------ */
html.lovemi-flat-glass .phone-container,
html.lovemi-flat-glass .quick-functions {
    -webkit-transform: none !important;
    transform: none !important;
    -webkit-backface-visibility: visible !important;
    backface-visibility: visible !important;
}

/* ------------------------------------------------------------------ */
/* 2) 可读性补偿：底色透明度过低（≲0.5）、原本依赖模糊撑起可读性的      */
/*    高频表面，去模糊后调实。只补底色，不动布局 / 交互。               */
/*    微信聊天页（输入栏 / 功能键 / 头部 / 心跳面板）的补偿已由         */
/*    mobile-real-device-fix.css 第 14 节（lovemi-chat-flat-glass）承担。*/
/* ------------------------------------------------------------------ */

/* 情侣空间私密页：相恋天数 / 双人昵称磨砂胶囊（用户截图中的界面） */
html.lovemi-flat-glass .couple-space-private-frost-text {
    background: rgba(255, 255, 255, 0.78) !important;
}

/* 情侣空间私密页：返回键 / 导出键玻璃圆钮 */
html.lovemi-flat-glass .couple-space-header--private .couple-space-back,
html.lovemi-flat-glass .couple-space-header--private .couple-space-export {
    background: rgba(255, 255, 255, 0.82) !important;
}

/* 好友邀请卡等全屏遮罩：去模糊后加深一点，维持前景面板与背景的分离感 */
html.lovemi-flat-glass .cs-invite-dec-backdrop {
    background: rgba(15, 23, 42, 0.5) !important;
}

/* 全局美化「香草青 / 温柔粉」预设的主卡片内容区：底色透明度仅 0.25~0.3，
   完全依赖 blur 撑起可读性，去模糊后调实（其余玻璃风格组件底色本身有
   0.7+ 的白色变量，无需补偿） */
html.lovemi-flat-glass[data-global-beautify="1"][data-global-beautify-preset="vanilla-cyan"] .main-card .card-content,
html.lovemi-flat-glass[data-global-beautify="1"][data-global-beautify-preset="gentle-pink"] .main-card .card-content {
    background-color: rgba(255, 255, 255, 0.72) !important;
}

/* 主屏壁纸态顶部状态栏：原 rgba(255,255,255,0.5) + blur(5px) 负责在任意壁纸上
   撑起深色时间/电量文字的可读性，去模糊后把白底略调实 */
html.lovemi-flat-glass #home-screen.home-screen--wallpaper > .status-bar {
    background: rgba(255, 255, 255, 0.68) !important;
}

/* 登录/注册卡片：原底色为白 0.22→0.1 渐变 + blur(18px)，完全依赖模糊撑起「浅蓝
   磨砂」观感与可读性。去模糊后改用与「原毛玻璃合成结果」等色的近实底渐变
   （暮蓝 gradient 中段 #7388A3 叠加白 0.22/0.1 的合成色）：
     1) 键盘弹出/收起、卡片内滚动时不再对下方全屏渐变做大面积 alpha 合成
        （真机反馈：Realme 11 Pro + 嗅探/via 等进入登录界面卡顿）；
     2) 观感与 iPhone 上的毛玻璃版本基本一致。 */
html.lovemi-flat-glass .love-mi-login-card {
    background: linear-gradient(180deg, rgba(146, 162, 180, 0.94) 0%, rgba(129, 147, 171, 0.94) 100%) !important;
}

/* 登录页顶部 Logo 磨砂托底：原白 0.18 + blur(10px)，flat 档去模糊后只剩 0.18 透明白，
   安卓重绘（键盘弹出/淡入过渡）时透底闪烁，与登录卡同法补实（安卓 APK 测试反馈：
   登录界面闪屏） */
html.lovemi-flat-glass .love-mi-login-logo {
    background: rgba(203, 213, 226, 0.92) !important;
}

/* 安卓登录层去掉 0.32s opacity 淡入/淡出过渡：boot 过场退场时登录层多为「半透明中间帧」，
   弱 GPU 合成掉帧会露出下方锁屏形成闪屏；flat 环境改为直接整帧显示（boot 层此时仍在
   最上层，用户感知不到「跳变」，只会少一段容易闪的渐变） */
html.lovemi-flat-glass .love-mi-login-overlay {
    transition: none !important;
}

/* 锁屏小组件（天气/名言卡）：原白 0.2→0.1 渐变 + blur(16px)，flat 档去模糊后
   透明度过低，锁屏时钟/天气每次重绘都在壁纸上透底闪烁（安卓 APK 测试反馈：
   锁屏界面闪屏）。补成与「白 0.2 叠暮蓝壁纸」合成结果等色的近实底渐变；
   壁纸对比度系统（lock-screen.js）设置的 --lock-widget-bg 变量优先级更高，不受影响。 */
html.lovemi-flat-glass .lock-screen-widget {
    background: var(--lock-widget-bg, linear-gradient(180deg, rgba(143, 158, 180, 0.92) 0%, rgba(132, 148, 170, 0.9) 100%)) !important;
}

/* 锁屏解锁滑条：原白 0.16 + blur(12px)，同法调实（深色半透明更贴近原毛玻璃观感，
   拖动滑块逐帧重绘时不再透底） */
html.lovemi-flat-glass .lock-screen-unlock-track {
    background: var(--lock-unlock-track-bg, rgba(52, 60, 78, 0.4)) !important;
}

/* 真心话大冒险顶栏：去模糊后加深底色，避免进入/键盘态半透明叠层闪一下 */
html.lovemi-flat-glass .tod-header {
    background: linear-gradient(180deg, rgba(17, 12, 28, 0.94), rgba(17, 12, 28, 0.88)) !important;
}
html.lovemi-flat-glass .tod-inputbar {
    background: linear-gradient(0deg, rgba(10, 8, 16, 0.94), rgba(10, 8, 16, 0.82)) !important;
}

/* 一起听歌按钮/顶栏：去模糊后调实，减轻 Realme / 安卓 Chromium 点击与歌名栏闪屏 */
html.lovemi-flat-glass .lt-icon-btn,
html.lovemi-flat-glass .lt-ctrl:not(.lt-ctrl--main) {
    background: rgba(255, 252, 253, 0.94) !important;
}
html.lovemi-flat-glass .lt-comment-zone__textarea {
    background: rgba(255, 255, 255, 0.92) !important;
}

/* ------------------------------------------------------------------ */
/* 3) 轻量毛玻璃档 html.lovemi-lite-glass（iOS + 所有 flat 环境叠加）   */
/*    只砍「滚动区内高频模糊层」与「常驻无限动画/filter 光晕」，        */
/*    顶栏 / 底栏 / 弹窗等静态镶边 backdrop-filter 原样保留。          */
/* ------------------------------------------------------------------ */

/* 3.1 微信三栏（消息/发现/我）全屏光影装饰层：停掉 18s 无限循环动画
   （opacity + transform 全屏层压在多个模糊镶边之下，是列表页持续掉帧
   的主因之一），保留静态光影观感。 */
html.lovemi-lite-glass #wechat-page::before,
html.lovemi-lite-glass #wechat-discover-page::before,
html.lovemi-lite-glass #wechat-me-page::before {
    animation: none !important;
    opacity: 0.7 !important;
    transform: none !important;
}

/* 3.2 聊天心跳图标：保留脉冲缩放动画（transform 合成足够便宜），
   但把光晕从 filter: blur(12px)（随父级 scale 逐帧重渲染模糊位图）
   换成等观感的径向渐变软光斑（零逐帧滤镜成本）。 */
html.lovemi-lite-glass .chat-heartbeat-monitor-glass::before {
    filter: none !important;
    -webkit-filter: none !important;
    background: radial-gradient(closest-side,
        rgba(255, 248, 252, 0.85) 0%,
        rgba(255, 248, 252, 0.4) 55%,
        rgba(255, 248, 252, 0) 78%) !important;
    border-radius: 50% !important;
}

/* 3.3 微信聊天气泡：去掉每条消息的 backdrop-filter（打开会话首帧要
   一次性栅格化最多 30 层、滚动/键盘弹起时逐帧重采样，是聊天窗口
   闪屏卡顿的最大单项）。:not(#lovemi-fg)×3 抬特异性，压过
   #wechat-user-bubble-css 等用户自定义气泡 CSS 的 !important 模糊。 */
html.lovemi-lite-glass #chat-page .chat-message .chat-message-bubble:not(#lovemi-fg):not(#lovemi-fg):not(#lovemi-fg),
html.lovemi-lite-glass #chat-page .chat-message .chat-message-bubble:not(#lovemi-fg):not(#lovemi-fg):not(#lovemi-fg)::before,
html.lovemi-lite-glass #chat-page .chat-message .chat-message-bubble:not(#lovemi-fg):not(#lovemi-fg):not(#lovemi-fg)::after {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

/* 雾面气泡去模糊后的可读性补偿：底色 0.7 → 0.92 调实。选择器与
   style.css 的雾面气泡规则（排除拍立得/转账/位置/翻面照片）保持一致；
   刻意不加 !important，让「微信-设置」用户自定义气泡 CSS 仍可覆盖底色。 */
html.lovemi-lite-glass #chat-page .chat-message.other-message .chat-message-bubble:not(.chat-message-bubble--polaroid):not(:has(.chat-transfer-bubble)):not(:has(.chat-location-bubble)):not(:has(.chat-photo-flip-root)),
html.lovemi-lite-glass #chat-page .chat-message.my-message .chat-message-bubble:not(.chat-message-bubble--polaroid):not(:has(.chat-transfer-bubble)):not(:has(.chat-location-bubble)):not(:has(.chat-photo-flip-root)) {
    background-color: rgba(235, 241, 246, 0.92);
}

/* 3.4 推特私信气泡：滚动区内逐条模糊，同理去掉并调实底色。
   底色补偿只针对浅色外观的对方气泡（0.78 → 0.94）；暗色外观底色本就
   接近实色、本人气泡为渐变实底，均无需补偿。 */
html.lovemi-lite-glass .twitter-dm-msg-bubble {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}
html.lovemi-lite-glass:not([data-appearance="dark"]) .twitter-dm-msg.from-peer .twitter-dm-msg-bubble {
    background: rgba(255, 255, 255, 0.94);
}

/* 3.5 朋友圈滚动流：每张动态卡片 blur(18px) + 卡内社交盒/时间胶囊/
   昵称胶囊各自再叠模糊，进入朋友圈首帧与滚动时压力最大。全部去模糊，
   底色按需调实（时间胶囊/社交盒原底色 0.74+，落在已调实的卡片上，
   无需补偿）。 */
html.lovemi-lite-glass .moments-post-card,
html.lovemi-lite-glass .moments-post-social-box,
html.lovemi-lite-glass .moments-post-time-inline,
html.lovemi-lite-glass .moments-ins-nickname,
html.lovemi-lite-glass .moments-cover-hint {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}
html.lovemi-lite-glass .moments-post-card {
    background-color: rgba(255, 255, 255, 0.88) !important;
}
html.lovemi-lite-glass .moments-ins-nickname {
    background-color: rgba(255, 255, 255, 0.88);
}
/* 封面提示胶囊为白字，去模糊后白底 0.18 太透，改半透明暗底衬托白字 */
html.lovemi-lite-glass .moments-cover-hint {
    background: rgba(45, 43, 85, 0.32);
}

/* 3.6 你画我猜（#draw-guess-game）：顶栏/底栏/画布发送按钮/设置遮罩的
   backdrop-filter 正好压在逐笔高频重绘的 canvas 与滚动聊天流之上，
   每一笔都迫使合成器重采样模糊层背后的画布位图（真机反馈：iPhone 15 +
   Safari 保存到桌面后，对局中持续闪屏抖屏）。全部去模糊并调实底色，
   观感保持「轻磨砂」。暗色外观分别按原暗底调实。 */
html.lovemi-lite-glass #draw-guess-game .dg-header,
html.lovemi-lite-glass #draw-guess-game .dg-footer,
html.lovemi-lite-glass #draw-guess-game .dg-canvas-send,
html.lovemi-lite-glass #draw-guess-game .dg-set-mask {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}
html.lovemi-lite-glass:not([data-appearance="dark"]) #draw-guess-game .dg-header {
    background: rgba(255, 255, 255, 0.94);
}
html.lovemi-lite-glass:not([data-appearance="dark"]) #draw-guess-game .dg-footer {
    background: rgba(255, 255, 255, 0.94);
}
html.lovemi-lite-glass:not([data-appearance="dark"]) #draw-guess-game .dg-canvas-send {
    background: rgba(255, 255, 255, 0.96);
}
html.lovemi-lite-glass:not([data-appearance="dark"]) #draw-guess-game .dg-set-mask {
    background: rgba(31, 42, 46, 0.5);
}
html.lovemi-lite-glass[data-appearance="dark"] #draw-guess-game .dg-header,
html.lovemi-lite-glass[data-appearance="dark"] #draw-guess-game .dg-footer {
    background: rgba(24, 31, 34, 0.94);
}
html.lovemi-lite-glass[data-appearance="dark"] #draw-guess-game .dg-canvas-send {
    background: rgba(29, 39, 43, 0.96);
}
html.lovemi-lite-glass[data-appearance="dark"] #draw-guess-game .dg-set-mask {
    background: rgba(10, 14, 15, 0.66);
}

/* 3.7 语音/视频通话层（用户反馈：一加 Ace 6 / ColorOS 高刷屏 APK
   语音、视频通话中偶发整屏闪烁）：
   .voice-call-background 常驻「22s 无限 transform+background-position 漂移
   + filter + translateZ 强制合成层 + backface-visibility:hidden」，压在
   blur(12px) 的全屏背景图之下，再叠逐秒计时重绘。国产安卓合成器（尤其
   高刷新率动态切换时）会周期性丢层重建 → 黑闪。flat 档只管 backdrop-filter，
   这里由 lite 档把通话背景静态化（渐变与背景图模糊观感保留）。 */
html.lovemi-lite-glass .voice-call-background {
    animation: none !important;
    -webkit-transform: none !important;
    transform: none !important;
    will-change: auto !important;
    -webkit-backface-visibility: visible !important;
    backface-visibility: visible !important;
}
/* 通话层隐藏时（含挂断后 1.2s 收尾态）连同装饰性无限动画一并暂停，
   避免退出通话瞬间的合成层重建叠加闪烁。 */
html.lovemi-lite-glass .voice-call-layer:not(.show) *,
html.lovemi-lite-glass .video-call-layer:not(.show) * {
    animation-play-state: paused !important;
}

/* ------------------------------------------------------------------ */
/* 4) 全平台兜底：系统开启「减弱动态效果」时，无条件停掉纯装饰性       */
/*    无限动画（不区分档位；功能性动画如加载转圈不受影响）。           */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    #wechat-page::before,
    #wechat-discover-page::before,
    #wechat-me-page::before,
    .chat-heartbeat-monitor-glass {
        animation: none !important;
    }
}
