/* ===== 人机校验（滑块 / 手机强化验证） =====
 * login.html 与 bind-account.html 共用，交互逻辑在同目录的 /js/capcha-gate.js。
 * 页面只需要引入本文件 + capcha-gate.js，并按约定放置 .capcha-* 结构。
 */

.capcha-box {
    /* 主题色由 JS 按 sessionId 轮换（blue / violet / teal），见 .capcha-accent-* */
    --capcha-accent: #3a7afe;
    --capcha-accent-2: #4ea8ff;
    --capcha-glow: rgba(58, 122, 254, 0.28);
    padding: 2px;
    user-select: none;
    -webkit-user-select: none;
}

.capcha-box.capcha-accent-violet {
    --capcha-accent: #7c5cff;
    --capcha-accent-2: #a78bfa;
    --capcha-glow: rgba(124, 92, 255, 0.28);
}

.capcha-box.capcha-accent-teal {
    --capcha-accent: #0e9f9f;
    --capcha-accent-2: #2dd4bf;
    --capcha-glow: rgba(14, 159, 159, 0.26);
}

/* ---------- 弹窗标题 ---------- */
.capcha-dialog-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.capcha-shield {
    flex: none;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--capcha-accent-2), var(--capcha-accent));
    box-shadow: 0 6px 14px var(--capcha-glow);
}

.capcha-shield svg {
    width: 15px;
    height: 15px;
    fill: #fff;
}

.capcha-title {
    font-size: 15px;
    font-weight: 600;
    color: #303133;
    letter-spacing: 0.2px;
}

/* ---------- 画面 ---------- */
.capcha-canvas {
    position: relative;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 14px;
    background: linear-gradient(135deg, #eef2f9, #f7f9fc);
    box-shadow: 0 12px 26px -14px rgba(31, 45, 61, 0.45),
                inset 0 0 0 1px rgba(31, 45, 61, 0.06);
    max-width: 100%;
}

.capcha-canvas::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 4;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    pointer-events: none;
}

.capcha-canvas .capcha-bg {
    display: block;
    width: 100%;
    height: 100%;
    opacity: 1;
    transition: opacity 0.25s ease;
}

.capcha-canvas.is-loading .capcha-bg {
    opacity: 0;
}

/* 图片加载中的骨架微光 */
.capcha-canvas.is-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    background: linear-gradient(100deg, #eef2f9 20%, #f8fbff 40%, #eef2f9 60%);
    background-size: 220% 100%;
    animation: capchaSkeleton 1.4s ease-in-out infinite;
    pointer-events: none;
}

.capcha-canvas .capcha-piece {
    position: absolute;
    left: 0;
    z-index: 3;
    pointer-events: none;
    filter: drop-shadow(0 4px 8px rgba(16, 24, 40, 0.35));
    transition: filter 0.2s ease;
}

.capcha-canvas.is-dragging .capcha-piece {
    filter: drop-shadow(0 9px 16px rgba(16, 24, 40, 0.45));
}

.capcha-canvas.is-click {
    cursor: crosshair;
}

/* ---------- 旋转题型 ---------- */
.capcha-canvas.is-rotate {
    border-radius: 50%;
    background: #f1f5fb;
    box-shadow: 0 16px 32px -18px rgba(31, 45, 61, 0.55),
                inset 0 0 0 1px rgba(31, 45, 61, 0.06);
}

.capcha-canvas.is-rotate .capcha-bg {
    border-radius: 50%;
    transform-origin: 50% 50%;
    will-change: transform;
}

/* 圆形外圈：固定不转，作为“正上方”的参照 */
.capcha-canvas.is-rotate::after {
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5),
                0 0 0 6px rgba(58, 122, 254, 0.05),
                0 0 22px rgba(31, 45, 61, 0.12);
}

.capcha-rotate-mark {
    position: absolute;
    left: 50%;
    top: 7px;
    z-index: 2;
    width: 0;
    height: 0;
    margin-left: -7px;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 10px solid var(--capcha-accent);
    filter: drop-shadow(0 2px 4px rgba(16, 24, 40, 0.35));
    opacity: 0.9;
    pointer-events: none;
}

.capcha-canvas.is-rotate .capcha-result {
    border-radius: 50%;
}

/* 点选题型的点击标记 */
.capcha-click-marker {
    position: absolute;
    z-index: 4;
    width: 26px;
    height: 26px;
    margin: -13px 0 0 -13px;
    border-radius: 50%;
    border: 2.5px solid var(--capcha-accent);
    background: rgba(255, 255, 255, 0.34);
    box-shadow: 0 0 0 6px var(--capcha-glow);
    pointer-events: none;
    animation: capchaMarkerPop 0.22s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.capcha-click-marker::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 5px;
    height: 5px;
    margin: -2.5px 0 0 -2.5px;
    border-radius: 50%;
    background: var(--capcha-accent);
}

.capcha-click-marker.is-bad {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.22);
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.25);
}

.capcha-click-marker.is-bad::after {
    background: #ef4444;
}

.capcha-click-ripple {
    position: absolute;
    inset: -2.5px;
    border-radius: 50%;
    border: 2px solid var(--capcha-accent);
    animation: capchaRipple 0.7s ease-out forwards;
}

.capcha-click-marker.is-bad .capcha-click-ripple {
    border-color: #ef4444;
}

.capcha-canvas.is-success {
    animation: capchaSuccessPulse 0.5s ease;
}

.capcha-canvas.is-error {
    animation: capchaShake 0.42s ease;
}

/* 失败后拼图块滑回起点 */
.capcha-canvas.is-error .capcha-piece {
    transition: left 0.25s ease, filter 0.2s ease;
}

/* ---------- 成功遮罩 ---------- */
.capcha-result {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    background: rgba(16, 185, 129, 0.14);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.capcha-result.is-show {
    opacity: 1;
}

.capcha-check {
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 10px 24px rgba(16, 185, 129, 0.35);
    transform: scale(0.6);
    animation: capchaPop 0.36s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}

.capcha-check svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: #10b981;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------- 滑轨 ---------- */
.capcha-track {
    position: relative;
    height: 44px;
    margin: 16px auto 0;
    max-width: 100%;
    border-radius: 22px;
    background: linear-gradient(180deg, #f6f8fc, #eef1f7);
    box-shadow: inset 0 1px 3px rgba(31, 45, 61, 0.12),
                inset 0 0 0 1px rgba(31, 45, 61, 0.05);
    overflow: hidden;
    cursor: pointer;
    touch-action: none;
}

/* 静止时的一道光，提示可以拖 */
.capcha-track::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -60%;
    width: 60%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent);
    animation: capchaShine 2.8s ease-in-out infinite;
    pointer-events: none;
}

.capcha-track.is-active::before,
.capcha-track.is-checking::before,
.capcha-track.is-success::before,
.capcha-track.is-error::before,
.capcha-track.is-disabled::before {
    animation: none;
    opacity: 0;
}

.capcha-track-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    border-radius: 22px;
    background: linear-gradient(90deg, var(--capcha-accent-2), var(--capcha-accent));
    opacity: 0.85;
}

.capcha-track.is-success .capcha-track-fill {
    background: linear-gradient(90deg, #34d399, #10b981);
}

.capcha-track.is-error .capcha-track-fill {
    background: linear-gradient(90deg, #f87171, #ef4444);
}

.capcha-handle {
    position: absolute;
    top: 4px;
    left: 0;
    width: 50px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(31, 45, 61, 0.18),
                0 0 0 1px rgba(31, 45, 61, 0.06);
    color: var(--capcha-accent);
    cursor: grab;
    z-index: 3;
    transition: transform 0.12s ease, box-shadow 0.2s ease;
}

.capcha-handle-arrow {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.capcha-handle-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(31, 45, 61, 0.12);
    border-top-color: var(--capcha-accent);
    animation: capchaSpin 0.7s linear infinite;
}

.capcha-track:not(.is-disabled):hover .capcha-handle {
    box-shadow: 0 6px 16px rgba(31, 45, 61, 0.22),
                0 0 0 1px rgba(31, 45, 61, 0.06);
}

.capcha-track.is-dragging .capcha-handle {
    cursor: grabbing;
    transform: scale(1.05);
    box-shadow: 0 8px 18px rgba(31, 45, 61, 0.24),
                0 0 0 1px rgba(31, 45, 61, 0.06);
}

.capcha-track.is-checking .capcha-handle {
    cursor: wait;
}

/* 失败/校验时让滑块与填充动画退回起点 */
.capcha-track.is-error .capcha-handle,
.capcha-track.is-checking .capcha-handle {
    transition: left 0.25s ease, transform 0.12s ease, box-shadow 0.2s ease;
}

.capcha-track.is-error .capcha-track-fill {
    transition: width 0.25s ease;
}

.capcha-track.is-checking .capcha-handle-arrow {
    display: none;
}

.capcha-track.is-checking .capcha-handle-spinner {
    display: block;
}

.capcha-track.is-success .capcha-handle {
    color: #10b981;
}

.capcha-track.is-disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.capcha-track-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #8a94a6;
    letter-spacing: 0.6px;
    pointer-events: none;
}

/* ---------- 剩余次数 / 换一张 ---------- */
.capcha-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 12px;
    color: #909399;
}

.capcha-attempts {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(58, 122, 254, 0.08);
    color: var(--capcha-accent);
    transition: background 0.2s ease, color 0.2s ease;
}

.capcha-attempts.is-danger {
    background: #fff1f0;
    color: #f56c6c;
}

.capcha-attempts svg {
    width: 13px;
    height: 13px;
    fill: currentColor;
}

.capcha-refresh {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 8px;
    color: var(--capcha-accent);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.capcha-refresh:hover {
    background: rgba(58, 122, 254, 0.08);
}

.capcha-refresh.is-disabled {
    color: #c0c4cc;
    cursor: not-allowed;
    background: none;
}

.capcha-refresh svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* ---------- 提示 ---------- */
.capcha-tip {
    margin-top: 10px;
    min-height: 18px;
    font-size: 12px;
    line-height: 18px;
    color: #909399;
    text-align: center;
    transition: color 0.2s ease;
}

.capcha-tip.is-error {
    color: #f56c6c;
}

.capcha-tip.is-success {
    color: #10b981;
}

/* 点选的题目说明更重要，用正文色加粗 */
.capcha-tip.is-instruction {
    color: #303133;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* ---------- 手机强化验证 ---------- */
.capcha-stepup-card {
    padding: 4px 2px 0;
}

.capcha-stepup-row {
    margin: 12px 0 10px;
    text-align: right;
}

.capcha-submit {
    width: 100%;
    margin-top: 14px;
}

/* ---------- 动画 ---------- */
@keyframes capchaShine {
    0% { left: -60%; }
    55%, 100% { left: 120%; }
}

@keyframes capchaSpin {
    to { transform: rotate(360deg); }
}

@keyframes capchaShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(3px); }
}

@keyframes capchaPop {
    to { transform: scale(1); }
}

@keyframes capchaSkeleton {
    0% { background-position: 120% 0; }
    100% { background-position: -120% 0; }
}

@keyframes capchaMarkerPop {
    from { transform: scale(0.4); opacity: 0.4; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes capchaRipple {
    from { transform: scale(1); opacity: 0.9; }
    to { transform: scale(2.2); opacity: 0; }
}

@keyframes capchaSuccessPulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.35), 0 12px 26px -14px rgba(31, 45, 61, 0.45); }
    100% { box-shadow: 0 0 0 12px rgba(16, 185, 129, 0), 0 12px 26px -14px rgba(31, 45, 61, 0.45); }
}

@media (prefers-reduced-motion: reduce) {
    .capcha-track::before,
    .capcha-check,
    .capcha-click-marker,
    .capcha-click-ripple,
    .capcha-canvas.is-loading::before,
    .capcha-canvas.is-success,
    .capcha-canvas.is-error {
        animation: none;
    }
}
