/**
 * Beautification effects for Codex Beautify Switcher.
 * 视觉效果与业务逻辑分离，具体启用由 body 上的 codex-feature-* class 控制。
 */

/* ========== 头像摇摆 ========== */
body.codex-feature-avatar-swing .user-avatar .avatar-img,
body.codex-feature-avatar-swing .img-ip:hover,
body.codex-feature-avatar-swing .w-a-info img {
    -webkit-animation: swing 3s 0.4s ease both;
    -moz-animation: swing 3s 0.4s ease both;
    animation: swing 3s 0.4s ease both;
}

@-webkit-keyframes swing {
    20%, 40%, 60%, 80%, 100% {
        -webkit-transform-origin: top center;
    }
    20% {
        -webkit-transform: rotate(15deg);
    }
    40% {
        -webkit-transform: rotate(-10deg);
    }
    60% {
        -webkit-transform: rotate(5deg);
    }
    80% {
        -webkit-transform: rotate(-5deg);
    }
    100% {
        -webkit-transform: rotate(0deg);
    }
}

@-moz-keyframes swing {
    20%, 40%, 60%, 80%, 100% {
        -moz-transform-origin: top center;
    }
    20% {
        -moz-transform: rotate(15deg);
    }
    40% {
        -moz-transform: rotate(-10deg);
    }
    60% {
        -moz-transform: rotate(5deg);
    }
    80% {
        -moz-transform: rotate(-5deg);
    }
    100% {
        -moz-transform: rotate(0deg);
    }
}

@keyframes swing {
    20%, 40%, 60%, 80%, 100% {
        transform-origin: top center;
    }
    20% {
        transform: rotate(15deg);
    }
    40% {
        transform: rotate(-10deg);
    }
    60% {
        transform: rotate(5deg);
    }
    80% {
        transform: rotate(-5deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

/* ========== 彩色昵称 ========== */
body.codex-feature-colorful-nickname .flex.ac.flex1 .mr6,
body.codex-feature-colorful-nickname .hide-sm.ml6,
body.codex-feature-colorful-nickname a.display-name.text-ellipsis,
body.codex-feature-colorful-nickname p.text-ellipsis.muted-2-color,
body.codex-feature-colorful-nickname span.flex1.flex {
    background-image: -webkit-linear-gradient(
        90deg,
        #07c160,
        #fb6bea 25%,
        #3aedff 50%,
        #fb6bea 75%,
        #28d079
    );
    -webkit-text-fill-color: transparent;
    -webkit-background-clip: text;
    background-size: 100% 600%;
    animation: wzw 10s linear infinite;
    display: inline-block;
    transition: transform 0.3s ease;
    padding: 0 4px;
    font-weight: bold;
}

body.codex-feature-colorful-nickname .flex.ac.flex1 .mr6:hover,
body.codex-feature-colorful-nickname .hide-sm.ml6:hover,
body.codex-feature-colorful-nickname a.display-name.text-ellipsis:hover,
body.codex-feature-colorful-nickname p.text-ellipsis.muted-2-color:hover,
body.codex-feature-colorful-nickname span.flex1.flex:hover {
    transform: scale(1.2);
}

body.codex-feature-colorful-nickname a.display-name.text-ellipsis,
body.codex-feature-colorful-nickname p.text-ellipsis.muted-2-color,
body.codex-feature-colorful-nickname span.flex1.flex {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

@keyframes wzw {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 0 -300%;
    }
}

/* 排除特定元素 */
body.codex-feature-colorful-nickname .text-ellipsis.muted-2-color span[data-toggle],
body.codex-feature-colorful-nickname span.flex1.flex .flex0,
body.codex-feature-colorful-nickname span.flex1.flex .icon-spot,
body.codex-feature-colorful-nickname span.flex1.flex .muted-3-color {
    background-image: none !important;
    -webkit-text-fill-color: initial !important;
    -webkit-background-clip: initial !important;
    animation: none !important;
    transform: none !important;
}

/* ========== 头像呼吸光环 ========== */
body.codex-feature-avatar-halo .avatar {
    border-radius: 50%;
    animation: light 4s ease-in-out infinite !important;
    transition: 0.5s;
}

body.codex-feature-avatar-halo .avatar:hover {
    transform: scale(1.15) rotate(720deg);
}

@keyframes light {
    0% {
        box-shadow: 0 0 4px #f00;
    }
    25% {
        box-shadow: 0 0 16px #0f0;
    }
    50% {
        box-shadow: 0 0 4px #00f;
    }
    75% {
        box-shadow: 0 0 16px #0f0;
    }
    100% {
        box-shadow: 0 0 4px #f00;
    }
}

body.codex-feature-avatar-halo .txgj {
    top: 2px;
    transform: scale(1.7);
    width: 90px;
    position: absolute;
    z-index: 1;
}

body.codex-feature-avatar-halo .top-user-info-box-name .txgj {
    left: -5px;
    transform: scale(1);
    top: 6px;
}

body.codex-feature-avatar-halo .post-meta-left .txgj {
    display: none;
}

body.codex-feature-avatar-halo .post-meta-left .avatar-parent .txgj {
    display: block;
    transform: scale(1.6);
    left: 0 !important;
}

/* ========== 圆形头像 ========== */
body.codex-feature-avatar-circle .avatar,
body.codex-feature-avatar-circle .top-user-box-drop .avatar,
body.codex-feature-avatar-circle .comment .gravatar img,
body.codex-feature-avatar-circle .w-a-info img,
body.codex-feature-avatar-circle .user-avatar .avatar-img {
    border-radius: 50%;
}

body.codex-feature-avatar-circle .author-header .avatar-img {
    --this-size: 95px;
}

body.codex-feature-avatar-circle .author-header .avatar-img .avatar {
    border-radius: 50%;
    border: 4px solid var(--main-bg-color);
}

/* ========== Logo 扫光 ========== */
body.codex-feature-logo-sweep .custom-logo-link,
body.codex-feature-logo-sweep .site-logo,
body.codex-feature-logo-sweep .site-logo a,
body.codex-feature-logo-sweep .navbar-brand {
    position: relative;
    display: inline-flex;
    overflow: hidden;
}

body.codex-feature-logo-sweep .custom-logo-link::after,
body.codex-feature-logo-sweep .site-logo::after,
body.codex-feature-logo-sweep .site-logo a::after,
body.codex-feature-logo-sweep .navbar-brand::after {
    content: '';
    position: absolute;
    top: 0;
    left: -120%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0));
    transform: skewX(-15deg) translateX(-50%);
    animation: codex-logo-sweep 3.5s linear infinite;
    opacity: 0.8;
    pointer-events: none;
}

/* ========== 菜单渐变文字 ========== */
body.codex-feature-menu-gradient .dropdown.open .option-dropdown,
body.codex-feature-menu-gradient .dropdown.open .padding-h10,
body.codex-feature-menu-gradient .dropdown.open .ajax-next,
body.codex-feature-menu-gradient .dropdown.open .dropdown-menu a {
    color: currentColor;
    font-weight: 700;
    font-size: 14px;
    background: linear-gradient(
        90deg,
        #ff6ec4,
        #7873f5,
        #4adede,
        #ffb86c,
        #ff6ec4
    );
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: codex-gradient-move 5s linear infinite;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

body.codex-feature-menu-gradient .dropdown.open .dropdown-menu a:hover {
    transform: translateY(-2px) scale(1.03);
    opacity: 0.95;
}

/* ========== 热门标题渐变 ========== */
body.codex-feature-hot-title-gradient .widget-tab-post .item-heading a {
    display: inline-block;
    max-width: 33ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: currentColor;
    background: linear-gradient(90deg, #ff6ec4, #7873f5, #4ade80, #facc15);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: codex-gradient-move 6s ease infinite;
    font-weight: 700;
    transform: scale(1.02);
    transition: transform 0.3s ease, filter 0.3s ease;
}

body.codex-feature-hot-title-gradient .widget-tab-post .item-heading a:hover {
    transform: scale(1.08);
    filter: brightness(1.3);
}

/* ========== 文章标签动效 ========== */
body.codex-feature-article-tags-fx .article-tags {
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

body.codex-feature-article-tags-fx .article-tags a {
    padding: 4px 10px;
    color: #fff;
    font-size: 12px;
    line-height: 16px;
    font-weight: 400;
    border-radius: 2px;
    display: inline-block;
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    z-index: 1;
    transform: scale(1);
    animation: codex-breathe 3s ease-in-out infinite;
}

body.codex-feature-article-tags-fx .article-tags a::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    transition: all 0.4s ease;
}

body.codex-feature-article-tags-fx .article-tags a:nth-child(5n)::before {
    background: linear-gradient(135deg, #4a4a4a 0%, #6a6a6a 50%, #4a4a4a 100%);
    background-size: 200% 200%;
    animation: codex-gradient-shift 4s ease infinite;
}

body.codex-feature-article-tags-fx .article-tags a:nth-child(5n + 1)::before {
    background: linear-gradient(135deg, #ff5e5c 0%, #ff8e8c 50%, #ff5e5c 100%);
    background-size: 200% 200%;
    animation: codex-gradient-shift 4s ease infinite;
}

body.codex-feature-article-tags-fx .article-tags a:nth-child(5n + 2)::before {
    background: linear-gradient(135deg, #ffbb50 0%, #ffdb90 50%, #ffbb50 100%);
    background-size: 200% 200%;
    animation: codex-gradient-shift 4s ease infinite;
}

body.codex-feature-article-tags-fx .article-tags a:nth-child(5n + 3)::before {
    background: linear-gradient(135deg, #1ac756 0%, #4ae786 50%, #1ac756 100%);
    background-size: 200% 200%;
    animation: codex-gradient-shift 4s ease infinite;
}

body.codex-feature-article-tags-fx .article-tags a:nth-child(5n + 4)::before {
    background: linear-gradient(135deg, #19b5fe 0%, #4bc6fe 50%, #19b5fe 100%);
    background-size: 200% 200%;
    animation: codex-gradient-shift 4s ease infinite;
}

body.codex-feature-article-tags-fx .article-tags a:hover {
    transform: scale(1.15) translateY(-2px);
    animation: none;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
    z-index: 2;
}

body.codex-feature-article-tags-fx .article-tags a:hover::before {
    animation: codex-gradient-shift-hover 2s ease infinite;
    filter: brightness(1.2);
}

/* ========== 首页侧边标题 ========== */
body.codex-feature-sidebar-title-fx .title-theme {
    font-weight: 700;
    color: currentColor;
    background: linear-gradient(135deg, #8e44ad, #2ecc71, #fbc2eb, #8e44ad);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: codex-gradient-flow 6s ease infinite;
    display: inline-block;
    transition: transform 0.25s ease, filter 0.25s ease;
}

body.codex-feature-sidebar-title-fx .title-theme:hover {
    transform: scale(1.08);
    filter: brightness(1.2);
}

/* ========== 文章标题渐变 ========== */
body.codex-feature-article-title-fx .item-heading a,
body.codex-feature-article-title-fx .text-ellipsis-2 a,
body.codex-feature-article-title-fx .forum-title.flex.ac a,
body.codex-feature-article-title-fx .article-title a,
body.codex-feature-article-title-fx .abs-center.left-bottom.graphic-text.text-ellipsis,
body.codex-feature-article-title-fx .fit-cover.ls-is-cached.lazyloaded,
body.codex-feature-article-title-fx .abs-center.left-bottom.box-body {
    color: currentColor;
    background: linear-gradient(90deg, #ff6ec4, #7873f5, #4ade80, #facc15) !important;
    background-size: 300% 300%;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    animation: codex-gradient-move 6s ease infinite !important;
    font-weight: 700 !important;
    transform: scale(1.02) !important;
    transition: transform 0.3s ease, filter 0.3s ease !important;
}

body.codex-feature-article-title-fx .item-heading a:hover,
body.codex-feature-article-title-fx .text-ellipsis-2 a:hover,
body.codex-feature-article-title-fx .forum-title.flex.ac a:hover,
body.codex-feature-article-title-fx .article-title a:hover,
body.codex-feature-article-title-fx .abs-center.left-bottom.graphic-text.text-ellipsis:hover,
body.codex-feature-article-title-fx .fit-cover.ls-is-cached.lazyloaded:hover,
body.codex-feature-article-title-fx .abs-center.left-bottom.box-body:hover {
    transform: scale(1.08) !important;
    filter: brightness(1.3) !important;
}

/* ========== Keyframes for new effects ========== */
@keyframes codex-gradient-move {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes codex-breathe {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes codex-gradient-shift {
    0%,
    100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@keyframes codex-gradient-shift-hover {
    0%,
    100% {
        background-position: 0% 50%;
        filter: brightness(1.2);
    }
    50% {
        background-position: 100% 50%;
        filter: brightness(1.3);
    }
}

@keyframes codex-gradient-flow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes codex-logo-sweep {
    0% {
        transform: skewX(-15deg) translateX(-60%);
    }
    100% {
        transform: skewX(-15deg) translateX(60%);
    }
}
