/**
 * 主题特效增强包
 * 与 assets/js/effects.js 配套使用，所有动效均可用 JS 中的 CONFIG 开关关闭。
 * 仅使用主题已有的 CSS 变量（--heo-main / --heo-main-op），自动跟随深浅色与主题色。
 */

/* ----------------------------------------------
 * 1. 顶部阅读进度条
 * ---------------------------------------------- */
#hao-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 10001;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease;
}

#hao-progress.is-active {
    opacity: 1;
}

#hao-progress > i {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--heo-main, #425aef), var(--heo-theme, var(--heo-main, #425aef)));
    box-shadow: 0 0 10px var(--heo-main-op, rgba(66, 90, 239, 0.14));
    will-change: width;
}

/* ----------------------------------------------
 * 2. 鼠标点击：涟漪 + 粒子迸发
 * ---------------------------------------------- */
#hao-click-layer {
    position: fixed;
    inset: 0;
    z-index: 9999;
    overflow: hidden;
    pointer-events: none;
}

.hao-click-wave {
    position: absolute;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid var(--heo-main, #425aef);
    border-radius: 50%;
    opacity: 0.9;
    animation: hao-click-wave 0.65s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

@keyframes hao-click-wave {
    0% {
        transform: scale(0.35);
        opacity: 0.9;
    }
    70% {
        opacity: 0.35;
    }
    100% {
        transform: scale(3.2);
        opacity: 0;
    }
}

.hao-click-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    background: var(--heo-main, #425aef);
    opacity: 0.95;
    animation: hao-click-dot 0.62s cubic-bezier(0.16, 0.84, 0.44, 1) forwards;
}

@keyframes hao-click-dot {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 0.95;
    }
    100% {
        transform: translate(var(--hao-x, 0), var(--hao-y, 0)) scale(0.2);
        opacity: 0;
    }
}

/* ----------------------------------------------
 * 3. 卡片光晕跟随鼠标
 * ---------------------------------------------- */
.hao-spotlight {
    position: relative;
}

.hao-spotlight::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease;
    background: radial-gradient(
        260px circle at var(--hao-mx, 50%) var(--hao-my, 50%),
        var(--heo-main-op, rgba(66, 90, 239, 0.14)),
        transparent 68%
    );
}

.hao-spotlight:hover::after {
    opacity: 1;
}

/* ----------------------------------------------
 * 4. 元素滚动入场
 *    .hao-reveal 仅由 JS 动态添加，脚本失效时内容依旧可见
 * ---------------------------------------------- */
/* 只负责初始隐藏，入场动画由 JS 的 Web Animations API 播放，
   结束后会移除 .hao-reveal，不会覆盖主题卡片自身的 transition / animation */
.hao-reveal {
    opacity: 0;
}

/* ----------------------------------------------
 * 5. 背景极光光斑
 * ---------------------------------------------- */
#hao-aurora {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    contain: layout paint;
}

#hao-aurora i {
    position: absolute;
    display: block;
    width: 62vmax;
    height: 62vmax;
    border-radius: 50%;
    opacity: 0.8;
    will-change: transform;
}

#hao-aurora i:nth-child(1) {
    top: -22vmax;
    left: -18vmax;
    background: radial-gradient(circle, var(--heo-main-op, rgba(66, 90, 239, 0.14)) 0%, transparent 65%);
    animation: hao-aurora-a 26s ease-in-out infinite alternate;
}

#hao-aurora i:nth-child(2) {
    right: -24vmax;
    bottom: -26vmax;
    background: radial-gradient(circle, var(--heo-main-op, rgba(66, 90, 239, 0.12)) 0%, transparent 65%);
    animation: hao-aurora-b 32s ease-in-out infinite alternate;
}

#hao-aurora i:nth-child(3) {
    top: 18vmax;
    right: -20vmax;
    width: 48vmax;
    height: 48vmax;
    opacity: 0.5;
    background: radial-gradient(circle, var(--heo-main-op, rgba(66, 90, 239, 0.1)) 0%, transparent 60%);
    animation: hao-aurora-c 22s ease-in-out infinite alternate;
}

@keyframes hao-aurora-a {
    from {
        transform: translate3d(0, 0, 0) scale(1);
    }
    to {
        transform: translate3d(7vmax, 5vmax, 0) scale(1.12);
    }
}

@keyframes hao-aurora-b {
    from {
        transform: translate3d(0, 0, 0) scale(1.05);
    }
    to {
        transform: translate3d(-8vmax, -4vmax, 0) scale(0.95);
    }
}

@keyframes hao-aurora-c {
    from {
        transform: translate3d(0, 0, 0);
    }
    to {
        transform: translate3d(-6vmax, 6vmax, 0);
    }
}

/* ----------------------------------------------
 * 适配与降级
 * ---------------------------------------------- */
@media (max-width: 768px) {
    /* 移动端关闭成本较高的背景光斑，保留点击与入场动画 */
    #hao-aurora {
        display: none;
    }

    #hao-progress {
        height: 2px;
    }
}

@media (hover: none) {
    .hao-spotlight::after {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    #hao-aurora,
    #hao-click-layer {
        display: none;
    }

    .hao-reveal {
        opacity: 1;
    }

    #hao-progress > i {
        transition: none;
    }
}
