/**
 * Yang Core 拖动验证样式
 * 使用 CSS 变量，可在主题里覆盖适配深色/浅色
 */

.yang-cap {
    --ycap-track-h: 48px;
    --ycap-bg: #f5f7fa;
    --ycap-border: #dfe4ec;
    --ycap-text: #8794a8;
    --ycap-accent: #2f7cf6;
    --ycap-ok: #3dbf74;
    --ycap-err: #f05252;

    width: 320px;
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.yang-cap *,
.yang-cap *::before,
.yang-cap *::after {
    box-sizing: border-box;
}

/* ---------- 图片区 ---------- */
.yang-cap-stage {
    position: relative;
    width: 320px;
    height: 160px;
    border-radius: 10px;
    overflow: hidden;
    background: #0e141e;
    border: 1px solid var(--ycap-border);
    line-height: 0;
}

.yang-cap-bg {
    display: block;
    width: 320px;
    height: 160px;
    object-fit: cover;
    opacity: 0.35;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.yang-cap-piece {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    will-change: left;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}

/* ---------- 拖动条 ---------- */
.yang-cap-track {
    position: relative;
    margin-top: 10px;
    width: 320px;
    height: var(--ycap-track-h);
    border-radius: 8px;
    background: var(--ycap-bg);
    border: 1px solid var(--ycap-border);
    overflow: hidden;
}

.yang-cap-hint {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
    font-size: 13px;
    line-height: 1;
    color: var(--ycap-text);
    letter-spacing: 0.02em;
    pointer-events: none;
    padding-left: 52px;
}

.yang-cap-handle {
    position: absolute;
    left: 0;
    top: 0;
    width: 52px;
    height: 100%;
    background: #ffffff;
    border-radius: 7px;
    box-shadow: 0 1px 4px rgba(20, 30, 50, 0.18);
    cursor: grab;
    touch-action: none;
    transition: background-color 0.15s ease;
}

.yang-cap-handle::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 8px;
    height: 8px;
    margin: -6px 0 0 -6px;
    border-right: 2px solid var(--ycap-accent);
    border-top: 2px solid var(--ycap-accent);
    transform: rotate(45deg);
    border-radius: 1px;
}

.yang-cap.is-drag .yang-cap-handle {
    cursor: grabbing;
    background: #f7f9fc;
}

/* ---------- 状态 ---------- */
.yang-cap.is-ok .yang-cap-track {
    border-color: var(--ycap-ok);
    background: #eefaf2;
}

.yang-cap.is-ok .yang-cap-handle {
    background: var(--ycap-ok);
}

.yang-cap.is-ok .yang-cap-handle::after {
    border-color: #ffffff;
    width: 6px;
    height: 11px;
    margin: -7px 0 0 -4px;
    border-right-width: 2px;
    border-top-width: 0;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg);
    border-radius: 0;
}

.yang-cap.is-err {
    animation: yang-cap-shake 0.4s ease;
}

.yang-cap.is-err .yang-cap-track {
    border-color: var(--ycap-err);
    background: #fdf0f0;
}

.yang-cap.is-err .yang-cap-handle {
    background: var(--ycap-err);
}

.yang-cap.is-err .yang-cap-handle::after {
    border-color: #ffffff;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border: 0;
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    transform: rotate(45deg);
    border-radius: 0;
}

@keyframes yang-cap-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    45% { transform: translateX(5px); }
    70% { transform: translateX(-3px); }
}

/* ---------- 提示文字 ---------- */
.yang-cap-msg {
    margin-top: 7px;
    min-height: 18px;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--ycap-text);
    cursor: default;
}

.yang-cap-msg.is-err {
    color: var(--ycap-err);
    cursor: pointer;
}

.yang-cap-msg.is-ok {
    color: var(--ycap-ok);
}

/*
 * 尺寸必须固定 320×160，不要做任何响应式缩放。
 * 原因：拼图块的 left / top 是按 320×160 坐标系算的，
 * 一旦图片被缩放，滑块位置就和缺口对不上了。
 */
