/* === КАПЧА — ДИНАМИЧЕСКИЕ РАЗМЕРЫ, КРИСТАЛЬНО ЧИСТЫЙ ПАЗЛ === */
/* /static/css/captcha-slider.css — НОЯБРЬ 2025 */

.slider-captcha-container {
    max-width: 100% !important;    /* ✅ Не выходит за модалку */
    width: 100%;
    margin: 24px 0 0 0 !important; /* ✅ Только сверху */
    padding: 0;
    text-align: center;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}

/* ✅ КАПЧА БОКС — ПОЛНЫЙ РАЗМЕР */
.captcha-box {
    position: relative;
    width: 400px;
    max-width: 100%;
    height: auto;
    margin: 0 auto 20px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 4px 16px rgba(0, 0, 0, 0.08);
    background: #000;
    transition: box-shadow 0.3s ease;
}

.captcha-box:hover {
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.15),
        0 4px 20px rgba(0, 0, 0, 0.10);
}

.captcha-bg-img {
    width: 100%;           /* ✅ JavaScript установит точные размеры */
    height: auto;
    display: block;
    object-fit: cover;     /* ✅ Сохраняет пропорции */
    transition: opacity 0.3s ease;
}

.captcha-puzzle {
    position: absolute;
    left: 0;
    top: 96px; /* ← Фиксируем, чтобы JS не конфликтовал */
    width: 62px;
    height: 62px;
    border-radius: 10px;
    clip-path: inset(0px round 10px);
    pointer-events: none;
    z-index: 10;
    background-repeat: no-repeat;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === СЛАЙДЕР === */
.slider-container {
    position: relative;
    height: 56px;
    background: linear-gradient(145deg, #f8f9fa, #e9ecef);
    border-radius: 28px;
    overflow: hidden;
    user-select: none;
    margin: 0 auto;
    max-width: 400px;      /* ✅ Адаптируется под размер изображения */
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.slider-track {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: all 0.4s ease;
    border-radius: 28px;
}

.slider-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.slider-success {
    display: none;
    color: #28a745;
    font-weight: bold;
    font-size: 14px;
    align-items: center;
    gap: 8px;
}

.slider-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #4caf50, #45a049, #28a745);
    box-shadow: 
        0 0 20px rgba(76, 175, 80, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
    transition: width 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border-radius: 28px;
}

.slider-button {
    position: absolute;
    left: 8px;
    top: 8px;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #ffffff, #f8f9fa);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    cursor: grab;
    z-index: 15;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.15),
        0 2px 8px rgba(0, 0, 0, 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.8);
}

.slider-button:hover {
    transform: scale(1.05);
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.18),
        0 4px 12px rgba(0, 0, 0, 0.12);
}

.slider-button:active {
    cursor: grabbing;
    transform: scale(0.95);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.20),
        inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* === АНИМАЦИЯ УСПЕХА === */
.captcha-success .slider-track {
    background: linear-gradient(135deg, #28a745, #20c997);
}

.captcha-success .slider-text {
    display: none;
}

.captcha-success .slider-success {
    display: flex;
}

.captcha-success .slider-bar {
    width: 100% !important;
    animation: successPulse 0.6s ease-in-out;
}

.captcha-success .slider-button {
    left: calc(100% - 48px) !important;
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: 
        0 8px 25px rgba(40, 167, 69, 0.4),
        0 0 0 4px rgba(40, 167, 69, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    animation: buttonSuccess 0.6s ease-in-out;
}

@keyframes successPulse {
    0% { 
        box-shadow: 0 0 0 rgba(40, 167, 69, 0); 
    }
    50% { 
        box-shadow: 0 0 30px rgba(40, 167, 69, 0.6); 
    }
    100% { 
        box-shadow: 0 0 20px rgba(40, 167, 69, 0.4); 
    }
}

@keyframes buttonSuccess {
    0% { 
        transform: scale(1) rotate(0deg); 
    }
    50% { 
        transform: scale(1.1) rotate(180deg); 
    }
    100% { 
        transform: scale(1) rotate(360deg); 
    }
}

/* === АНИМАЦИЯ ОШИБКИ === */
.captcha-error .slider-container {
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* === СОСТОЯНИЯ ЗАГРУЗКИ === */
.captcha-loading {
    position: relative;
}

.captcha-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 5;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === СООБЩЕНИЯ === */
.captcha-error {
    color: #dc3545;
    font-size: 14px;
    font-weight: 500;
    margin-top: 12px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    border: 1px solid #fecaca;
    border-radius: 12px;
    display: none;
    align-items: center;
    gap: 8px;
}

.captcha-error::before {
    content: '⚠️';
    font-size: 16px;
}

.captcha-success .captcha-error {
    display: none !important;
}

/* === КНОПКА ОБНОВЛЕНИЯ === */
.captcha-refresh {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.captcha-refresh:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.captcha-refresh:active {
    transform: translateY(0);
}

/* === АДАПТИВНОСТЬ === */
@media (max-width: 480px) {
    .slider-captcha-container {
        margin: 15px auto;
        padding: 0 10px;
        max-width: 100%;
    }
    
    .captcha-box {
        max-width: 100%;
        border-radius: 12px;
    }
    
    .slider-container {
        max-width: 100%;
        margin: 0 5px;
    }
    
    .captcha-error {
        margin: 0 5px;
        padding: 8px 12px;
        font-size: 13px;
    }
}

@media (max-width: 360px) {
    .slider-container {
        height: 48px;
        border-radius: 24px;
    }
    
    .slider-button {
        width: 36px;
        height: 36px;
        left: 6px;
        top: 6px;
        font-size: 16px;
    }
}

/* === ТЕМНАЯ ТЕМА === */
@media (prefers-color-scheme: dark) {
    .slider-captcha-container {
        color: #e9ecef;
    }
    
    .slider-container {
        background: linear-gradient(145deg, #2c2c2e, #1c1c1e);
        box-shadow: 
            0 6px 24px rgba(0, 0, 0, 0.4),
            0 2px 8px rgba(0, 0, 0, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .slider-button {
        background: linear-gradient(135deg, #38383a, #2c2c2e);
        border-color: rgba(255, 255, 255, 0.2);
    }
    
    .captcha-error {
        background: linear-gradient(135deg, #3d1e1e, #4a1e1e);
        border-color: #6b1e1e;
        color: #fca5a5;
    }
}

/* === ПОДДЕРЖКА БОЛЬШИХ ИЗОБРАЖЕНИЙ === */
@media (min-width: 768px) {
    .slider-captcha-container {
        max-width: 600px;
    }
}

/* === АКСЕССИБИЛЬНОСТЬ === */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* === ФОКУС === */
.slider-button:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* === СОВМЕСТИМОСТЬ === */
@supports not (aspect-ratio: 1) {
    .captcha-box {
        height: 255px; /* Fallback для старых браузеров */
    }
}

/* ✅ ТОЧНАЯ СИНХРОНИЗАЦИЯ */
#sliderCaptcha {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.captcha-box {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#puzzlePiece {
    position: absolute;
    z-index: 10;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
    box-sizing: border-box;
    border: 2px solid transparent;
    transition: left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.captcha-frame {
    position: absolute !important;
    z-index: 9 !important;
    pointer-events: none !important;
    box-sizing: border-box !important;
    transition: left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}
 
