/**
 * Rainbow Button Effects - Frontend Styles
 * 
 * Smooth continuous rainbow border animation
 */

/* CSS Variables with defaults */
:root {
    --rbe-animation-speed: 3s;
    --rbe-border-width: 3px;
    --rbe-border-radius: 6px;
    --rbe-padding-x: 28px;
    --rbe-padding-y: 12px;
    --rbe-button-bg: #1a1a1a;
    --rbe-button-text: #ffffff;
    --rbe-button-hover-bg: #2a2a2a;
}

/* Main Rainbow Button Class */
.rainbow-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--rbe-padding-y) + var(--rbe-border-width)) calc(var(--rbe-padding-x) + var(--rbe-border-width));
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--rbe-button-text) !important;
    background: transparent;
    border: none;
    border-radius: var(--rbe-border-radius);
    cursor: pointer;
    overflow: visible;
    z-index: 1;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    isolation: isolate;
}

/* Rainbow gradient border - moves horizontally across the border */
.rainbow-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--rbe-border-radius);
    padding: var(--rbe-border-width);
    background: linear-gradient(
        90deg,
        #ff0000 0%,
        #ff7f00 14.28%,
        #ffff00 28.57%,
        #00ff00 42.85%,
        #00ffff 57.14%,
        #0000ff 71.42%,
        #8b00ff 85.71%,
        #ff0000 100%
    );
    background-size: 200% 100%;
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    animation: rainbowMove var(--rbe-animation-speed) linear infinite;
    z-index: -2;
}

/* Button background (inner fill) */
.rainbow-btn::after {
    content: '';
    position: absolute;
    inset: var(--rbe-border-width);
    background: var(--rbe-button-bg);
    border-radius: calc(var(--rbe-border-radius) - var(--rbe-border-width));
    z-index: -1;
    transition: background 0.3s ease;
}

/* Hover states */
.rainbow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.3);
}

.rainbow-btn:hover::after {
    background: var(--rbe-button-hover-bg);
}

/* Active state */
.rainbow-btn:active {
    transform: translateY(0);
}

/* Focus state for accessibility */
.rainbow-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 4px;
}

.rainbow-btn:focus:not(:focus-visible) {
    outline: none;
}

/* Animation keyframes - smooth horizontal movement */
@keyframes rainbowMove {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 200% 50%;
    }
}

/* Glow effect variant (optional class) */
.rainbow-btn-glow::before {
    filter: blur(4px);
    opacity: 0.8;
}

.rainbow-btn-glow:hover::before {
    filter: blur(6px);
    opacity: 1;
}

/* Paused animation variant */
.rainbow-btn-paused::before {
    animation-play-state: paused;
}

.rainbow-btn-paused:hover::before {
    animation-play-state: running;
}

/* Reverse animation direction */
.rainbow-btn-reverse::before {
    animation-direction: reverse;
}

/* Disable animation (static rainbow) */
.rainbow-btn-static::before {
    animation: none;
    background-position: 0% 50%;
}

/* Accessibility - respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .rainbow-btn::before {
        animation: none;
        background-position: 0% 50%;
    }
    
    .rainbow-btn:hover {
        transform: none;
    }
}

/* Theme compatibility */
.ast-button.rainbow-btn,
.ast-custom-button.rainbow-btn,
.wp-block-button__link.rainbow-btn,
.elementor-button.rainbow-btn {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.ast-button.rainbow-btn:hover,
.ast-custom-button.rainbow-btn:hover,
.wp-block-button__link.rainbow-btn:hover,
.elementor-button.rainbow-btn:hover {
    background: transparent !important;
}

.wp-block-button.is-style-outline .wp-block-button__link.rainbow-btn {
    border: none !important;
}

.woocommerce .rainbow-btn.button,
.woocommerce .rainbow-btn.add_to_cart_button {
    background: transparent !important;
}
