/* ============================================================
   anime-vitality.v8.css — 二次元活力动效层（第八轮迭代 2026-10-08：趴桌待机×点站交互）
   v7 变更：仅替换角色形象与版本号，样式规则与 v6 一致；
   · 13 位 AI 伙伴换成中文社区流行拟人形象（DeepSeek 蓝色女仆大鱼、
     ChatGPT 白龙娘、Grok 小魅魔……），每位一张独立透明 webp。
   · 页脚由“两张拼图 + 对齐窗口”改为“每位伙伴一个按钮 + 一张独立图”，
     彻底移除了 v5 的窗口/分身/克隆样式，残影机制从根上不存在。
   · 卡片头像（.ai-portrait-crop）与小圆头像（.companion-portrait）
     改为直接适配独立角色图（整身顶部构图 / 脸部特写图）。
   保留：单一角色鼠标指针（少女 + 魔杖）、樱花、点击星星、
         微交互、入场动效、打字机台词、悄悄话、头顶符号。
   全部效果均：
   · 仅在 <html> 拥有 av-on 时启用（JS 按 localStorage 开关控制）
   · 呼吸浮动与互动动作仅在 <html> 拥有 av-friends 时启用
   · 尊重 prefers-reduced-motion 与站内 site-reduced-motion 偏好
   ============================================================ */

/* ---------- 1. 动漫角色鼠标指针（仅精确指针设备） ---------- */
@media (pointer: fine) {
  html[data-owner-cursor="agent"] {--owner-default-cursor:url("/ai-companions/owner/cursors/agent-default.png") 4 2;--owner-pointer-cursor:url("/ai-companions/owner/cursors/agent-pointer.png") 4 2;}
  html[data-owner-cursor="embedded"] {--owner-default-cursor:url("/ai-companions/owner/cursors/embedded-default.png") 2 2;--owner-pointer-cursor:url("/ai-companions/owner/cursors/embedded-pointer.png") 4 2;}
  html.av-on.av-cursor[data-owner-cursor="agent"] body,html.av-on.av-cursor[data-owner-cursor="embedded"] body {
    cursor: var(--owner-default-cursor), auto;
  }
  html.av-on.av-cursor:is([data-owner-cursor="agent"],[data-owner-cursor="embedded"]) body :is(a,button,[role="button"],summary,label,select,input[type="checkbox"],input[type="radio"]) {
    cursor: var(--owner-pointer-cursor), pointer;
  }
  html.av-on.av-cursor body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]),textarea,[contenteditable="true"]){cursor:text;}
  html.av-on.av-cursor body :is(button,input,select,textarea):disabled {cursor:not-allowed;}
  html.av-on.av-cursor body input[type="range"] {cursor:ew-resize;}
}

/* ---------- 2. 樱花飘落画布 ---------- */
.av-sakura-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 35;
}

/* ---------- 3. 点击星星特效 ---------- */
.av-spark {
  position: fixed;
  pointer-events: none;
  z-index: 110;
  font-size: 18px;
  line-height: 1;
  color: var(--accent, #527ec3);
  text-shadow: 0 0 6px color-mix(in srgb, var(--accent, #527ec3) 55%, transparent);
  animation: av-spark-pop 0.75s ease-out forwards;
  will-change: transform, opacity;
}
@keyframes av-spark-pop {
  0% { transform: translate(-50%, -50%) scale(0.3) rotate(0deg); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--av-dx, 0px)), calc(-50% + var(--av-dy, -34px))) scale(1.15) rotate(var(--av-rot, 90deg)); opacity: 0; }
}

/* ---------- 4. 角色与纸片卡 hover 动效 ---------- */
html.av-on .companion-portrait {
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
html.av-on .companion-portrait:hover {
  animation: av-wiggle 0.55s ease-in-out;
  transform: scale(1.12);
  z-index: 2;
}
@keyframes av-wiggle {
  0%, 100% { rotate: 0deg; }
  25% { rotate: 5deg; }
  60% { rotate: -4deg; }
}

html.av-on .hero-avatar {
  animation: av-float 4.2s ease-in-out infinite;
}
html.av-on .avatar-sparkle {
  animation: av-sparkle-twinkle 2.6s ease-in-out infinite;
}
@keyframes av-float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -5px; }
}
@keyframes av-sparkle-twinkle {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.18) rotate(18deg); }
}

html.av-on .content-card,
html.av-on .taxonomy-card,
html.av-on .update-card,
html.av-on .note-card {
  transition: transform 0.3s cubic-bezier(0.34, 1.3, 0.64, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}
html.av-on .content-card:hover,
html.av-on .taxonomy-card:hover,
html.av-on .update-card:hover,
html.av-on .note-card:hover {
  transform: translateY(-4px) rotate(-0.35deg);
}
html.av-on .update-card:nth-child(even):hover,
html.av-on .note-card:nth-child(even):hover {
  transform: translateY(-4px) rotate(0.35deg);
}

html.av-on .ai-friend-card:hover {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent),
              0 10px 26px rgba(46, 58, 71, 0.14);
}

/* ---------- 4b. 独立角色图的几何适配（v6 新增） ----------
   Base 样式里卡片头像/小圆头像按“拼图坐标”裁剪（--face-x/y 等）。
   独立透明图不再需要那套数学：
   · 卡片头像：整身图以顶部构图填满圆（头与上半身在圆内）；
   · 小圆头像：直接使用 256×256 脸部特写图，完整覆盖圆。
   本文件在 Base.css 之后加载，同权重下自然覆盖。 */
.ai-portrait-crop img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: top center;
}
.companion-portrait img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
}

/* ---------- 5. 页脚 AI 伙伴：每位一张独立图，逐个互动（v6） ---------- */
/* 每位伙伴是一个真正的按钮（可点按、可键盘聚焦），内含独立角色图 */
html.av-on .ai-footer-art { position: relative; }
.av-friend-solo {
  position: relative;
  z-index: 3;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  margin: 0 3px;
  padding: 0;
  border: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: inherit;
}
.av-friend-solo img {
  display: block;
  width: 132px;
  height: 158px;
  max-width: none;
  object-fit: contain;
  object-position: center bottom;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  filter: drop-shadow(0 4px 6px rgba(31, 42, 68, 0.16));
}
.av-friend-solo img.av-standing { object-position: center bottom; }
.av-friend-solo:hover img, .av-friend-solo:focus-visible img { filter: drop-shadow(0 6px 10px rgba(31, 42, 68, 0.24)); }
.ai-footer-art[data-ai-group="1"] .av-friend-solo img { width: 118px; height: 140px; }
.av-friend-solo:focus-visible {
  outline: 2px solid var(--accent, #527ec3);
  outline-offset: 2px;
  border-radius: 12px;
}
/* 平时：每位伙伴各自轻轻“呼吸浮动”（相位/周期由 JS 按人写入 --av-idle-*） */
html.av-friends .av-friend-solo img {
  animation: av-fr-idle var(--av-idle-dur, 6s) ease-in-out infinite;
  animation-delay: var(--av-idle-delay, 0s);
}
@keyframes av-fr-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1.2%); }
}
/* 互动时：专属小符号从头顶飘出 */
.av-friend-glyph {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  line-height: 1;
  color: var(--accent, #527ec3);
  text-shadow: 0 0 6px color-mix(in srgb, var(--accent, #527ec3) 45%, transparent);
  animation: av-glyph-rise 1s ease-out forwards;
}
@keyframes av-glyph-rise {
  0% { opacity: 0; transform: translateY(6px) scale(0.5) rotate(-8deg); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-34px) scale(1.05) rotate(14deg); }
}
/* 聊天式台词：先“…”思考，再逐字打出 */
.av-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin: 0 1.5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: av-dot-pulse 1s ease-in-out infinite;
}
.av-dot:nth-child(2) { animation-delay: 0.18s; }
.av-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes av-dot-pulse {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  45% { opacity: 1; transform: translateY(-2px); }
}
/* 激活时按各自动作播放一次（av-active 由 JS 在悬停/点按时添加） */
html.av-friends .av-friend-solo.av-anim-hop.av-active img { animation: av-fr-hop 0.85s cubic-bezier(0.34, 1.4, 0.64, 1); }
html.av-friends .av-friend-solo.av-anim-sway.av-active img { animation: av-fr-sway 1.1s ease-in-out; }
html.av-friends .av-friend-solo.av-anim-dive.av-active img { animation: av-fr-dive 1.05s cubic-bezier(0.34, 1.3, 0.64, 1); }
html.av-friends .av-friend-solo.av-anim-twinkle.av-active img { animation: av-fr-twinkle 0.9s ease-in-out; }
html.av-friends .av-friend-solo.av-anim-bounce.av-active img { animation: av-fr-bounce 0.8s cubic-bezier(0.34, 1.4, 0.64, 1); }
html.av-friends .av-friend-solo.av-anim-lean.av-active img { animation: av-fr-lean 1.0s ease-in-out; }
html.av-friends .av-friend-solo.av-anim-shake.av-active img { animation: av-fr-shake 0.55s ease-in-out 2; }
html.av-friends .av-friend-solo.av-anim-float.av-active img { animation: av-fr-float 1.6s ease-in-out; }
html.av-friends .av-friend-solo.av-anim-nod.av-active img { animation: av-fr-nod 0.8s ease-in-out 2; }
@keyframes av-fr-hop {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-7%) scale(1.02); }
  70% { transform: translateY(1.5%) scale(0.99, 1.02); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes av-fr-sway {
  0%, 100% { transform: rotate(0deg); }
  30% { transform: rotate(-3.5deg); }
  65% { transform: rotate(2.5deg); }
}
@keyframes av-fr-dive {
  0% { transform: translateY(0); }
  30% { transform: translateY(5%) rotate(-2deg); }
  65% { transform: translateY(-6%) rotate(2deg); }
  100% { transform: translateY(0); }
}
@keyframes av-fr-twinkle {
  0%, 100% { transform: scale(1) rotate(0deg); }
  40% { transform: scale(1.07) rotate(-3deg); }
  70% { transform: scale(0.96) rotate(2deg); }
}
@keyframes av-fr-bounce {
  0% { transform: scale(1, 1); }
  30% { transform: scale(1.1, 0.86); }
  60% { transform: scale(0.94, 1.1) translateY(-4%); }
  100% { transform: scale(1, 1); }
}
@keyframes av-fr-lean {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  40% { transform: rotate(5deg) translateY(2%); }
}
@keyframes av-fr-shake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-4.5deg); }
  60% { transform: rotate(3.5deg); }
}
@keyframes av-fr-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5%); }
}
@keyframes av-fr-nod {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  40% { transform: translateY(2.5%) rotate(2deg); }
}

/* 台词气泡：悬停 / 键盘聚焦 / 触屏点按时浮现 */
.av-friend-bubble {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  width: max-content;
  max-width: 200px;
  padding: 8px 12px;
  background: var(--surface, #fffdf8);
  border: 1px solid color-mix(in srgb, var(--accent, #527ec3) 38%, transparent);
  border-radius: 14px;
  box-shadow: var(--shadow, 0 6px 18px rgba(46, 58, 71, 0.16));
  font-size: 13px;
  line-height: 1.6;
  color: var(--text, #33383f);
  white-space: normal;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
  pointer-events: none;
  z-index: 6;
}
.av-friend-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 8px;
  height: 8px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--surface, #fffdf8);
  border-right: 1px solid color-mix(in srgb, var(--accent, #527ec3) 38%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent, #527ec3) 38%, transparent);
}
.av-friend-solo:hover .av-friend-bubble,
.av-friend-solo:focus-visible .av-friend-bubble,
.av-friend-solo.av-active .av-friend-bubble {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
/* 靠边的伙伴：气泡向内偏，避免溢出屏幕 */
.av-friend-solo.av-bubble-left .av-friend-bubble {
  left: 0;
  transform: translateY(5px);
}
.av-friend-solo.av-bubble-left:hover .av-friend-bubble,
.av-friend-solo.av-bubble-left:focus-visible .av-friend-bubble,
.av-friend-solo.av-bubble-left.av-active .av-friend-bubble {
  transform: translateY(0);
}
.av-friend-solo.av-bubble-left .av-friend-bubble::after { left: 26px; }
.av-friend-solo.av-bubble-right .av-friend-bubble {
  left: auto;
  right: 0;
  transform: translateY(5px);
}
.av-friend-solo.av-bubble-right:hover .av-friend-bubble,
.av-friend-solo.av-bubble-right:focus-visible .av-friend-bubble,
.av-friend-solo.av-bubble-right.av-active .av-friend-bubble {
  transform: translateY(0);
}
.av-friend-solo.av-bubble-right .av-friend-bubble::after { left: auto; right: 26px; }

/* 页脚插画两角的星光点缀（保留自 v2） */
html.av-on .ai-footer-art::before,
html.av-on .ai-footer-art::after {
  content: "✦";
  position: absolute;
  color: var(--gold, #d8a94e);
  opacity: 0;
  font-size: 15px;
  pointer-events: none;
  animation: av-corner-twinkle 3.2s ease-in-out infinite;
  z-index: 1;
}
html.av-on .ai-footer-art::before { top: 6px; left: 6%; animation-delay: 0.4s; }
html.av-on .ai-footer-art::after { top: 42%; right: 5%; animation-delay: 1.7s; }
@keyframes av-corner-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.5) rotate(0deg); }
  50% { opacity: 0.9; transform: scale(1) rotate(24deg); }
}

/* ---------- 5b. 伙伴页卡片：悬停弹出个性台词（保留自 v4） ---------- */
html.av-on .ai-friend-card.av-has-bubble { position: relative; }
.av-card-bubble {
  position: absolute;
  top: 10px;
  right: 12px;
  width: max-content;
  max-width: 62%;
  padding: 7px 11px;
  background: var(--surface, #fffdf8);
  border: 1px solid color-mix(in srgb, var(--accent, #527ec3) 38%, transparent);
  border-radius: 12px;
  box-shadow: var(--shadow, 0 6px 18px rgba(46, 58, 71, 0.16));
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text, #33383f);
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px) rotate(1deg);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
  pointer-events: none;
  z-index: 4;
}
html.av-on .ai-friend-card.av-has-bubble:hover .av-card-bubble {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) rotate(0.5deg);
}

/* ---------- 6. 其他微交互（沿用 v2） ---------- */
html.av-on .tags a:hover {
  animation: av-jiggle 0.35s ease-in-out;
}
@keyframes av-jiggle {
  0%, 100% { rotate: 0deg; }
  30% { rotate: 2.5deg; }
  70% { rotate: -2deg; }
}
html.av-on .brand:hover .brand-icon {
  animation: av-brand-spin 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes av-brand-spin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(-14deg) scale(1.12); }
  100% { transform: rotate(0deg) scale(1); }
}
html.av-on .intro-paper .paper-stamp {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
html.av-on .intro-paper:hover .paper-stamp {
  transform: rotate(12deg) scale(1.15);
}
html.av-on .read-link,
html.av-on .text-link {
  transition: translate 0.25s ease;
}
html.av-on .read-link:hover,
html.av-on .text-link:hover {
  translate: 2px 0;
}

/* ---------- 7. 入场动效 ---------- */
html.av-on .intro-paper {
  animation: av-paper-in 0.7s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
@keyframes av-paper-in {
  from { opacity: 0; transform: rotate(-0.65deg) translateY(18px) scale(0.96); }
  to { opacity: 1; transform: rotate(-0.65deg) translateY(0) scale(1); }
}
html.av-on .card-grid > * {
  animation: av-rise 0.5s ease-out both;
}
html.av-on .card-grid > :nth-child(1) { animation-delay: 0.05s; }
html.av-on .card-grid > :nth-child(2) { animation-delay: 0.12s; }
html.av-on .card-grid > :nth-child(3) { animation-delay: 0.19s; }
html.av-on .card-grid > :nth-child(4) { animation-delay: 0.26s; }
html.av-on .card-grid > :nth-child(5) { animation-delay: 0.33s; }
html.av-on .card-grid > :nth-child(6) { animation-delay: 0.40s; }
@keyframes av-rise {
  from { opacity: 0; translate: 0 10px; }
  to { opacity: 1; translate: 0 0; }
}

/* ---------- 8. 减少动态偏好：关闭所有主动画，仅保留过渡与台词 ---------- */
@media (prefers-reduced-motion: reduce) {
  html.av-on .av-sakura-canvas { display: none; }
  html.av-on .hero-avatar,
  html.av-on .avatar-sparkle,
  html.av-on .companion-portrait,
  html.av-on .companion-portrait:hover,
  html.av-on .ai-footer-art::before,
  html.av-on .ai-footer-art::after,
  html.av-on .tags a:hover,
  html.av-on .brand:hover .brand-icon,
  html.av-on .intro-paper .paper-stamp,
  html.av-on .intro-paper:hover .paper-stamp,
  html.av-on .intro-paper,
  html.av-on .card-grid > *,
  html.av-on .content-card:hover,
  html.av-on .taxonomy-card:hover,
  html.av-on .update-card:hover,
  html.av-on .note-card:hover,
  .av-spark,
  html.av-on .av-friend-solo img,
  html.av-on .av-friend-solo.av-active img,
  html.av-on .av-friend-glyph,
  html.av-on .av-dot {
    animation: none !important;
    transition: none !important;
    transform: none;
    translate: none;
  }
  html.av-on .ai-footer-art::before,
  html.av-on .ai-footer-art::after { content: none; }
}
html.av-reduced .av-sakura-canvas { display: none; }
html.av-reduced .hero-avatar,
html.av-reduced .avatar-sparkle,
html.av-reduced .companion-portrait:hover,
html.av-reduced .ai-footer-art::before,
html.av-reduced .ai-footer-art::after,
html.av-reduced .tags a:hover,
html.av-reduced .brand:hover .brand-icon,
html.av-reduced .intro-paper,
html.av-reduced .intro-paper:hover .paper-stamp,
html.av-reduced .card-grid > *,
html.av-reduced .content-card:hover,
html.av-reduced .taxonomy-card:hover,
html.av-reduced .update-card:hover,
html.av-reduced .note-card:hover,
html.av-reduced .av-friend-solo img,
html.av-reduced .av-friend-solo.av-active img,
html.av-reduced .av-friend-glyph,
html.av-reduced .av-dot {
  animation: none !important;
  transform: none;
  translate: none;
}
html.av-reduced .ai-footer-art::before,
html.av-reduced .ai-footer-art::after { content: none; }

/* ---------- 9. 小屏适配 ---------- */
@media (max-width: 720px) {
  .ai-footer-art { flex-wrap: wrap; gap: 2px 0; }
  .av-friend-solo { margin: 0 1px; }
  .av-friend-solo img { width: 76px; height: 92px; }
  .ai-footer-art[data-ai-group="1"] .av-friend-solo img { width: 68px; height: 82px; }
  .av-friend-bubble {
    max-width: 52vw;
    font-size: 12px;
    padding: 7px 10px;
  }
  .av-card-bubble {
    max-width: 70%;
    font-size: 12px;
  }
}

/* ---------- 10. 设置页：二次元活力区块（沿用站内既有控件样式） ---------- */
.av-settings-note { font-size: 0.85em; opacity: 0.75; }
