/* ==================================================================
 * SILENTFORGE DEV STATION — 桌宠样式
 * 左侧：韩立（点击发动技能）
 * 右侧：南宫婉 / 元瑶 / 紫灵（点击切换，会时不时凑过来）
 * ================================================================== */

/* ------------------------------------------------------------------
 * 1. 容器
 * ------------------------------------------------------------------ */
.pet-zone {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;   /* 只有桌宠本体可点 */
  overflow: hidden;
}

.pet {
  position: absolute;
  bottom: 0;
  /* 高挑比例立绘，画布在 JS 里按 1:1.62 设定 */
  width: 196px;
  pointer-events: auto;
  will-change: transform;
  transition: transform .55s cubic-bezier(.22, .68, .28, 1), opacity .4s ease;
}
.pet-left { left: 10px; }
.pet-right { right: 10px; }

/* 被关闭时整组淡出（保留 DOM 以便快捷键唤回） */
.pet-zone.is-off .pet { opacity: 0; pointer-events: none; transform: translateY(30px); }

/* ------------------------------------------------------------------
 * 2. 画布（角色本体）
 * ------------------------------------------------------------------ */
.pet-canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: auto;
  transition: filter .3s ease;
  /* 底部柔光，让角色不像贴纸 */
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, .45));
}
.pet-left .pet-canvas { cursor: url("../assets/img/cursor-pointer.png") 8 2, pointer; }
.pet-right .pet-canvas { cursor: url("../assets/img/cursor-pointer.png") 8 2, pointer; }

/* 悬停时轻微上浮，暗示可点 */
.pet:hover { transform: translateY(-6px); }
.pet:active { transform: translateY(-2px) scale(.985); }

/* 技能冷却中 */
.pet.is-cooling .pet-canvas { filter: drop-shadow(0 10px 16px rgba(0, 0, 0, .45)) grayscale(.35) brightness(.92); }

/* 施法瞬间：整体提亮 */
.pet.is-casting .pet-canvas {
  filter: drop-shadow(0 0 14px var(--accent)) brightness(1.16) saturate(1.2);
}

/* ------------------------------------------------------------------
 * 3. 名牌
 * ------------------------------------------------------------------ */
.pet-label {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .18em;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--bg) 76%, transparent);
  border: 1px solid var(--accent-line);
  backdrop-filter: blur(6px);
  white-space: nowrap;
  opacity: .85;
  transition: opacity var(--fast), transform var(--fast);
  pointer-events: none;
}
.pet:hover .pet-label { opacity: 1; }

/* ------------------------------------------------------------------
 * 4. 对话气泡
 * ------------------------------------------------------------------ */
.pet-bubble {
  position: absolute;
  bottom: calc(100% - 18px);
  max-width: 190px;
  padding: 8px 12px;
  font-size: 12.6px;
  line-height: 1.5;
  color: var(--text);
  background: color-mix(in srgb, var(--panel-solid) 95%, transparent);
  border: 1px solid var(--accent-line);
  border-radius: 3px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .32);
  opacity: 0;
  transform: translateY(6px) scale(.94);
  transform-origin: bottom center;
  transition: opacity .24s var(--ease), transform .24s var(--ease);
  pointer-events: none;
  z-index: 3;
}
.pet-bubble.is-on { opacity: 1; transform: none; }

/* 姘旀场灏忓皷瑙?*/
.pet-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  width: 8px; height: 8px;
  background: inherit;
  border-right: 1px solid var(--accent-line);
  border-bottom: 1px solid var(--accent-line);
  transform: rotate(45deg) translateY(-5px);
}
.pet-left .pet-bubble { left: 4px; }
.pet-left .pet-bubble::after { left: 26px; }
.pet-right .pet-bubble { right: 4px; }
.pet-right .pet-bubble::after { right: 26px; }

/* 技能名气泡（更醒目） */
.pet-bubble.is-skill {
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--accent-ink);
  border-color: var(--accent-ink);
  box-shadow: 0 0 0 1px var(--accent-line), 0 10px 30px color-mix(in srgb, var(--accent) 26%, transparent);
}

/* ------------------------------------------------------------------
 * 5. 鍙充晶瑙掕壊鍒囨崲鍣? * ------------------------------------------------------------------ */
.pet-switch {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--mid), transform var(--mid);
  pointer-events: auto;
}
.pet-right:hover .pet-switch,
.pet-switch:focus-within { opacity: 1; }
/* 触屏设备常显 */
@media (hover: none) {
  .pet-switch { opacity: .92; }
}

.pet-switch button {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  border-radius: 2px;
  color: var(--text-dim);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border: 1px solid var(--line-soft);
  backdrop-filter: blur(6px);
  transition: color var(--fast), border-color var(--fast), background var(--fast), transform var(--fast);
}
.pet-switch button:hover { color: var(--accent-ink); border-color: var(--accent-line); transform: translateX(-2px); }
.pet-switch button.is-active {
  color: var(--accent-ink);
  border-color: var(--accent-ink);
  background: var(--accent-soft);
  font-weight: 700;
}

/* ------------------------------------------------------------------
 * 6. 底部控制台（技能栏 + 开关）
 * ------------------------------------------------------------------ */
.pet-dock {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 45;
  display: grid;
  gap: 7px;
  justify-items: center;
  max-width: min(96vw, 720px);
  transition: opacity var(--mid), transform var(--mid);
}
.pet-dock.is-off { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(14px); }

.pet-dock-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 6px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .34);
}
.pet-dock-row:empty { display: none; }

/* 鎶€鑳芥寜閽?*/
.skill-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 12.6px;
  white-space: nowrap;
  overflow: hidden;
  transition: color var(--fast), border-color var(--fast), transform var(--fast), box-shadow var(--fast);
}
.skill-btn:hover { color: var(--accent-ink); border-color: var(--accent-line); transform: translateY(-2px); box-shadow: var(--glow); }
.skill-btn:active { transform: translateY(0) scale(.97); }
.skill-btn .sk-no {
  font-family: var(--font-mono);
  font-size: 9.5px;
  opacity: .55;
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: 0 3px;
  line-height: 1.4;
}
.skill-btn .sk-name { font-weight: 600; }

/* 冷却遮罩 */
.skill-btn.is-cooling { pointer-events: none; opacity: .48; }
.skill-btn.is-cooling::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 30%, transparent));
  animation: coolSweep .5s linear infinite;
}
@keyframes coolSweep {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* 控制按钮 */
.dock-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: transparent;
  color: var(--text-faint);
  font-size: 12.4px;
  transition: color var(--fast), border-color var(--fast), transform var(--fast);
}
.dock-btn:hover { color: var(--accent-ink); border-color: var(--accent-line); transform: translateY(-1px); }
.dock-btn:active { transform: scale(.97); }
.dock-btn .dock-ico { font-size: 11px; opacity: .8; }
.dock-btn.ghost { border-style: dashed; }

.pet-dock-hint {
  font-size: 11.4px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 6px 13px;
  backdrop-filter: blur(10px);
  animation: slideDown .3s var(--ease);
  text-align: center;
  line-height: 1.7;
}
.pet-dock-hint kbd { margin: 0 1px; }

/* ------------------------------------------------------------------
 * 7. 关闭后的悬浮唤出按钮
 * ------------------------------------------------------------------ */
.pet-reopen {
  position: fixed;
  left: 14px;
  bottom: 16px;
  z-index: 46;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px 9px 10px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .34);
  animation: reopenIn .4s var(--ease);
  transition: transform var(--fast), border-color var(--fast), box-shadow var(--fast);
}
@keyframes reopenIn {
  from { opacity: 0; transform: translateY(12px) scale(.94); }
  to { opacity: 1; transform: none; }
}
.pet-reopen:hover { transform: translateY(-2px); box-shadow: var(--glow); }
.pet-reopen > span {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 700;
}
.pet-reopen em {
  font-style: normal;
  font-size: 12.4px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.pet-reopen:hover em { color: var(--accent-ink); }

/* 呼吸提示光圈，提醒可以按 H */
.pet-reopen::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  opacity: 0;
  animation: reopenPulse 3.4s var(--ease) infinite;
  pointer-events: none;
}
@keyframes reopenPulse {
  0%, 60% { opacity: 0; transform: scale(1); }
  75% { opacity: .5; }
  100% { opacity: 0; transform: scale(1.06); }
}

/* ------------------------------------------------------------------
 * 8. 响应式
 * ------------------------------------------------------------------ */
@media (max-width: 900px) {
  .pet { width: 156px; }
  .pet-left { left: 2px; }
  .pet-right { right: 2px; }
  .pet-switch button { width: 28px; height: 28px; }
}

@media (max-width: 720px) {
  .pet { width: 122px; }
  .pet-left { left: -6px; }
  .pet-right { right: -6px; }
  .pet-bubble { max-width: 150px; font-size: 12px; padding: 6px 10px; }
  .pet-bubble { bottom: calc(100% - 12px); }
  .pet-label { font-size: 9.5px; padding: 2px 8px; letter-spacing: .12em; }
  .pet-switch { right: 2px; gap: 5px; }
  .pet-switch button { width: 26px; height: 26px; font-size: 10px; }

  .pet-dock { bottom: 10px; gap: 5px; max-width: 96vw; }
  .pet-dock-row { padding: 4px; gap: 4px; }
  .skill-btn { padding: 7px 9px; font-size: 12px; gap: 5px; }
  .skill-btn .sk-no { display: none; }
  .dock-btn { padding: 7px 10px; font-size: 12px; }
  .pet-dock-hint { font-size: 10.8px; padding: 5px 10px; }

  .pet-reopen { left: 8px; bottom: 10px; padding: 7px 12px 7px 8px; }
  .pet-reopen em { font-size: 11.8px; }
}

@media (max-width: 420px) {
  .pet { width: 104px; }
  .pet-right .pet-switch { flex-direction: column; }
  .pet-dock-row { max-width: 94vw; }
  .skill-btn .sk-name { font-size: 11.2px; }
}

/* 极矮屏（横屏手机）收小，避免挡住正文 */
@media (max-height: 460px) {
  .pet { width: 96px; }
}

/* 减少动画时隐藏呼吸光圈 */
html[data-reduce="1"] .pet-reopen::after { display: none; }

/* 鎵撳嵃鏃跺叏閮ㄩ殣钘?*/
@media print {
  .pet-zone, .pet-dock, .pet-reopen { display: none !important; }
}
