/* =============== 交互状态样式 - 统一系统配合 =============== */

/* =============== 鼠标交互动画 - PC端专用 =============== */

/* 鼠标悬停呼吸增强 - 使用统一变量优化速度 */
@media (hover: hover) and (pointer: fine) {
    .hover-breath:hover {
        animation: 
            hoverBreathEnhanced var(--hover-duration) var(--breath-easing) infinite,
            hoverGlow var(--glow-duration) var(--breath-easing) infinite;
        animation-fill-mode: both;
        transform-origin: center;
        z-index: 10;
        position: relative;
        transition: transform 0.3s var(--breath-easing);
    }
    
    .hover-breath:hover::after {
        content: '';
        position: absolute;
        top: -5px;
        left: -5px;
        right: -5px;
        bottom: -5px;
        background: linear-gradient(45deg, 
            rgba(59, 130, 246, 0.08), 
            rgba(99, 102, 241, 0.08), 
            rgba(139, 92, 246, 0.08),
            rgba(59, 130, 246, 0.08));
        border-radius: inherit;
        z-index: -1;
        animation: hoverHalo var(--shadow-duration) linear infinite;
        opacity: 0;
        transition: opacity 0.4s ease;
    }
    
    .hover-breath.mouse-hovering:hover::after {
        opacity: 1;
        transition-delay: 0.2s;
    }
}

@keyframes hoverBreathEnhanced {
    0%, 100% {
        transform: scale(1.015);
        filter: brightness(1.03) saturate(1.03);
    }
    25% {
        transform: scale(1.025);
        filter: brightness(1.05) saturate(1.06);
    }
    50% {
        transform: scale(1.035);
        filter: brightness(1.07) saturate(1.08);
    }
    75% {
        transform: scale(1.025);
        filter: brightness(1.05) saturate(1.06);
    }
}

@keyframes hoverGlow {
    0%, 100% {
        box-shadow: 
            0 0 15px rgba(59, 130, 246, 0.15),
            0 6px 20px rgba(0, 0, 0, 0.12);
    }
    50% {
        box-shadow: 
            0 0 30px rgba(59, 130, 246, 0.3),
            0 10px 30px rgba(0, 0, 0, 0.18),
            0 0 60px rgba(99, 102, 241, 0.2);
    }
}

@keyframes hoverHalo {
    0% { opacity: 0.2; }
    50% { opacity: 0.4; }
    100% { opacity: 0.2; }
}

/* 鼠标按下效果 - 保持快速响应但不冲突 */
@media (hover: hover) and (pointer: fine) {
    .click-breath:active {
        transform: scale(0.94) !important;
        animation: clickPulse 0.4s var(--breath-easing) forwards;
        filter: brightness(0.92) saturate(1.2);
    }
    
    .click-breath:active::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0%, transparent 70%);
        border-radius: 50%;
        transform: translate(-50%, -50%);
        animation: clickExplosion 0.6s ease-out forwards;
        z-index: 5;
        pointer-events: none;
    }
}

@keyframes clickPulse {
    0% { 
        transform: scale(0.94);
        box-shadow: inset 0 0 15px rgba(59, 130, 246, 0.4);
    }
    50% { 
        transform: scale(0.90);
        box-shadow: inset 0 0 30px rgba(59, 130, 246, 0.6);
    }
    100% { 
        transform: scale(0.94);
        box-shadow: inset 0 0 15px rgba(59, 130, 246, 0.4);
    }
}

@keyframes clickExplosion {
    0% {
        width: 0;
        height: 0;
        opacity: 0.6;
    }
    50% {
        width: 80px;
        height: 80px;
        opacity: 0.3;
    }
    100% {
        width: 150px;
        height: 150px;
        opacity: 0;
    }
}

/* =============== 触摸交互动画 - 移动端专用 =============== */

/* 触摸开始呼吸效果 */
@media (hover: none) and (pointer: coarse) {
    .touch-breath.touching {
        animation: touchBreathStart 0.3s var(--breath-easing) forwards;
        transform-origin: var(--touch-x, 50%) var(--touch-y, 50%);
    }
    
    .touch-breath.touch-holding {
        animation: touchBreathHold calc(var(--breath-duration) * 0.5) var(--breath-easing) infinite;
        filter: brightness(1.08) saturate(1.15);
        box-shadow: 
            0 0 25px rgba(59, 130, 246, 0.3),
            0 6px 20px rgba(0, 0, 0, 0.15);
    }
    
    .touch-breath.touch-ending {
        animation: touchBreathEnd 0.4s var(--breath-easing) forwards;
    }
}

@keyframes touchBreathStart {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    100% {
        transform: scale(0.96);
        filter: brightness(1.04);
        box-shadow: 
            0 0 20px rgba(59, 130, 246, 0.25),
            inset 0 0 15px rgba(255, 255, 255, 0.15);
    }
}

@keyframes touchBreathHold {
    0%, 100% {
        transform: scale(0.96);
        filter: brightness(1.04) saturate(1.15);
    }
    50% {
        transform: scale(0.98);
        filter: brightness(1.06) saturate(1.2);
    }
}

@keyframes touchBreathEnd {
    0% {
        transform: scale(0.96);
        filter: brightness(1.04);
    }
    50% {
        transform: scale(1.04);
        filter: brightness(1.08);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

/* =============== 统一交互呼吸效果应用 =============== */

/* 为所有可交互元素添加基础呼吸效果 */
.interactive-element {
    transition: all 0.4s var(--breath-easing);
    cursor: pointer;
}

/* 悬停态呼吸增强 */
.interactive-element:hover {
    animation-duration: var(--hover-duration);
}

/* 焦点态呼吸效果 */
.interactive-element:focus {
    outline: none;
    animation: focusBreath var(--glow-duration) var(--breath-easing) infinite;
    box-shadow: 
        0 0 0 3px rgba(59, 130, 246, 0.25),
        0 6px 20px rgba(0, 0, 0, 0.12);
}

@keyframes focusBreath {
    0%, 100% {
        box-shadow: 
            0 0 0 3px rgba(59, 130, 246, 0.25),
            0 6px 20px rgba(0, 0, 0, 0.12);
    }
    50% {
        box-shadow: 
            0 0 0 4px rgba(59, 130, 246, 0.4),
            0 10px 30px rgba(0, 0, 0, 0.18);
    }
}

/* =============== 特殊交互动画 =============== */

/* 磁性呼吸吸附效果 - 大幅优化速度 */
.magnetic-breath {
    transition: all 0.6s var(--breath-easing);
}

.magnetic-breath.magnetic-attracting {
    animation: magneticPull var(--magnetic-duration) var(--breath-easing) infinite;
    filter: brightness(1.03);
    transform: translate(var(--magnetic-x, 0), var(--magnetic-y, 0));
    transition: all 0.3s var(--breath-easing);
}

@keyframes magneticPull {
    0%, 100% {
        transform: scale(1) translate(var(--magnetic-x, 0), var(--magnetic-y, 0));
    }
    25% {
        transform: scale(1.01) translate(var(--magnetic-x, 0), var(--magnetic-y, 0));
        box-shadow: 
            0 4px 15px rgba(59, 130, 246, 0.15),
            0 0 20px rgba(99, 102, 241, 0.1);
    }
    50% {
        transform: scale(1.02) translate(var(--magnetic-x, 0), var(--magnetic-y, 0));
        box-shadow: 
            0 6px 20px rgba(59, 130, 246, 0.18),
            0 0 25px rgba(99, 102, 241, 0.12);
    }
    75% {
        transform: scale(1.01) translate(var(--magnetic-x, 0), var(--magnetic-y, 0));
        box-shadow: 
            0 4px 15px rgba(59, 130, 246, 0.15),
            0 0 20px rgba(99, 102, 241, 0.1);
    }
}

/* 双击呼吸效果 - 减慢速度 */
.double-click-breath {
    animation: doubleClickBreath 0.8s var(--breath-easing);
}

@keyframes doubleClickBreath {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    25% {
        transform: scale(0.92);
        filter: brightness(1.15);
    }
    50% {
        transform: scale(1.08);
        filter: brightness(0.92);
    }
    75% {
        transform: scale(0.96);
        filter: brightness(1.1);
    }
}

/* 长按呼吸效果 - 使用统一变量 */
.long-press-breath {
    animation: longPressBreath calc(var(--breath-duration) * 0.3) var(--breath-easing) infinite;
}

@keyframes longPressBreath {
    0%, 100% {
        transform: scale(0.96);
        filter: brightness(1.04);
        box-shadow: 
            0 0 15px rgba(59, 130, 246, 0.25),
            inset 0 0 15px rgba(255, 255, 255, 0.08);
    }
    25% {
        transform: scale(0.94);
        filter: brightness(1.08);
        box-shadow: 
            0 0 25px rgba(59, 130, 246, 0.4),
            inset 0 0 25px rgba(255, 255, 255, 0.15);
    }
    50% {
        transform: scale(0.98);
        filter: brightness(1.12);
        box-shadow: 
            0 0 35px rgba(59, 130, 246, 0.5),
            inset 0 0 20px rgba(255, 255, 255, 0.12);
    }
    75% {
        transform: scale(0.95);
        filter: brightness(1.06);
        box-shadow: 
            0 0 30px rgba(59, 130, 246, 0.35),
            inset 0 0 30px rgba(255, 255, 255, 0.2);
    }
}

/* =============== 鼠标和触摸状态类 =============== */

/* 鼠标状态 */
.mouse-hovering {
    z-index: 15;
    transition: transform 0.3s var(--breath-easing), 
                filter 0.3s var(--breath-easing),
                box-shadow 0.3s var(--breath-easing);
}

.mouse-leaving {
    animation: mouseLeaveBreath 0.4s ease-out forwards;
    animation-fill-mode: forwards;
}

@keyframes mouseLeaveBreath {
    0% {
        transform: scale(1.02);
        filter: brightness(1.04);
    }
    40% {
        transform: scale(1.01);
        filter: brightness(1.02);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
        box-shadow: inherit;
    }
}

.clicking {
    z-index: 20;
}

/* 触摸状态 */
.touching {
    z-index: 15;
}

.focused {
    z-index: 10;
}

/* 点击爆炸效果元素 */
.click-explosion-effect {
    transform: translate(-50%, -50%);
}

/* =============== 原有功能保持 =============== */

/* Toast 提示框状态 */
.toast {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.toast.toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.toast-hide {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
}

@media (min-width: 768px) {
    .toast {
        transform: translate(-50%, -50%) scale(0.9);
    }
    
    .toast.toast-show {
        transform: translate(-50%, -50%) scale(1);
    }
    
    .toast.toast-hide {
        transform: translate(-50%, -50%) scale(0.9);
    }
}

/* 按钮触摸状态 - 移除可能冲突的animation-play-state */
.btn-pressing {
    transform: scale(0.95) !important;
    transition: transform 0.2s ease;
}

.btn-touching {
    transform: scale(0.98) !important;
    transition: transform 0.15s ease;
}

/* 拖拽状态 */
.dragging {
    transition: none !important;
    transform: translate(var(--drag-x, 0), var(--drag-y, 0)) !important;
}

.drag-ending {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* 模态框状态 */
.modal {
    background: rgba(0, 0, 0, var(--modal-opacity, 0.8));
    transition: background 0.3s ease;
    display: none;
}

.modal.modal-show {
    display: flex !important;
}

/* 滑动手势状态 */
.swiping {
    transform: translateY(var(--swipe-y, 0)) !important;
    transition: none !important;
}

.swipe-ending {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* 禁用选择 */
.no-select {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* 下拉刷新状态 */
.pull-refreshing .card-container {
    transform: translateY(var(--pull-distance, 0px)) !important;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 触摸反馈波纹效果 */
.ripple-container {
    position: relative;
    overflow: hidden;
}

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    transform: scale(0);
    animation: ripple 0.8s ease-out;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* 磁性吸附效果 */
.magnetic-field.active {
    transform: scale(1.08) !important;
    z-index: 1001;
}

/* 长按状态 */
.long-pressing {
    transform: scale(0.96) !important;
    filter: brightness(0.92);
    transition: all 0.3s ease;
}

/* 复制提示状态 */
.copy-hint-show::after {
    content: attr(data-copy-text);
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    background: rgba(59, 130, 246, 0.95);
    color: white;
    padding: 8px 16px;
    border-radius: 15px;
    font-size: 13px;
    font-weight: 600;
    opacity: 1;
    visibility: visible;
    transition: all 0.3s ease;
    white-space: nowrap;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: hintPulse 0.6s ease-in-out;
}

/* 长按提示动画 */
@keyframes hintPulse {
    0% {
        opacity: 0;
        transform: translateY(-50%) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

/* 加载状态 */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
    z-index: 10;
}

@keyframes spin {
    0% { 
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.7;
    }
    100% { 
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* 错误状态 */
.error-state {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: white !important;
    animation: shake 0.6s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* 成功状态 */
.success-state {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: white !important;
    animation: pulse 0.8s ease-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

/* 禁用状态 */
.disabled {
    opacity: 0.5 !important;
    pointer-events: none !important;
    animation: none !important;
}

/* =============== 特殊交互组合效果 =============== */

/* 呼吸+悬停组合 */
.breath-hover-combo {
    animation: unifiedBreath var(--breath-duration) var(--breath-easing) infinite;
}

@media (hover: hover) and (pointer: fine) {
    .breath-hover-combo:hover {
        animation: 
            unifiedBreath var(--hover-duration) var(--breath-easing) infinite,
            hoverBreathEnhanced var(--glow-duration) var(--breath-easing) infinite;
    }
}

/* 呼吸+点击组合 */
.breath-click-combo.clicking {
    animation: 
        unifiedBreath calc(var(--breath-duration) * 0.5) var(--breath-easing) infinite,
        clickPulse 0.4s var(--breath-easing) infinite;
}

/* 响应式交互优化 */
@media (max-width: 480px) {
    .copy-hint-show::after {
        right: 10px;
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .btn-pressing {
        transform: scale(0.94) !important;
    }
    
    .btn-touching {
        transform: scale(0.97) !important;
    }
    
    /* 移动端交互动画性能优化 */
    @keyframes hoverBreathEnhanced {
        0%, 100% {
            transform: scale(1);
            filter: brightness(1);
        }
        50% {
            transform: scale(1.02);
            filter: brightness(1.04);
        }
    }
    
    /* 小屏设备禁用磁性位移，仅保留缩放效果 */
    .magnetic-breath.magnetic-attracting {
        animation: none;
        transform: scale(1.01) !important;
        filter: brightness(1.02);
        transition: all 0.3s ease;
    }
    
    /* 清除磁性位移变量 */
    .magnetic-breath {
        --magnetic-x: 0px !important;
        --magnetic-y: 0px !important;
    }
}

/* =============== 移动端和低端设备优化 =============== */

/* 触摸设备专用 */
@media (hover: none) and (pointer: coarse) {

    /* 触摸设备禁用鼠标专用效果 */
    .hover-breath:hover::after {
        display: none;
    }
    
    /* 禁用可能导致抖动的鼠标类名效果 */
    .mouse-hovering,
    .mouse-leaving {
        animation: none !important;
        transform: none !important;
        transition: none !important;
    }
    
    /* 磁性效果在触摸设备上简化，但不完全禁用 */
    .magnetic-breath {
        transition: transform 0.3s ease;
    }
    
    .magnetic-breath.magnetic-attracting {
        animation: none;
        transform: scale(1.015);
        filter: brightness(1.04);
    }
}

/* 减少动画时优化 */
@media (prefers-reduced-motion: reduce) {
    .ripple-effect,
    .btn-pressing,
    .btn-touching,
    .loading::before,
    .hover-breath:hover,
    .touch-breath.touching,
    .magnetic-breath.magnetic-attracting,
    .double-click-breath,
    .long-press-breath {
        animation: none !important;
        transition: none !important;
    }
    
    /* 保持基本交互反馈 */
    .interactive-element:hover {
        transform: scale(1.015);
        filter: brightness(1.06);
    }
    
    .interactive-element:active {
        transform: scale(0.98);
        filter: brightness(0.94);
    }
}