/* =============================================================================
   WhatsApp Button widget
   Custom properties (--cc-wa-*) are set inline by the global floating button
   (see canasa_build_whatsapp_button_html()); the Elementor "WhatsApp Button"
   widget instead overrides these same properties via its own per-instance
   Elementor-generated selectors, which win on specificity either way.
   ============================================================================= */

.cc-wa-widget {
    position: fixed;
    bottom: var(--cc-wa-offset-bottom, 24px);
    z-index: var(--cc-wa-z, 9999);
    display: flex;
    align-items: center;
}

.cc-wa-widget.cc-wa-pos-right {
    right: var(--cc-wa-offset-side, 24px);
    left: auto;
    flex-direction: row-reverse;
}

.cc-wa-widget.cc-wa-pos-left {
    left: var(--cc-wa-offset-side, 24px);
    right: auto;
    flex-direction: row;
}

.cc-wa-btn {
    width: var(--cc-wa-size, 60px);
    height: var(--cc-wa-size, 60px);
    border-radius: 50%;
    background-color: var(--cc-wa-bg, #25D366);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: background-color 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.cc-wa-btn:hover {
    background-color: var(--cc-wa-bg-hover, #1ebe5a);
    transform: scale(1.05);
}

.cc-wa-icon svg {
    width: var(--cc-wa-icon-size, 32px);
    height: var(--cc-wa-icon-size, 32px);
    fill: var(--cc-wa-icon-color, #ffffff);
    display: block;
}

.cc-wa-label {
    background: #ffffff;
    color: #111827;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    margin: 0 12px;
}

/* Pulse animation — a soft expanding ring behind the button */
.cc-wa-btn.cc-wa-pulse {
    position: relative;
}

.cc-wa-btn.cc-wa-pulse::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: inherit;
    animation: cc-wa-pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    z-index: -1;
}

@keyframes cc-wa-pulse-ring {
    0%   { transform: scale(1);   opacity: 0.6; }
    100% { transform: scale(1.8); opacity: 0; }
}

/* Visibility */
@media (max-width: 767px) {
    .cc-wa-visibility-desktop { display: none; }
}

@media (min-width: 768px) {
    .cc-wa-visibility-mobile { display: none; }
}

/* Popup delay — hidden until assets/js/whatsapp-global.js adds
   .cc-wa-visible after the configured delay */
.cc-wa-widget.cc-wa-delayed {
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.cc-wa-widget.cc-wa-delayed.cc-wa-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* =============================================================================
   Attention presets — short looping movements on the button. Each cycle is
   3s with the motion packed into the first part, so it nudges, then rests.
   ============================================================================= */

.cc-wa-btn.cc-wa-attn-bounce    { animation: cc-wa-attn-bounce 3s ease-in-out infinite; }
.cc-wa-btn.cc-wa-attn-shake     { animation: cc-wa-attn-shake 3s ease-in-out infinite; }
.cc-wa-btn.cc-wa-attn-wobble    { animation: cc-wa-attn-wobble 3s ease-in-out infinite; }
.cc-wa-btn.cc-wa-attn-heartbeat { animation: cc-wa-attn-heartbeat 3s ease-in-out infinite; }
.cc-wa-btn.cc-wa-attn-ring .cc-wa-icon {
    display: block;
    animation: cc-wa-attn-ring 3s ease-in-out infinite;
}

/* Hold still while the visitor is aiming at it */
.cc-wa-btn[class*="cc-wa-attn-"]:hover,
.cc-wa-btn.cc-wa-attn-ring:hover .cc-wa-icon {
    animation-play-state: paused;
}

@keyframes cc-wa-attn-bounce {
    0%, 20%, 40%, 100% { transform: translateY(0); }
    10%                { transform: translateY(-14px); }
    30%                { transform: translateY(-6px); }
}

@keyframes cc-wa-attn-shake {
    0%, 30%, 100%   { transform: translateX(0); }
    5%, 15%, 25%    { transform: translateX(-6px); }
    10%, 20%        { transform: translateX(6px); }
}

@keyframes cc-wa-attn-wobble {
    0%, 30%, 100% { transform: rotate(0); }
    6%            { transform: rotate(-14deg); }
    12%           { transform: rotate(11deg); }
    18%           { transform: rotate(-7deg); }
    24%           { transform: rotate(4deg); }
}

@keyframes cc-wa-attn-ring {
    0%, 32%, 100%          { transform: rotate(0); }
    2%, 10%, 18%, 26%      { transform: rotate(-18deg); }
    6%, 14%, 22%, 30%      { transform: rotate(18deg); }
}

@keyframes cc-wa-attn-heartbeat {
    0%, 35%, 100% { transform: scale(1); }
    7%            { transform: scale(1.15); }
    14%           { transform: scale(1); }
    21%           { transform: scale(1.15); }
}

/* =============================================================================
   Animated message tile — slides out from behind the button (z-index -1
   inside the fixed wrapper's stacking context keeps it under the button).
   Opened/closed by assets/js/whatsapp-global.js via .cc-wa-teaser-open.
   ============================================================================= */

.cc-wa-teaser {
    position: absolute;
    top: 50%;
    z-index: -1;
    box-sizing: border-box;
    width: max-content;
    max-width: min(
        var(--cc-wa-teaser-max-width, 260px),
        calc(100vw - var(--cc-wa-size, 60px) - var(--cc-wa-offset-side, 24px) - 32px)
    );
    padding: 12px 34px 12px 16px;
    background: var(--cc-wa-teaser-bg, #ffffff);
    color: var(--cc-wa-teaser-color, #111827);
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform-origin: center;
    transition:
        transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.3s ease,
        visibility 0s linear 0.55s;
}

/* Closed state: shrunk and parked on the button's centre, i.e. behind it */
.cc-wa-pos-right .cc-wa-teaser {
    right: calc(var(--cc-wa-size, 60px) + 14px);
    transform: translate(calc(50% + var(--cc-wa-size, 60px) / 2 + 14px), -50%) scale(0.2);
}

.cc-wa-pos-left .cc-wa-teaser {
    left: calc(var(--cc-wa-size, 60px) + 14px);
    transform: translate(calc(-50% - var(--cc-wa-size, 60px) / 2 - 14px), -50%) scale(0.2);
}

.cc-wa-widget .cc-wa-teaser.cc-wa-teaser-open {
    transform: translate(0, -50%) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition:
        transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.3s ease,
        visibility 0s;
}

/* Speech-bubble tail pointing at the button */
.cc-wa-teaser::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    background: inherit;
    border-radius: 2px;
    transform: translateY(-50%) rotate(45deg);
}

.cc-wa-pos-right .cc-wa-teaser::after { right: -5px; }
.cc-wa-pos-left  .cc-wa-teaser::after { left: -5px; }

.cc-wa-widget .cc-wa-teaser-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 20px;
    height: 20px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    color: inherit;
    font-size: 16px;
    line-height: 20px;
    text-align: center;
    opacity: 0.45;
    cursor: pointer;
}

.cc-wa-widget .cc-wa-teaser-close:hover,
.cc-wa-widget .cc-wa-teaser-close:focus-visible {
    opacity: 1;
    background: rgba(0, 0, 0, 0.06);
}

/* The static text label makes way while the tile is out */
.cc-wa-label {
    transition: opacity 0.25s ease;
}

.cc-wa-teaser-active .cc-wa-label {
    opacity: 0;
}

/* Full message for screen readers (the animated copy is aria-hidden) */
.cc-wa-teaser-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ── Text effects ── */

.cc-wa-fx-typewriter::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 2px;
    vertical-align: -0.15em;
    background: currentColor;
    animation: cc-wa-caret 0.8s steps(1) infinite;
}

@keyframes cc-wa-caret {
    50% { opacity: 0; }
}

.cc-wa-fx-word {
    display: inline-block;
    white-space: nowrap;
}

.cc-wa-fx-unit {
    display: inline-block;
    opacity: 0;
    animation: cc-wa-fx-word 0.45s ease forwards;
}

.cc-wa-fx-letters .cc-wa-fx-unit {
    animation-name: cc-wa-fx-letter;
}

@keyframes cc-wa-fx-word {
    from { opacity: 0; transform: translateY(8px); filter: blur(3px); }
    to   { opacity: 1; transform: none; filter: none; }
}

@keyframes cc-wa-fx-letter {
    0%   { opacity: 0; transform: translateY(10px) scale(0.6); }
    60%  { opacity: 1; transform: translateY(-3px) scale(1.1); }
    100% { opacity: 1; transform: none; }
}

/* ── Reduced motion: no looping movement, tile simply fades ── */
@media (prefers-reduced-motion: reduce) {
    .cc-wa-btn[class*="cc-wa-attn-"],
    .cc-wa-btn.cc-wa-attn-ring .cc-wa-icon {
        animation: none;
    }

    .cc-wa-pos-right .cc-wa-teaser,
    .cc-wa-pos-left .cc-wa-teaser {
        transform: translate(0, -50%);
    }
}
