/* ===== 数字人讲解员 · 右下角讲解卡片 =====
   浅灰影棚风：白玻璃 + 发丝线 + 柔阴影 + accent #0fa392。
   卡片本身不拦截指针（只有声音按钮可点），避免盖住下方可交互面板。 */

.guide-card {
  --guide-w: 292px;
  --guide-ink: var(--text, #161b22);
  --guide-ink-2: var(--text-2, #5b6575);
  --guide-ink-3: var(--text-3, #8b94a3);
  --guide-accent: var(--accent, #0fa392);
  --guide-accent-ink: var(--accent-ink, #0a7a6e);
  --guide-hair: var(--line, rgba(16, 24, 40, 0.08));

  position: fixed;
  z-index: 32;
  right: 24px;
  bottom: 96px;
  box-sizing: border-box;
  width: var(--guide-w);
  padding: 12px 14px 13px;
  border-radius: 14px;
  border: 1px solid var(--guide-hair);
  background:
    linear-gradient(170deg, rgba(255, 255, 255, 0.96) 0%, rgba(252, 253, 254, 0.9) 56%, rgba(247, 250, 251, 0.92) 100%);
  box-shadow:
    0 22px 52px -32px rgba(16, 24, 40, 0.55),
    0 2px 6px -4px rgba(16, 24, 40, 0.16),
    0 1px 0 rgba(255, 255, 255, 0.92) inset;
  -webkit-backdrop-filter: blur(18px) saturate(1.05);
  backdrop-filter: blur(18px) saturate(1.05);
  color: var(--guide-ink);
  font-family: var(--sans, "Noto Sans SC", system-ui, sans-serif);
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  animation: guide-card-in 0.46s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.guide-card * { box-sizing: border-box; }

@keyframes guide-card-in {
  to { opacity: 1; transform: none; }
}

/* ---------- 头部：头像 + 身份 + 声音开关 ---------- */

.guide-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.guide-avatar {
  position: relative;
  flex: none;
  width: 92px;
  height: 92px;
}
.guide-avatar::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1px solid rgba(15, 163, 146, 0);
  transition: border-color 0.38s var(--ease, ease);
  pointer-events: none;
}
.guide-card.is-speaking:not(.is-muted) .guide-avatar::after {
  border-color: rgba(15, 163, 146, 0.32);
}

.guide-figure {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 6px 16px -10px rgba(16, 24, 40, 0.5);
}

.guide-id {
  flex: 1 1 auto;
  min-width: 0;
}
.guide-kicker {
  margin: 0 0 2px;
  font-family: var(--mono, "Cascadia Mono", Consolas, monospace);
  font-size: 9px;
  line-height: 1.3;
  letter-spacing: 0.14em;
  color: var(--guide-ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.guide-name {
  margin: 0;
  font-size: 13px;
  font-weight: 620;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: var(--guide-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.guide-state-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 5px 0 0;
  min-width: 0;
}
.guide-live {
  flex: none;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--guide-ink-3);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.guide-card.is-speaking:not(.is-muted) .guide-live {
  background: var(--guide-accent);
  animation: guide-live 1.7s ease-out infinite;
}
@keyframes guide-live {
  0% { box-shadow: 0 0 0 0 rgba(15, 163, 146, 0.32); }
  70% { box-shadow: 0 0 0 7px rgba(15, 163, 146, 0); }
  100% { box-shadow: 0 0 0 0 rgba(15, 163, 146, 0); }
}
.guide-state {
  font-size: 10.5px;
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: var(--guide-ink-3);
  white-space: nowrap;
}
.guide-card.is-speaking:not(.is-muted) .guide-state { color: var(--guide-accent-ink); }

/* 4 根声波柱：只在真正发声（非静音）时起伏 */
.guide-wave {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 10px;
  margin-left: 1px;
  opacity: 0.42;
}
.guide-wave i {
  display: block;
  width: 2px;
  height: 100%;
  border-radius: 1px;
  background: var(--guide-accent);
  transform: scaleY(0.26);
  transform-origin: 50% 100%;
}
.guide-wave i:nth-child(2) { height: 74%; }
.guide-wave i:nth-child(3) { height: 92%; }
.guide-wave i:nth-child(4) { height: 62%; }
.guide-card.is-speaking:not(.is-muted) .guide-wave { opacity: 1; }
.guide-card.is-speaking:not(.is-muted) .guide-wave i {
  animation: guide-wave 0.86s ease-in-out infinite;
}
.guide-card.is-speaking:not(.is-muted) .guide-wave i:nth-child(2) { animation-delay: 0.11s; }
.guide-card.is-speaking:not(.is-muted) .guide-wave i:nth-child(3) { animation-delay: 0.23s; }
.guide-card.is-speaking:not(.is-muted) .guide-wave i:nth-child(4) { animation-delay: 0.34s; }
@keyframes guide-wave {
  0%, 100% { transform: scaleY(0.28); }
  38% { transform: scaleY(1); }
  66% { transform: scaleY(0.5); }
}

.guide-sound {
  pointer-events: auto;
  flex: none;
  align-self: flex-start;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  margin-top: 1px;
  border-radius: 6px;
  border: 1px solid var(--guide-hair);
  background: rgba(255, 255, 255, 0.92);
  color: var(--guide-ink-3);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.guide-sound:hover {
  color: var(--guide-accent-ink);
  border-color: rgba(15, 163, 146, 0.34);
  background: #ffffff;
}
.guide-sound:focus-visible {
  outline: 2px solid rgba(15, 163, 146, 0.45);
  outline-offset: 2px;
}
.guide-sound .guide-icon { width: 13px; height: 13px; display: block; }
.guide-sound .guide-icon-off { display: none; }
.guide-card.is-muted .guide-sound .guide-icon-on { display: none; }
.guide-card.is-muted .guide-sound .guide-icon-off { display: block; }
.guide-card.is-muted .guide-sound { color: var(--guide-ink-2); }

/* ---------- 字幕（最多 3 行） ---------- */

.guide-caption {
  box-sizing: content-box;
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(16, 24, 40, 0.07);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  min-height: 4.5em;
  max-height: 4.5em;
  font-size: 12.5px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  color: var(--guide-ink);
  overflow-wrap: anywhere;
  word-break: break-word;
  transition: color 0.25s ease;
}
.guide-caption.is-quiet {
  color: var(--guide-ink-3);
}

/* ---------- 眨眼：上眼睑下压 ---------- */

.guide-card .gg-lid {
  transition: transform 0.08s ease;
}
.guide-card.is-blinking .gg-lid {
  transform: translateY(3.6px);
}

/* ---------- 响应式 ---------- */

body[data-story="1"] .guide-card {
  right: 44px;
  bottom: 112px;
}

@media (max-width: 980px) {
  .guide-card {
    left: 16px;
    right: 16px;
    bottom: 84px;
    width: auto;
    max-width: none;
    padding: 12px 14px;
  }
  .guide-head { gap: 11px; }
  .guide-avatar { width: 76px; height: 76px; }
  .guide-caption { min-height: 4.5em; max-height: 4.5em; font-size: 12.5px; }
}

@media (max-width: 560px) {
  .guide-card {
    left: 12px;
    right: 12px;
    bottom: 78px;
    padding: 10px 12px 11px;
  }
  .guide-head { gap: 10px; }
  .guide-avatar { width: 56px; height: 56px; }
  .guide-kicker { display: none; }
  .guide-name { font-size: 12.5px; }
  .guide-state-row { margin-top: 3px; }
  .guide-caption {
    margin-top: 9px;
    padding-top: 9px;
    font-size: 12px;
    min-height: 4.5em;
    max-height: 4.5em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .guide-card { animation-duration: 0.01ms; }
  .guide-card.is-speaking:not(.is-muted) .guide-wave i,
  .guide-card.is-speaking:not(.is-muted) .guide-live { animation: none; }
  .guide-card .gg-lid { transition: none; }
}
