/* ==========================================================================
   Mandit Global — Pip, the scroll guide robot
   A small flying robot that follows the scroll, points at the part of the
   page it is explaining and types the explanation into a glass bubble.
   Namespaced (pip-*) so it can be dropped onto any page.
   ========================================================================== */

/* The section Pip is talking about */
.pip-on {outline: 2px solid rgba(10, 60, 130, 0.8); outline-offset: 10px; border-radius: 14px; box-shadow: 0 0 0 8px rgba(10, 60, 130, 0.07), 0 24px 70px -40px rgba(10, 60, 130, 0.9); transition: outline-color 0.3s var(--ease); 
}

/* ---------- The robot ---------- */
#pip-bot {position: fixed; left: 0; top: 0; width: 96px; z-index: 90; /* under the header and the account bar */
  transform: translate(20px, 140px); transition: transform 1s cubic-bezier(0.5, -0.25, 0.2, 1.2); cursor: pointer; will-change: transform; 
}

#pip-bot .pip-tilt {transition: transform 0.5s ease; transform-origin: 50% 90%;  }
/* Pip stays hidden until the visitor scrolls: without this rule the robot
   paints at the top-left corner over the page and swallows clicks. */
#pip-bot.pip-idle {opacity: 0; visibility: hidden; pointer-events: none;  }
#pip-bot {transition: transform 1s cubic-bezier(0.5, -0.25, 0.2, 1.2);  }
#pip-bot:not(.pip-idle) {opacity: 1; visibility: visible; transition: transform 1s cubic-bezier(0.5, -0.25, 0.2, 1.2), opacity 0.35s ease;  }
#pip-bot.pip-drag {transition: none;  }          /* a drag has to track the pointer 1:1 */
#pip-bot svg {width: 96px; height: auto; display: block; overflow: visible; animation: pipBob 3s ease-in-out infinite; filter: drop-shadow(0 10px 22px rgba(12, 32, 62, 0.3)); }

/* Each new section: Pip lifts off, hovers for a beat and lands back in the
   exact same spot — straight up and straight down, no spinning */
@keyframes pipHop {
  0% { transform: translateY(0); }
  16% { transform: translateY(-52px); }
  38% { transform: translateY(-78px); }
  56% { transform: translateY(-70px); }
  78% { transform: translateY(0); }
  88% { transform: translateY(-13px); }
  100% { transform: translateY(0); }
}
@keyframes pipHopShadow {
  0% { transform: scale(1); opacity: 1; }
  16% { transform: scale(0.7); opacity: 0.5; }
  38% { transform: scale(0.42); opacity: 0.22; }
  56% { transform: scale(0.48); opacity: 0.28; }
  78% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
#pip-bot.hop .pip-body {animation: pipHop 1.15s cubic-bezier(0.34, 1.35, 0.5, 1);  }
#pip-bot.hop .pip-shadow {animation: pipHopShadow 1.15s ease-in-out;  }
#pip-bot .pip-shadow {width: 50px; height: 8px; border-radius: 50%; background: rgba(10, 60, 130, 0.18); margin: -2px auto 0; animation: pipShadow 3s ease-in-out infinite; 
}

@keyframes pipBob { 50% { transform: translateY(-8px); } }
@keyframes pipShadow { 50% { transform: scaleX(0.75); opacity: 0.6; } }

.pip-eyes {transform-box: fill-box; transform-origin: center; animation: pipBlink 4.5s infinite;  }
@keyframes pipBlink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(0.1); } }

.pip-arm-r {transform-box: fill-box; transform-origin: 20% 15%;  }
#pip-bot.talk .pip-arm-r {animation: pipWave 0.5s ease-in-out 3;  }
@keyframes pipWave { 50% { transform: rotate(-35deg); } }

.pip-glow {filter: drop-shadow(0 0 3px #0a7e43);  }

#pip-bot {--pip-f: 0.65;  }
#pip-bot.fly {--pip-f: 1.9;  }
.pip-flame {transform-box: fill-box; transform-origin: 50% 0; animation: pipFlick 0.14s ease-in-out infinite alternate; filter: drop-shadow(0 0 5px rgba(10, 126, 67, 0.8)); 
}
@keyframes pipFlick {
  from { transform: scaleY(calc(var(--pip-f) * 0.8)) scaleX(0.9); }
  to { transform: scaleY(calc(var(--pip-f) * 1.15)) scaleX(1.05); }
}
#pip-bot.fly .pip-shadow {opacity: 0;  }
#pip-bot.fly .pip-tilt {transition-duration: 0.25s;  }

/* Thruster sparks */
.pip-spark {position: fixed; width: 7px; height: 7px; margin: -3px 0 0 -3px; border-radius: 50%; background: #0a7e43; box-shadow: 0 0 10px #0a7e43; pointer-events: none; z-index: 89; animation: pipSpark 0.8s ease-out forwards; 
}
@keyframes pipSpark { to { transform: translate(var(--pip-sx, 0), 34px) scale(0.2); opacity: 0; } }

/* ---------- The bubble ---------- */
.pip-bubble {position: absolute; left: 104px; bottom: 108px; /* sits just above Pip, never runs off the bottom */
  top: auto; width: 280px; max-height: 46vh; overflow-y: auto; padding: 12px 14px; border-radius: 16px 16px 16px 4px; border: 1px solid var(--border-strong); background: rgba(255, 255, 255, 0.97); backdrop-filter: blur(16px) saturate(150%); -webkit-backdrop-filter: blur(16px) saturate(150%); box-shadow: var(--shadow-md); font-size:0.7rem; line-height: 1.55; color: var(--text-soft); pointer-events: none; z-index: 2; 
}

.pip-bubble__title {display: block; margin-bottom: 4px; font-family: var(--font-display); font-size:0.7rem; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 600; color: var(--green-ink); 
}

/* when there is no room on the right, the bubble flips to Pip's left */
.pip-bubble--left {left: auto; right: 104px; border-radius: 16px 16px 4px 16px;  }

/* ---------- The on / off switch ---------- */
#pip-toggle {position: fixed; left: 16px; bottom: 16px; z-index: 95; padding: 9px 15px; border-radius: 999px; border: 1px solid var(--border-strong); background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); color: var(--text-soft); font-family: var(--font-body); font-size:0.7rem; font-weight: 600; cursor: pointer; transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease); 
}
#pip-toggle:hover {color: var(--text); border-color: rgba(10, 60, 130, 0.55); background: rgba(10, 60, 130, 0.16);  }
#pip-toggle:focus-visible {outline: 2px solid var(--brand); outline-offset: 3px;  }

body.pip-off #pip-bot {display: none;  }
body.pip-off .pip-on {outline: none; box-shadow: none;  }

/* ---------- The chat panel ---------- */
.pip-chat {position: fixed; left: 16px; bottom: 64px; width: min(384px, calc(100vw - 32px)); max-height: min(72vh, 540px); display: flex; flex-direction: column; z-index: 96; border-radius: var(--r-lg); border: 1px solid var(--border-strong); background: rgba(255, 255, 255, 0.97); backdrop-filter: blur(20px) saturate(150%); -webkit-backdrop-filter: blur(20px) saturate(150%); box-shadow: var(--shadow-lg); overflow: hidden; opacity: 0; transform: translateY(16px) scale(0.98); pointer-events: none; transition: opacity 0.3s var(--ease), transform 0.3s var(--ease); 
}
.pip-chat.is-open {opacity: 1; transform: none; pointer-events: auto;  }

.pip-chat__head {display: flex; align-items: center; gap: 11px; padding: 13px 14px; border-bottom: 1px solid var(--border); background: rgba(10, 60, 130, 0.06); 
}
.pip-chat__avatar {width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-brand); color: #ffffff; font-family: var(--font-display); font-weight: 700; font-size:0.7rem; flex: 0 0 auto; 
}
.pip-chat__title {font-family: var(--font-display); font-weight: 600; font-size:0.7rem; line-height: 1.2;  }
.pip-chat__sub {font-size:0.7rem; color: var(--muted);  }
.pip-chat__close {margin-left: auto; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; flex: 0 0 auto; transition: color 0.2s var(--ease), border-color 0.2s var(--ease); 
}
.pip-chat__close:hover {color: var(--text); border-color: var(--border-strong);  }
.pip-chat__close svg {width: 14px; height: 14px;  }

.pip-chat__log {flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; 
}

.pip-msg {max-width: 88%; padding: 10px 12px; border-radius: 14px; font-size:0.7rem; line-height: 1.55; 
}
.pip-msg--bot {align-self: flex-start; background: rgba(10, 60, 130, 0.09); border: 1px solid var(--border); border-bottom-left-radius: 4px; color: var(--text-soft); 
}
.pip-msg--user {align-self: flex-end; background: rgba(10, 60, 130, 0.18); border: 1px solid rgba(10, 60, 130, 0.42); border-bottom-right-radius: 4px; color: var(--text); 
}
.pip-msg a {color: var(--green-ink); font-weight: 600;  }
.pip-msg a:hover {text-decoration: none;  }

.pip-msg__go {display: inline-flex; align-items: center; gap: 7px; margin-top: 9px; padding: 7px 13px; border-radius: 999px; border: 1px solid rgba(10, 60, 130, 0.5); background: rgba(10, 60, 130, 0.14); color: var(--text); font-size:0.7rem; font-weight: 600; text-decoration: none; 
}
.pip-msg__go:hover {background: rgba(10, 60, 130, 0.26); text-decoration: none;  }

.pip-typing {display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px;  }
.pip-typing i {width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: pipDot 1.1s ease-in-out infinite; 
}
.pip-typing i:nth-child(2) {animation-delay: 0.15s;  }
.pip-typing i:nth-child(3) {animation-delay: 0.3s;  }
@keyframes pipDot { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.pip-chips {display: flex; flex-wrap: wrap; gap: 7px; padding: 0 14px 4px;  }
.pip-chip {padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: rgba(10, 60, 130, 0.06); color: var(--text-soft); font-size:0.7rem; font-weight: 600; cursor: pointer; transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease); 
}
.pip-chip:hover {color: var(--text); border-color: rgba(10, 60, 130, 0.55); background: rgba(10, 60, 130, 0.16);  }

.pip-chat__form {display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: rgba(10, 60, 130, 0.03); 
}
.pip-chat__input {flex: 1; min-width: 0; padding: 10px 13px; border-radius: 999px; border: 1px solid var(--border); background: rgba(10, 60, 130, 0.06); color: var(--text); font-family: var(--font-body); font-size:0.7rem; 
}
.pip-chat__input::placeholder {color: var(--muted);  }
.pip-chat__input:focus {outline: none; border-color: rgba(10, 60, 130, 0.6);  }
.pip-chat__send {width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; border: 0; background: var(--grad-brand); color: #ffffff; cursor: pointer; flex: 0 0 auto; 
}
.pip-chat__send svg {width: 16px; height: 16px;  }

body.pip-off .pip-chat {display: none;  }

@media (max-width: 620px) {
  .pip-chat { left: 12px; right: 12px; width: auto; bottom: 60px; max-height: 66vh; }
}

/* ---------- Small screens: the bubble sits beside Pip, never over it ---------- */
@media (max-width: 1099px) {
  /* Pip carries a transform, so a fixed child would be sized against Pip and
     collapse to the width of the robot. Keep it absolute and anchor it. */
  .pip-bubble {
    left: auto;
    right: 78px;
    bottom: 26px;
    top: auto;
    width: min(300px, calc(100vw - 108px));
    max-height: 44vh;
    overflow-y: auto;
    border-radius: 16px 16px 4px 16px;
    z-index: 94;
  }
  .pip-bubble--left { right: 68px; }
  #pip-bot { width: 72px; }
  #pip-bot svg { width: 72px; }
  #pip-toggle { left: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  #pip-bot { transition-duration: 0.01s; }
  #pip-bot svg, #pip-bot .pip-shadow, .pip-eyes, .pip-flame { animation: none; }
  #pip-bot.hop .pip-body, #pip-bot.hop .pip-shadow { animation: none; }
  .pip-spark { display: none; }
  .pip-typing i { animation: none; }
}
