/**
 * PuzzleCaptcha — стили
 * Apple-стиль, тёмно-светлые темы наследуются от var(--bg-card) и var(--border).
 */

.pcaptcha {
    display: inline-block;
    max-width: 100%;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.pcaptcha__canvas {
    position: relative;
    width: 320px;
    height: 180px;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

.pcaptcha__bg,
.pcaptcha__piece {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    pointer-events: none;
}

.pcaptcha__bg {
    width: 100%;
    height: 100%;
}

.pcaptcha__piece {
    width: 50px;
    height: 50px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
    transition: none;
}

.pcaptcha__status {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.95);
    color: #1D1D1F;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    display: none;
}
.pcaptcha__status:not(:empty) { display: block; }
.pcaptcha__status--loading { background: rgba(255,255,255,0.95); color: #86868B; }
.pcaptcha__status--success { background: #34C759; color: #fff; }
.pcaptcha__status--error   { background: #E53935; color: #fff; }

.pcaptcha__slider {
    position: relative;
    width: 320px;
    height: 40px;
    margin-top: 10px;
    background: #F2F2F7;
    border: 1px solid #E5E5EA;
    border-radius: 8px;
    overflow: hidden;
}

.pcaptcha__track {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #86868B;
}

.pcaptcha__hint {
    position: relative;
    z-index: 1;
    transition: opacity 0.2s;
    pointer-events: none;
}

.pcaptcha__fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0;
    background: rgba(0, 122, 255, 0.12);
    border-right: 1px solid #007AFF;
    transition: none;
}

.pcaptcha__handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    background: #fff;
    border: 1px solid #E5E5EA;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    color: #007AFF;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 2;
    transition: background 0.15s, color 0.15s;
}

.pcaptcha__handle:hover { background: #F2F2F7; }
.pcaptcha__handle--active { cursor: grabbing; }
.pcaptcha__handle--success { background: #34C759; color: #fff; border-color: #34C759; }
.pcaptcha__handle--error { background: #E53935; color: #fff; border-color: #E53935; animation: pcaptcha-shake 0.4s; }

@keyframes pcaptcha-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.pcaptcha__refresh {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    cursor: pointer;
    color: #1D1D1F;
    font-size: 16px;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    z-index: 3;
}
.pcaptcha__refresh:hover { background: #fff; transform: rotate(90deg); transition: transform 0.3s; }

/* Тёмная тема */
@media (prefers-color-scheme: dark) {
    .pcaptcha__slider { background: #1C1C1E; border-color: #2C2C2E; }
    .pcaptcha__handle { background: #2C2C2E; border-color: #3A3A3C; }
    .pcaptcha__handle:hover { background: #3A3A3C; }
    .pcaptcha__status { background: rgba(28,28,30,0.95); color: #F2F2F7; }
    .pcaptcha__track { color: #8E8E93; }
}
