/* ===========================================================================
   点击单词 · 高级动效（word_tap_fx.js 配套样式，2026-12-04）
   ---------------------------------------------------------------------------
   硬约束（与 theme/pixar 红线一致，必须遵守）：
     · 不给 .word-letters / 字母 <span> 写 transform —— .word-cursor 的 left 由
       JS 按 getBoundingClientRect 计算，span 位移会让光标错位；
     · 字母的弹跳 transform 只打在 span 内部的 <svg> 上（hs_word.js 渲染产物），
       svg 变换不影响 span 盒模型，光标测量纹丝不动；
     · 四线格脉冲用 box-shadow / filter，不动容器 transform。
   触发：JS 给 .word-letters 加 .wtf-active，给 .word-text 加 .wtf-host。
   ========================================================================= */

/* 点击热区：提示可点 */
body .word-text {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* 涟漪 / 星点的定位参照系；让字母层浮在特效之上 */
body .word-text.wtf-host {
    position: relative;
    overflow: visible;
}
body .word-text.wtf-host .word-letters {
    position: relative;
    z-index: 1;          /* 字母在涟漪(0) 之上、星点(2) 之下 */
}

/* ---- 四线格脉冲：外圈辉光 + 整体微亮 -------------------------------------- */
@keyframes wtfGrid {
    0%   { box-shadow: 0 0 0 0 rgba(56, 170, 108, 0); filter: brightness(1); }
    28%  { box-shadow: 0 0 20px 3px rgba(56, 170, 108, .55),
                       0 0 55px 12px rgba(56, 170, 108, .22);
           filter: brightness(1.14); }
    100% { box-shadow: 0 0 0 0 rgba(56, 170, 108, 0); filter: brightness(1); }
}
body .word-letters.wtf-active {
    border-radius: 6px;
    animation: wtfGrid .9s ease-out;
    will-change: box-shadow, filter;
}

/* ---- 字母弹跳波：错峰由 --i 控制（JS 写入每个字母 span） -------------------- */
@keyframes wtfPop {
    0%   { transform: scale(1)    translateY(0)        rotate(0deg); }
    20%  { transform: scale(1.26) translateY(-0.09em)  rotate(-3.5deg); }
    46%  { transform: scale(0.93) translateY(0.025em)  rotate(2.5deg); }
    70%  { transform: scale(1.07) translateY(0)        rotate(-1deg); }
    100% { transform: scale(1)    translateY(0)        rotate(0deg); }
}
body .word-letters.wtf-active > span.letter-visible > svg {
    transform-origin: 50% 72%;          /* 略低于中线，弹跳更自然 */
    animation: wtfPop .72s cubic-bezier(.34, 1.56, .64, 1);
    animation-delay: calc(var(--i, 0) * 65ms);
    will-change: transform;
}

/* ---- 元音额外强调：更大幅度 + 珊瑚色辉光（自包含 transform+filter，避免与
        wtfPop 抢同一 animation 属性；本规则特异性更高，覆盖普通字母） -------- */
@keyframes wtfVowelPop {
    0%   { transform: scale(1)    translateY(0)        rotate(0deg);
           filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0)); }
    22%  { transform: scale(1.42) translateY(-0.13em)  rotate(-5deg);
           filter: drop-shadow(0 0 7px rgba(255, 120, 90, .95))
                   drop-shadow(0 0 3px rgba(255, 190, 90, .9)); }
    50%  { transform: scale(0.95) translateY(0.03em)   rotate(3deg);
           filter: drop-shadow(0 0 4px rgba(255, 120, 90, .6)); }
    75%  { transform: scale(1.08) translateY(0)        rotate(-1.5deg); }
    100% { transform: scale(1)    translateY(0)        rotate(0deg);
           filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0)); }
}
body .word-letters.wtf-active > span.letter-visible.vowel > svg {
    animation: wtfVowelPop .82s cubic-bezier(.34, 1.56, .64, 1);
    animation-delay: calc(var(--i, 0) * 65ms);
    will-change: transform, filter;
}

/* ---- 点击涟漪：从触点扩散的柔光环 ----------------------------------------- */
.wtf-ripple {
    position: absolute;
    left: 0; top: 0;
    width: 14px; height: 14px;
    margin: 0;
    border-radius: 50%;
    background: radial-gradient(circle,
        rgba(56, 170, 108, .5) 0%,
        rgba(56, 170, 108, .2) 42%,
        transparent 72%);
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    z-index: 0;
    animation: wtfRipple .7s ease-out forwards;
    will-change: transform, opacity;
}
@keyframes wtfRipple {
    0%   { transform: translate(-50%, -50%) scale(0);   opacity: .95; }
    100% { transform: translate(-50%, -50%) scale(20);  opacity: 0; }
}

/* ---- 星点：从触点向外飞散的高光粒子 --------------------------------------- */
.wtf-spark {
    position: absolute;
    left: 0; top: 0;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: radial-gradient(circle,
        #ffffff 0%,
        rgba(255, 220, 120, .95) 40%,
        transparent 72%);
    box-shadow: 0 0 6px 1px rgba(255, 230, 150, .8);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 2;
    animation: wtfSpark .85s cubic-bezier(.2, .7, .3, 1) forwards;
    will-change: transform, opacity;
}
@keyframes wtfSpark {
    0%   { transform: translate(-50%, -50%) scale(0);                 opacity: 1; }
    80%  { opacity: 1; }
    100% { transform: translate(calc(-50% + var(--dx, 0px)),
                                calc(-50% + var(--dy, 0px))) scale(1); opacity: 0; }
}

/* 尊重「减少动态效果」系统偏好：动效降级为一次短促提亮，不做弹跳/位移 */
@media (prefers-reduced-motion: reduce) {
    body .word-letters.wtf-active > span.letter-visible > svg { animation: none; }
    .wtf-ripple, .wtf-spark { animation: none; display: none; }
}
