/* ==============================================================
 * LobeHub UI 定制样式 —— 通过 nginx sub_filter 注入到每个 HTML 响应
 * 改这个文件后浏览器强刷即可生效，不用重启容器。
 * 选择器尽量基于 aria-label / data-* / href 等稳定属性。
 * ============================================================== */

/* 1. 隐藏左下角 GitHub 图标
 * 来源：lobe/src/routes/(main)/home/_layout/Footer/index.tsx */
a[aria-label="GitHub"] {
    display: none !important;
}

/* 2. 隐藏左下角"帮助中心"问号图标 */
[aria-label="帮助中心"],
[aria-label="Help Center"],
[aria-label="Help"] {
    display: none !important;
}

/* 3. 隐藏头像下拉菜单里的"下载客户端"项
 * 来源：antd Menu data-menu-id 后缀含 download-client；兜底走链接 href */
li.ant-menu-item[data-menu-id*="download-client"],
li.ant-menu-item:has(a[href*="lobehub.com/downloads"]) {
    display: none !important;
}

/* 4. 隐藏头像下拉底部 "Powered by LobeHub" 水印
 * 来源：lobe/src/components/BrandWatermark/index.tsx
 * 唯一锚点：a 标签 href 里的 utm_content=brand_watermark */
.lobe-flex:has(> a[href*="utm_content=brand_watermark"]) {
    display: none !important;
}

/* 5. 隐藏 设置页 左侧栏的"关于"菜单项
 * 来源：lobe/src/routes/(main)/settings/hooks/useCategory.tsx，key=SettingsTabs.About='about'
 * 渲染后 URL 是 /settings/about
 * 注：实际 sidebar 菜单不是 <a href>，最终由 JS 文本规则兜底（custom.js） */
a[href="/settings/about"],
a[href$="/settings/about/"],
li:has(> a[href="/settings/about"]),
li:has(> a[href$="/settings/about/"]) {
    display: none !important;
}

/* 6. 自定义助理详情页 → "发布到社区"按钮（不希望员工把内部 Agent 发到 lobehub.com）
 * 锚点：button title="分享到助理社区"（i18n 字面字符串） */
button[title="分享到助理社区"],
button[title="Share to Agent Marketplace"],
button[title="Share to Marketplace"] {
    display: none !important;
}

/* 7. 用本地 logo 替换 npmmirror 上的 lobehub assets（CSS content 即时生效，无延迟） */
img[src*="registry.npmmirror.com/@lobehub/assets-logo/"],
img[src*="registry.npmmirror.com/@lobehub/assets-emoji/"] {
    content: url("/logo.png") !important;
}

/* 8. 隐藏登录页"继续即表示你已阅读并同意服务条款与隐私政策"整行
 * 锚点：同一容器内同时含有 terms 和 privacy 两个链接 */
:has(> a[href*="terms"]):has(> a[href*="privacy"]) {
    display: none !important;
}

/* 9. 隐藏 settings/community 等页面底部"喜欢我们的产品？在 GitHub 添加星标 并 分享你的建议！"
 * 来源：lobe/src/features/Setting/Footer.tsx，class 由 LayoutSettingsFooterClassName 常量给出 */
.settings-layout-footer {
    display: none !important;
}

/* 10. 隐藏 community 详情页右上角"需要帮助?"链接（指向官方 discord 群）
 * 来源：lobe/src/routes/(main)/community/(detail)/*/features/Details/Nav.tsx，<a href={SOCIAL_URL.discord}> */
a[href*="discord.gg"],
a[href*="discord.com/invite"] {
    display: none !important;
}

/* 11. 隐藏所有"分享"按钮（含数据统计页右上角 + community 详情页等）
 * 来源：lobe/src/routes/(main)/community/(detail)/features/ShareButton.tsx
 *      lobe/src/routes/(main)/me/dashboard/features/ShareButton.tsx 等多处
 * 设计取舍："单 gateway"姿态——员工不应把内部对话 / 数据统计分享到外部，所有 share button 一律隐
 *
 * 关键陷阱：lobe-flex 渲染的 ActionIcon 用的是 <div role="button">（不是 <button> 标签），
 *           普通 `button:has(...)` selector 抓不到。必须用 :is(button, [role="button"]) 双匹配。
 *           (实测：数据统计页右上 share 按钮 DevTools 显示 <div role="button" class="lobe-flex acss-...">)
 *
 * 覆盖：
 *   - lucide Share2 / Share / Share3 等任何 share 系图标（不同页面使用不同变体）
 *   - aria-label="分享" / "Share"（icon-only button 通常带 aria-label）
 *   - title="分享" / "Share"（旧版 antd Tooltip 常用） */
:is(button, [role="button"]):has(svg[class*="lucide-share"]),
:is(button, [role="button"]):has(span > svg[class*="lucide-share"]),
:is(button, [role="button"])[aria-label="分享"],
:is(button, [role="button"])[aria-label="Share"],
:is(button, [role="button"])[title="分享"],
:is(button, [role="button"])[title="Share"] {
    display: none !important;
}

/* 12. 隐藏命令面板（CmdK）"关于"分组：联系我们 / 提交问题 / 在 GitHub 上给我们 Star / 社区支持
 * 来源：lobe/src/features/CommandMenu/MainMenu.tsx，每个 CommandItem 有 value 属性，
 * cmdk 库渲染为 <div cmdk-item data-value="..."> */
[cmdk-group]:has([cmdk-item][data-value="contact-via-email"]),
[cmdk-group]:has([cmdk-item][data-value="submit-issue"]),
[cmdk-group]:has([cmdk-item][data-value="star-github"]),
[cmdk-group]:has([cmdk-item][data-value="discord"]) {
    display: none !important;
}

/* 12a. 隐藏官方社区/云服务推广 banner。
 * 只命中 alert/banner 容器里带 LobeHub/LobeChat 官方链接的推广块，不影响普通聊天内容。 */
:is([role="alert"], .ant-alert, [class*="banner"], [class*="Banner"]):has(a[href*="lobehub.com"]),
:is([role="alert"], .ant-alert, [class*="banner"], [class*="Banner"]):has(a[href*="lobe.chat"]) {
    display: none !important;
}

/* 13. 加载页 LobeHub 字标 → FORCOME 文字 + 描边/填充动画
 *
 * 替换对象：所有 viewBox="0 0 940 320" 的 SVG（即 LobeHub wordmark）出现在两处加载链路：
 *   a. SPA shell 静态壳 #loading-screen（源 /app/.next/server/app/spa/<locale>__0.body）
 *      —— 跑在 React JS 加载之前，DOM-level JS 替换永远追不上
 *   b. React 组件版本（客户端 chunk 0xgpa.tz~9-xx.js）—— hydration 后作为 loading
 *      占位符渲染；容器是 <div aria-label="Loading">
 *
 * 策略（纯 CSS，render-blocking 在 paint 前生效，无闪烁）：
 *   1) 在 loading 容器内，把 SVG 的 <path>/<title> 隐掉，但保留 <svg> 自身（占位，不破坏 flex 布局）
 *   2) 在 loading 容器上加 ::after 伪元素绘 FORCOME 文字
 *   3) 用 -webkit-text-stroke（描边）+ -webkit-text-fill-color 关键帧（透明→淡→实色）
 *      模拟原 stroke-dashoffset/fill-opacity 双动画效果（"先描边 后填充"）
 *
 * scope 选择器只命中 loading 容器内部，header logo 等其它 LobeHub 字标 SVG 用法不受影响。 */

/* 13a. loading 容器内 SVG 字标内容隐掉（保留 SVG 容器） */
#loading-brand svg[viewBox="0 0 940 320"] > path,
#loading-brand svg[viewBox="0 0 940 320"] > title,
[aria-label="Loading"] svg[viewBox="0 0 940 320"] > path,
[aria-label="Loading"] svg[viewBox="0 0 940 320"] > title {
    display: none !important;
}

/* 13b. FORCOME 加载字 + 多维联动入场动画
 *
 * 抖动消除：position:fixed inset:0 把伪元素锚到视口中心，跟 #loading-brand /
 * [aria-label="Loading"] 父容器尺寸完全解耦——SPA shell 阶段（SVG height=40）
 * 切到 React 组件阶段（SVG height≈1em）那一帧，文字不再跟着父容器跳。
 *
 * Premium 感来自 5 维同步动画（不是单纯 fade-in 或单纯描边）：
 *   1. blur 6px → 0          —— 焦距推进，"从远处对上焦"的电影感入场
 *   2. letter-spacing 18→7px —— 字距 tracking-in 收紧（高端品牌片头标配）
 *   3. text-stroke transparent→实色→transparent —— 描边浮现再隐去
 *   4. text-fill   transparent→微透→实色       —— 填充从虚到实，"先轮廓后实体"
 *   5. opacity 0→1→0          —— 整体淡入再淡出，循环点完全隐（消除环回跳变）
 *
 * Timing 设计：linear + 3.4s 周期 + 6 个 keyframe 手工节奏，节奏由帧间距控制：
 *   - 0%→22% (≈750ms)  入场：描边浮现 + 焦距对上 + 字距收紧
 *   - 22%→42% (≈680ms) 静默：描边稳定，等填充
 *   - 42%→62% (≈680ms) 填充：fill 从微透涨到实色（"先轮廓后实体"）
 *   - 62%→80% (≈610ms) 高潮：glow 起，描边渐变透明融成实心，字距微撑开 0.5px（"光呼吸"）
 *   - 80%→100% (≈680ms) 收尾：opacity / fill / glow 三条线同步淡出到 0
 *
 * 不用 cubic-bezier 的原因：cubic-bezier(0.65,0,0.35,1) 是"一次性 in-out"曲线，
 * 每周期开头/结尾都被强调，循环时"一顿一顿"。linear 让 keyframe 间距完全控制
 * 节奏，配合 100% / 0% 都 opacity=0 的循环锚点，环回点"眼睛看不见"。 */

#loading-brand::after,
[aria-label="Loading"]:has(svg[viewBox="0 0 940 320"])::after {
    content: "FORCOME";
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99998;
    font-size: 34px;
    font-weight: 800;
    letter-spacing: 7px;
    line-height: 1;
    font-family: "HarmonyOS Sans", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #1f1f1f;
    -webkit-text-stroke: 1px #1f1f1f;
    -webkit-text-fill-color: transparent;
    animation: forcome-brand-loading 3.4s linear infinite;
    pointer-events: none;
    white-space: nowrap;
    text-rendering: geometricPrecision;
    will-change: opacity, filter, letter-spacing;
}

html[data-theme="dark"] #loading-brand::after,
html[data-theme="dark"] [aria-label="Loading"]:has(svg[viewBox="0 0 940 320"])::after {
    color: #f0f0f0;
    -webkit-text-stroke-color: #f0f0f0;
}

@keyframes forcome-brand-loading {
    /* 0%：完全隐（与 100% 等价，循环锚点） */
    0% {
        opacity: 0;
        filter: blur(6px);
        letter-spacing: 18px;
        -webkit-text-stroke-color: transparent;
        -webkit-text-fill-color: transparent;
        text-shadow: 0 0 0 rgb(from currentcolor r g b / 0);
    }
    /* 22%：描边入场完成（焦距对上、字距收紧、描边浮现） */
    22% {
        opacity: 1;
        filter: blur(0);
        letter-spacing: 7.5px;
        -webkit-text-stroke-color: currentcolor;
        -webkit-text-fill-color: transparent;
        text-shadow: 0 0 0 rgb(from currentcolor r g b / 0);
    }
    /* 42%：描边稳定，填充未起（"轮廓阶段"呼吸） */
    42% {
        opacity: 1;
        filter: blur(0);
        letter-spacing: 7px;
        -webkit-text-stroke-color: currentcolor;
        -webkit-text-fill-color: rgb(from currentcolor r g b / 0);
        text-shadow: 0 0 0 rgb(from currentcolor r g b / 0);
    }
    /* 62%：填充涨满，glow 起步 */
    62% {
        opacity: 1;
        filter: blur(0);
        letter-spacing: 7px;
        -webkit-text-stroke-color: currentcolor;
        -webkit-text-fill-color: currentcolor;
        text-shadow: 0 0 12px rgb(from currentcolor r g b / 0.3);
    }
    /* 80%：glow 顶峰 + 描边渐变透明（"轮廓自然消融成实心"），字距微撑 0.5px */
    80% {
        opacity: 1;
        filter: blur(0);
        letter-spacing: 7.5px;
        -webkit-text-stroke-color: rgb(from currentcolor r g b / 0);
        -webkit-text-fill-color: currentcolor;
        text-shadow: 0 0 20px rgb(from currentcolor r g b / 0.5);
    }
    /* 100%：opacity / fill / glow 三条线同步淡出到 0，等于 0% 帧（循环无缝） */
    100% {
        opacity: 0;
        filter: blur(4px);
        letter-spacing: 12px;
        -webkit-text-stroke-color: transparent;
        -webkit-text-fill-color: rgb(from currentcolor r g b / 0);
        text-shadow: 0 0 0 rgb(from currentcolor r g b / 0);
    }
}
