/* ============================================
   captcha.css — XStartX
   Капча-слайдер. Подключается асинхронно в base.html.
   ============================================ */

.slider-captcha-container {
    width: 100%;
    max-width: 100%;
    margin: 24px 0 0;
    padding: 0;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

.captcha-box {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: auto;
    margin: 0 auto 20px;
    border-radius: 12px;
    background: #f0f0f0;
    box-shadow: 0 8px 32px rgb(0 0 0 / 12%), 0 4px 16px rgb(0 0 0 / 8%);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.captcha-box:hover {
    box-shadow: 0 12px 40px rgb(0 0 0 / 15%), 0 4px 20px rgb(0 0 0 / 10%);
}

.captcha-bg-img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.captcha-puzzle {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    width: 62px;
    height: 62px;
    box-sizing: border-box;
    border: 2px solid transparent;
    border-radius: 10px;
    background-repeat: no-repeat;
    clip-path: inset(0 round 10px);
    cursor: grab;
    pointer-events: none;
    user-select: none;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.slider-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: 56px;
    margin: 0 auto;
    border: 1px solid rgb(0 0 0 / 5%);
    border-radius: 28px;
    background: linear-gradient(145deg, #f8f9fa, #e9ecef);
    box-shadow: 0 4px 20px rgb(0 0 0 / 8%), 0 2px 8px rgb(0 0 0 / 5%), inset 0 1px 0 rgb(255 255 255 / 60%);
    overflow: hidden;
    user-select: none;
}

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

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

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

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

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

.slider-button:hover {
    box-shadow: 0 8px 25px rgb(0 0 0 / 18%), 0 4px 12px rgb(0 0 0 / 12%);
    transform: scale(1.05);
}

.slider-button:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.slider-button:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* === УСПЕХ === */
.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%;
    animation: success-pulse 0.6s ease-in-out;
}

.captcha-success .slider-button {
    left: calc(100% - 48px);
    background: linear-gradient(135deg, #28a745, #20c997);
    border-color: rgb(255 255 255 / 90%);
    color: white;
    animation: button-success 0.6s ease-in-out;
}

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

.captcha-error .slider-button {
    background: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

/* === СООБЩЕНИЯ === */
.captcha-error,
.captcha-blocked-msg {
    margin-top: 12px;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    display: none;
    align-items: center;
    gap: 8px;
}

.captcha-error {
    border: 1px solid #fecaca;
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #dc3545;
}

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

.captcha-blocked-msg {
    border: 1px solid rgb(220 53 69 / 20%);
    background: rgb(220 53 69 / 10%);
    color: #dc3545;
    text-align: center;
}

/* ✅ Перенесено ПОСЛЕ .captcha-error, чтобы не было no-descending-specificity */
.captcha-success .captcha-error {
    display: none;
}

.captcha-blocked .captcha-box {
    opacity: 50%;
    filter: grayscale(1);
    pointer-events: none;
}

.captcha-blocked .slider-container {
    opacity: 50%;
    pointer-events: none;
}

.captcha-blocked .slider-button {
    background: #dc3545;
    border-color: #dc3545;
    color: #fff;
    cursor: not-allowed;
}

.captcha-error-msg {
    padding: 5px;
    font-weight: 500;
    text-align: center;
}

.captcha-loading {
    position: relative;
    padding: 10px;
    color: #6c757d;
}

.captcha-refresh {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.captcha-refresh:hover {
    box-shadow: 0 6px 20px rgb(102 126 234 / 30%);
    transform: translateY(-1px);
}

/* === АНИМАЦИИ === */
@keyframes success-pulse {
    0% {
        box-shadow: 0 0 0 rgb(40 167 69 / 0%);
    }

    50% {
        box-shadow: 0 0 30px rgb(40 167 69 / 60%);
    }

    100% {
        box-shadow: 0 0 20px rgb(40 167 69 / 40%);
    }
}

@keyframes button-success {
    0% {
        transform: scale(1) rotate(0deg);
    }

    50% {
        transform: scale(1.1) rotate(180deg);
    }

    100% {
        transform: scale(1) rotate(360deg);
    }
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

/* === АДАПТИВНОСТЬ === */
@media (width <= 480px) {
    .slider-captcha-container {
        margin: 15px auto;
        padding: 0 10px;
    }

    .captcha-box {
        border-radius: 12px;
    }

    .slider-container {
        margin: 0 5px;
    }
}

@media (width <= 360px) {
    .slider-container {
        height: 48px;
        border-radius: 24px;
    }

    .slider-button {
        top: 6px;
        left: 6px;
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

/* === ТЁМНАЯ ТЕМА === */
@media (prefers-color-scheme: dark) {
    .slider-captcha-container {
        color: #e9ecef;
    }

    .slider-container {
        border: 1px solid rgb(255 255 255 / 10%);
        background: linear-gradient(145deg, #2c2c2e, #1c1c1e);
    }

    .slider-button {
        border-color: rgb(255 255 255 / 20%);
        background: linear-gradient(135deg, #38383a, #2c2c2e);
    }

    .captcha-error {
        border-color: #6b1e1e;
        background: linear-gradient(135deg, #3d1e1e, #4a1e1e);
        color: #fca5a5;
    }
}

/* === АКСЕССИБИЛЬНОСТЬ (только капча) === */
@media (prefers-reduced-motion: reduce) {
    .slider-container,
    .slider-track,
    .slider-bar,
    .slider-button,
    .captcha-box,
    .captcha-puzzle,
    .captcha-frame,
    .captcha-error {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}