/* =========================================================================
   Help chat
   ========================================================================= */
.hsh-chat {
  --chat-red: #ed1c24;
  --chat-red-dark: #c8141b;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  font-family: "Nunito", system-ui, sans-serif;
}
.chat-launcher {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--chat-red);
  color: white;
  display: grid;
  place-items: center;
  box-shadow: 0 14px 30px #ed1c2459;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s;
  position: relative;
}
.chat-launcher:hover {
  transform: scale(1.08) rotate(-6deg);
  background: var(--chat-red-dark);
}
.chat-launcher svg {
  width: 30px;
  height: 30px;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
}
.chat-launcher .chat-icon-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}
.hsh-chat.is-open .chat-icon-open {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}
.hsh-chat.is-open .chat-icon-close {
  opacity: 1;
  transform: none;
}
.motion .hsh-chat:not(.is-open) .chat-launcher::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--chat-red);
  animation: hsh-chat-ping 2.6s ease-out infinite;
}
@keyframes hsh-chat-ping {
  from { transform: scale(1); opacity: 0.7; }
  to { transform: scale(1.6); opacity: 0; }
}

/* Hello bubble */
.chat-hello {
  position: absolute;
  right: 0;
  bottom: 76px;
  white-space: nowrap;
  background: white;
  color: #1a1917;
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 12px 28px #2a1c101f;
  cursor: pointer;
}
.motion .chat-hello:not([hidden]) {
  animation: hsh-chat-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Panel */
.chat-panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  width: 370px;
  height: min(580px, calc(100vh - 140px));
  display: flex;
  flex-direction: column;
  background: #e8f3fd;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 30px 70px #1a191733;
  transform-origin: bottom right;
}
.chat-panel[hidden] {
  display: none !important;
}
.motion .chat-panel:not([hidden]) {
  animation: hsh-chat-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes hsh-chat-pop {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 16px 18px;
  background: var(--chat-red);
  color: white;
}
.chat-head strong {
  display: block;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 17px;
}
.chat-head > div {
  flex: 1;
}
.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #ffffff33;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.chat-avatar svg {
  width: 26px;
  height: 26px;
}
.chat-status .open-status {
  margin-top: 4px;
  padding: 2px 10px;
  font-size: 12px;
  background: #ffffff;
}
.chat-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  line-height: 1;
  background: #ffffff26;
  transition: background 0.2s, transform 0.2s;
}
.chat-close:hover {
  background: #ffffff4d;
  transform: rotate(90deg);
}

/* Messages */
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.45;
}
.chat-msg p {
  color: inherit;
  white-space: pre-line;
}
.chat-msg p + p {
  margin-top: 8px;
}
.chat-msg.bot {
  align-self: flex-start;
  background: white;
  color: #2c2b27;
  border-bottom-left-radius: 6px;
  box-shadow: 0 4px 12px #2a1c100a;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--chat-red);
  color: white;
  border-bottom-right-radius: 6px;
}
.motion .chat-msg {
  animation: hsh-msg-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes hsh-msg-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
.chat-msg.typing {
  display: flex;
  gap: 5px;
  padding: 14px 16px;
}
.chat-msg.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c9c6bd;
  animation: hsh-typing 1s ease-in-out infinite;
}
.chat-msg.typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-msg.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes hsh-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-5px); opacity: 1; }
}
.chat-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chat-links a {
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 13.5px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fdecec;
  color: var(--chat-red);
  transition: background 0.2s, color 0.2s;
}
.chat-links a:hover {
  background: var(--chat-red);
  color: white;
}

/* Quick links */
.chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px 12px;
}
.chat-quick button {
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 13.5px;
  padding: 7px 12px;
  border-radius: 999px;
  background: white;
  border: 1.5px solid #f3c9cb;
  color: #2c2b27;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chat-quick button:hover {
  background: var(--chat-red);
  border-color: var(--chat-red);
  color: white;
  transform: translateY(-2px);
}

/* Input */
.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: white;
  border-top: 1px solid #eeede7;
}
.chat-form input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid #eeede7;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-size: 15px;
  background: #e8f3fd;
  transition: border-color 0.2s, background 0.2s;
}
.chat-form input:focus {
  outline: none;
  border-color: var(--chat-red);
  background: white;
}
.chat-form button {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--chat-red);
  color: white;
  display: grid;
  place-items: center;
  transition: transform 0.2s, background 0.2s;
}
.chat-form button:hover {
  background: var(--chat-red-dark);
  transform: rotate(-12deg);
}
.chat-form button svg {
  width: 20px;
  height: 20px;
}
.chat-callbar {
  display: block;
  text-align: center;
  padding: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--chat-red);
  background: white;
  border-top: 1px dashed #f3c9cb;
}
.chat-callbar:hover {
  background: #fdecec;
}

/* Make room for the chat button: rocket and call buttons sit above it. */
/* Desktop: rocket "back to top" sits in the bottom-left corner. */
@media (min-width: 701px) {
  .to-top {
    left: 24px !important;
    right: auto !important;
    bottom: 24px !important;
  }
}
@media (max-width: 700px) {
  .hsh-chat {
    right: 16px;
    bottom: 16px;
  }
  .chat-launcher {
    width: 56px;
    height: 56px;
  }
  .mobile-call {
    right: 16px !important;
    bottom: 84px !important;
    width: 50px !important;
    height: 50px !important;
  }
  .chat-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 82px;
    width: auto;
    height: min(76vh, 600px);
  }
  .hsh-chat.is-open ~ .mobile-call,
  body:has(.hsh-chat.is-open) .mobile-call,
  body:has(.hsh-chat.is-open) .to-top {
    display: none !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  .chat-msg.typing span {
    animation: none;
  }
}


/* =========================================================================
   Lily the Ladybug: chat button, avatar and the 10-second pop-out wave
   ========================================================================= */
.chat-launcher {
  width: 74px;
  height: 74px;
  background: white;
  border: 3px solid #ed1c24;
  overflow: visible;
}
.chat-launcher:hover {
  background: white;
  transform: scale(1.06);
}
.chat-mascot {
  position: relative;
  display: block;
  width: 54px;
  height: 66px;
  margin-top: -14px;
  transform-origin: 50% 90%;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
}
.chat-mascot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 4px #00000026);
}
.chat-launcher:hover .chat-mascot {
  transform: rotate(-8deg) translateY(-3px);
}
/* Gentle idle bob so Lily feels alive. */
.motion .hsh-chat:not(.is-open):not(.peeking) .chat-mascot {
  animation: mascot-bob 3.2s ease-in-out infinite;
}
@keyframes mascot-bob {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-4px) rotate(3deg); }
}
.hsh-chat.is-open .chat-mascot {
  opacity: 0;
  transform: scale(0.4);
}
.hsh-chat.is-open .chat-launcher {
  background: #ed1c24;
}
.chat-launcher .chat-icon-close {
  color: white;
}
.mascot-wave {
  position: absolute;
  right: -16px;
  top: 4px;
  font-size: 22px;
  opacity: 0;
  transform-origin: 70% 80%;
  pointer-events: none;
}

/* Pop-out: Lily jumps up, wiggles and waves, and says something kind. */
.hsh-chat.peeking .chat-launcher::after {
  display: none;
}
.motion .hsh-chat.peeking .chat-mascot {
  animation: mascot-jump 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) both, mascot-wiggle 1.4s ease-in-out 0.9s 3;
}
.hsh-chat.peeking .chat-mascot {
  transform: translateY(-22px) scale(1.35);
}
@keyframes mascot-jump {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-40px) scale(1.4) rotate(-6deg); }
  70% { transform: translateY(-16px) scale(1.3) rotate(4deg); }
  100% { transform: translateY(-22px) scale(1.35); }
}
@keyframes mascot-wiggle {
  0%, 100% { transform: translateY(-22px) scale(1.35) rotate(0); }
  25% { transform: translateY(-24px) scale(1.35) rotate(-9deg); }
  75% { transform: translateY(-24px) scale(1.35) rotate(9deg); }
}
.hsh-chat.peeking .mascot-wave {
  opacity: 1;
}
.motion .hsh-chat.peeking .mascot-wave {
  animation: mascot-hand 0.5s ease-in-out 0.9s 8 alternate;
}
@keyframes mascot-hand {
  from { transform: rotate(-20deg); }
  to { transform: rotate(25deg); }
}

.chat-peek {
  position: absolute;
  right: 6px;
  bottom: 118px;
  width: 260px;
  padding: 18px 18px 16px;
  background: white;
  border-radius: 20px 20px 6px 20px;
  box-shadow: 0 20px 44px #2a1c1026;
  border: 2px solid #fdecec;
}
.chat-peek::after {
  content: "";
  position: absolute;
  right: 34px;
  bottom: -11px;
  width: 20px;
  height: 20px;
  background: white;
  border-right: 2px solid #fdecec;
  border-bottom: 2px solid #fdecec;
  transform: rotate(45deg);
}
.motion .chat-peek:not([hidden]) {
  animation: mascot-bubble 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.45s both;
}
@keyframes mascot-bubble {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.85);
  }
}
.chat-peek-text {
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 17px;
  line-height: 1.35;
  color: #1a1917;
  padding-right: 18px;
}
.chat-peek-open {
  margin-top: 12px;
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 15px;
  padding: 8px 16px;
  border-radius: 999px;
  background: #ed1c24;
  color: white;
  transition: background 0.2s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chat-peek-open:hover {
  background: #c8141b;
  transform: translateX(3px);
}
.chat-peek-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  color: #4a4e55;
  transition: background 0.2s, color 0.2s;
}
.chat-peek-close:hover {
  background: #e8f3fd;
  color: #1a1917;
}

/* Chat header avatar */
.chat-avatar {
  background: white;
  overflow: hidden;
}
.chat-avatar img {
  width: 32px;
  height: 40px;
  object-fit: contain;
  margin-top: 8px;
}

@media (max-width: 700px) {
  .chat-launcher {
    width: 64px;
    height: 64px;
  }
  .chat-mascot {
    width: 46px;
    height: 58px;
    margin-top: -12px;
  }
  .mobile-call {
    bottom: 92px !important;
  }
  .chat-peek {
    right: 0;
    bottom: 104px;
    width: min(260px, calc(100vw - 32px));
  }
}
@media (prefers-reduced-motion: reduce) {
  .hsh-chat.peeking .chat-mascot {
    transform: none;
  }
}


/* Phones: Lily and the chat sit on the LEFT; call and rocket on the right. */
@media (max-width: 700px) {
  .hsh-chat {
    right: auto !important;
    left: 16px !important;
    bottom: 16px;
  }
  .chat-panel {
    left: 10px;
    right: 10px;
    transform-origin: bottom left;
  }
  .chat-peek {
    right: auto !important;
    left: 0 !important;
    border-radius: 20px 20px 20px 6px;
  }
  .chat-peek::after {
    right: auto;
    left: 26px;
    border-right: 0;
    border-bottom: 2px solid #fdecec;
    border-left: 2px solid #fdecec;
    transform: rotate(-45deg);
  }
  .mascot-wave {
    right: auto;
    left: -16px;
    transform: scaleX(-1);
  }
  .mobile-call {
    right: 16px !important;
    left: auto !important;
    bottom: 16px !important;
    width: 56px !important;
    height: 56px !important;
  }
  .to-top {
    left: auto !important;
    right: 18px !important;
    bottom: 86px !important;
  }
}
