/* CUSTOMER ASSISTANT DEMO (Founder 2026-11-02): the chat bubble. Bottom left, so it never covers the review button. */
.wf-chat-launcher {
    position: fixed;
    left: 2rem;
    bottom: 2rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    box-sizing: border-box;
    height: 48px; /* Irvine 2026-11-23: the same height as the WhatsApp button, so the two sit level */
    padding: 0 1.25rem;
    border-radius: 50px;
    border: 1px solid rgba(124, 58, 237, 0.55);
    background: rgba(8, 10, 15, 0.8);
    /* 2026-11-19 (speed): no backdrop blur; a little more opaque instead */
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #f0f6fc);
    font-family: var(--font-display, 'Outfit', sans-serif);
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.4s, border-color 0.25s, box-shadow 0.25s;
    animation: wf-chat-launch 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.8s both;
}
@keyframes wf-chat-launch { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
/* Waits while the privacy choice is open, then glides in once it's answered. */
body:has(.webfly-consent:not([hidden])) .wf-chat-launcher { opacity: 0; visibility: hidden; transform: translateY(14px); pointer-events: none; }
.wf-chat-launcher:hover { transform: translateY(-2px); border-color: rgba(167, 139, 250, 0.9); }
.wf-chat-launcher:focus-visible, .wf-chat button:focus-visible, .wf-chat textarea:focus-visible { outline: 2px solid var(--accent-cyan, #22d3ee); outline-offset: 2px; }
.wf-chat-launcher .wf-chat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-cyan, #22d3ee); box-shadow: 0 0 10px rgba(34, 211, 238, 0.8); }
.wf-chat-launcher .wf-chat-icon { display: none; }
.wf-chat-launcher[aria-expanded="true"] { opacity: 0; pointer-events: none; transform: translateY(8px); }

.wf-chat {
    position: fixed;
    left: 2rem;
    bottom: 2rem;
    z-index: 1001;
    width: min(380px, calc(100vw - 2rem));
    height: min(560px, calc(100dvh - 4rem));
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-panel, 16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(6, 8, 13, 0.96);
    /* 2026-11-19 (speed): no backdrop blur (the panel is already 96% opaque) */
    box-shadow: var(--shadow-panel, 0 24px 60px rgba(0, 0, 0, 0.45)), 0 0 0 1px rgba(124, 58, 237, 0.15);
    color: var(--text-primary, #f0f6fc);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow: hidden;
    transform-origin: bottom left;
    animation: wf-chat-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.wf-chat[hidden] { display: none; }
@keyframes wf-chat-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }

.wf-chat-head { display: flex; align-items: center; gap: 0.75rem; padding: 1rem 1.1rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.wf-chat-head img { width: 30px; height: 30px; border-radius: 8px; }
.wf-chat-title { flex: 1; min-width: 0; }
.wf-chat-title strong { display: block; font-family: var(--font-display, 'Outfit', sans-serif); font-size: 0.98rem; font-weight: 600; }
.wf-chat-title span { display: block; color: var(--text-secondary, #8b949e); font-size: 0.75rem; }
.wf-chat-close { background: none; border: 0; color: var(--text-secondary, #8b949e); font-size: 1.4rem; line-height: 1; padding: 0.25rem 0.4rem; cursor: pointer; border-radius: 6px; }
.wf-chat-close:hover { color: var(--text-primary, #f0f6fc); }

.wf-chat-log { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.6rem; overscroll-behavior: contain; }
.wf-chat-msg { max-width: 85%; padding: 0.65rem 0.85rem; border-radius: 12px; font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.wf-chat-msg.bot { align-self: flex-start; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.07); border-bottom-left-radius: 4px; }
.wf-chat-msg.you { align-self: flex-end; background: rgba(6, 182, 212, 0.16); border: 1px solid rgba(6, 182, 212, 0.3); border-bottom-right-radius: 4px; }
.wf-chat-msg.note { align-self: center; max-width: 100%; background: none; color: var(--text-secondary, #8b949e); font-size: 0.8rem; text-align: center; padding: 0.2rem; }
.wf-chat-typing { display: inline-flex; gap: 4px; }
.wf-chat-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-secondary, #8b949e); animation: wf-chat-dot 1.1s infinite ease-in-out; }
.wf-chat-typing i:nth-child(2) { animation-delay: 0.15s; }
.wf-chat-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes wf-chat-dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.wf-chat-form { display: flex; gap: 0.5rem; padding: 0.75rem 0.9rem 0.4rem; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.wf-chat-form textarea {
    flex: 1; resize: none; min-height: 42px; max-height: 110px; padding: 0.6rem 0.75rem;
    border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary, #f0f6fc); font: inherit; font-size: 16px; line-height: 1.4;
}
.wf-chat-form textarea::placeholder { color: var(--text-muted, #6e7681); }
.wf-chat-send {
    align-self: flex-end; height: 42px; padding: 0 1rem; border: 0; border-radius: 10px; cursor: pointer;
    background: var(--accent-blue, #06b6d4); color: var(--btn-ink, #001018); font-weight: 600; font-size: 0.88rem;
}
.wf-chat-send:disabled { opacity: 0.45; cursor: default; }
.wf-chat-foot { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.35rem 1rem 0.75rem; font-size: 0.72rem; color: var(--text-muted, #6e7681); }
.wf-chat-foot a { color: var(--text-secondary, #8b949e); text-decoration: underline; text-underline-offset: 2px; }
.wf-chat-foot strong { color: var(--text-secondary, #8b949e); font-weight: 600; }

@media (max-width: 600px) {
    /* Phone (Founder 2026-11-10: the pill sat over the first service card's heading): a small round button; the words stay for screen readers. */
    .wf-chat-launcher { left: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); width: 3.25rem; height: 3.25rem; padding: 0; justify-content: center; gap: 0; }
    .wf-chat-launcher .wf-chat-icon { display: block; }
    .wf-chat-launcher .wf-chat-dot { position: absolute; top: 0.35rem; right: 0.35rem; }
    .wf-chat-launcher .wf-chat-label { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .wf-chat { left: 0.5rem; right: 0.5rem; bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px)); width: auto; height: min(560px, calc(100dvh - 1rem)); }
}
@media (prefers-reduced-motion: reduce) {
    .wf-chat, .wf-chat-typing i { animation: none; }
    .wf-chat-launcher { transition: none; animation: none; }
}

/* PHASE 0 (2026-11-18 audit): WhatsApp, bottom right. On a phone the chat button and WhatsApp both rise above the
   sticky estimate bar while it shows, so neither covers the price. */
.wf-whatsapp {
    position: fixed;
    right: 2rem;
    bottom: 2rem; /* Irvine 2026-11-23: level with the Ask Webfly button (the review button it used to sit above is gone) */
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-sizing: border-box;
    height: 48px; /* level with the Ask Webfly button */
    padding: 0.7rem 1.1rem;
    border-radius: 50px;
    background: #128c4a;
    color: #fff;
    font-family: var(--font-display, 'Outfit', sans-serif);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.wf-whatsapp:hover { transform: translateY(-2px); }
.wf-whatsapp:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
body:has(.webfly-consent:not([hidden])) .wf-whatsapp { visibility: hidden; }
body:has(.review-drawer-overlay.is-open) .wf-whatsapp, body:has(.wf-chat:not([hidden])) .wf-whatsapp { visibility: hidden; }
@media (max-width: 768px) {
    .wf-whatsapp { bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); right: 1rem; }
}
@media (max-width: 600px) {
    .wf-whatsapp { right: 1rem; width: 52px; height: 52px; padding: 0; justify-content: center; }
    .wf-whatsapp-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    body:has(.mobile-estimate-bar.is-visible) .wf-whatsapp,
    body:has(.mobile-estimate-bar.is-visible) .wf-chat-launcher { bottom: calc(5.75rem + env(safe-area-inset-bottom, 0px)); }
}

/* Homepage on phones (2026-11-19): the chat and WhatsApp buttons wait while the hero's own buttons are on screen, then
   fade in (craft.js sets html.ht-cta-visible). On the homepage the launcher's entrance animation is off on phones,
   because its "both" fill would pin opacity and transform and the fade would never show. */
@media (max-width: 640px) {
    html:has(#hero-type) .wf-chat-launcher { animation: none; }
    html:has(#hero-type) .wf-whatsapp { transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s; }
    html.ht-cta-visible .wf-chat-launcher,
    html.ht-cta-visible .wf-whatsapp { opacity: 0; visibility: hidden; transform: translateY(14px); pointer-events: none; animation: none; }
}
/* Homepage on bigger screens (Irvine 2026-11-23): WhatsApp waits while the hero's own buttons are on screen, then fades
   in; the Ask Webfly button stays. */
@media (min-width: 641px) {
    html:has(#hero-type) .wf-whatsapp { transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s; }
    html.ht-cta-visible .wf-whatsapp { opacity: 0; visibility: hidden; transform: translateY(14px); pointer-events: none; }
}
@media (min-width: 641px) and (prefers-reduced-motion: reduce) {
    html:has(#hero-type) .wf-whatsapp { transition: none; }
    html.ht-cta-visible .wf-whatsapp { transform: none; }
}
@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
    html:has(#hero-type) .wf-whatsapp { transition: none; }
    html.ht-cta-visible .wf-chat-launcher, html.ht-cta-visible .wf-whatsapp { transform: none; }
}

/* Phones: the chat and WhatsApp buttons step aside while a form button is on screen or a field has focus
   (site-assistant.js sets html.wf-float-off), so they never cover "Send me the report" or any other button. */
@media (max-width: 768px) {
    .wf-whatsapp { transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, visibility 0.3s; }
    html.wf-float-off .wf-chat-launcher,
    html.wf-float-off .wf-whatsapp { opacity: 0; visibility: hidden; transform: translateY(14px); pointer-events: none; animation: none; }
}
@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    .wf-whatsapp { transition: none; }
    html.wf-float-off .wf-chat-launcher, html.wf-float-off .wf-whatsapp { transform: none; }
}

/* Phones (Irvine 2026-11-23): while you read down the page the chat and WhatsApp buttons slide off the bottom edge,
   so they never sit on text, and glide back as soon as scrolling pauses or turns up (script.js sets html.float-tuck). */
@media (max-width: 640px) {
    .wf-whatsapp { transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.35s; }
    html.float-tuck .wf-chat-launcher,
    html.float-tuck .wf-whatsapp { transform: translateY(calc(100% + 1.5rem)); opacity: 0; pointer-events: none; }
}
@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
    html.float-tuck .wf-chat-launcher, html.float-tuck .wf-whatsapp { transform: none; }
}

/* Smaller laptops (Irvine 2026-11-23): on the homepage's first screen the Ask Webfly button shows as its round icon
   only, so it never touches the hero text; it opens out to "Ask Webfly" once you scroll. */
@media (min-width: 641px) and (max-width: 1500px) {
    html.ht-cta-visible .wf-chat-launcher { width: 48px; padding: 0; justify-content: center; gap: 0; }
    html.ht-cta-visible .wf-chat-launcher .wf-chat-label { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    html.ht-cta-visible .wf-chat-launcher .wf-chat-dot { position: absolute; top: 0.3rem; right: 0.3rem; }
    html.ht-cta-visible .wf-chat-launcher .wf-chat-icon { display: block; }
}
