/*
 * 网址详情页悬浮胶囊导航
 *
 * 几何值逐项取自 doubao.com/work 真机 computed style：
 *   容器 800×56 / radius 100px / blur(15px) / border rgba(0,0,0,.05)
 *   阴影 0 20px 30px rgba(77,90,108,.12) / 内层 798×54 / padding 8 12 8 20
 *   按钮高 32 / radius 60 / 描边 rgba(0,0,0,.2) / 黑底按钮 padding 0 19
 * 唯一改动：--cnav-bg 从原站 rgba(255,255,255,.2) 提到 .62 —— 原站底色是彩色主视觉，
 *   本站详情页是浅灰底，.2 的白几乎不可见（只剩阴影），故提高不透明度保住「玻璃白胶囊」观感。
 *   想完全还原改回 .2 即可。
 */

.cnav-nav {
    --cnav-bg: rgba(255, 255, 255, .78);
    position: fixed;
    top: 18px; /* JS 会按 #header 实际高度改写 */
    left: 50%;
    z-index: 1070; /* 原生 #header 是 1080，胶囊压在它下面一层 */
    width: 800px;
    min-width: 500px;
    height: 56px;
    border-radius: 100px;
    background: var(--cnav-bg);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 0, 0, .05);
    box-shadow: 0 20px 30px 0 rgba(77, 90, 108, .12);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-50%) translateY(-20px);
    transition: opacity .26s ease, transform .26s ease, visibility .26s ease;
    will-change: opacity, transform;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    box-sizing: border-box;
}

.cnav-nav.is-show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.cnav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    padding: 8px 12px 8px 20px;
    box-sizing: border-box;
}

/* ---------- 左侧：站点图标 + 名称 ---------- */
.cnav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    min-width: 0;
    height: 32px;
    text-decoration: none;
    color: inherit;
}

.cnav-logo {
    display: block;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 8px;
    object-fit: contain;
    background: rgba(0, 0, 0, .04);
}

.cnav-name {
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
    color: #12131a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

/* ---------- 中间：文字导航（原站无底、无内边距） ---------- */
.cnav-tabs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px; /* 有底色后单项更宽，间距从 20 收到 12，避免 4 项被挤到省略号 */
    margin: 0 16px; /* 项多到溢出时仍与左品牌/右按钮保持 16px 间距（溢出被裁在本盒内） */
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden; /* 后台可能配 5 个长网址名，超出时裁切而不是顶破胶囊 */
}

.cnav-tab {
    display: block;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--cnav-chip-bg, transparent);
    font-size: 14px;
    font-weight: 400;
    line-height: 16.8px;
    color: var(--cnav-chip-fg, rgba(0, 0, 0, .7));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    text-decoration: none;
    transition: opacity .2s, background-color .2s;
}

/* 主题的 `a` 颜色会盖掉 .cnav-tab 的字色（尤其深色模式），这里用两级类名压过去 */
.cnav-nav .cnav-tab {
    color: var(--cnav-chip-fg, rgba(0, 0, 0, .7));
}

.cnav-tab:hover {
    opacity: .82;
    text-decoration: none;
}

/* ---------- 中间文字按钮的随机底色（PHP 每次刷新随机起序号，按序取色） ---------- */
.cnav-chip-1 { --cnav-chip-bg: #EEF3FF; --cnav-chip-fg: #2B5ACC; }
.cnav-chip-2 { --cnav-chip-bg: #FFF1E6; --cnav-chip-fg: #B45309; }
.cnav-chip-3 { --cnav-chip-bg: #E9F7EF; --cnav-chip-fg: #15803D; }
.cnav-chip-4 { --cnav-chip-bg: #FFEFF3; --cnav-chip-fg: #BE185D; }
.cnav-chip-5 { --cnav-chip-bg: #F3EEFF; --cnav-chip-fg: #6D28D9; }
.cnav-chip-6 { --cnav-chip-bg: #E8F6F8; --cnav-chip-fg: #0E7490; }
.cnav-chip-7 { --cnav-chip-bg: #FFF7E0; --cnav-chip-fg: #A16207; }
.cnav-chip-8 { --cnav-chip-bg: #EFF1F4; --cnav-chip-fg: #374151; }

/* ---------- 右侧：描边按钮 + 黑底胶囊 ---------- */
.cnav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}

/* 两个按钮共用一套尺寸：同高 30、同最小宽 88、同内边距、同字重，保证视觉上完全一致 */
.cnav-ghost {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 88px;
    height: 30px;
    padding: 0 14px;
    border: 1px solid rgba(0, 0, 0, .2);
    border-radius: 60px;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    letter-spacing: -.02em;
    color: #000;
    white-space: nowrap;
    cursor: pointer;
    transition: color .2s, background-color .2s, border-color .2s;
}

.cnav-ghost:hover {
    background: rgba(0, 0, 0, .06);
    border-color: rgba(0, 0, 0, .32);
}

.cnav-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 88px;
    height: 30px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 60px;
    background: #000;
    font-family: "PingFang SC", inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    color: #fff;
    white-space: nowrap;
    text-decoration: none;
    transition: color .2s, background-color .2s, border-color .2s;
}

.cnav-cta:hover {
    background: #2b2b2b;
    color: #fff;
    text-decoration: none;
}

.cnav-cta.is-disabled {
    background: rgba(0, 0, 0, .28);
    cursor: not-allowed;
}

/* 复制成功后的临时态 */
.cnav-ghost.is-copied {
    border-color: rgba(0, 0, 0, .32);
    background: rgba(0, 0, 0, .06);
}

/* ---------- 响应式（断点与原站一致） ---------- */
@media (max-width: 899px) {
    .cnav-nav {
        width: calc(100% - 64px);
    }
}

@media (max-width: 768px) {
    .cnav-nav {
        width: calc(100% - 24px);
        min-width: 0;
    }

    .cnav-inner {
        padding: 8px 12px 8px 14px;
    }

    .cnav-logo {
        width: 28px;
        height: 28px;
        flex-basis: 28px;
    }

    .cnav-brand {
        gap: 8px;
    }

    .cnav-name {
        font-size: 14px;
        max-width: 30vw;
    }

    /* 移动端不再整体隐藏中间按钮：按后台「移动端显示数量」只留前 N 个 */
    .cnav-tabs {
        margin: 0 8px;
        gap: 10px;
    }

    .cnav-tab {
        font-size: 13px;
        max-width: 120px;
    }

    .cnav-tab.is-mobile-hidden {
        display: none;
    }

    .cnav-actions {
        gap: 6px;
        margin-left: auto;
    }

    .cnav-ghost {
        display: none;
    }

    .cnav-cta {
        min-width: 78px;
        padding: 0 12px;
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cnav-nav {
        transition: none;
    }
}

/* ---------- 深色模式（父主题用 html.io-black-mode，见 js/app.js themeChange） ---------- */
html.io-black-mode .cnav-nav {
    --cnav-bg: rgba(38, 40, 44, .72);
    border-color: rgba(255, 255, 255, .10);
    box-shadow: 0 20px 30px 0 rgba(0, 0, 0, .5);
}

html.io-black-mode .cnav-name {
    color: #f2f3f5;
}

/* 深色模式：字色同样需要压过主题的 `html.io-black-mode a{color:#c6c9cf}` */
html.io-black-mode .cnav-nav .cnav-tab {
    color: var(--cnav-chip-fg, rgba(255, 255, 255, .72));
}

/* 深色模式下的随机底色（半透明高光 + 亮字），压过亮色配色 */
html.io-black-mode .cnav-chip-1 { --cnav-chip-bg: rgba(84, 124, 255, .18); --cnav-chip-fg: #A9C0FF; }
html.io-black-mode .cnav-chip-2 { --cnav-chip-bg: rgba(255, 160, 60, .16); --cnav-chip-fg: #FFC48A; }
html.io-black-mode .cnav-chip-3 { --cnav-chip-bg: rgba(60, 200, 120, .16); --cnav-chip-fg: #93E6B4; }
html.io-black-mode .cnav-chip-4 { --cnav-chip-bg: rgba(255, 90, 140, .16); --cnav-chip-fg: #FFA8C2; }
html.io-black-mode .cnav-chip-5 { --cnav-chip-bg: rgba(150, 110, 255, .18); --cnav-chip-fg: #C9B6FF; }
html.io-black-mode .cnav-chip-6 { --cnav-chip-bg: rgba(60, 190, 200, .16); --cnav-chip-fg: #9FE3EA; }
html.io-black-mode .cnav-chip-7 { --cnav-chip-bg: rgba(255, 200, 60, .16); --cnav-chip-fg: #FFDD8A; }
html.io-black-mode .cnav-chip-8 { --cnav-chip-bg: rgba(255, 255, 255, .10); --cnav-chip-fg: #D6DAE0; }

html.io-black-mode .cnav-logo {
    background: rgba(255, 255, 255, .08);
}

html.io-black-mode .cnav-ghost {
    color: #fff;
    border-color: rgba(255, 255, 255, .24);
}

html.io-black-mode .cnav-ghost:hover {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .36);
}

html.io-black-mode .cnav-ghost.is-copied {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .36);
}

/* 黑底按钮在深色底上反相，保持主 CTA 的层级
   注意：父主题深色模式有 `html.io-black-mode a{color:#c6c9cf}` 这类规则，
   选择器必须压过它（实测白底被刷成浅灰字，等于看不见），故加 .cnav-nav 前缀 + !important */
html.io-black-mode .cnav-nav .cnav-cta {
    background: #fff !important;
    color: #12131a !important;
}

html.io-black-mode .cnav-nav .cnav-cta:hover {
    background: #e4e5e8 !important;
    color: #12131a !important;
}

html.io-black-mode .cnav-nav .cnav-cta.is-disabled {
    background: rgba(255, 255, 255, .2) !important;
    color: rgba(255, 255, 255, .55) !important;
}
