/* 2026-11-27 Option 1 · Obsidian Intelligent Pod (Disney 12-Principles Spring Physics + 60/120fps Overlapping Action) */
.companion-dock {
  position: fixed;
  right: 22px;
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 84px;
  height: 110px;
  z-index: 70;
  isolation: isolate;
  /* Elastic spring glide when snapping back to screen edge after drag release! */
  transition: left 0.44s cubic-bezier(0.22, 1.24, 0.36, 1), top 0.44s cubic-bezier(0.22, 1.24, 0.36, 1), opacity 0.18s ease;
}

.chat-open .companion-dock {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.companion-dock .companion-launch,
.companion-dock .companion-launch:hover,
.companion-dock .companion-launch:active {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  right: auto;
  bottom: auto;
  width: 84px;
  height: 110px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 26px;
  background: transparent;
  box-shadow: none;
  transform: none;
  color: #1d1d1f;
  cursor: grab;
  overflow: visible;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.companion-launch:focus-visible {
  outline: 2px solid #0071e3;
  outline-offset: 6px;
}

.companion-stage {
  position: relative;
  display: block;
  flex: 0 0 80px;
  width: 84px;
  height: 80px;
  pointer-events: none;
  overflow: visible;
}

/* Physics-coupled floating shadow (driven directly by rAF height, lateral lean & squash!) */
.companion-ground {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 2px;
  height: 11px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.28) 0%, rgba(0, 0, 0, 0) 74%);
  will-change: transform, opacity;
  transition: background 0.28s ease;
}

.companion-dock[data-surface="dark"] .companion-ground {
  background: radial-gradient(ellipse, rgba(41, 151, 255, 0.42) 0%, rgba(41, 151, 255, 0) 76%);
}

.companion-actor {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

/* Oversized SVG canvas matches bleed viewBox (-16 -18 100 104) so 54x52 pod renders full 60x58px with zero drop-shadow clipping! */
.companion-dock .xq-pod {
  position: absolute;
  left: -14px;
  top: -17px;
  width: 112px;
  height: 116px;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.24));
  transition: filter 0.25s ease;
}

.companion-dock[data-surface="dark"] .xq-pod {
  filter: drop-shadow(0 8px 24px rgba(41, 151, 255, 0.28)) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.58));
}

.companion-launch:hover .xq-pod {
  filter: drop-shadow(0 14px 26px rgba(0, 113, 227, 0.36));
}

/* Explicit transform-box: view-box locks user-unit pivot points consistently across Chrome/Safari/Firefox */
.xq-body {
  transform-box: view-box;
  transform-origin: 34px 59px;
}

.xq-visor-g,
.xq-brow-g,
.xq-face-g,
.xq-glass-sheen {
  transform-box: view-box;
  transform-origin: 34px 33.5px;
}

.xq-eye {
  transform-box: fill-box;
  transform-origin: center;
  filter: drop-shadow(0 0 5px rgba(41, 151, 255, 0.72));
}

.xq-spark {
  pointer-events: none;
  transition: opacity 0.08s ease;
}

.xq-brow {
  filter: drop-shadow(0 0 5px rgba(41, 151, 255, 0.6));
  transition: stroke 0.2s ease;
}

.xq-eyes,
.xq-smile,
.xq-squeeze,
.xq-wave {
  transform-box: view-box;
  transform-origin: 34px 33.5px;
  transition: opacity 0.12s ease;
}

.xq-smile,
.xq-squeeze,
.xq-wave {
  opacity: 0;
}

/* Expression states driven by data-expr (JS state machine) */
.companion-dock[data-expr="smile"] .xq-eyes,
.companion-dock[data-expr="squeeze"] .xq-eyes,
.companion-dock[data-expr="thinking"] .xq-eyes,
.chat-panel[data-state="thinking"] .xq-eyes,
.chat-panel[data-state="replied"] .xq-eyes {
  opacity: 0;
}

.companion-dock[data-expr="smile"] .xq-smile,
.chat-panel[data-state="replied"] .xq-smile {
  opacity: 1;
}

.companion-dock[data-expr="smile"] .xq-brow {
  stroke: #5ac8fa;
}

.companion-dock[data-expr="squeeze"] .xq-squeeze {
  opacity: 1;
}

.companion-dock[data-expr="thinking"] .xq-wave,
.chat-panel[data-state="thinking"] .xq-wave {
  opacity: 1;
}

.xq-bar {
  transform-box: fill-box;
  transform-origin: center;
}

/* Chat panel avatar wave fallback */
html[data-aq-motion="on"] .chat-panel[data-state="thinking"] .xq-b1 { animation: xq-wave 0.72s ease-in-out infinite 0s; }
html[data-aq-motion="on"] .chat-panel[data-state="thinking"] .xq-b2 { animation: xq-wave 0.72s ease-in-out infinite 0.14s; }
html[data-aq-motion="on"] .chat-panel[data-state="thinking"] .xq-b3 { animation: xq-wave 0.72s ease-in-out infinite 0.28s; }
html[data-aq-motion="on"] .chat-panel[data-state="thinking"] .xq-b4 { animation: xq-wave 0.72s ease-in-out infinite 0.42s; }

.companion-dock[data-dragging="true"] {
  z-index: 95;
  transition: none;
}

.companion-dock[data-dragging="true"] .companion-launch {
  cursor: grabbing !important;
}

/* Crisp Apple Frosted Caption Pill */
.companion-caption {
  display: block;
  position: relative;
  margin-top: 2px;
  padding: 4px 12px;
  font: 500 11px/1.45 var(--font);
  letter-spacing: 0.03em;
  color: #1d1d1f;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 980px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  white-space: nowrap;
  pointer-events: none;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.companion-dock[data-surface="dark"] .companion-caption {
  color: #f5f5f7;
  background: rgba(24, 25, 30, 0.88);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.42);
}

.companion-launch:hover .companion-caption,
.companion-launch:focus-visible .companion-caption {
  color: #fff;
  background: #0071e3;
  border-color: #0071e3;
  transform: scale(1.06) translateY(-1px);
}

/* Unread notification pulse dot */
.companion-notice {
  position: absolute;
  right: 8px;
  top: 6px;
  width: 10px;
  height: 10px;
  background: #0071e3;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(0, 113, 227, 0.68);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: scale(0.4);
}

.companion-dock[data-unread="true"] .companion-notice {
  opacity: 1;
  transform: scale(1);
}

/* Hover Tooltip Bubble (Apple Clean Glass + Spring Entrance) */
.companion-hint {
  position: absolute;
  right: 92px;
  bottom: 30px;
  width: 238px;
  padding: 15px 17px;
  background: rgba(255, 255, 255, 0.96);
  color: #1d1d1f;
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  cursor: default;
  transform-origin: right bottom;
  animation: xq-hint-pop 0.30s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-sizing: border-box;
}

.companion-hint::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: 16px;
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid rgba(0, 0, 0, 0.09);
  border-right: 1px solid rgba(0, 0, 0, 0.09);
}

.companion-dock[data-surface="dark"] .companion-hint {
  background: rgba(22, 23, 28, 0.96);
  color: #f5f5f7;
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

.companion-dock[data-surface="dark"] .companion-hint::after {
  background: rgba(22, 23, 28, 0.96);
  border-color: rgba(255, 255, 255, 0.14);
}

.companion-hint strong {
  display: block;
  font: 600 13.5px/1.5 var(--font);
  margin-bottom: 3px;
}

.companion-hint > span {
  display: block;
  font: 12.5px/1.65 var(--font);
  color: #6e6e73;
}

.companion-dock[data-surface="dark"] .companion-hint > span {
  color: #a1a1a6;
}

.companion-hint small {
  display: block;
  font: 11px/1.4 var(--font);
  margin-top: 10px;
  color: #0071e3;
}

.companion-dock[data-surface="dark"] .companion-hint small {
  color: #2997ff;
}

.companion-dock[data-edge="left"] .companion-hint {
  left: 92px;
  right: auto;
  transform-origin: left bottom;
  border-radius: 16px 16px 16px 4px;
}

.companion-dock[data-edge="left"] .companion-hint::after {
  left: -5px;
  right: auto;
  transform: rotate(225deg);
}

.companion-reset {
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: transparent;
  color: #6e6e73;
  border-radius: 980px;
  font: inherit;
  padding: 3px 9px;
  cursor: pointer;
}

.companion-reset:hover {
  background: #f5f5f7;
  color: #1d1d1f;
}

.site-footer .footer-bottom {
  padding-right: 104px;
}

.chat-avatar > .companion-actor {
  width: 100%;
  height: 100%;
}

.chat-avatar .xq-pod {
  display: block;
  width: 100%;
  height: 100%;
  filter: none;
}

@keyframes xq-wave {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1.45); }
}

@keyframes xq-hint-pop {
  from { opacity: 0; transform: translateX(10px) scale(0.88); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* Restore Xiaoqi transitions/animations when data-aq-motion="on" (even if OS Reduce Motion is active), while honoring explicit pause toggle */
html[data-aq-motion="on"] .companion-dock {
  transition: left 0.44s cubic-bezier(0.22, 1.24, 0.36, 1), top 0.44s cubic-bezier(0.22, 1.24, 0.36, 1), opacity 0.18s ease !important;
}
html[data-aq-motion="on"] .companion-dock[data-dragging="true"] {
  transition: none !important;
}
html[data-aq-motion="on"] .companion-dock .xq-eyes,
html[data-aq-motion="on"] .companion-dock .xq-smile,
html[data-aq-motion="on"] .companion-dock .xq-squeeze,
html[data-aq-motion="on"] .companion-dock .xq-wave {
  transition: opacity 0.12s ease !important;
}
html[data-aq-motion="on"] .companion-dock .xq-pod {
  transition: filter 0.25s ease !important;
}
html[data-aq-motion="on"] .companion-dock .companion-caption {
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
html[data-aq-motion="on"] .companion-dock .companion-hint {
  animation: xq-hint-pop 0.30s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
html[data-aq-motion="on"] .chat-panel[data-state="thinking"] .xq-b1 { animation: xq-wave 0.72s ease-in-out infinite 0s !important; }
html[data-aq-motion="on"] .chat-panel[data-state="thinking"] .xq-b2 { animation: xq-wave 0.72s ease-in-out infinite 0.14s !important; }
html[data-aq-motion="on"] .chat-panel[data-state="thinking"] .xq-b3 { animation: xq-wave 0.72s ease-in-out infinite 0.28s !important; }
html[data-aq-motion="on"] .chat-panel[data-state="thinking"] .xq-b4 { animation: xq-wave 0.72s ease-in-out infinite 0.42s !important; }

html[data-aq-motion="off"] .xq-bar,
html[data-aq-motion="off"] .companion-hint { animation: none !important; }
html[data-aq-motion="off"] .companion-dock,
html[data-aq-motion="off"] .companion-ground { transition: none !important; }

/* Mobile (<= 700px): Compact draggable obsidian pill */
@media (max-width: 700px) {
  .companion-dock {
    right: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
    width: auto;
    height: 44px;
  }

  .companion-dock .companion-launch,
  .companion-dock .companion-launch:hover,
  .companion-dock .companion-launch:active {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: auto;
    height: 44px;
    padding: 4px 14px 4px 6px;
    border-radius: 980px;
    background: rgba(17, 18, 23, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .companion-stage {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
  }

  .companion-ground {
    display: none;
  }

  .companion-dock .xq-pod {
    left: -7px;
    top: -8px;
    width: 48px;
    height: 50px;
    filter: none !important;
  }

  .companion-caption {
    margin-top: 0;
    padding: 0;
    border: 0;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none;
    transform: none !important;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.2;
    color: #f5f5f7 !important;
  }

  .companion-hint {
    right: 0;
    bottom: 54px;
    width: min(236px, calc(100vw - 32px));
    border-radius: 14px 14px 4px 14px;
  }

  .companion-hint::after {
    right: 26px;
    bottom: -5px;
    border-top: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.09);
  }

  .companion-dock[data-edge="left"] .companion-hint {
    left: 0;
    right: auto;
    border-radius: 14px 14px 14px 4px;
  }

  .companion-dock[data-edge="left"] .companion-hint::after {
    left: 26px;
    right: auto;
    transform: rotate(45deg);
  }

  .companion-dock[data-hint-placement="below"] .companion-hint {
    bottom: auto;
    top: 54px;
  }

  .companion-dock[data-hint-placement="below"] .companion-hint::after {
    bottom: auto;
    top: -5px;
    border-top: 1px solid rgba(0, 0, 0, 0.09);
    border-bottom: 0;
  }

  .companion-notice {
    width: 8px;
    height: 8px;
    right: 0;
    top: 0;
  }
}
