/* Jinli Neko v1.0.1 (Zibll Edition) - CSS */

/* ==========================================
 * 1. 容器样式
 * ========================================== */
#jinli-pet-root {
    position: fixed;
    z-index: 99999;
    width: 64px;
    height: 64px;
    bottom: 0;
    left: 20px;
    cursor: grab;
    image-rendering: pixelated;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
    will-change: left, bottom, transform;
}

#jinli-pet-root.dragging {
    cursor: grabbing;
    transition: none !important;
}

/* 移动端隐藏 */
@media screen and (max-width: 768px) {
    #jinli-pet-root.jinli-hide-mobile {
        display: none !important;
    }
}

/* ==========================================
 * 2. 宠物主体
 * ========================================== */
#jinli-pet-flipper {
    width: 100%;
    height: 100%;
    transition: transform 0.1s linear;
    transform-origin: center center;
    pointer-events: none;
}

#jinli-pet-body {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.jinli-pixel-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 2px rgba(0, 0, 0, 0.3));
}

/* 幽灵特殊样式 */
.jinli-model-ghost {
    opacity: 0.9;
}

.jinli-model-ghost.moving {
    opacity: 0.7;
}

/* ==========================================
 * 3. 气泡对话框
 * ========================================== */
#jinli-pet-msg {
    position: absolute;
    bottom: 85px;
    width: max-content;
    max-width: 200px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    word-break: break-word;
    z-index: 100001;
}

#jinli-pet-msg:after {
    content: "";
    position: absolute;
    bottom: -6px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.8);
    border-bottom: 0;
}

/* 气泡位置 */
#jinli-pet-msg.jinli-bubble-center {
    left: 50%;
    transform: translateX(-50%);
}

#jinli-pet-msg.jinli-bubble-center:after {
    left: 50%;
    transform: translateX(-50%);
}

#jinli-pet-msg.jinli-bubble-left {
    left: 0;
}

#jinli-pet-msg.jinli-bubble-left:after {
    left: 20px;
}

#jinli-pet-msg.jinli-bubble-right {
    right: 0;
}

#jinli-pet-msg.jinli-bubble-right:after {
    right: 20px;
}

#jinli-pet-msg.show {
    opacity: 1;
    bottom: 95px;
}

/* ==========================================
 * 4. 睡眠状态
 * ========================================== */
#jinli-pet-sleep {
    position: absolute;
    left: 50%;
    bottom: 70px;
    transform: translateX(-50%);
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: bold;
    font-size: 24px;
    color: #8a2be2;
    text-shadow: 2px 2px 0 #fff;
    opacity: 0;
    pointer-events: none;
}

#jinli-pet-root.sleeping #jinli-pet-sleep {
    animation: jinli-zzz 2s infinite;
    opacity: 1;
}

/* ==========================================
 * 5. 动画库
 * ========================================== */
@keyframes jinli-walk-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

@keyframes jinli-tail {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(10deg); }
}

@keyframes jinli-blink {
    0%, 92%, 100% { transform: scaleY(1); }
    94% { transform: scaleY(0.2); }
}

@keyframes jinli-dog-wag {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}

@keyframes jinli-jump {
    0% { transform: translateY(0); }
    35% { transform: translateY(-16px); }
    100% { transform: translateY(0); }
}

@keyframes jinli-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes jinli-sit {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

@keyframes jinli-sniff {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

@keyframes jinli-peck {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}

@keyframes jinli-stretch {
    0% { transform: scaleX(1) translateY(0); }
    50% { transform: scaleX(1.10) translateY(-2px); }
    100% { transform: scaleX(1) translateY(0); }
}

@keyframes jinli-eat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    35% { transform: translateY(2px) rotate(-6deg); }
    70% { transform: translateY(2px) rotate(6deg); }
}

@keyframes jinli-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes jinli-zzz {
    0% { transform: translateX(-50%) scale(0.5) translateY(10px); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateX(-30%) scale(1.2) translateY(-20px); opacity: 0; }
}

@keyframes jinli-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

/* 动画类 */
#jinli-pet-body.jinli-act-jump { animation: jinli-jump 0.6s ease-out; }
#jinli-pet-body.jinli-act-spin { animation: jinli-spin 0.8s linear; transform-origin: 50% 75%; }
#jinli-pet-body.jinli-act-sit { animation: jinli-sit 0.6s ease-out forwards; }
#jinli-pet-body.jinli-act-sniff { animation: jinli-sniff 0.8s ease-in-out; }
#jinli-pet-body.jinli-act-peck { animation: jinli-peck 0.7s ease-in-out; }
#jinli-pet-body.jinli-act-stretch { animation: jinli-stretch 1.0s ease-in-out; }
#jinli-pet-body.jinli-act-eat { animation: jinli-eat 0.9s ease-in-out; transform-origin: 50% 80%; }

/* ==========================================
 * 6. 睡眠状态样式
 * ========================================== */
#jinli-pet-root.sleeping #jinli-pet-body {
    filter: grayscale(0.5);
    transition: transform 0.5s ease;
    transform: scaleY(0.6) translateY(20px);
    animation: none !important;
}

/* 幽灵睡眠状态 */
.jinli-model-ghost.sleeping #jinli-pet-body {
    transform: scale(0.9);
    opacity: 0.5;
    animation: jinli-float 5s infinite ease-in-out;
}

/* ==========================================
 * 7. 道具和特效层
 * ========================================== */
#jinli-toy-layer, #jinli-effect-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 99998;
}

.jinli-toy {
    position: fixed;
    width: 36px;
    height: 36px;
    z-index: 99998;
    display: none;
    image-rendering: pixelated;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.jinli-claw-mark {
    position: absolute;
    background: #000;
    opacity: 0.8;
    transform: rotate(-45deg);
    width: 300px;
    height: 40px;
}

/* ==========================================
 * 8. 特效动画
 * ========================================== */
body.jinli-glitch-active {
    animation: jinli-glitch-body 0.2s infinite;
}

@keyframes jinli-glitch-body {
    0% { transform: translate(0); filter: hue-rotate(0deg); }
    25% { transform: translate(-3px, 3px); filter: invert(0.2); }
    100% { transform: translate(0); filter: none; }
}

/* ==========================================
 * 9. 子比主题适配
 * ========================================== */

/* 暗色模式适配 */
body.dark #jinli-pet-msg {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

body.dark #jinli-pet-msg:after {
    border-top-color: rgba(255, 255, 255, 0.9);
}

/* 响应式调整 */
@media screen and (max-width: 480px) {
    #jinli-pet-root {
        width: 48px;
        height: 48px;
        left: 10px;
    }
    
    #jinli-pet-msg {
        max-width: 160px;
        font-size: 12px;
        padding: 6px 10px;
    }
}

/* 高DPI屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .jinli-pixel-svg {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}
