/* ============================================================
   ZUPI AMBIENT LAYER (prefix: zpa-) — pairs with js/zupi-ambient.js
   Revert: remove this file + js/zupi-ambient.js (+ their 2 tags).
   Features: aurora orbs + film grain, smart glass header,
   magnetic CTAs + double-tick click, WhatsApp-style toasts.
   All motion is transform/opacity only. Full reduced-motion fallback.
   ============================================================ */

/* ────────────────────────────────────────────────────────────
   1. AURORA ORBS + FILM GRAIN
   ──────────────────────────────────────────────────────────── */

/* Host sections get a local stacking context so z-index:-1 orbs
   sit above the section background but below ALL its content. */
.zpa-host { position: relative; isolation: isolate; }

.zpa-aurora {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: -1;
}

.zpa-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    -webkit-filter: blur(90px);
    transform: translate3d(0, 0, 0);
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    animation-direction: alternate;
    animation-play-state: paused; /* runs only while section is on screen */
}
.zpa-aurora.zpa-on .zpa-orb {
    animation-play-state: running;
    will-change: transform;
}

/* Teal orb */
.zpa-orb--a {
    width: 560px; height: 560px;
    top: -12%; left: -8%;
    background: radial-gradient(circle at 50% 50%, rgba(18, 140, 126, 0.10) 0%, rgba(18, 140, 126, 0) 70%);
    animation-name: zpa-drift-a;
    animation-duration: 22s;
}
/* WhatsApp green orb */
.zpa-orb--b {
    width: 480px; height: 480px;
    bottom: -18%; right: -6%;
    background: radial-gradient(circle at 50% 50%, rgba(37, 211, 102, 0.09) 0%, rgba(37, 211, 102, 0) 70%);
    animation-name: zpa-drift-b;
    animation-duration: 25s;
}
/* Pale chat-bubble mint orb (#d9fdd3 is near-white, so higher alpha
   inside the gradient ≈ the same ~6% perceived tint on white) */
.zpa-orb--c {
    width: 420px; height: 420px;
    top: 35%; left: 52%;
    background: radial-gradient(circle at 50% 50%, rgba(217, 253, 211, 0.85) 0%, rgba(217, 253, 211, 0) 70%);
    animation-name: zpa-drift-c;
    animation-duration: 19s;
}

@keyframes zpa-drift-a {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(70px, -50px, 0) scale(1.15); }
}
@keyframes zpa-drift-b {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(-60px, -40px, 0) scale(1.10); }
}
@keyframes zpa-drift-c {
    from { transform: translate3d(0, 0, 0) scale(0.95); }
    to   { transform: translate3d(40px, 50px, 0) scale(1.08); }
}

/* Full-page film grain (static — never animated) */
.zpa-grain {
    position: fixed;
    inset: 0;
    z-index: 99990; /* above toasts (9990/9998), below #zc-demo-overlay (99999) */
    pointer-events: none;
    opacity: 0.035;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='zpaN'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23zpaN)'/%3E%3C/svg%3E");
    background-size: 180px 180px;
}

/* Lighter ambient load on phones */
@media (max-width: 575px) {
    .zpa-orb { filter: blur(60px); -webkit-filter: blur(60px); }
    .zpa-orb--a { width: 320px; height: 320px; }
    .zpa-orb--b { width: 280px; height: 280px; }
    .zpa-orb--c { display: none; }
}

/* ────────────────────────────────────────────────────────────
   2. SMART GLASS HEADER (.zc-header gets zpa-glass / zpa-hide;
      JS appends .zpa-progress inside it)
   ──────────────────────────────────────────────────────────── */

header.zc-header {
    transition:
        transform 0.38s cubic-bezier(0.32, 0.72, 0, 1),
        background-color 0.3s ease,
        box-shadow 0.3s ease,
        border-color 0.3s ease;
}
header.zc-header.zpa-hide {
    transform: translateY(-102%);
}
header.zc-header.zpa-glass {
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(14px) saturate(1.6);
    backdrop-filter: blur(14px) saturate(1.6);
    border-bottom-color: rgba(18, 140, 126, 0.14);
    box-shadow: 0 8px 30px rgba(10, 71, 76, 0.08);
}

.zpa-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: #0F2E2B;
    transform: scaleX(0);
    transform-origin: 0 50%;
    pointer-events: none;
    z-index: 5;
}

/* ────────────────────────────────────────────────────────────
   3. MAGNETIC CTAs + SHINE + DOUBLE-TICK CLICK
      (JS adds .zpa-cta / .zpa-shine to .btn-premium-primary,
       .zc-btn-signup, .cmp-cta-btn; magnetic transform is inline)
   ──────────────────────────────────────────────────────────── */

.zpa-cta { position: relative; overflow: hidden; }

/* Diagonal shine sweep — hover-capable pointers only.
   (.btn-premium-primary is excluded in JS: it already owns an
   ::after sweep in premium-upgrades.css — no double shine.) */
@media (hover: hover) and (pointer: fine) {
    .zpa-shine::before {
        content: "";
        position: absolute;
        top: -35%;
        bottom: -35%;
        left: -10%;
        width: 36%;
        background: linear-gradient(105deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.32) 50%, rgba(255, 255, 255, 0) 100%);
        transform: translateX(-170%) skewX(-20deg);
        pointer-events: none;
    }
    .zpa-shine:hover::before {
        transform: translateX(480%) skewX(-20deg);
        transition: transform 0.65s ease;
    }
}

/* Click press + tick state: label goes transparent, tick overlays */
.zpa-cta.zpa-ticking {
    color: transparent !important;
    transform: scale(0.97) !important;
    transition: transform 0.15s ease !important;
}
.zpa-cta.zpa-ticking * { color: transparent !important; }

.zpa-tick {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8696a0;          /* WhatsApp sent-grey */
    pointer-events: none;
}
.zpa-tick svg { width: 24px; height: 15px; display: block; }
.zpa-tick.zpa-tick--read { color: #53bdeb; }  /* WhatsApp read-blue */

/* ────────────────────────────────────────────────────────────
   4. WHATSAPP-NOTIFICATION TOASTS (#sp-toast + #zc-toast)
      Look only — show/hide stays driven by the existing JS.
   ──────────────────────────────────────────────────────────── */

#sp-toast, div#zc-toast {
    background: #ffffff !important;
    border: 1px solid rgba(18, 140, 126, 0.14) !important;
    border-radius: 16px !important;
    padding: 12px 14px !important;
    box-shadow: 0 12px 40px -8px rgba(11, 87, 78, 0.22), 0 2px 8px rgba(10, 22, 40, 0.06) !important;
}

/* Springy movement for #sp-toast's existing inline translateY toggle
   (beats its inline `transition:all .4s ease`) */
#sp-toast {
    transition: opacity 0.35s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

/* Retire the old left slide-in on #zc-toast; zpa entrance replaces it */
div#zc-toast { animation: none; }

/* Spring slide-in + one subtle rotate wiggle (class added by zpa JS
   when the toasts' own scripts show them; transform/opacity only) */
#sp-toast.zpa-wa-in, div#zc-toast.zpa-wa-in {
    animation: zpa-toast-in 0.6s cubic-bezier(0.3, 1.1, 0.4, 1);
}
@keyframes zpa-toast-in {
    0%   { transform: translateY(18px) scale(0.94) rotate(0deg); }
    55%  { transform: translateY(-4px) scale(1.015) rotate(-1.5deg); }
    78%  { transform: translateY(1px) scale(1) rotate(0.6deg); }
    100% { transform: translateY(0) scale(1) rotate(0deg); }
}

/* WhatsApp-green avatar with app-icon badge dot */
#sp-toast #sp-avatar, #zc-toast .zc-toast-avatar {
    background: linear-gradient(135deg, #25D366, #0F2E2B) !important;
    position: relative !important;
    overflow: visible !important;
}
#sp-toast #sp-avatar::after, #zc-toast .zc-toast-avatar::after {
    content: "";
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    background: #25D366 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath fill='%23ffffff' d='M16 5C9.9 5 5 9.8 5 15.7c0 2.1.6 4.1 1.8 5.8L5.4 27l5.3-1.5c1.7.9 3.6 1.4 5.3 1.4 6.1 0 11-4.8 11-10.7S22.1 5 16 5z'/%3E%3C/svg%3E") center / 9px 9px no-repeat;
}

/* Notification typography: bold name, muted body, 'just now' stamp */
#sp-toast #sp-name, #zc-toast .zc-toast-name {
    font-weight: 700 !important;
    color: #111b21 !important;
}
#sp-toast #sp-action, #zc-toast .zc-toast-msg {
    color: #667781 !important;
}
/* #sp-toast already prints "• just now"; give #zc-toast one too */
#zc-toast .zc-toast-msg::after {
    content: " · just now";
    color: #8696a0;
    font-size: 0.7rem;
}

/* ────────────────────────────────────────────────────────────
   REDUCED MOTION — instant-show, zero motion
   ──────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .zpa-orb { animation: none !important; }
    header.zc-header { transition: none !important; }
    header.zc-header.zpa-hide { transform: none !important; }
    .zpa-progress { transition: none !important; }
    .zpa-shine::before { display: none !important; }
    .zpa-cta.zpa-ticking { transform: none !important; transition: none !important; }
    #sp-toast.zpa-wa-in, div#zc-toast.zpa-wa-in { animation: none !important; }
    #sp-toast { transition: opacity 0.3s ease !important; }
}

/* orchestrator fix: banner's legacy #sp-toast duplicates #zc-toast — hide it */
#sp-toast { display: none !important; }

/* ═══ PERF PATCH (2026-07-29): kill continuous GPU load ═══ */
/* 1. Orb drift OFF everywhere — animating huge blurred layers forces constant
      compositing, and under backdrop-filter glass it recomputes blur per frame */
.zpa-orb, .zpa-aurora.zpa-on .zpa-orb {
    animation: none !important;
    will-change: auto !important;
}
/* 2. Ambient's own orbs are redundant inside glass-pricing (zgp has its own static set) */
#pricing .zpa-aurora { display: none !important; }
/* 3. Grain: mix-blend-mode on a full-viewport fixed layer repaints the whole
      page every scroll frame — plain low-opacity overlay looks the same */
.zpa-grain {
    mix-blend-mode: normal !important;
    opacity: 0.025 !important;
    transform: translateZ(0);
}
/* 4. Glass header: cheaper blur */
header.zc-header.zpa-glass { 
    -webkit-backdrop-filter: blur(9px) !important; 
    backdrop-filter: blur(9px) !important; 
}
