:root {
    --glass-x: 50%;
    --glass-y: 50%;
    --glass-vector-x: 0;
    --glass-vector-y: 0;
    --magnet-x: 0px;
    --magnet-y: 0px;
    --hover-lift: 0px;
    --hover-scale: 1;
}

#liquid-glass-filter-definitions {
    position: fixed;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

.liquid-surface {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background: transparent !important;
    border-color: transparent !important;
    transform: translate3d(
        var(--magnet-x, 0px),
        calc(var(--magnet-y, 0px) + var(--hover-lift, 0px)),
        0
    ) scale(var(--hover-scale, 1));
    transform-origin: center;
    transition:
        transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 2.2),
        box-shadow 0.3s ease,
        filter 0.3s ease,
        color 0.3s ease,
        opacity 0.3s ease;
    box-shadow: 0 16px 42px rgba(0, 8, 30, 0.2);
    will-change: transform;
}

.liquid-surface > :not(.liquid-glass-layer) {
    position: relative;
    z-index: 5;
}

.liquid-glass-layer {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
}

/* The four layers mirror the supplied Juejin reference. */
.liquid-glass-outer {
    z-index: 0;
    padding: 5px;
    backdrop-filter: url(#liquid_glass_filter);
    -webkit-backdrop-filter: url(#liquid_glass_filter);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

.liquid-glass-cover {
    z-index: 2;
    background: rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.liquid-glass-sharp {
    z-index: 3;
    box-shadow:
        inset 1px 1px 0 0 rgba(255, 255, 255, 0.5),
        inset -1px -1px 0 0 rgba(255, 255, 255, 0.6);
}

.liquid-glass-reflect {
    z-index: 2;
    inset: 1px;
    box-shadow:
        inset 2px 2px 6px 2px rgba(255, 255, 255, 0.2),
        inset -2px -2px 4px -1px rgba(255, 255, 255, 0.2);
}

/* The reference material stays neutral and transparent on every component. */

.topbar.liquid-surface {
    overflow: visible;
    box-shadow: 0 18px 48px rgba(0, 8, 30, 0.24);
}

.topbar > .liquid-glass-layer {
    overflow: hidden;
    border-radius: inherit;
}

.profile-card:hover,
.focus-card:hover,
.stat-card:hover,
.article-card:hover,
.about-section:hover {
    --hover-lift: -2px;
    --hover-scale: 1.008;
    box-shadow: 0 26px 68px rgba(0, 8, 30, 0.3);
}

.resource-card:hover {
    --hover-lift: -3px;
    --hover-scale: 1.012;
    box-shadow: 0 22px 54px rgba(0, 8, 30, 0.32);
}

.nav-cta:hover,
.spring-button:hover,
.icon-action:hover,
.social-link:hover,
.menu-toggle:hover {
    --hover-lift: -2px;
    --hover-scale: 1.01;
    box-shadow:
        0 8px 20px rgba(0, 8, 30, 0.26),
        inset 1px 1px 4px rgba(255, 255, 255, 0.22);
    filter: brightness(1.08) saturate(1.12);
}

.topic-chip:hover {
    --hover-scale: 1.1;
    box-shadow:
        0 8px 20px rgba(37, 89, 173, 0.16),
        inset 1px 1px 4px rgba(255, 255, 255, 0.48);
}

.topic-chip > span {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 2.2);
}

.topic-chip:hover > span {
    transform: scale(0.9);
}

.liquid-surface.is-liquid-pressed,
.liquid-surface:active {
    --hover-lift: -1px;
    --hover-scale: 0.98;
    box-shadow: 0 3px 9px rgba(27, 69, 137, 0.16);
}

.liquid-surface.is-pointer-inside .liquid-glass-reflect {
    background:
        radial-gradient(
            150px circle at var(--glass-x, 50%) var(--glass-y, 50%),
            rgba(255, 255, 255, 0.2),
            transparent 66%
        );
}

.liquid-surface.is-pointer-inside .liquid-glass-sharp {
    box-shadow:
        inset calc(1px + var(--glass-vector-x, 0) * 0.5px)
            calc(1px + var(--glass-vector-y, 0) * 0.5px)
            0 rgba(255, 255, 255, 0.58),
        inset -1px -1px 0 rgba(255, 255, 255, 0.52);
}

.resource-icon,
.brand-mark,
.profile-avatar {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 2.2), filter 0.3s ease;
}

.resource-card:hover .resource-icon {
    transform: scale(1.12) rotate(-4deg);
    filter: drop-shadow(0 8px 12px rgba(31, 83, 172, 0.18));
}

.brand-link:hover .brand-mark {
    transform: scale(1.08) rotate(-4deg);
}

.article-container.liquid-surface {
    border-radius: 26px;
}

.back-link.liquid-surface {
    display: inline-flex !important;
    overflow: hidden;
    color: #fff !important;
    background: transparent !important;
}

.article-container .article-content code {
    color: #bce9ff !important;
    background: rgba(3, 17, 49, 0.42) !important;
}

@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
    .liquid-glass-cover {
        background: rgba(4, 19, 55, 0.72) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .liquid-surface {
        --magnet-x: 0px !important;
        --magnet-y: 0px !important;
        --hover-lift: 0px !important;
        --hover-scale: 1 !important;
        transform: none !important;
        will-change: auto;
    }
}
