/* ============================================================
   Floating site widgets (every public page)

   Two controls pinned to the bottom-right corner:
   · Back to top — appears once the page is scrolled, with a ring
     that fills as the visitor reads.
   · WhatsApp composer — opens a small chat panel; sending hands
     the typed message to WhatsApp.

   Kept at z-index 90 so the mobile drawer (105) and the toast rail
   (2000) always win.
   ============================================================ */

.site-fabs {
    position: fixed;
    right: clamp(0.9rem, 2.4vw, 1.6rem);
    bottom: clamp(0.9rem, 2.4vw, 1.6rem);
    z-index: 90;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.7rem;
    transition: opacity 0.3s;
}

/* The drawer backdrop covers them, but fading out is cleaner. */
.nav-open .site-fabs {
    opacity: 0;
    pointer-events: none;
}

/* ---------- Back to top ---------- */
.to-top {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: #fff;
    color: var(--main);
    font-size: 1.05rem;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(var(--panel-rgb), 0.16);
    /* Hidden until the page is scrolled — slides and scales into place. */
    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(0.82);
    transition:
        opacity 0.3s,
        transform 0.35s cubic-bezier(0.2, 0, 0, 1),
        visibility 0.3s,
        background 0.25s,
        border-color 0.25s,
        color 0.25s,
        box-shadow 0.25s;
}

.to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.to-top:hover {
    background: var(--main);
    border-color: var(--main);
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 16px 32px rgba(var(--main-rgb), 0.34);
}

.to-top:focus-visible {
    outline: 2px solid var(--main);
    outline-offset: 3px;
}

.to-top-ring {
    position: absolute;
    inset: -1px;
    width: calc(100% + 2px);
    height: calc(100% + 2px);
    transform: rotate(-90deg);
    pointer-events: none;
}

.to-top-track,
.to-top-progress {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
}

.to-top-track {
    stroke: rgba(var(--main-rgb), 0.18);
}

.to-top-progress {
    stroke: var(--main);
    transition: stroke-dashoffset 0.12s linear, stroke 0.25s;
}

/* On the gold hover the gold ring would vanish, so it flips to white. */
.to-top:hover .to-top-track {
    stroke: rgba(255, 255, 255, 0.34);
}

.to-top:hover .to-top-progress {
    stroke: #fff;
}

/* ---------- WhatsApp composer ---------- */
.wa-widget {
    position: relative;
}

.wa-launcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(140deg, #34e07a, #25d366 45%, #128c7e);
    color: #fff;
    font-size: 1.6rem;
    cursor: pointer;
    box-shadow: 0 14px 30px rgba(18, 140, 126, 0.34);
    transition: transform 0.28s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.28s;
}

.wa-launcher:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 18px 38px rgba(18, 140, 126, 0.44);
}

.wa-launcher:focus-visible {
    outline: 2px solid #128c7e;
    outline-offset: 3px;
}

/* Soft halo so the button reads as tappable without shouting. */
.wa-launcher::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: rgba(37, 211, 102, 0.45);
    animation: waPulse 2.8s ease-out infinite;
    pointer-events: none;
}

@keyframes waPulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    70%,
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* The two icons cross-fade; the halo stops once the panel is open. */
.wa-launcher i {
    position: absolute;
    transition: opacity 0.24s, transform 0.3s cubic-bezier(0.2, 0, 0, 1);
}

.wa-launcher .wa-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}

.wa-widget.is-open .wa-launcher::before {
    animation: none;
    opacity: 0;
}

.wa-widget.is-open .wa-icon-wa {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}

.wa-widget.is-open .wa-icon-close {
    opacity: 1;
    transform: none;
}

.wa-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.85rem);
    width: min(360px, calc(100vw - 2rem));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 26px 60px rgba(var(--secondary-rgb), 0.3);
    transform-origin: bottom right;
    animation: waOpen 0.32s cubic-bezier(0.2, 0, 0, 1) both;
}

.wa-panel[hidden] {
    display: none;
}

@keyframes waOpen {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.wa-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #128c7e, #075e54);
    color: #fff;
}

.wa-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
}

.wa-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wa-head-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.wa-head-text strong {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: #fff;
}

.wa-head-text small {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.82);
}

.wa-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.22);
}

/* Outside opening hours the same dot goes quiet rather than disappearing, so
   the panel always states the current availability. */
.wa-status-dot.is-offline {
    background: #b9c0c6;
    box-shadow: 0 0 0 3px rgba(185, 192, 198, 0.22);
}

/* Availability mirror on the launcher itself: a small dot pinned to the edge. */
.wa-launcher-status {
    position: absolute;
    right: 1px;
    bottom: 1px;
    z-index: 2;
    width: 13px;
    height: 13px;
    border: 2px solid #fff;
    border-radius: 50%;
}

.wa-launcher-status.is-online {
    background: #22c55e;
}

.wa-launcher-status.is-offline {
    background: #9ca3af;
}

.wa-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    margin-left: auto;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.25s, transform 0.25s;
}

.wa-close:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: rotate(90deg);
}

.wa-body {
    display: grid;
    gap: 0.6rem;
    max-height: 200px;
    overflow-y: auto;
    padding: 1.1rem;
    background:
        radial-gradient(circle at 18% 12%, rgba(37, 211, 102, 0.07), transparent 46%),
        #eff3f1;
}

.wa-bubble {
    max-width: 84%;
    padding: 0.7rem 0.85rem 0.55rem;
    border-radius: 14px 14px 14px 4px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.wa-bubble p {
    margin: 0 0 0.2rem;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--secondary);
}

.wa-time {
    font-size: 0.68rem;
    color: var(--muted);
}

.wa-hint {
    margin: 0;
    font-size: 0.76rem;
    line-height: 1.5;
    text-align: center;
    color: var(--muted);
}

.wa-form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.7rem;
    border-top: 1px solid var(--border);
    background: #fff;
}

.wa-form textarea {
    flex: 1 1 auto;
    min-width: 0;
    max-height: 96px;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-soft);
    font-family: var(--font-body);
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--secondary);
    resize: none;
    overflow-y: auto;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.wa-form textarea:focus {
    outline: none;
    border-color: #25d366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.18);
}

.wa-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(140deg, #34e07a, #25d366);
    color: #fff;
    font-size: 1.05rem;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.32);
    transition: transform 0.24s, box-shadow 0.24s;
}

.wa-send:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 10px 22px rgba(37, 211, 102, 0.42);
}

.wa-send:focus-visible {
    outline: 2px solid #128c7e;
    outline-offset: 2px;
}

/* Nudge when Send is pressed with nothing typed. */
.wa-form.is-nudge {
    animation: waNudge 0.4s;
}

@keyframes waNudge {
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .to-top {
        width: 42px;
        height: 42px;
    }

    .wa-launcher {
        width: 52px;
        height: 52px;
        font-size: 1.45rem;
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .site-fabs,
    .to-top,
    .wa-launcher,
    .wa-launcher i,
    .wa-send,
    .to-top-progress {
        transition: none;
    }

    .wa-launcher::before,
    .wa-panel,
    .wa-form.is-nudge {
        animation: none;
    }

    .wa-launcher::before {
        opacity: 0;
    }
}
