/**
 * Piexl Button Styles
 *
 * Responsive CTA button with hover effects and loading state.
 * Uses CSS custom properties for dynamic color theming.
 */

/* ============================
   Button Wrapper
   ============================ */
.piexl-button-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 0;
    width: 100%;
}

/* ============================
   CTA Button Base
   ============================ */
.piexl-cta-button {
    display: inline-block;
    padding: 14px 48px;
    background-color: var(--piexl-btn-bg, #1877F2);
    color: var(--piexl-btn-color, #FFFFFF) !important;
    border-radius: var(--piexl-btn-radius, 8px);
    text-decoration: none !important;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    cursor: pointer;
    border: none;
    outline: none;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    letter-spacing: 0.02em;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    max-width: 100%;
    box-sizing: border-box;
}

/* ============================
   Hover & Active States
   ============================ */
.piexl-cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    filter: brightness(1.08);
    text-decoration: none !important;
    color: var(--piexl-btn-color, #FFFFFF) !important;
}

.piexl-cta-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    filter: brightness(0.95);
}

/* Ripple effect on click */
.piexl-cta-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease, opacity 0.4s ease;
    opacity: 0;
}

.piexl-cta-button:active::after {
    width: 300px;
    height: 300px;
    opacity: 1;
    transition: width 0s, height 0s, opacity 0s;
}

/* ============================
   Loading State
   ============================ */
.piexl-cta-button.piexl-loading {
    pointer-events: none;
    opacity: 0.85;
    cursor: wait;
}

.piexl-cta-button.piexl-loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: piexl-spin 0.6s linear infinite;
    vertical-align: middle;
}

@keyframes piexl-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================
   Focus State (Accessibility)
   ============================ */
.piexl-cta-button:focus {
    outline: 3px solid rgba(24, 119, 242, 0.4);
    outline-offset: 3px;
}

.piexl-cta-button:focus:not(:focus-visible) {
    outline: none;
}

.piexl-cta-button:focus-visible {
    outline: 3px solid rgba(24, 119, 242, 0.4);
    outline-offset: 3px;
}

/* ============================
   Mobile Responsive
   ============================ */
@media screen and (max-width: 768px) {
    .piexl-button-wrapper {
        padding: 10px 16px;
    }

    .piexl-cta-button {
        display: block;
        width: 100%;
        padding: 16px 24px;
        font-size: 17px;
        text-align: center;
    }
}

@media screen and (max-width: 480px) {
    .piexl-cta-button {
        padding: 14px 20px;
        font-size: 16px;
    }
}

/* ============================
   Blocksy Theme Compatibility
   ============================ */
.entry-content .piexl-button-wrapper,
.ct-container .piexl-button-wrapper,
.alignwide .piexl-button-wrapper,
.alignfull .piexl-button-wrapper {
    margin-left: auto;
    margin-right: auto;
}

/* Override Blocksy link styles */
.entry-content .piexl-cta-button,
.ct-container .piexl-cta-button {
    color: var(--piexl-btn-color, #FFFFFF) !important;
    text-decoration: none !important;
    border-bottom: none !important;
    background-image: none !important;
}

.entry-content .piexl-cta-button:hover,
.ct-container .piexl-cta-button:hover {
    color: var(--piexl-btn-color, #FFFFFF) !important;
    text-decoration: none !important;
}
