/* ============================================================
   Joker X · 大肥鱼桌宠（dsh-pet web 版）
   ------------------------------------------------------------
   素材来自 DSH 插件 dsh-pet（PC2005-cloud/dsh-pet）：
     代码 MIT；动画素材允许开源使用、禁止商用。见 assets/dsh-pet/NOTICE.md。
   约束：
     · 页面加载后自动出现（先静态图，动作加载完切视频）
     · 只占角色本体大小，不拿透明留白挡页面；可拖到屏幕任意边缘
     · 隐藏 / 切后台时暂停播放；不支持透明 webm（Safari）时用静态图
     · 打印隐藏
   ============================================================ */

/* 角色在原视频里的位置（640×360 首帧 alpha 包围盒：x 212-428，y 63-330）。
   容器只包住角色本体；整帧视频放大后向左上偏移，道具/特效允许溢出容器显示。 */
.jx-fish {
  --w: 132px;
  --frame-scale: 2.963;   /* 整帧宽 / 角色宽 */
  --art-ratio: 1.236;     /* 角色高 / 角色宽 */
  position: fixed;
  left: 0;
  top: 0;
  width: var(--w);
  height: calc(var(--w) * var(--art-ratio));
  /* 内容层之上，保证桌宠本身可拖动；默认停在右侧空白区，不压卡片 */
  z-index: 30;
  transform-origin: 50% 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: grab;
  filter: drop-shadow(0 8px 10px rgba(16, 24, 40, 0.16));
  will-change: transform;
}

.jx-fish.is-dragging {
  z-index: 65;
  cursor: grabbing;
  filter: drop-shadow(0 14px 18px rgba(16, 24, 40, 0.22));
}

.jx-fish__stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(var(--dir, 1));
  transform-origin: 50% 100%;
}

/* 整帧视频/静态图：按 640×360 的比例放大，偏移到角色本体正好铺满容器 */
.jx-fish__video,
.jx-fish__poster {
  position: absolute;
  width: calc(var(--w) * var(--frame-scale));
  height: calc(var(--w) * var(--frame-scale) * 0.5625);
  left: calc(var(--w) * -0.9815);
  top: calc(var(--w) * -0.2917);
}

.jx-fish__video {
  object-fit: fill;
  opacity: 0;
  transition: opacity 0.16s ease;
  pointer-events: none;
}

.jx-fish__video.is-active {
  opacity: 1;
}

.jx-fish__poster {
  object-fit: fill;
  pointer-events: none;
}

.jx-fish__poster[hidden] {
  display: none;
}

.jx-fish.is-static .jx-fish__video {
  display: none;
}

.jx-fish__poster.is-bounce {
  animation: jx-fish-bounce 0.5s cubic-bezier(0.2, 1.3, 0.4, 1);
}

.jx-fish.is-static .jx-fish__poster {
  animation: jx-fish-bob 3.6s ease-in-out infinite;
}

@keyframes jx-fish-bounce {
  0% { transform: scale(1); }
  35% { transform: scale(1.06, 0.94); }
  70% { transform: scale(0.98, 1.02); }
  100% { transform: scale(1); }
}

@keyframes jx-fish-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* 召唤 / 加载 / 召回 共用的小胶囊 */
.jx-fish-chip {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  background: #ffffff;
  color: #374151;
  font-size: 12.5px;
  line-height: 1.2;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.10);
  cursor: pointer;
}

.jx-fish-chip:active {
  transform: scale(0.97);
}

.jx-fish-chip[disabled] {
  cursor: default;
  opacity: 0.72;
}

.jx-fish-chip::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0071e3;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.16);
}

html[data-theme="dark"] .jx-fish-chip {
  border-color: rgba(255, 255, 255, 0.1);
  background: #1f1f24;
  color: #e5e7eb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

@media (max-width: 720px) {
  /* 手机默认不显示桌宠；用户点“大肥鱼”胶囊显式召回后才叠在内容上 */
  .jx-fish {
    --w: 96px;
    z-index: 30;
  }

  .jx-fish-chip {
    display: none;
  }
}

/* ---------- 右键 / 长按菜单（竖排 + 次级菜单） ---------- */
.jx-fish-menu {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 61;
  width: 170px;
  padding: 6px;
  border-radius: 10px;
  background: #ffffff;
  color: #1d1d1f;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(15, 23, 42, 0.06);
}

html[data-theme="dark"] .jx-fish-menu {
  background: #202024;
  color: #f5f5f7;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.jx-fish-menu[hidden] {
  display: none;
}

.jx-fish-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

.jx-fish-menu-item:hover,
.jx-fish-menu-item.is-open {
  background: rgba(0, 113, 227, 0.1);
  color: #0062c4;
}

html[data-theme="dark"] .jx-fish-menu-item:hover,
html[data-theme="dark"] .jx-fish-menu-item.is-open {
  background: rgba(64, 156, 255, 0.18);
  color: #a3d1ff;
}

.jx-fish-menu-arrow {
  color: #9ca3af;
  font-size: 12px;
  line-height: 1;
}

.jx-fish-menu-sep {
  height: 1px;
  margin: 5px 6px;
  background: rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] .jx-fish-menu-sep {
  background: rgba(255, 255, 255, 0.1);
}

/* 次级菜单：桌面悬浮在右侧；触屏设备嵌在菜单里（inline） */
.jx-fish-submenu {
  position: absolute;
  left: 100%;
  top: 0;
  width: 168px;
  max-height: 68vh;
  overflow: auto;
  padding: 6px;
  border-radius: 10px;
  background: #ffffff;
  color: #1d1d1f;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.06);
  -webkit-overflow-scrolling: touch;
}

html[data-theme="dark"] .jx-fish-submenu {
  background: #202024;
  color: #f5f5f7;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.jx-fish-submenu[hidden] {
  display: none;
}

.jx-fish-submenu.is-left {
  left: auto;
  right: 100%;
}

.jx-fish-submenu.is-inline {
  position: static;
  width: auto;
  max-height: 42vh;
  margin: 2px 0 4px;
  box-shadow: none;
  background: rgba(15, 23, 42, 0.045);
}

html[data-theme="dark"] .jx-fish-submenu.is-inline {
  background: rgba(255, 255, 255, 0.06);
}

.jx-fish-submenu button {
  display: block;
  width: 100%;
  min-height: 30px;
  padding: 5px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

.jx-fish-submenu button:hover {
  background: rgba(0, 113, 227, 0.1);
  color: #0062c4;
}

html[data-theme="dark"] .jx-fish-submenu button:hover {
  background: rgba(64, 156, 255, 0.18);
  color: #a3d1ff;
}

@media (prefers-reduced-motion: reduce) {
  .jx-fish__video,
  .jx-fish-chip {
    transition: none;
  }

  .jx-fish.is-static .jx-fish__poster,
  .jx-fish__poster.is-bounce {
    animation: none;
  }
}

@media print {
  .jx-fish,
  .jx-fish-chip,
  .jx-fish-menu,
  .jx-fish-submenu {
    display: none !important;
  }
}

/* ---------- 随机点名：班级列表 / 头顶名字气泡 ---------- */
.jx-fish-submenu.is-classes {
  width: 220px;
}

.jx-fish-submenu button[data-class] {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.jx-fish-submenu-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jx-fish-submenu-count {
  flex: none;
  color: #9ca3af;
  font-size: 10.5px;
}

.jx-fish-submenu-note {
  padding: 9px 10px;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.55;
}

html[data-theme="dark"] .jx-fish-submenu-note {
  color: #a3d1ff;
}

.jx-fish-name-bubble {
  position: fixed;
  z-index: 64;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: min(280px, calc(100vw - 24px));
  padding: 8px 14px;
  border-radius: 14px;
  background: #fff;
  color: #1d1d1f;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.2), 0 0 0 1px rgba(15, 23, 42, 0.06);
  text-align: center;
  opacity: 0;
  transform: translateY(6px) scale(0.92);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: auto;
  cursor: pointer;
}

.jx-fish-name-bubble.is-show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.jx-fish-name-bubble strong {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.25;
  word-break: break-word;
}

.jx-fish-name-bubble span {
  color: #6b7280;
  font-size: 10.5px;
  line-height: 1.3;
}

.jx-fish-name-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: #fff;
  transform: translateX(-50%) rotate(45deg);
}

.jx-fish-name-bubble.is-below::after {
  top: -5px;
  bottom: auto;
}

html[data-theme="dark"] .jx-fish-name-bubble {
  background: #1f1f24;
  color: #f5f5f7;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .jx-fish-name-bubble span {
  color: #a1a1aa;
}

html[data-theme="dark"] .jx-fish-name-bubble::after {
  background: #1f1f24;
}

@media (prefers-reduced-motion: reduce) {
  .jx-fish-name-bubble {
    transition: none;
  }
}

@media print {
  .jx-fish-name-bubble {
    display: none !important;
  }
}
