/* ========================================
 *  代码块复制按钮优化
 *  修复：选中文字 + 增强交互特效
 * ======================================== */

/* 防止复制按钮点击时选中代码文本 */
figure.highlight .copy {
    opacity: 0.7;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    padding: 4px 8px;
    font-size: 14px;
    color: #363636;
}

figure.highlight .copy:hover {
    opacity: 1;
    transform: scale(1.05);
    color: #00d1b2;
}

/* 复制成功状态 */
figure.highlight .copy.copied {
    color: #48c774 !important;
    opacity: 1 !important;
    animation: copySuccess 0.6s ease;
}

figure.highlight .copy.copied i::before {
    content: '\f00c' !important;
}

/* 成功提示 */
figure.highlight .copy.copied::after {
    content: '已复制!';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-right: 8px;
    background: #48c774;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    animation: fadeInOut 2s ease forwards;
}

/* 复制失败状态 */
figure.highlight .copy.error {
    color: #f14668 !important;
    opacity: 1 !important;
    animation: copyError 0.6s ease;
}

figure.highlight .copy.error::after {
    content: '复制失败';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-right: 8px;
    background: #f14668;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    animation: fadeInOut 2s ease forwards;
}

/* 确保figcaption支持相对定位（用于提示框） */
figure.highlight figcaption {
    position: relative;
}

/* 复制成功动画 */
@keyframes copySuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* 复制失败动画 */
@keyframes copyError {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* 提示框淡入淡出 */
@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateY(-50%) translateX(10px);
    }
    20% {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
    80% {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-50%) translateX(-10px);
    }
}

/* 代码块整体优化 */
figure.highlight {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}
