/* ============================================================
   Site Pet v1.0 — 前端样式
   ============================================================ */

#site-pet-root {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9998;
}

.site-pet {
    position: fixed;
    z-index: 9999;
    pointer-events: auto;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.12));
    transition: filter 0.2s;
}
.site-pet:active { cursor: grabbing; }
.site-pet.is-dragging {
    transition: none;
    cursor: grabbing;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2));
}
.site-pet:hover {
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.2));
}

/* ============================================================
   精灵图元素
   ============================================================ */
.site-pet__sprite {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background-repeat: no-repeat;
    background-position: 0 0;
    pointer-events: none;
    /* 尺寸 / 背景大小 / 背景图 全部由 JS 设置 */
}

/* ============================================================
   简单模式（静态图）—— 保留浮动动画
   ============================================================ */
.site-pet__sprite--simple {
    animation: pet-float 3s ease-in-out infinite;
    background: none !important;
}
.site-pet__sprite--simple img {
    display: block;
    image-rendering: pixelated;
}

@keyframes pet-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}

/* 拖拽时暂停浮动 */
.site-pet.is-dragging .site-pet__sprite--simple {
    animation-play-state: paused;
}

/* ============================================================
   说话气泡
   ============================================================ */
.site-pet__bubble {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    background: #fff;
    color: #334155;
    padding: 8px 16px;
    border-radius: 14px;
    font-size: 0.85rem;
    font-family: 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
    max-width: 260px;
    text-align: center;
    line-height: 1.5;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 10;
    white-space: normal;
    word-break: break-word;
}
.site-pet__bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 7px solid transparent;
    border-top-color: #fff;
}
.site-pet--speaking .site-pet__bubble {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.site-pet.is-dragging .site-pet__bubble {
    opacity: 0 !important;
}

/* ============================================================
   移动端
   ============================================================ */
@media (max-width: 640px) {
    .site-pet__bubble {
        font-size: 0.78rem;
        padding: 6px 12px;
        max-width: 180px;
    }
}

/* ============================================================
   尊重 prefers-reduced-motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .site-pet__sprite--simple { animation: none !important; }
}