/**
 * iOS Liquid Glass — 仅作用于少量 UI 铬层元素
 *
 * 性能原则：
 * - 真实 backdrop-filter 只给固定/小面积：顶栏、徽章、次要按钮、RSI 侧栏
 * - 横向滚动的模型卡用「假玻璃」（渐变 + 高光边），去掉 blur，避免滚动时每帧重绘
 * - 模糊半径克制；移动端再降一档；尊重 reduced-transparency / reduced-motion
 */

:root {
    --lg-blur: 18px;
    --lg-saturate: 1.65;
    --lg-fill: rgba(255, 255, 255, 0.52);
    --lg-fill-strong: rgba(255, 255, 255, 0.72);
    --lg-rim: rgba(255, 255, 255, 0.62);
    --lg-rim-soft: rgba(255, 255, 255, 0.28);
    --lg-edge: rgba(15, 23, 42, 0.08);
    --lg-specular:
        inset 0 1px 0 rgba(255, 255, 255, 0.78),
        inset 0 -0.5px 0 rgba(255, 255, 255, 0.18);
    --lg-lift: 0 8px 28px rgba(15, 23, 42, 0.08);
    --lg-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---- 共享：真玻璃层（可复用） ----
   注意：登录按钮/手机菜单在 header 内，父级 backdrop 会限制子级模糊，
   故二者用绘制高光材质，不依赖页面背景模糊。 */
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    header,
    .hero-actions .btn-secondary,
    .rsi-lineage,
    .trust-badge {
        -webkit-backdrop-filter: saturate(var(--lg-saturate)) blur(var(--lg-blur));
        backdrop-filter: saturate(var(--lg-saturate)) blur(var(--lg-blur));
    }
}

/* ---- 顶栏 ---- */
header {
    background: var(--lg-fill);
    border-bottom: 1px solid transparent;
    box-shadow: var(--lg-specular);
    transition:
        background-color 0.28s var(--lg-ease),
        border-color 0.28s var(--lg-ease),
        box-shadow 0.28s var(--lg-ease);
}

header.scrolled {
    background: var(--lg-fill-strong);
    border-bottom-color: var(--lg-edge);
    box-shadow:
        var(--lg-specular),
        0 4px 18px rgba(15, 23, 42, 0.06);
}

/* ---- Hero 徽章：[ 文本 ] 无胶囊底，光效跟随鼠标 ---- */
.hero-badge {
    --lg-mx: 50%;
    --lg-my: 50%;
    position: relative;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
    margin: 0 0 16px !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    overflow: visible !important;
    isolation: auto;
    text-decoration: none;
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    line-height: 1.4;
    /* 光斑跟随 --lg-mx / --lg-my；覆盖 style.css 胶囊底 */
    background: radial-gradient(
        120px circle at var(--lg-mx) var(--lg-my),
        #7ec8ff 0%,
        #2f7dff 28%,
        #0056d2 58%,
        #003d99 100%
    ) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    color: transparent !important;
    -webkit-text-fill-color: transparent;
    transition: filter 0.2s var(--lg-ease);
}

.hero-badge::before,
.hero-badge::after {
    font-weight: 400;
    color: #adadad;
    -webkit-text-fill-color: #adadad;
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    position: static;
    inset: auto;
    width: auto;
    height: auto;
    opacity: 1;
    transform: none;
    animation: none;
    pointer-events: none;
}

.hero-badge::before {
    content: "[";
}

.hero-badge::after {
    content: "]";
}

.hero-badge:hover {
    filter: brightness(1.08);
}

.hero-badge:hover::before,
.hero-badge:hover::after {
    color: #7a7a7a;
    -webkit-text-fill-color: #7a7a7a;
}

.hero-badge.is-tracking {
    filter: brightness(1.12);
}

@media (prefers-reduced-motion: reduce) {
    .hero-badge {
        background-image: none;
        color: #0056d2;
        -webkit-text-fill-color: #0056d2;
    }
}

/* ---- Hero 次要按钮（液态玻璃，无上浮） ---- */
.hero-actions .btn-secondary {
    --lg-mx: 50%;
    --lg-my: 40%;
    position: relative;
    border-radius: 10px;
    background:
        radial-gradient(
            100px circle at var(--lg-mx) var(--lg-my),
            rgba(255, 255, 255, 0.5),
            transparent 55%
        ),
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.82) 0%,
            rgba(255, 255, 255, 0.48) 100%
        );
    border: 1px solid var(--lg-rim-soft);
    color: var(--text-main, #1d1d1f);
    box-shadow: var(--lg-specular), 0 4px 16px rgba(15, 23, 42, 0.06);
    overflow: hidden;
    isolation: isolate;
    -webkit-backdrop-filter: saturate(var(--lg-saturate)) blur(12px);
    backdrop-filter: saturate(var(--lg-saturate)) blur(12px);
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.25s var(--lg-ease);
}

.hero-actions .btn-secondary:hover {
    border-color: rgba(0, 86, 210, 0.28);
    color: var(--primary-color, #0056d2);
    box-shadow:
        var(--lg-specular),
        0 6px 18px rgba(0, 86, 210, 0.1);
    transform: none;
}

.hero-actions .btn-secondary:active {
    transform: none;
}

/* ---- 指针跟随高光（lg-interactive） ---- */
.lg-interactive {
    --lg-mx: 50%;
    --lg-my: 40%;
}

.rsi-card.lg-interactive,
.rsi-lineage.lg-interactive,
.product-card.lg-interactive,
.low-altitude-card.lg-interactive,
.npu-card.lg-interactive,
.trust-badge.lg-interactive,
.matrix-card.lg-interactive {
    position: relative;
}

.lg-interactive > .lg-spot {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.25s ease;
    background: radial-gradient(
        160px circle at var(--lg-mx) var(--lg-my),
        rgba(255, 255, 255, 0.42),
        transparent 58%
    );
    mix-blend-mode: soft-light;
}

/* 徽章/按钮不使用 spot 层（徽章用文字渐变跟手，按钮用背景径向） */
.hero-badge > .lg-spot,
.btn-secondary > .lg-spot {
    display: none !important;
}

.rsi-card > .rsi-inner,
.product-card > .product-card-image,
.product-card > .product-card-content,
.low-altitude-card > .low-altitude-inner,
.npu-card > .npu-inner,
.trust-badge {
    position: relative;
    z-index: 2;
}

.lg-interactive:hover > .lg-spot,
.lg-interactive.is-tracking > .lg-spot {
    opacity: 1;
}

/* ---- 手机菜单面板（动效见 style.css） ---- */
.mobile-menu {
    padding: 8px 0 10px;
    border-radius: 18px;
    background: linear-gradient(
        165deg,
        rgba(255, 255, 255, 0.97) 0%,
        rgba(246, 249, 253, 0.94) 100%
    );
    border: 1px solid rgba(255, 255, 255, 0.82);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        0 8px 16px rgba(15, 23, 42, 0.06),
        0 22px 48px rgba(15, 23, 42, 0.14);
    -webkit-backdrop-filter: saturate(1.35) blur(18px);
    backdrop-filter: saturate(1.35) blur(18px);
}

.mobile-menu-links {
    gap: 1px;
    padding: 2px 8px 4px;
}

.mobile-menu-links a {
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
}

.mobile-menu-overlay {
    background: rgba(15, 23, 42, 0.22);
    -webkit-backdrop-filter: blur(6px) saturate(1.2);
    backdrop-filter: blur(6px) saturate(1.2);
}

/* ---- RSI 侧栏 + 芯片 ---- */
.rsi-card.lg-interactive {
    --lg-mx: 50%;
    --lg-my: 35%;
    background:
        radial-gradient(
            220px circle at var(--lg-mx) var(--lg-my),
            rgba(255, 255, 255, 0.55),
            transparent 55%
        ),
        linear-gradient(165deg, rgba(255, 255, 255, 0.92) 0%, rgba(245, 249, 255, 0.88) 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.7) !important;
    box-shadow:
        var(--lg-specular),
        0 12px 32px rgba(15, 23, 42, 0.06) !important;
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    backdrop-filter: saturate(1.4) blur(14px);
}

.rsi-lineage {
    background: linear-gradient(
        165deg,
        rgba(255, 255, 255, 0.82) 0%,
        rgba(248, 251, 255, 0.58) 100%
    );
    border: 1px solid var(--lg-rim-soft);
    box-shadow: var(--lg-specular), 0 10px 28px rgba(37, 99, 235, 0.08);
}

.rsi-lineage-chip {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(238, 244, 255, 0.72) 100%
    );
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.85),
        0 2px 8px rgba(37, 99, 235, 0.06);
}

/* ---- Trust 徽章 ---- */
.trust-badge {
    background: linear-gradient(
        165deg,
        rgba(255, 255, 255, 0.28) 0%,
        rgba(255, 255, 255, 0.1) 100%
    );
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: var(--lg-specular);
}

/* ---- 工具类：大面积表面用「绘玻璃」（无实时 blur，可维护） ---- */
.lg-surface {
    --lg-mx: 50%;
    --lg-my: 40%;
    position: relative;
    background:
        linear-gradient(
            165deg,
            rgba(255, 255, 255, 0.88) 0%,
            rgba(245, 249, 255, 0.72) 100%
        );
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow:
        var(--lg-specular),
        0 8px 24px rgba(15, 23, 42, 0.06);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.showcase-gallery.lg-surface {
    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.78) 0%,
            rgba(240, 246, 255, 0.62) 100%
        );
    border: 1px solid rgba(0, 86, 210, 0.08);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        0 6px 20px rgba(15, 23, 42, 0.05);
}

.product-tabs-card.lg-surface {
    background:
        linear-gradient(
            165deg,
            rgba(255, 255, 255, 0.92) 0%,
            rgba(245, 249, 255, 0.78) 100%
        );
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow:
        var(--lg-specular),
        0 12px 36px rgba(15, 23, 42, 0.07);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* ---- 模型卡：纸面玻璃高光（无 blur，保证滚动性能） ---- */
.home-model-rail .bailu-model-carousel .mc-card,
.bailu-model-carousel .mc-card {
    background: linear-gradient(
        165deg,
        rgba(255, 255, 255, 0.96) 0%,
        rgba(245, 248, 255, 0.9) 100%
    );
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        0 4px 14px rgba(15, 23, 42, 0.05);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.home-model-rail .bailu-model-carousel .mc-card:hover,
.bailu-model-carousel .mc-card:hover {
    border-color: rgba(0, 86, 210, 0.3);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.98),
        0 8px 22px rgba(0, 86, 210, 0.1);
}

/* ---- 3D 角标：统一液态玻璃配方 ---- */
.low-altitude-3d::after,
.npu-3d::after {
    background: rgba(15, 23, 42, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    backdrop-filter: saturate(1.4) blur(10px);
}

/* ---- 移动端：降模糊，减合成成本 ---- */
@media (max-width: 768px) {
    :root {
        --lg-blur: 12px;
        --lg-saturate: 1.4;
    }

    .hero-actions .btn-secondary:hover {
        transform: none;
    }
}

/* ---- 无 backdrop-filter 时的实色回退 ---- */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    header {
        background: rgba(255, 255, 255, 0.94);
    }

    header.scrolled {
        background: #ffffff;
    }

    .hero-actions .btn-secondary,
    .rsi-lineage {
        background: rgba(255, 255, 255, 0.96);
    }

    .trust-badge {
        background: rgba(255, 255, 255, 0.22);
    }
}

/* ---- 系统「减少透明度」：关闭模糊，改用不透明表面 ---- */
@media (prefers-reduced-transparency: reduce) {
    header,
    .hero-actions .btn-secondary,
    .rsi-lineage,
    .trust-badge,
    .low-altitude-3d::after,
    .npu-3d::after {
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }

    header,
    header.scrolled {
        background: #ffffff;
    }

    .hero-actions .btn-secondary,
    .rsi-lineage {
        background: #ffffff;
    }

    .trust-badge {
        background: rgba(255, 255, 255, 0.85);
        color: inherit;
    }

    .low-altitude-3d::after,
    .npu-3d::after {
        background: rgba(15, 23, 42, 0.78);
    }
}

@media (prefers-reduced-motion: reduce) {
    .hero-actions .btn-secondary {
        transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    .hero-actions .btn-secondary:hover {
        transform: none;
    }
}
