/* Docs assistant — floating chat widget for the gated microsite pages.
 *
 * A floating chat widget built in plain CSS:
 *   - the launcher is a pure-CSS orb (no assets)
 *   - bubble geometry and the composer pill follow a standard chat layout
 *     (no external assets)
 * Design note: rather than docking the chat as a right-hand
 * column of an app shell, this is a floating
 * panel anchored to the same bottom-right corner as the launcher.
 *
 * Every colour is an existing --hx-* / --glass-* token from css/semantic-tokens.css,
 * which each gated page already loads. No new tokens, and the light-mode block in
 * that file re-points them, so the widget follows the page theme for free.
 */

:root {
  --hx-asst-width: 400px;
  --hx-asst-radius: 14px;
  --hx-asst-z: 9000;
}

/* ─── Launcher orb (pure CSS, button variant, md size) ─── */

.hx-asst-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--hx-asst-z);
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: 50%;
  overflow: hidden;
  isolation: isolate;
  cursor: pointer;
  background: var(--hx-canvas);
  --hx-orb-blur-base: 3px;
  box-shadow:
    0 0 30px rgba(29, 184, 242, 0.22),
    0 0 0 1.5px rgba(0, 88, 171, 0.55),
    0 4px 16px rgba(0, 88, 171, 0.3);
  transition:
    transform 180ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 180ms cubic-bezier(0.4, 0, 0.2, 1),
    opacity 180ms ease;
}

.hx-asst-launcher:hover {
  transform: scale(1.06);
  box-shadow:
    0 0 0 2px rgba(29, 184, 242, 0.65),
    0 6px 24px rgba(29, 184, 242, 0.4),
    0 0 32px rgba(0, 205, 195, 0.2);
}

.hx-asst-launcher:active { transform: scale(0.97); }

.hx-asst-launcher:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(29, 184, 242, 0.75),
    0 4px 20px rgba(29, 184, 242, 0.35);
}

.hx-asst-launcher[hidden],
.hx-asst-panel[hidden] { display: none; }

.hx-asst-orb {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  background: var(--hx-canvas);
}

.hx-asst-blob {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(var(--hx-orb-blur-base, 3px));
}

/* Capgemini blue. The platform reads --hx-obscurus-blob-1 here; the microsite
   token set does not define it, so the brand value is inlined as a fallback. */
.hx-asst-blob--1 {
  width: 85%; height: 85%; top: 7%; left: 7%;
  background: radial-gradient(ellipse,
    color-mix(in srgb, var(--hx-obscurus-blob-1, var(--brand-primary, #0058ab)) 70%, transparent) 0%,
    color-mix(in srgb, var(--hx-obscurus-blob-1, var(--brand-primary, #0058ab)) 32%, transparent) 50%,
    transparent 72%);
  animation: hxAsstBlob1 19s ease-in-out infinite alternate;
}
.hx-asst-blob--2 {
  width: 70%; height: 70%; top: 15%; left: 15%;
  background: radial-gradient(ellipse, rgba(255, 75, 5, 0.75) 0%, rgba(210, 45, 0, 0.34) 50%, transparent 72%);
  animation: hxAsstBlob2 14s ease-in-out infinite alternate -4s;
}
.hx-asst-blob--3 {
  width: 70%; height: 70%; top: 15%; left: 15%;
  background: radial-gradient(ellipse, rgba(40, 160, 255, 0.68) 0%, rgba(20, 110, 230, 0.28) 50%, transparent 72%);
  animation: hxAsstBlob3 22s ease-in-out infinite alternate -8s;
}
.hx-asst-blob--4 {
  width: 65%; height: 65%; top: 17%; left: 17%;
  background: radial-gradient(ellipse, rgba(0, 205, 195, 0.62) 0%, rgba(0, 165, 175, 0.26) 50%, transparent 72%);
  animation: hxAsstBlob4 17s ease-in-out infinite alternate -2s;
}
.hx-asst-blob--core {
  width: 38%; height: 38%; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse, rgba(210, 245, 255, 0.92) 0%, rgba(130, 220, 255, 0.5) 40%, transparent 72%);
  filter: blur(calc(var(--hx-orb-blur-base, 3px) * 0.6));
  animation: hxAsstCore 11s ease-in-out infinite alternate -6s;
}

.hx-asst-launcher:hover .hx-asst-blob--1 { animation-duration: 11s; }
.hx-asst-launcher:hover .hx-asst-blob--2 { animation-duration: 8s; }
.hx-asst-launcher:hover .hx-asst-blob--3 { animation-duration: 13s; }
.hx-asst-launcher:hover .hx-asst-blob--4 { animation-duration: 10s; }
.hx-asst-launcher:hover .hx-asst-blob--core { animation-duration: 6s; }

/* Spherical rim + top-left gloss, matching the platform orb. */
.hx-asst-orb::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%, transparent 55%,
      color-mix(in srgb, var(--hx-canvas) 10%, transparent) 78%,
      color-mix(in srgb, var(--hx-canvas) 30%, transparent) 100%),
    radial-gradient(ellipse 40% 28% at 35% 28%, rgba(255, 255, 255, 0.07) 0%, transparent 100%);
}

@keyframes hxAsstBlob1 {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(14%, -10%) scale(1.07); }
  66%  { transform: translate(-8%, 13%) scale(0.93); }
  100% { transform: translate(10%, 6%) scale(1.04); }
}
@keyframes hxAsstBlob2 {
  0%   { transform: translate(0, 0) scale(1.05); }
  33%  { transform: translate(-16%, 11%) scale(0.89); }
  66%  { transform: translate(11%, -16%) scale(1.11); }
  100% { transform: translate(-6%, -8%) scale(0.96); }
}
@keyframes hxAsstBlob3 {
  0%   { transform: translate(0, 0) scale(0.94); }
  33%  { transform: translate(9%, 16%) scale(1.09); }
  66%  { transform: translate(-13%, -9%) scale(0.91); }
  100% { transform: translate(5%, -12%) scale(1.05); }
}
@keyframes hxAsstBlob4 {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(-11%, -13%) scale(1.07); }
  66%  { transform: translate(15%, 7%) scale(0.92); }
  100% { transform: translate(-4%, 14%) scale(1.03); }
}
@keyframes hxAsstCore {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 0.85; }
  50%  { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.94); opacity: 0.78; }
}

/* ─── Panel ─── */

.hx-asst-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--hx-asst-z);
  display: flex;
  flex-direction: column;
  width: var(--hx-asst-width);
  height: min(640px, calc(100vh - 40px));
  border-radius: var(--hx-asst-radius);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.42);
  overflow: hidden;
  font-family: var(--font-label, "Ubuntu", sans-serif);
  animation: hxAsstPanelIn 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes hxAsstPanelIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.hx-asst-header {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  flex-shrink: 0;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--hx-state-border);
  background: rgba(255, 255, 255, 0.04);
}

.hx-asst-header__orb {
  position: relative;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  isolation: isolate;
  --hx-orb-blur-base: 1.5px;
}

.hx-asst-header__title {
  flex: 1;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--hx-text-high);
}

.hx-asst-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  color: var(--hx-text-low);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.hx-asst-close:hover {
  background: var(--hx-state-hover);
  color: var(--hx-text-high);
}

.hx-asst-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ─── Messages (chat bubble geometry) ─── */

.hx-asst-row { display: flex; align-items: flex-start; gap: 6px; }
.hx-asst-row--ai { align-self: flex-start; max-width: 92%; }
.hx-asst-row--user { align-self: flex-end; max-width: 78%; }

.hx-asst-avatar {
  position: relative;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  margin-top: 2px;
  border-radius: 50%;
  overflow: hidden;
  isolation: isolate;
  --hx-orb-blur-base: 1.5px;
}

.hx-asst-bubble {
  min-width: 52px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--hx-text-high);
  text-wrap: pretty;
}

/* The asymmetric radii are the platform's signature: the flat corner is the
   tail, pointing back at whoever is speaking. */
.hx-asst-bubble--user {
  background: rgba(0, 88, 171, 0.28);
  border-radius: 10px 10px 2px 10px;
}
.hx-asst-bubble--ai {
  background: var(--hx-state-default, rgba(255, 255, 255, 0.05));
  border-radius: 2px 10px 10px 10px;
}

.hx-asst-bubble p { margin: 0 0 8px; }
.hx-asst-bubble p:last-child { margin-bottom: 0; }
.hx-asst-bubble ul, .hx-asst-bubble ol { margin: 0 0 8px; padding-left: 18px; }
.hx-asst-bubble li { margin-bottom: 3px; }
.hx-asst-bubble a { color: var(--hx-accent); text-underline-offset: 2px; }
.hx-asst-bubble code {
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--hx-surface-2);
  font-size: 0.92em;
}
.hx-asst-bubble strong { font-weight: 600; }

/* Inline citation marker — a superscript that scrolls to the source list. */
.hx-asst-cite {
  display: inline-block;
  min-width: 14px;
  margin-left: 1px;
  padding: 0 3px;
  border-radius: 4px;
  background: var(--hx-tint-accent-soft, rgba(41, 190, 244, 0.12));
  color: var(--hx-accent);
  font-size: 10px;
  font-weight: 600;
  line-height: 15px;
  text-align: center;
  vertical-align: 1px;
  text-decoration: none;
}
.hx-asst-cite:hover { background: var(--hx-tint-accent-border, rgba(41, 190, 244, 0.25)); }

/* ─── Sources ─── */

.hx-asst-sources {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--hx-state-border);
}
.hx-asst-sources__label {
  margin-bottom: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hx-text-low);
}
.hx-asst-source {
  display: flex;
  gap: 6px;
  margin-bottom: 3px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--hx-text-med);
}
.hx-asst-source__n { flex-shrink: 0; color: var(--hx-accent); font-weight: 600; }
.hx-asst-source a { color: var(--hx-text-med); text-underline-offset: 2px; }
.hx-asst-source a:hover { color: var(--hx-text-high); }
/* Repo-only sources have no page to open, so they render as a plain label
   rather than a link that would 404. */
.hx-asst-source__path {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 10.5px;
  color: var(--hx-text-low);
}

/* ─── Thinking indicator ─── */

.hx-asst-dots { display: flex; align-items: center; gap: 4px; padding: 10px 2px; }
.hx-asst-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--hx-accent);
  animation: hxAsstDot 1.2s ease-in-out infinite;
}
.hx-asst-dot:nth-child(2) { animation-delay: 0.15s; }
.hx-asst-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes hxAsstDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ─── Suggestion chips ─── */

.hx-asst-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hx-asst-chip {
  padding: 5px 12px;
  border: 1px solid var(--hx-state-border);
  border-radius: 100px;
  background: transparent;
  color: var(--hx-text-med);
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  animation: hxAsstChipIn 0.25s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.hx-asst-chip:hover { background: var(--hx-state-hover); color: var(--hx-text-high); }

@keyframes hxAsstChipIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.hx-asst-intro {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--hx-text-med);
}

/* ─── Composer (command bar) ─── */

.hx-asst-footer {
  flex-shrink: 0;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--hx-state-border);
}

.hx-asst-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--glass-bg);
  transition: border-color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.hx-asst-form:focus-within {
  padding: 10px 14px;
  border-color: var(--hx-accent);
  box-shadow: 0 0 0 3px var(--hx-tint-accent-bar, rgba(41, 190, 244, 0.15));
}

.hx-asst-input {
  flex: 1;
  max-height: 96px;
  border: none;
  outline: none;
  background: none;
  resize: none;
  color: var(--hx-text-high);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
}
.hx-asst-input::placeholder { color: var(--hx-text-low); }

.hx-asst-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: var(--hx-primary, var(--brand-primary, #0058ab));
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.hx-asst-send:disabled { opacity: 0.35; cursor: default; }

.hx-asst-disclaimer {
  margin-top: 7px;
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
  color: var(--hx-text-low);
}

/* ─── Mobile: full-width bottom sheet ─── */

@media (max-width: 520px) {
  .hx-asst-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 88vh;
    border-radius: var(--hx-asst-radius) var(--hx-asst-radius) 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
  .hx-asst-launcher { right: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .hx-asst-blob,
  .hx-asst-dot,
  .hx-asst-chip,
  .hx-asst-panel { animation: none; }
  .hx-asst-launcher { transition: none; }
}
