/* ==========================================================================
   AI 语音助手「小索」—— 底部常驻语音球
   参考 Siri / Gemini Live / GPT-4o 语音模式的通用视觉语言：
   · 三个模糊色块以 mix-blend-mode:screen 叠加，不同周期永不同步 → 有机流动
   · 光球常驻页面底部，点击即说话（无弹窗、无全屏遮罩，页面始终可见）
   · 支持 barge-in：聆听/播报中再次点击立即打断
   · 答案以打字机方式逐字呈现，配合语音播报
   ========================================================================== */

:root {
  --asst-ink: #0a1a2b;
  --asst-gold: #c9a227;
  --asst-gold-lt: #e8c85a;
  --asst-text: #eef4fa;
  --asst-dim: #8ba4bf;
}

/* ---------------- 底部 Dock ---------------- */
.asst-dock {
  position: fixed;
  right: 28px;
  bottom: 24px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  width: min(430px, calc(100vw - 56px));
}

.asst-dock > * { pointer-events: auto; }

/* ---------------- 答案卡片 ---------------- */
.asst-card {
  width: 100%;
  /* 高度随内容自适应：内容多高卡片就多高，不再固定高度强制滚动。
     只有当答案长到逼近屏幕顶部时才启用滚动，避免溢出到屏幕外。 */
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  margin-bottom: 16px;
  padding: 20px 24px;
  border-radius: 14px;
  background: rgba(11, 32, 54, .93);
  border: 1px solid rgba(143, 168, 196, .22);
  box-shadow: 0 24px 60px rgba(4, 14, 26, .5);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: none;
}

.asst-card.show { display: block; animation: cardUp .42s cubic-bezier(.2, .8, .3, 1); }

@keyframes cardUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.asst-card-q {
  font-size: 12.5px;
  color: var(--asst-dim);
  letter-spacing: .5px;
  padding-bottom: 11px;
  margin-bottom: 13px;
  border-bottom: 1px dashed rgba(143, 168, 196, .22);
}

.asst-card-q b {
  color: var(--asst-gold-lt);
  font-weight: 600;
}

.asst-card-a {
  font-size: 15.5px;
  line-height: 1.92;
  color: #dbe6f2;
  letter-spacing: .3px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 打字机闪烁光标 */
.asst-caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--asst-gold-lt);
  animation: caretBlink .9s step-end infinite;
}

@keyframes caretBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.asst-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px dashed rgba(143, 168, 196, .2);
  font-size: 12px;
  color: var(--asst-dim);
}

.asst-card-meta b { color: var(--asst-gold-lt); font-weight: 600; }

.asst-cites { margin-top: 13px; }

.asst-cites-label {
  font-size: 11.5px;
  color: var(--asst-dim);
  letter-spacing: 1.4px;
  margin-bottom: 8px;
}

.asst-cite {
  display: flex;
  gap: 9px;
  align-items: baseline;
  padding: 8px 11px;
  margin-bottom: 5px;
  border-radius: 6px;
  background: rgba(74, 144, 226, .1);
  border: 1px solid rgba(74, 144, 226, .2);
  cursor: pointer;
  font-size: 13.5px;
  color: #cfe0f2;
  transition: all .2s;
}

.asst-cite:hover {
  background: rgba(201, 162, 39, .15);
  border-color: rgba(201, 162, 39, .5);
  color: #fff;
}

.asst-cite-no { color: var(--asst-gold-lt); font-weight: 700; flex: none; }

.asst-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--asst-dim);
}

.asst-thinking i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--asst-gold-lt);
  animation: dotJump 1.2s ease-in-out infinite;
}

.asst-thinking i:nth-child(2) { animation-delay: .16s; }
.asst-thinking i:nth-child(3) { animation-delay: .32s; }

@keyframes dotJump {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30%           { transform: translateY(-7px); opacity: 1; }
}

/* ---------------- 字幕 ---------------- */
.asst-caption {
  max-width: 100%;
  margin-bottom: 12px;
  text-align: right;
  font-size: 15px;
  line-height: 1.7;
  color: rgba(238, 244, 250, .78);
  text-shadow: 0 2px 12px rgba(0, 0, 0, .75);
  min-height: 0;
  transition: opacity .3s;
}

.asst-caption:empty { display: none; }

/* ---------------- 光球 ---------------- */
.asst-orb {
  position: relative;
  width: 148px;
  height: 148px;
  flex: none;
  cursor: pointer;
  border-radius: 50%;
  overflow: hidden;
  isolation: isolate;              /* 让 mix-blend-mode 只在球内混合 */
  background: radial-gradient(circle at 50% 50%, #0d2b48 0%, #071726 100%);
  box-shadow:
    0 18px 46px rgba(4, 14, 26, .55),
    0 0 0 1px rgba(201, 162, 39, .28),
    0 0 34px rgba(47, 111, 208, .3);
  /* 待机时缩小为一枚徽章，激活时放大 —— 只动 transform，GPU 友好 */
  transform: scale(.46);
  transition: transform .52s cubic-bezier(.34, 1.36, .64, 1), box-shadow .4s;
}

.is-listening .asst-orb,
.is-thinking .asst-orb,
.is-speaking .asst-orb,
.has-result .asst-orb { transform: scale(1); }

.is-listening .asst-orb {
  box-shadow: 0 18px 46px rgba(4, 14, 26, .55), 0 0 0 1px rgba(201, 162, 39, .6),
    0 0 60px rgba(47, 111, 208, .55);
}

.is-speaking .asst-orb {
  box-shadow: 0 18px 46px rgba(4, 14, 26, .55), 0 0 0 1px rgba(232, 200, 90, .7),
    0 0 60px rgba(201, 162, 39, .48);
}

.asst-orb:hover { transform: scale(1.04); }

/* 三个模糊色块：screen 叠加让重叠区变亮而非变浑 */
.asst-blob {
  position: absolute;
  width: 82%;
  height: 82%;
  border-radius: 50%;
  filter: blur(13px);
  mix-blend-mode: screen;
  animation: blobDrift 6s ease-in-out infinite;
  will-change: transform;
}

.asst-blob.b1 {
  background: radial-gradient(circle, #2f6fd0 0%, rgba(47, 111, 208, 0) 70%);
  top: 2%; left: 2%;
  animation-duration: 6s;
  animation-delay: -.4s;
}

.asst-blob.b2 {
  background: radial-gradient(circle, #29b6d8 0%, rgba(41, 182, 216, 0) 70%);
  top: 12%; right: 0%;
  animation-duration: 7.5s;
  animation-delay: -2.3s;
}

.asst-blob.b3 {
  background: radial-gradient(circle, #d4a92c 0%, rgba(212, 169, 44, 0) 70%);
  bottom: 0%; left: 16%;
  animation-duration: 9s;
  animation-delay: -4.1s;
}

@keyframes blobDrift {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(16%, -13%) scale(1.15); }
  66%  { transform: translate(-12%, 11%) scale(.9); }
  100% { transform: translate(0, 0) scale(1); }
}

/* 思考/播报时加速搅动，视觉上"被激活" */
.is-thinking .asst-blob { animation-duration: 3s; }
.is-speaking .asst-blob { animation-duration: 2.4s; }

/* 球内高光，增加体积感 */
.asst-orb::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .3) 0%, rgba(255, 255, 255, 0) 46%);
  pointer-events: none;
  z-index: 3;
}

/* ---------------- 声呐脉冲环 ---------------- */
.asst-ring {
  position: absolute;
  top: 50%; left: 50%;
  width: 148px; height: 148px;
  margin: -74px 0 0 -74px;
  border-radius: 50%;
  border: 1.5px solid rgba(74, 144, 226, .55);
  opacity: 0;
  pointer-events: none;
}

.is-listening .asst-ring { animation: sonarPulse 2s ease-out infinite; }
.is-listening .asst-ring.r2 { animation-delay: .5s; }

@keyframes sonarPulse {
  0%   { transform: scale(.82); opacity: .85; }
  100% { transform: scale(1.7); opacity: 0; }
}

/* ---------------- 均衡器（播报中）---------------- */
.asst-eq {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  opacity: 0;
  transition: opacity .3s;
  z-index: 4;
  pointer-events: none;
}

.is-speaking .asst-eq { opacity: 1; }

.asst-eq i {
  display: block;
  width: 4px;
  height: 9px;
  border-radius: 3px;
  background: linear-gradient(180deg, #fff, rgba(232, 200, 90, .85));
}

.is-speaking .asst-eq i { animation: eqBar .92s ease-in-out infinite; }

.asst-eq i:nth-child(1) { animation-delay: 0s; }
.asst-eq i:nth-child(2) { animation-delay: .12s; }
.asst-eq i:nth-child(3) { animation-delay: .24s; }
.asst-eq i:nth-child(4) { animation-delay: .36s; }
.asst-eq i:nth-child(5) { animation-delay: .48s; }

@keyframes eqBar {
  0%, 100% { height: 9px; }
  50%      { height: 36px; }
}

/* 中心图标 */
.asst-orb-icon {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  color: rgba(255, 255, 255, .92);
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}

.asst-orb-icon svg { width: 34px; height: 34px; display: block; }

/* 待机时露出麦克风图标，提示"可点击说话" */
.is-idle .asst-orb-icon { opacity: .85; }
.is-listening .asst-orb-icon,
.is-speaking .asst-orb-icon { opacity: 0; }

/* ---------------- Dock 操作区 ---------------- */
.asst-dock-bar {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .35s, transform .35s;
  pointer-events: none;
}

.has-result .asst-dock-bar,
.is-listening .asst-dock-bar,
.is-speaking .asst-dock-bar { opacity: 1; transform: translateY(0); pointer-events: auto; }

.asst-dock-btn {
  height: 30px;
  padding: 0 13px;
  border-radius: 15px;
  border: 1px solid rgba(143, 168, 196, .3);
  background: rgba(11, 32, 54, .82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--asst-dim);
  font-size: 12px;
  letter-spacing: .5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .22s;
}

.asst-dock-btn:hover {
  color: #fff;
  border-color: rgba(201, 162, 39, .7);
  background: rgba(201, 162, 39, .16);
}

.asst-dock-btn svg { width: 14px; height: 14px; }

.asst-dock-btn.on {
  color: var(--asst-gold-lt);
  border-color: rgba(201, 162, 39, .6);
}

/* 状态提示条 */
.asst-dock-hint {
  margin-top: 10px;
  font-size: 11.5px;
  color: rgba(139, 164, 191, .8);
  letter-spacing: .8px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .8);
  opacity: 0;
  transition: opacity .35s;
}

.is-listening .asst-dock-hint,
.is-speaking .asst-dock-hint { opacity: 1; }

/* 待机时页面底部的一行引导语 */
.asst-hello {
  margin-bottom: 12px;
  padding: 7px 16px;
  border-radius: 16px;
  background: rgba(11, 32, 54, .8);
  border: 1px solid rgba(201, 162, 39, .3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #dbe7f3;
  font-size: 12.5px;
  letter-spacing: .5px;
  box-shadow: 0 8px 24px rgba(4, 14, 26, .4);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity .4s, transform .4s;
}

.asst-hello b { color: var(--asst-gold-lt); font-weight: 600; }

/* 隐藏时彻底移出文档流，避免在激活态下方留出空洞 */
.is-listening .asst-hello,
.is-thinking .asst-hello,
.is-speaking .asst-hello,
.has-result .asst-hello { display: none; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 720px) {
  .asst-dock { right: 14px; bottom: 14px; width: calc(100vw - 28px); }
  .asst-orb { width: 120px; height: 120px; }
  .asst-ring { width: 120px; height: 120px; margin: -60px 0 0 -60px; }
  .asst-card { max-height: calc(100vh - 270px); padding: 15px 17px; }
  .asst-caption { font-size: 14px; }
}

/* 尊重系统的"减少动态效果"设置 */
@media (prefers-reduced-motion: reduce) {
  .asst-blob, .asst-ring, .asst-eq i, .asst-caret { animation: none !important; }
  .asst-orb { transition: none; }
}
