/* ==========================================================================
   Kromdraai Blomme — the floating WhatsApp button.

   A round forest button with a gold hairline, the WhatsApp mark in ivory and
   a slow breathing ring. The label slides out on a pointer, and the button
   keeps clear of the cookie notice and the footer.

   The legacy stylesheet drew a 16px glyph on top of a green image. This
   replaces it, and it is loaded after that stylesheet so it wins.
   ========================================================================== */

.kb-whatsapp,
.kb-whatsapp * {
    box-sizing: border-box;
}

/* The link carries the label and the round button. */
.kb-whatsapp__link {
    position: fixed;
    right: clamp(1rem, 2.6vw, 1.9rem);
    bottom: clamp(1rem, 2.6vw, 1.9rem);
    z-index: 1005;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    text-decoration: none;
    color: var(--kb-ivory);
}

/* The round button itself. It is the element the cookie notice lifts, so it
   keeps that class and that transform. */
.kb-whatsapp__button {
    position: relative;
    display: grid;
    place-items: center;
    width: var(--kb-wa-size, 54px);
    height: var(--kb-wa-size, 54px);
    padding: 0;
    margin: 0;
    /* The legacy button was a green image behind a small glyph. */
    background-image: radial-gradient(120% 120% at 28% 18%,
            rgba(247, 245, 239, 0.18), rgba(0, 0, 0, 0) 62%);
    background-color: var(--kb-wa-color, var(--kb-forest));
    border: 1px solid rgba(247, 245, 239, 0.22);
    border-radius: 50%;
    box-shadow:
        0 16px 34px rgba(12, 24, 17, 0.34),
        0 2px 6px rgba(12, 24, 17, 0.22),
        inset 0 1px 0 rgba(247, 245, 239, 0.18);
    transition:
        transform 0.5s var(--kb-ease),
        box-shadow 0.5s var(--kb-ease),
        background-color 0.5s var(--kb-ease);
}

/* The gold hairline that circles the button. */
.kb-whatsapp__button::before {
    content: "";
    position: absolute;
    inset: -5px;
    border: 1px solid var(--kb-gold);
    border-radius: 50%;
    opacity: 0.45;
    transition: inset 0.55s var(--kb-ease), opacity 0.55s var(--kb-ease);
}

/* The breathing ring: it opens out and fades, twice, slowly. */
.kb-whatsapp__button::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 1px solid var(--kb-gold);
    border-radius: 50%;
    opacity: 0;
    transform: scale(1);
    animation: kb-wa-pulse 3.6s var(--kb-ease) infinite;
    pointer-events: none;
}

@keyframes kb-wa-pulse {
    0% {
        opacity: 0.5;
        transform: scale(1);
    }

    70% {
        opacity: 0;
        transform: scale(1.75);
    }

    100% {
        opacity: 0;
        transform: scale(1.75);
    }
}

/* The mark. It settles in once the page has arrived. */
.kb-whatsapp__icon {
    position: relative;
    z-index: 1;
    display: block;
    width: 46%;
    height: 46%;
    color: var(--kb-ivory);
    opacity: 0;
    animation: kb-wa-mark 0.9s var(--kb-ease) 0.35s forwards;
    transition: transform 0.55s var(--kb-ease);
}

@keyframes kb-wa-mark {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* The label, which slides out to the left on a pointer. */
.kb-whatsapp__label {
    position: absolute;
    right: calc(100% + 0.85rem);
    top: 50%;
    display: grid;
    gap: 0.15rem;
    padding: 0.6rem 0.95rem;
    background: var(--kb-forest);
    border: 1px solid rgba(138, 106, 68, 0.55);
    box-shadow: 0 14px 32px rgba(16, 30, 22, 0.26);
    white-space: nowrap;
    text-align: right;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) translateX(0.7rem);
    transition:
        opacity 0.45s var(--kb-ease),
        transform 0.55s var(--kb-ease);
}

.kb-whatsapp__label-title {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--kb-sage-soft);
}

.kb-whatsapp__label-number {
    font-family: var(--kb-font-display);
    font-size: 1.05rem;
    line-height: 1.2;
    color: var(--kb-ivory);
}

/* On a pointer the label comes out and the mark lifts. */
.kb-whatsapp__link:hover .kb-whatsapp__label,
.kb-whatsapp__link:focus-visible .kb-whatsapp__label {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.kb-whatsapp__link:hover .kb-whatsapp__icon,
.kb-whatsapp__link:focus-visible .kb-whatsapp__icon {
    transform: scale(1.12);
}

.kb-whatsapp__link:hover .kb-whatsapp__button,
.kb-whatsapp__link:focus-visible .kb-whatsapp__button {
    box-shadow:
        0 18px 40px rgba(16, 30, 22, 0.34),
        inset 0 1px 0 rgba(247, 245, 239, 0.18);
}

.kb-whatsapp__link:hover .kb-whatsapp__button::before,
.kb-whatsapp__link:focus-visible .kb-whatsapp__button::before {
    inset: -8px;
    opacity: 0.8;
}

/* The focus ring belongs to the link, which is the control. */
.kb-whatsapp__link:focus-visible {
    outline: 2px solid var(--kb-gold);
    outline-offset: 6px;
}

/* On a phone the label is in the way of the page, so it is kept away and
   the button is a little smaller. */
@media (max-width: 640px) {
    .kb-whatsapp__label {
        display: none;
    }

    .kb-whatsapp__button {
        width: 50px;
        height: 50px;
    }
}

/* The footer clears the button, so the strapline is never sat on. */
:root {
    --kb-footer-whatsapp-space: 78px;
}

@media (prefers-reduced-motion: reduce) {

    .kb-whatsapp__button::after {
        animation: none;
        opacity: 0;
    }

    .kb-whatsapp__icon {
        animation: none;
        opacity: 1;
    }

    .kb-whatsapp__icon,
    .kb-whatsapp__label,
    .kb-whatsapp__button,
    .kb-whatsapp__button::before {
        transition-duration: 0.01ms;
    }
}
