/**
 * NC DSGVO Captcha – Frontend-Styles
 * WCAG 2.1 AA: Kontrast >= 4.5:1, Focus-Indikator, reduced-motion, dark mode
 */

/* -------------------------------------------------------------------------- */
/* Container                                                                  */
/* -------------------------------------------------------------------------- */
.nc-captcha-wrap {
    margin: 1rem 0;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    color: inherit;
}

/* -------------------------------------------------------------------------- */
/* Honeypot – visuell + a11y versteckt, bleibt im Form-Submit                 */
/* -------------------------------------------------------------------------- */
.nc-captcha-hp {
    position: absolute !important;
    left: -10000px !important;
    top: auto !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}
.nc-captcha-hp input,
.nc-captcha-hp label {
    pointer-events: none !important;
}

/* -------------------------------------------------------------------------- */
/* PoW-Widget                                                                 */
/* -------------------------------------------------------------------------- */
.nc-pow-widget {
    display: block;
    padding: 0.75rem 1rem;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #f9fafb;
    color: #111827;
}

.nc-pow-hidden {
    display: none !important;
}

.nc-pow-inner {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
}

.nc-pow-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #0090A7;
    flex-shrink: 0;
}

.nc-pow-label {
    flex: 1 1 auto;
    min-width: 10ch;
    font-size: 0.9375rem;
    color: #111827;
}

.nc-pow-progress-wrap {
    flex: 1 1 100%;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.nc-pow-progress-bar {
    display: block;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #0090A7 0%, #00b8d4 100%);
    transition: width 0.2s ease;
    border-radius: 2px;
}

/* Erfolgreich-Zustand */
.nc-pow-widget.nc-pow-done {
    border-color: #85b538;
    background: #f3f9ec;
}
.nc-pow-widget.nc-pow-done .nc-pow-icon,
.nc-pow-widget.nc-pow-done .nc-pow-label {
    color: #4a7a1f;
}
.nc-pow-widget.nc-pow-done .nc-pow-progress-bar {
    width: 100% !important;
    background: #85b538;
}

/* Fehler-Zustand */
.nc-pow-widget.nc-pow-error {
    border-color: #AC144C;
    background: #fdf2f6;
}
.nc-pow-widget.nc-pow-error .nc-pow-icon,
.nc-pow-widget.nc-pow-error .nc-pow-label {
    color: #AC144C;
}

/* Indeterminate-Animation während Worker läuft (CSS-only Fallback) */
.nc-pow-widget:not(.nc-pow-done):not(.nc-pow-error) .nc-pow-progress-bar {
    animation: nc-pow-pulse 1.4s ease-in-out infinite;
}

@keyframes nc-pow-pulse {
    0%   { width: 10%; opacity: 0.6; }
    50%  { width: 70%; opacity: 1; }
    100% { width: 10%; opacity: 0.6; }
}

/* -------------------------------------------------------------------------- */
/* Math-Widget (JS-Fallback)                                                  */
/* -------------------------------------------------------------------------- */
.nc-math-widget {
    display: block;
    padding: 0.75rem 1rem;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #f9fafb;
    color: #111827;
}

.nc-math-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.375rem;
    color: #111827;
}

.nc-math-input {
    width: auto;
    max-width: 8rem;
    min-height: 2.25rem;
    padding: 0.375rem 0.625rem;
    border: 1px solid #9ca3af;
    border-radius: 4px;
    background: #ffffff;
    color: #111827;
    font-size: 1rem;
    line-height: 1.5;
}

.nc-math-input:focus {
    outline: 2px solid #0090A7;
    outline-offset: 2px;
    border-color: #0090A7;
}

.nc-math-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: #4b5563;
}

/* -------------------------------------------------------------------------- */
/* Dark Mode                                                                  */
/* -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    .nc-pow-widget,
    .nc-math-widget {
        background: #1f2937;
        border-color: #374151;
        color: #f3f4f6;
    }
    .nc-pow-label,
    .nc-math-label {
        color: #f3f4f6;
    }
    .nc-math-hint {
        color: #9ca3af;
    }
    .nc-math-input {
        background: #111827;
        color: #f3f4f6;
        border-color: #4b5563;
    }
    .nc-pow-progress-wrap {
        background: #374151;
    }
    .nc-pow-widget.nc-pow-done {
        background: #1a2e0f;
        border-color: #85b538;
    }
    .nc-pow-widget.nc-pow-done .nc-pow-icon,
    .nc-pow-widget.nc-pow-done .nc-pow-label {
        color: #b6e07a;
    }
    .nc-pow-widget.nc-pow-error {
        background: #2a1018;
        border-color: #AC144C;
    }
    .nc-pow-widget.nc-pow-error .nc-pow-icon,
    .nc-pow-widget.nc-pow-error .nc-pow-label {
        color: #ff6b9a;
    }
}

/* -------------------------------------------------------------------------- */
/* Reduced motion                                                             */
/* -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .nc-pow-widget:not(.nc-pow-done):not(.nc-pow-error) .nc-pow-progress-bar {
        animation: none;
        width: 50%;
    }
    .nc-pow-progress-bar {
        transition: none;
    }
}
