/* mySmartPool chat — the Service Hub widget (loaded at the end of base.njk), the
   site's own launcher (built by assets/js/msp-chat.js) and the product-page
   "Need help?" card. Loaded on every page after app.css; the tokens
   (--color-text, --color-accent, --color-teal, --color-surface, --font-base) come from there. */

/* The widget host: its offsets are read through the widget's shadow root. */
[data-shp-chat] { --shp-bottom: 20px; --shp-side: 20px; }
@media (max-width: 599.98px) {
  [data-shp-chat] { --shp-bottom: 16px; --shp-side: 12px; }
}
/* Product pages on phones dock a buy bar to the bottom edge (.pdp-mobile-cta, 88px): sit above it. */
@media (max-width: 768px) {
  body:has(.pdp-mobile-cta) [data-shp-chat] { --shp-bottom: 96px; }
  body:has(.pdp-mobile-cta) .msp-chat-launcher { bottom: 96px; }
}
/* Out of the way while the phone menu or the cart drawer is open. */
body.msp-menu-open [data-shp-chat],
body.msp-menu-open .msp-chat-launcher,
body:has(#cart.cart-open) [data-shp-chat],
body:has(#cart.cart-open) .msp-chat-launcher { display: none; }

/* ---- The launcher: the expert's photo in the brand ring, with a speech bubble ---- */
.msp-chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147482000;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-family: var(--font-base, inherit);
  color: var(--color-text, #1d1d1f);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.35s cubic-bezier(0.25, 0.1, 0.25, 1), transform 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
}
.msp-chat-launcher.is-in { opacity: 1; transform: none; }
/* hidden = gone (the display: flex above would otherwise beat the hidden attribute's display: none) */
.msp-chat-launcher[hidden] { display: none; }
.msp-chat-launcher:focus-visible { outline: none; }
.msp-chat-launcher:focus-visible .msp-chat-launcher__bubble { box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.35), 0 10px 30px rgba(0, 0, 0, 0.12); }

/* the bubble: the header's frosted glass, a message-bubble corner toward the photo */
.msp-chat-launcher__bubble {
  display: grid;
  gap: 3px;
  margin-bottom: 8px;
  padding: 10px 15px 11px;
  border-radius: 18px 18px 5px 18px;
  background: rgba(251, 251, 253, 0.9);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), box-shadow 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), background 0.3s;
}
.msp-chat-launcher__bubble strong {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--color-text, #1d1d1f);
  white-space: nowrap;
}
.msp-chat-launcher__bubble small {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.2;
  color: var(--color-text-secondary, #86868b);
  white-space: nowrap;
}
.msp-chat-launcher__bubble small::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #30d158;
  box-shadow: 0 0 0 2px rgba(48, 209, 88, 0.22);
}
.msp-chat-launcher:hover .msp-chat-launcher__bubble,
.msp-chat-launcher:focus-visible .msp-chat-launcher__bubble {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.96);
}

/* the photo: the brand's teal-to-blue ring (the logo's wave colours), a chat badge */
.msp-chat-launcher__photo {
  position: relative;
  flex: none;
  width: 60px;
  height: 60px;
  padding: 3px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-teal, #00778b) 0%, var(--color-accent, #0071e3) 55%, #9acade 100%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), box-shadow 0.3s;
}
.msp-chat-launcher__photo img {
  display: block;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 28%;
  border: 2px solid #fff;
  background: #e9e9ee;
  box-sizing: border-box;
}
.msp-chat-launcher__badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-accent, #0071e3);
  border: 2px solid #fff;
  color: #fff;
  box-sizing: border-box;
}
.msp-chat-launcher__badge svg { width: 12px; height: 12px; }
.msp-chat-launcher:hover .msp-chat-launcher__photo,
.msp-chat-launcher:focus-visible .msp-chat-launcher__photo {
  transform: scale(1.05);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

@media (max-width: 599.98px) {
  .msp-chat-launcher { right: 12px; bottom: 16px; gap: 8px; }
  .msp-chat-launcher__bubble { margin-bottom: 6px; padding: 9px 13px 10px; }
  .msp-chat-launcher__bubble strong { font-size: 13.5px; }
  .msp-chat-launcher__bubble small { font-size: 12px; }
  .msp-chat-launcher__photo { width: 54px; height: 54px; }
  .msp-chat-launcher__photo img { width: 48px; height: 48px; }
  .msp-chat-launcher__badge { width: 22px; height: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .msp-chat-launcher,
  .msp-chat-launcher__bubble,
  .msp-chat-launcher__photo { transition: none; }
}

/* ---- Product pages: the "Need help?" card under the buy box ---- */
/* (products/simple-pdp.njk + products/ico-pool.njk — the first Pool Expert's face + one line,
   the whole card opens the chat; it sits with the trust pills, in their light surface and radius.) */
.pp-help-cta {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0.75rem 0 0;
  padding: 10px 16px 10px 10px;
  border-radius: 12px;
  background: var(--color-surface, #f5f5f7);
  border: 1px solid transparent;
  color: var(--color-text, #1d1d1f);
  font-size: 14px;
  line-height: 1.35;
  text-decoration: none;
  transition: background 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), border-color 0.3s, transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), box-shadow 0.3s;
}
.pp-help-cta:hover,
.pp-help-cta:focus-visible {
  transform: translateY(-1px);
  background: #eef4fb;
  border-color: rgba(0, 113, 227, 0.35);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.06);
  color: var(--color-text, #1d1d1f);
  text-decoration: none;
  outline: none;
}
.pp-help-cta .pp-help-face {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 28%;
  border: 2px solid #fff;
  background: #e9e9ee;
  box-shadow: 0 0 0 2px var(--color-teal, #00778b);
}
.pp-help-text { min-width: 0; }
.pp-help-text strong { font-weight: 600; }
.pp-help-arrow { color: var(--color-accent, #0071e3); font-weight: 600; margin-left: 2px; }

/* An in-copy chat link (the ICO page's "Expert Support" line). */
.msp-chat-link { color: var(--color-accent, #0071e3); font-weight: 500; text-decoration: none; cursor: pointer; }
.msp-chat-link:hover { text-decoration: underline; }
