/* Sparkle Button Component for dignity.ink */
/* Based on the gorgeous sparkle effect - adapted for our digital sovereignty aesthetic */

.sparkle-button {
    position: relative;
    display: inline-block;
}

.sparkle-button *,
.sparkle-button *:after,
.sparkle-button *:before {
    box-sizing: border-box;
}

.sparkle-button button {
    --cut: 0.1em;
    --active: 0;
    --bg:
        radial-gradient(
            40% 50% at center 100%,
            hsl(160 calc(var(--active) * 97%) 72% / var(--active)),
            transparent
        ),
        radial-gradient(
            80% 100% at center 120%,
            hsl(150 calc(var(--active) * 97%) 70% / var(--active)),
            transparent
        ),
        hsl(160 calc(var(--active) * 97%) calc((var(--active) * 44%) + 12%));
    background: var(--bg);
    font-size: 1.5rem;
    font-weight: 600;
    border: 0;
    cursor: pointer;
    padding: 1.2em 2em;
    display: flex;
    align-items: center;
    gap: 0.5em;
    white-space: nowrap;
    border-radius: 50px;
    position: relative;
    font-family: 'Courier New', monospace;
    color: #000;
    box-shadow:
        0 0 calc(var(--active) * 6em) calc(var(--active) * 3em) hsl(160 97% 61% / 0.75),
        0 0.05em 0 0 hsl(160 calc(var(--active) * 97%) calc((var(--active) * 50%) + 30%)) inset,
        0 -0.05em 0 0 hsl(160 calc(var(--active) * 97%) calc(var(--active) * 60%)) inset;
    transition: box-shadow 0.25s, scale 0.25s, background 0.25s;
    scale: calc(1 + (var(--active) * 0.1));
}

.sparkle-button button:active {
    scale: 1;
}

.sparkle-button svg {
    overflow: visible !important;
}

.sparkle-button .sparkle path {
    color: hsl(0 0% calc((var(--active, 0) * 70%) + var(--base)));
    transform-box: fill-box;
    transform-origin: center;
    fill: currentColor;
    stroke: currentColor;
    animation-delay: calc((0.25s * 1.5) + (var(--delay) * 1s));
    animation-duration: 0.6s;
    transition: color 0.25s;
}

.sparkle-button button:is(:hover, :focus-visible) path {
    animation-name: sparkle-bounce;
}

@keyframes sparkle-bounce {
    35%, 65% {
        scale: var(--scale);
    }
}

.sparkle-button .sparkle path:nth-of-type(1) {
    --scale: 0.5;
    --delay: 0.1;
    --base: 40%;
}

.sparkle-button .sparkle path:nth-of-type(2) {
    --scale: 1.5;
    --delay: 0.2;
    --base: 20%;
}

.sparkle-button .sparkle path:nth-of-type(3) {
    --scale: 2.5;
    --delay: 0.35;
    --base: 30%;
}

.sparkle-button button:before {
    content: "";
    position: absolute;
    inset: -0.25em;
    z-index: -1;
    border: 0.25em solid hsl(160 97% 50% / 0.5);
    border-radius: 50px;
    opacity: var(--active, 0);
    transition: opacity 0.25s;
}

.sparkle-button .spark {
    position: absolute;
    inset: 0;
    border-radius: 50px;
    rotate: 0deg;
    overflow: hidden;
    mask: linear-gradient(white, transparent 50%);
    animation: spark-flip calc(1.8s * 2) infinite steps(2, end);
}

@keyframes spark-flip {
    to {
        rotate: 360deg;
    }
}

.sparkle-button .spark:before {
    content: "";
    position: absolute;
    width: 200%;
    aspect-ratio: 1;
    top: 0%;
    left: 50%;
    z-index: -1;
    translate: -50% -15%;
    rotate: 0;
    transform: rotate(-90deg);
    opacity: calc((var(--active)) + 0.4);
    background: conic-gradient(
        from 0deg,
        transparent 0 340deg,
        white 360deg
    );
    transition: opacity 0.25s;
    animation: spark-rotate 1.8s linear infinite both;
}

.sparkle-button .spark:after {
    content: "";
    position: absolute;
    inset: var(--cut);
    border-radius: 50px;
}

.sparkle-button .backdrop {
    position: absolute;
    inset: var(--cut);
    background: var(--bg);
    border-radius: 50px;
    transition: background 0.25s;
}

@keyframes spark-rotate {
    to {
        transform: rotate(90deg);
    }
}

.sparkle-button button:is(:hover, :focus-visible) {
    --active: 1;
    --play-state: running;
}

.sparkle-button .particle-pen {
    position: absolute;
    width: 200%;
    aspect-ratio: 1;
    top: 50%;
    left: 50%;
    translate: -50% -50%;
    -webkit-mask: radial-gradient(white, transparent 65%);
    z-index: -1;
    opacity: var(--active, 0);
    transition: opacity 0.25s;
}

.sparkle-button .particle {
    fill: white;
    width: calc(var(--size, 0.25) * 1rem);
    aspect-ratio: 1;
    position: absolute;
    top: calc(var(--y) * 1%);
    left: calc(var(--x) * 1%);
    opacity: var(--alpha, 1);
    animation: particle-float-out calc(var(--duration, 1) * 1s) calc(var(--delay) * -1s) infinite linear;
    transform-origin: var(--origin-x, 1000%) var(--origin-y, 1000%);
    z-index: -1;
    animation-play-state: var(--play-state, paused);
}

.sparkle-button .particle path {
    fill: hsl(160 80% 80%);
    stroke: none;
}

.sparkle-button .particle:nth-of-type(even) {
    animation-direction: reverse;
}

@keyframes particle-float-out {
    to {
        rotate: 360deg;
    }
}

.sparkle-button .text {
    translate: 2% -6%;
    letter-spacing: 0.01ch;
    background: linear-gradient(90deg, 
        hsl(0 0% calc((var(--active) * 100%) + 65%)), 
        hsl(0 0% calc((var(--active) * 100%) + 26%))
    );
    -webkit-background-clip: text;
    color: transparent;
    transition: background 0.25s;
}

.sparkle-button button svg {
    inline-size: 1.25em;
    translate: -25% -5%;
}

.sparkle-button button:is(:hover, :focus-visible) ~ .particle-pen {
    --active: 1;
    --play-state: running;
}

/* Body glow effect for dignity.ink */
body:has(.sparkle-button button:is(:hover, :focus-visible)) {
    background: linear-gradient(135deg, 
        hsl(160, 97%, 8%) 0%, 
        hsl(150, 90%, 6%) 50%, 
        hsl(140, 85%, 4%) 100%
    );
    transition: background 0.25s;
}

/* Size variations */
.sparkle-button.size-large button {
    font-size: 2rem;
    padding: 1.5em 2.5em;
}

.sparkle-button.size-small button {
    font-size: 1.2rem;
    padding: 1em 1.5em;
}

/* Color variations for different buttons */
.sparkle-button.variant-primary button {
    --bg:
        radial-gradient(
            40% 50% at center 100%,
            hsl(160 calc(var(--active) * 97%) 72% / var(--active)),
            transparent
        ),
        radial-gradient(
            80% 100% at center 120%,
            hsl(150 calc(var(--active) * 97%) 70% / var(--active)),
            transparent
        ),
        hsl(160 calc(var(--active) * 97%) calc((var(--active) * 44%) + 12%));
}

.sparkle-button.variant-secondary button {
    --bg:
        radial-gradient(
            40% 50% at center 100%,
            hsl(200 calc(var(--active) * 97%) 72% / var(--active)),
            transparent
        ),
        radial-gradient(
            80% 100% at center 120%,
            hsl(190 calc(var(--active) * 97%) 70% / var(--active)),
            transparent
        ),
        hsl(200 calc(var(--active) * 97%) calc((var(--active) * 44%) + 12%));
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .sparkle-button button {
        font-size: 1.2rem;
        padding: 1rem 1.5rem;
        min-width: 160px; /* Ensure enough space for "Yes, I Care" */
        white-space: nowrap;
    }
    
    .sparkle-button.size-large button {
        font-size: 1.4rem;
        padding: 1.2rem 2rem;
        min-width: 180px;
    }
    
    .sparkle-button.size-small button {
        font-size: 1rem;
        padding: 0.8rem 1.2rem;
        min-width: 140px;
    }
    
    .sparkle-button .text {
        font-size: inherit;
        letter-spacing: 0.02ch; /* Slightly more spacing on mobile */
    }
}

@media (max-width: 480px) {
    .sparkle-button button {
        font-size: 1.1rem;
        padding: 0.9rem 1.3rem;
        min-width: 150px;
    }
    
    .sparkle-button.size-large button {
        font-size: 1.3rem;
        padding: 1.1rem 1.8rem;
        min-width: 170px;
    }
    
    /* Adjust sparkle effects for smaller screens */
    .sparkle-button button svg {
        inline-size: 1.1em;
    }
    
    .sparkle-button .particle-pen {
        width: 180%; /* Slightly smaller particle area on very small screens */
    }
}