/* Floating WhatsApp chat widget — Ceylon Heritage Canada */
.chc-wa {
    --chc-wa-green: #25d366;
    --chc-wa-green-dark: #128c7e;
    --chc-wa-size: 62px;
    --chc-wa-right: 20px;
    --chc-wa-bottom: 124px; /* sits above the theme's #scrollUp button */
    position: fixed;
    right: var(--chc-wa-right);
    bottom: calc(var(--chc-wa-bottom) + env(safe-area-inset-bottom, 0px));
    z-index: 9900;
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: inherit;
    pointer-events: none;
}

.chc-wa > * { pointer-events: auto; }

/* ---------- Main button ---------- */
.chc-wa-btn {
    position: relative;
    display: inline-flex;
    flex: none;
    width: var(--chc-wa-size);
    height: var(--chc-wa-size);
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(145deg, #2fe377 0%, var(--chc-wa-green) 45%, var(--chc-wa-green-dark) 100%);
    color: #fff;
    box-shadow: 0 10px 24px rgba(18, 140, 126, .45), 0 2px 6px rgba(0, 0, 0, .18);
    text-decoration: none;
    transform: translateY(0) scale(1);
    transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), box-shadow .25s ease;
    animation: chc-wa-enter .6s cubic-bezier(.34, 1.56, .64, 1) both, chc-wa-wiggle 6s ease-in-out 2.5s infinite;
    -webkit-tap-highlight-color: transparent;
}

.chc-wa-btn:hover,
.chc-wa-btn:focus-visible {
    color: #fff;
    transform: translateY(-3px) scale(1.07);
    box-shadow: 0 14px 30px rgba(18, 140, 126, .55), 0 3px 8px rgba(0, 0, 0, .2);
    animation-play-state: paused;
}

.chc-wa-btn:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

.chc-wa-btn svg {
    position: relative;
    z-index: 2;
    width: 34px;
    height: 34px;
    fill: currentColor;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .15));
}

/* Pulsing rings */
.chc-wa-btn::before,
.chc-wa-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: 50%;
    background: var(--chc-wa-green);
    opacity: .55;
    animation: chc-wa-pulse 2.4s cubic-bezier(.2, .6, .35, 1) infinite;
}

.chc-wa-btn::after { animation-delay: 1.2s; }

/* Notification badge */
.chc-wa-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    z-index: 3;
    display: inline-flex;
    min-width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid #fff;
    border-radius: 11px;
    background: #ff3b30;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    animation: chc-wa-badge-pop .5s cubic-bezier(.34, 1.56, .64, 1) 1.2s both;
}

.chc-wa.is-seen .chc-wa-badge { display: none; }

/* ---------- Greeting bubble ---------- */
.chc-wa-bubble {
    position: relative;
    width: 268px;
    max-width: calc(100vw - var(--chc-wa-size) - var(--chc-wa-right) - 34px);
    padding: 14px 16px 14px 14px;
    border-radius: 16px 16px 4px 16px;
    background: #fff;
    color: #253d30;
    box-shadow: 0 14px 36px rgba(37, 61, 48, .2), 0 2px 6px rgba(0, 0, 0, .08);
    opacity: 0;
    visibility: hidden;
    transform: translateX(14px) scale(.92);
    transform-origin: right bottom;
    transition: opacity .3s ease, transform .35s cubic-bezier(.34, 1.56, .64, 1), visibility 0s linear .35s;
    cursor: pointer;
}

.chc-wa.is-open .chc-wa-bubble {
    opacity: 1;
    visibility: visible;
    transform: translateX(0) scale(1);
    transition-delay: 0s;
}

.chc-wa-bubble::after {
    content: "";
    position: absolute;
    right: -7px;
    bottom: 14px;
    width: 14px;
    height: 14px;
    background: #fff;
    transform: rotate(45deg);
    border-radius: 2px;
}

.chc-wa-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.chc-wa-avatar {
    position: relative;
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff url("../res/logo.jpeg") center / cover no-repeat;
    box-shadow: 0 0 0 1px #e5e0d4;
}

.chc-wa-avatar::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    width: 10px;
    height: 10px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--chc-wa-green);
}

.chc-wa-name {
    display: block;
    color: #253d30;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
}

.chc-wa-status {
    display: block;
    color: #128c7e;
    font-size: 11.5px;
    line-height: 1.3;
}

.chc-wa-msg {
    margin: 0 0 12px;
    color: #4a574d;
    font-size: 13.5px;
    line-height: 1.5;
}

.chc-wa-cta {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--chc-wa-green);
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
    text-decoration: none;
    transition: background-color .2s ease, transform .2s ease;
}

.chc-wa-cta:hover,
.chc-wa-cta:focus-visible {
    background: var(--chc-wa-green-dark);
    color: #fff;
    transform: translateY(-1px);
}

.chc-wa-cta svg { width: 16px; height: 16px; fill: currentColor; }

.chc-wa-close {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-flex;
    width: 26px;
    height: 26px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #8a948c;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.chc-wa-close:hover,
.chc-wa-close:focus-visible { background: #f1efe9; color: #253d30; }

/* Typing dots shown briefly before the message */
.chc-wa-typing { display: none; gap: 4px; padding: 4px 0 10px; }
.chc-wa.is-typing .chc-wa-typing { display: flex; }
.chc-wa.is-typing .chc-wa-msg,
.chc-wa.is-typing .chc-wa-cta { display: none; }
.chc-wa-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #b5bdb7;
    animation: chc-wa-dot 1s ease-in-out infinite;
}
.chc-wa-typing span:nth-child(2) { animation-delay: .15s; }
.chc-wa-typing span:nth-child(3) { animation-delay: .3s; }

/* ---------- Keyframes ---------- */
@keyframes chc-wa-enter {
    from { opacity: 0; transform: translateY(30px) scale(.4); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes chc-wa-pulse {
    0%   { transform: scale(1); opacity: .55; }
    80%, 100% { transform: scale(1.75); opacity: 0; }
}

@keyframes chc-wa-wiggle {
    0%, 86%, 100% { transform: rotate(0) scale(1); }
    88% { transform: rotate(-14deg) scale(1.08); }
    90% { transform: rotate(12deg) scale(1.08); }
    92% { transform: rotate(-10deg) scale(1.08); }
    94% { transform: rotate(8deg) scale(1.04); }
    96% { transform: rotate(-4deg) scale(1); }
}

@keyframes chc-wa-badge-pop {
    from { opacity: 0; transform: scale(0); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes chc-wa-dot {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
    .chc-wa {
        --chc-wa-size: 56px;
        --chc-wa-right: 16px;
        --chc-wa-bottom: 112px; /* scrollUp is 40px on mobile */
        gap: 10px;
    }
    .chc-wa-btn svg { width: 30px; height: 30px; }
    .chc-wa-bubble { width: 240px; padding: 12px 14px 12px 12px; }
    .chc-wa-msg { font-size: 13px; }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
    .chc-wa-btn,
    .chc-wa-btn::before,
    .chc-wa-btn::after,
    .chc-wa-badge,
    .chc-wa-typing span { animation: none !important; }
    .chc-wa-btn::before,
    .chc-wa-btn::after { display: none; }
    .chc-wa-bubble { transition: opacity .2s ease; transform: none; }
}

@media print { .chc-wa { display: none; } }

