/**
 * 冒泡排序可视化样式
 * @author changyadai
 * 
 * 算法特有样式 - 柱状条和动画效果
 */

/* 柱状条样式 */
.bar {
    width: 45px;
    border-radius: 8px 8px 4px 4px;
    background: linear-gradient(180deg, #00d9ff 0%, #00ff88 50%, #ff00aa 100%);
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 8px;
    font-size: 14px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 30%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.3) 0%, transparent 100%);
    border-radius: 8px 8px 0 0;
}

/* 比较状态 - 高亮发光 */
.bar.comparing {
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.8),
        0 0 40px rgba(0, 255, 255, 0.4),
        0 0 60px rgba(0, 255, 255, 0.2);
    transform: scaleX(1.1);
    z-index: 10;
}

/* 交换状态 */
.bar.swapping {
    box-shadow: 
        0 0 25px rgba(255, 100, 200, 0.9),
        0 0 50px rgba(255, 100, 200, 0.5);
}

/* 已排序状态 - 绿色 */
.bar.sorted {
    background: linear-gradient(180deg, #00ff88 0%, #00cc6a 100%);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
}

/* 气泡粒子效果 */
.bubble {
    position: absolute;
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, rgba(0, 255, 255, 0.4) 50%, transparent 100%);
    border-radius: 50%;
    pointer-events: none;
    animation: bubbleRise 1s ease-out forwards;
}

@keyframes bubbleRise {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: translateY(-100px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-200px) scale(0.5);
    }
}

/* 交换移动动画 */
.bar.move-right {
    animation: moveRight 0.4s ease-in-out forwards;
}

.bar.move-left {
    animation: moveLeft 0.4s ease-in-out forwards;
}

@keyframes moveRight {
    0% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(26.5px) translateY(-20px) scale(1.05);
    }
    100% {
        transform: translateX(53px);
    }
}

@keyframes moveLeft {
    0% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(-26.5px) translateY(20px) scale(0.95);
    }
    100% {
        transform: translateX(-53px);
    }
}

/* 完成时的庆祝动画 */
.bar.celebrate {
    animation: celebrate 0.6s ease-in-out;
}

@keyframes celebrate {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.1) translateY(-10px);
    }
    50% {
        transform: scale(1) translateY(0);
    }
    75% {
        transform: scale(1.05) translateY(-5px);
    }
}
