/* ================================================================
   AutoCopy.css — 点击自动复制插件样式
   ================================================================ */

/* ── 1. 基础触发元素 ────────────────────────────────────────── */
.autocopy {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: color 0.2s ease, background 0.2s ease, transform 0.1s ease;
    vertical-align: middle;
}

/* 聚焦时显示轮廓（无障碍） */
.autocopy:focus {
    outline: 2px dashed #4a90e2;
    outline-offset: 2px;
    border-radius: 3px;
}

/* ── 2. 图标 ─────────────────────────────────────────────────── */
.autocopy-icon {
    font-style: normal;
    font-size: 1.1em;       /* 加大基础尺寸 */
    opacity: 0.65;
    transition: opacity 0.2s ease, transform 0.15s ease;
    line-height: 1;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
}

.autocopy:hover .autocopy-icon,
.autocopy:focus .autocopy-icon {
    opacity: 1;
    transform: scale(1.15);
}

/* ── 3. 行内默认样式（inline） ─────────────────────────────── */
.autocopy--inline {
    color: #3a7bd5;
    border-bottom: 1px dashed #3a7bd5;
    padding: 0 2px;
    border-radius: 2px;
}

.autocopy--inline:hover {
    background: rgba(58, 123, 213, 0.08);
    color: #1a5bbf;
    border-bottom-style: solid;
}

/* ── 4. 按钮样式（button） ─────────────────────────────────── */
.autocopy--button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: #fff;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(74, 144, 226, 0.30);
    border: none;
}

.autocopy--button:hover {
    background: linear-gradient(135deg, #357abd 0%, #2567a0 100%);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.40);
    transform: translateY(-1px);
    color: #fff;
}

.autocopy--button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(74, 144, 226, 0.25);
}

.autocopy--button .autocopy-icon {
    opacity: 0.9;
    font-size: 1em;
}

/* ── 5. 徽章样式（badge） ─────────────────────────────────── */
.autocopy--badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    background: #f0f5ff;
    color: #2c5cc5;
    border: 1px solid #c5d8ff;
    border-radius: 99px;
    font-size: 0.82em;
    font-weight: 600;
    letter-spacing: 0.05em;
    font-family: 'Courier New', Courier, monospace;
}

.autocopy--badge:hover {
    background: #d8e8ff;
    border-color: #8fb3f5;
    color: #1a3fa0;
}

/* ── 6. 提取码专属样式 ─────────────────────────────────────── */
.autocopy--code {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    letter-spacing: 0.12em;
    background: #fffbe6;
    border: 1px dashed #f0b429;
    color: #b8520a;
    padding: 1px 8px;
    border-radius: 4px;
}

.autocopy--code:hover {
    background: #fff0cc;
    border-color: #e0982a;
}

/* ── 7. 链接专属样式 ─────────────────────────────────────────── */
.autocopy--link {
    border-bottom: none;
    gap: 6px;           /* 链接与图标间距略大 */
}

.autocopy--link a {
    color: inherit;
    text-decoration: underline;
    text-decoration-style: dotted;
}

/* 链接旁的复制图标单独放大，更易点击 */
.autocopy--link .autocopy-icon {
    font-size: 1.25em;
    opacity: 0.75;
    background: rgba(58, 123, 213, 0.08);
    border-radius: 4px;
    padding: 1px 4px;
}

.autocopy--link:hover .autocopy-icon {
    opacity: 1;
    background: rgba(58, 123, 213, 0.18);
}

/* ── 8. 复制成功动画 ─────────────────────────────────────────── */
.autocopy--copied {
    animation: autocopy-flash 0.35s ease;
}

@keyframes autocopy-flash {
    0%   { opacity: 1; }
    30%  { opacity: 0.4; transform: scale(0.96); }
    100% { opacity: 1; transform: scale(1); }
}

/* ── 9. 气泡提示 ─────────────────────────────────────────────── */
.autocopy-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    z-index: 99999;
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.autocopy-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.autocopy-toast--ok {
    background: rgba(40, 167, 69, 0.92);
    color: #fff;
}

.autocopy-toast--fail {
    background: rgba(220, 53, 69, 0.92);
    color: #fff;
}

/* ── 10. 深色模式适配 ─────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    .autocopy--inline {
        color: #79b8ff;
        border-bottom-color: #79b8ff;
    }
    .autocopy--inline:hover {
        background: rgba(121, 184, 255, 0.10);
        color: #a8d1ff;
    }
    .autocopy--badge {
        background: #1a2a4a;
        color: #a8d1ff;
        border-color: #2d4a7a;
    }
    .autocopy--badge:hover {
        background: #1e3360;
        border-color: #4a7ac5;
    }
    .autocopy--code {
        background: #2d2200;
        border-color: #9d7a25;
        color: #f5c542;
    }
    .autocopy--code:hover {
        background: #3a2d00;
    }
}

/* ── 11. 移动端适配 ─────────────────────────────────────────── */
@media (max-width: 768px) {
    /* 移动端图标更大，手指更容易点击 */
    .autocopy-icon {
        font-size: 1.3em;
        opacity: 0.8;
    }

    /* 链接旁图标在移动端更显眼 */
    .autocopy--link .autocopy-icon {
        font-size: 1.5em;
        padding: 2px 6px;
        background: rgba(58, 123, 213, 0.12);
    }

    /* 整体点击区域放大（手指点击友好） */
    .autocopy {
        min-height: 28px;
        padding-top: 2px;
        padding-bottom: 2px;
    }

    .autocopy-toast {
        bottom: 20px;
        font-size: 14px;
        padding: 10px 20px;
        /* 移动端防止过宽溢出 */
        max-width: calc(100vw - 40px);
        white-space: normal;
        text-align: center;
    }

    .autocopy--button {
        padding: 8px 14px;
        font-size: 0.95em;
    }

    /* 触摸设备：移除 hover 状态残留 */
    @media (hover: none) {
        .autocopy:hover .autocopy-icon {
            opacity: 0.8;
            transform: none;
        }
        .autocopy--link:hover .autocopy-icon {
            background: rgba(58, 123, 213, 0.12);
        }
    }
}
