/**
 * Checkbox animada (padrão “cosmic”) — tema verde Emprega BP.
 * Usar em: Nova Vaga (urgente), Cadastro (aceite de políticas).
 */

.cosmic-checkbox {
    position: relative;
    --size: 28px;
    --clr-idle: color-mix(in srgb, var(--muted) 88%, var(--border));
    --clr-active: var(--primary);
    --clr-glow: var(--primary-light);
    --clr-core: var(--ink);
    --clr-spark: var(--secondary);
    --duration: 0.6s;
    display: inline-flex;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    max-width: 100%;
}

.cosmic-checkbox input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    white-space: nowrap;
}

.cosmic-checkbox .checkbox-container {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.cosmic-checkbox .checkbox-box {
    position: relative;
    width: var(--size);
    height: var(--size);
    margin-top: 2px;
    border: 2px solid var(--clr-idle);
    border-radius: 8px;
    transition:
        border-color 0.3s,
        background 0.3s,
        box-shadow 0.3s,
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cosmic-checkbox:hover .checkbox-box {
    border-color: var(--clr-glow);
    box-shadow: 0 0 8px rgba(0, 214, 111, 0.22);
}

.cosmic-checkbox .checkbox-bg {
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    opacity: 0;
    transform: scale(0.5);
    transition:
        opacity 0.4s ease,
        transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1;
}

.cosmic-checkbox input:checked ~ .checkbox-container .checkbox-bg {
    opacity: 1;
    transform: scale(1);
    box-shadow:
        0 0 12px rgba(0, 214, 111, 0.45),
        0 0 28px rgba(0, 214, 111, 0.18),
        inset 0 0 8px rgba(255, 255, 255, 0.12);
}

.cosmic-checkbox .checkmark {
    width: 16px;
    height: 16px;
    color: #fff;
    opacity: 0;
    transform: scale(0) rotate(-20deg);
    transition:
        opacity 0.25s ease,
        transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 2;
    pointer-events: none;
}

.cosmic-checkbox .checkmark path {
    stroke-dasharray: 28;
    stroke-dashoffset: 28;
    transition: stroke-dashoffset 0.5s cubic-bezier(0.65, 0, 0.35, 1) 0.15s;
}

.cosmic-checkbox .signup-policies-accept__text {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    font-weight: inherit;
    color: var(--clr-idle);
    letter-spacing: 0.02em;
    transition: color 0.35s;
    min-width: 0;
}

.cosmic-checkbox .particle {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--clr-spark);
    opacity: 0;
    pointer-events: none;
    top: 50%;
    left: 50%;
    z-index: 3;
}

.cosmic-checkbox .ring {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid var(--clr-glow);
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

.cosmic-checkbox .spark {
    position: absolute;
    width: 2px;
    height: 10px;
    background: linear-gradient(to top, var(--clr-spark), transparent);
    opacity: 0;
    top: 50%;
    left: 50%;
    transform-origin: center center;
    pointer-events: none;
    border-radius: 2px;
    z-index: 3;
}

.cosmic-checkbox .s1 { transform: rotate(0deg) translateY(-2px); }
.cosmic-checkbox .s2 { transform: rotate(45deg) translateY(-2px); }
.cosmic-checkbox .s3 { transform: rotate(90deg) translateY(-2px); }
.cosmic-checkbox .s4 { transform: rotate(135deg) translateY(-2px); }
.cosmic-checkbox .s5 { transform: rotate(180deg) translateY(-2px); }
.cosmic-checkbox .s6 { transform: rotate(225deg) translateY(-2px); }
.cosmic-checkbox .s7 { transform: rotate(270deg) translateY(-2px); }
.cosmic-checkbox .s8 { transform: rotate(315deg) translateY(-2px); }

.cosmic-checkbox input:checked ~ .checkbox-container .checkbox-box {
    border-color: var(--clr-active);
    transform: scale(1);
    animation: emprega-cosmic-box-pulse 0.5s ease;
}

@keyframes emprega-cosmic-box-pulse {
    0% { transform: scale(1); }
    30% { transform: scale(0.85); }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.cosmic-checkbox input:checked ~ .checkbox-container .checkmark {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.cosmic-checkbox input:checked ~ .checkbox-container .checkmark path {
    stroke-dashoffset: 0;
}

.cosmic-checkbox input:checked ~ .checkbox-container .signup-policies-accept__text {
    color: var(--clr-core);
}

.cosmic-checkbox input:checked ~ .checkbox-container .p1 {
    animation: emprega-cosmic-particle-fly 0.65s ease-out forwards;
    --angle: -45deg;
    --dist: 22px;
    --clr: #b8fad9;
}

.cosmic-checkbox input:checked ~ .checkbox-container .p2 {
    animation: emprega-cosmic-particle-fly 0.6s 0.05s ease-out forwards;
    --angle: -90deg;
    --dist: 26px;
    --clr: #8ef5c4;
}

.cosmic-checkbox input:checked ~ .checkbox-container .p3 {
    animation: emprega-cosmic-particle-fly 0.55s 0.08s ease-out forwards;
    --angle: 0deg;
    --dist: 20px;
    --clr: #bbff65;
}

.cosmic-checkbox input:checked ~ .checkbox-container .p4 {
    animation: emprega-cosmic-particle-fly 0.7s 0.03s ease-out forwards;
    --angle: 45deg;
    --dist: 24px;
    --clr: #00d66f;
}

.cosmic-checkbox input:checked ~ .checkbox-container .p5 {
    animation: emprega-cosmic-particle-fly 0.5s 0.1s ease-out forwards;
    --angle: 135deg;
    --dist: 18px;
    --clr: #00bf62;
}

.cosmic-checkbox input:checked ~ .checkbox-container .p6 {
    animation: emprega-cosmic-particle-fly 0.65s 0.06s ease-out forwards;
    --angle: -135deg;
    --dist: 23px;
    --clr: #34d399;
}

@keyframes emprega-cosmic-particle-fly {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(var(--angle)) translateY(0) scale(1);
        background: var(--clr);
    }
    60% {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(var(--angle)) translateY(calc(var(--dist) * -1)) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(var(--angle)) translateY(calc(var(--dist) * -1.4)) scale(0);
    }
}

.cosmic-checkbox input:checked ~ .checkbox-container .ring-1 {
    animation: emprega-cosmic-shockwave 0.7s ease-out forwards;
}

.cosmic-checkbox input:checked ~ .checkbox-container .ring-2 {
    animation: emprega-cosmic-shockwave 0.7s 0.12s ease-out forwards;
}

.cosmic-checkbox input:checked ~ .checkbox-container .ring-3 {
    animation: emprega-cosmic-shockwave 0.7s 0.24s ease-out forwards;
}

@keyframes emprega-cosmic-shockwave {
    0% {
        opacity: 0.7;
        transform: scale(0.5);
        border-color: var(--clr-glow);
    }
    50% {
        opacity: 0.4;
        border-color: var(--clr-spark);
    }
    100% {
        opacity: 0;
        transform: scale(2.2);
        border-color: transparent;
    }
}

.cosmic-checkbox input:checked ~ .checkbox-container .s1 {
    animation: emprega-cosmic-spark-burst 0.5s 0.05s ease-out forwards;
    --rot: 0deg;
}

.cosmic-checkbox input:checked ~ .checkbox-container .s2 {
    animation: emprega-cosmic-spark-burst 0.45s 0.08s ease-out forwards;
    --rot: 45deg;
}

.cosmic-checkbox input:checked ~ .checkbox-container .s3 {
    animation: emprega-cosmic-spark-burst 0.5s 0.03s ease-out forwards;
    --rot: 90deg;
}

.cosmic-checkbox input:checked ~ .checkbox-container .s4 {
    animation: emprega-cosmic-spark-burst 0.55s 0.1s ease-out forwards;
    --rot: 135deg;
}

.cosmic-checkbox input:checked ~ .checkbox-container .s5 {
    animation: emprega-cosmic-spark-burst 0.5s 0.06s ease-out forwards;
    --rot: 180deg;
}

.cosmic-checkbox input:checked ~ .checkbox-container .s6 {
    animation: emprega-cosmic-spark-burst 0.45s 0.09s ease-out forwards;
    --rot: 225deg;
}

.cosmic-checkbox input:checked ~ .checkbox-container .s7 {
    animation: emprega-cosmic-spark-burst 0.5s 0.04s ease-out forwards;
    --rot: 270deg;
}

.cosmic-checkbox input:checked ~ .checkbox-container .s8 {
    animation: emprega-cosmic-spark-burst 0.55s 0.07s ease-out forwards;
    --rot: 315deg;
}

@keyframes emprega-cosmic-spark-burst {
    0% {
        opacity: 1;
        transform: rotate(var(--rot)) translateY(-4px) scaleY(0.5);
    }
    50% {
        opacity: 0.9;
        transform: rotate(var(--rot)) translateY(-20px) scaleY(1.2);
        background: linear-gradient(to top, var(--clr-active), transparent);
    }
    100% {
        opacity: 0;
        transform: rotate(var(--rot)) translateY(-30px) scaleY(0.3);
    }
}

.cosmic-checkbox .checkbox-box::before {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 10px;
    background: radial-gradient(circle, rgba(0, 214, 111, 0.14), transparent 70%);
    opacity: 0;
    animation: emprega-cosmic-idle-breathe 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes emprega-cosmic-idle-breathe {
    0%,
    100% {
        opacity: 0;
        transform: scale(0.95);
    }
    50% {
        opacity: 1;
        transform: scale(1.15);
    }
}

.cosmic-checkbox input:checked ~ .checkbox-container .checkbox-box::before {
    animation: none;
    opacity: 0.55;
    transform: scale(1.2);
    background: radial-gradient(circle, rgba(0, 214, 111, 0.22), transparent 70%);
    transition: opacity 0.5s, transform 0.5s;
}

.cosmic-checkbox .checkbox-box::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 8px;
    opacity: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.28) 0%,
        transparent 50%,
        rgba(255, 255, 255, 0.1) 100%
    );
    pointer-events: none;
    transition: opacity 0.4s 0.2s;
}

.cosmic-checkbox input:checked ~ .checkbox-container .checkbox-box::after {
    opacity: 1;
}

.cosmic-checkbox input:not(:checked) ~ .checkbox-container .checkbox-box {
    background: transparent;
    box-shadow: none;
}

.cosmic-checkbox input:not(:checked) ~ .checkbox-container .checkmark {
    opacity: 0;
    transform: scale(0) rotate(-20deg);
}

.cosmic-checkbox input:not(:checked) ~ .checkbox-container .checkmark path {
    stroke-dashoffset: 28;
}

.cosmic-checkbox input:focus-visible ~ .checkbox-container .checkbox-box {
    outline: 2px solid var(--clr-glow);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .cosmic-checkbox .checkbox-box::before {
        animation: none;
    }

    .cosmic-checkbox input:checked ~ .checkbox-container .checkbox-box {
        animation: none;
    }

    .cosmic-checkbox input:checked ~ .checkbox-container .particle,
    .cosmic-checkbox input:checked ~ .checkbox-container .ring,
    .cosmic-checkbox input:checked ~ .checkbox-container .spark {
        animation: none !important;
        opacity: 0 !important;
    }

    .cosmic-checkbox .checkbox-box,
    .cosmic-checkbox .checkbox-bg,
    .cosmic-checkbox .checkmark,
    .cosmic-checkbox .checkmark path {
        transition-duration: 0.01ms !important;
    }
}
