/* Стилі для механіки "Джек втік" */

.jack-dog {
    position: absolute;
    cursor: pointer;
    z-index: 15;
    transition: transform 0.2s ease;
    transform: translate(-50%, -50%); /* Центруємо іконку відносно координат */
}

/* Анімація руху Джека */
.jack-dog.jack-moving {
    transition: left 0.7s ease-in-out, top 0.7s ease-in-out;
}

.jack-dog.jack-moving img {
    animation: jackRunning 0.3s ease-in-out infinite alternate;
}

@keyframes jackRunning {
    0% { transform: scale(1) rotate(-2deg); }
    100% { transform: scale(1.05) rotate(2deg); }
}

/* Стилі для Джека в клітці */
.jack-dog.jack-in-cage img {
    width: 40px;  /* Зменшено вдвічі з 80px */
    height: 40px;
    border: 2px solid #4CAF50; /* Зелена рамка замість помаранчевої */
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4);
}

.jack-dog.jack-in-cage:hover img {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.6);
}

/* Підпис "В клітці" */
.jack-cage-label {
    position: absolute;
    bottom: 30px; /* Перенесено над іконкою замість під неї */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(76, 175, 80, 0.9);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    display: none;;
    white-space: nowrap;
    pointer-events: none;
}

/* Анімація погладжування */
.jack-dog.jack-being-petted img {
    animation: jackBeingPetted 0.5s ease-in-out;
}

@keyframes jackBeingPetted {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.1) rotate(-5deg); }
    75% { transform: scale(1.1) rotate(5deg); }
}

/* Діалог догляду за Джеком */
.jack-care-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: modalFadeIn 0.3s ease-out;
}

.jack-care-panel {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 350px;
    width: 90%;
    text-align: center;
    animation: panelSlideIn 0.4s ease-out;
}

.jack-care-panel h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #4CAF50;
    font-size: 18px;
}

.jack-care-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.jack-care-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.jack-care-btn:hover {
    background-color: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.jack-care-btn:active {
    transform: translateY(1px);
}

.jack-care-btn:disabled {
    background-color: #9E9E9E !important;
    color: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.jack-care-btn:disabled:hover {
    background-color: #9E9E9E !important;
    transform: none;
    box-shadow: none;
}

/* Повідомлення про результат догляду */
.jack-care-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(76, 175, 80, 0.95);
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    z-index: 10002;
    animation: careMessageFade 2.5s ease-out;
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.3);
}

.jack-care-result p {
    margin: 5px 0;
    font-size: 16px;
    font-weight: 500;
}

@keyframes careMessageFade {
    0% { opacity: 0; transform: translate(-50%, -60%) scale(0.8); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -40%) scale(0.8); }
}

/* Анімація годування */
.jack-dog.jack-being-fed img {
    animation: jackBeingFed 0.6s ease-in-out;
}

@keyframes jackBeingFed {
    0%, 100% { transform: scale(1); }
    20% { transform: scale(1.05) rotateZ(-3deg); }
    40% { transform: scale(1.1) rotateZ(3deg); }
    60% { transform: scale(1.05) rotateZ(-2deg); }
    80% { transform: scale(1.08) rotateZ(2deg); }
}

/* Стилі для щасливого кота */
.happy-cat {
    position: absolute;
    cursor: pointer;
    z-index: 15;
    transition: transform 0.2s ease;
    transform: translate(-50%, -50%);
    animation: catAppear 0.8s ease-out;
}

.happy-cat img {
    width: 40px;  /* Такий же розмір як у Джека в клітці */
    height: 40px;
    border-radius: 50%;
    border: 2px solid #FF9800; /* Риже кружельце */
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.4);
    transition: all 0.2s ease;
}

.happy-cat:hover img {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.6);
}

.happy-cat:active img {
    transform: scale(0.95);
}

/* Анімація появи кота */
@keyframes catAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3) rotate(180deg);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2) rotate(90deg);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
    }
}

/* Анімація святкування кота */
.happy-cat.cat-celebrating img {
    animation: catCelebrating 0.5s ease-in-out;
}

@keyframes catCelebrating {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.15) rotate(-10deg); }
    50% { transform: scale(1.2) rotate(0deg); }
    75% { transform: scale(1.15) rotate(10deg); }
}

/* Повідомлення щасливого кота */
.cat-happy-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 152, 0, 0.95);
    color: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    z-index: 10002;
    animation: catMessageFade 3s ease-out;
    box-shadow: 0 4px 20px rgba(255, 152, 0, 0.4);
    max-width: 400px;
    width: 90%;
}

.cat-happy-content p {
    margin: 8px 0;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.4;
}

@keyframes catMessageFade {
    0% { opacity: 0; transform: translate(-50%, -60%) scale(0.8); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    85% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -40%) scale(0.8); }
}

.jack-dog img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid #FF6B35;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.4);
    transition: all 0.2s ease;
}

.jack-dog:hover img {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.6);
}

.jack-dog:active img {
    transform: scale(0.95);
}

/* Підказка над Джеком */
.jack-tooltip {
    position: absolute;
    bottom: 65px; /* Підняв вище над іконкою */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 107, 53, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    opacity: 0;
    animation: jackTooltip 2s ease-in-out infinite;
    pointer-events: none;
}

/* Анімація підказки */
@keyframes jackTooltip {
    0%, 70%, 100% { opacity: 0; }
    10%, 60% { opacity: 1; }
}

/* Анімація появи Джека */
.jack-dog {
    animation: jackAppear 0.5s ease-out;
}

@keyframes jackAppear {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-10deg);
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* Анімація спіймання Джека */
@keyframes jackCaught {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    50% {
        transform: scale(1.3) rotate(360deg);
    }
    100% {
        opacity: 0;
        transform: scale(0) rotate(720deg);
    }
}

/* Адаптивність для мобільних пристроїв */
@media (max-width: 768px) {
    .jack-dog img {
        width: 70px;
        height: 70px;
    }
    
    .jack-dog.jack-in-cage img {
        width: 35px;  /* Половина від мобільного розміру */
        height: 35px;
    }
    
    .jack-tooltip {
        font-size: 13px;
        bottom: 55px;
        padding: 5px 10px;
    }
    
    .jack-cage-label {
        font-size: 10px;
        bottom: 25px;
    }
    
    .jack-care-result p {
        font-size: 15px;
    }
    
    .jack-care-panel {
        padding: 20px;
        margin: 20px;
    }
    
    .jack-care-panel h3 {
        font-size: 16px;
    }
    
    .jack-care-btn {
        padding: 12px 18px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .jack-dog img {
        width: 60px;
        height: 60px;
    }
    
    .jack-dog.jack-in-cage img {
        width: 30px;  /* Половина від мобільного розміру */
        height: 30px;
    }
    
    .jack-tooltip {
        font-size: 12px;
        bottom: 45px;
        padding: 4px 8px;
    }
    
    .jack-cage-label {
        font-size: 9px;
        bottom: 20px;
    }
    
    .jack-care-result p {
        font-size: 14px;
    }
    
    .jack-care-panel {
        padding: 18px;
        margin: 15px;
    }
    
    .jack-care-panel h3 {
        font-size: 15px;
        margin-bottom: 15px;
    }
    
    .jack-care-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
}

/* Діалог команд для Джека */
.jack-command-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.jack-command-panel {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: panelSlideIn 0.4s ease-out;
}

@keyframes panelSlideIn {
    from { 
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.jack-command-panel h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #FF6B35;
    font-size: 20px;
}

.jack-commands {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
}

.jack-command-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.jack-command-btn:hover {
    background-color: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.jack-command-btn:active {
    transform: translateY(1px);
}



/* Відповідь Джека */
.jack-response {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #FF6B35;
}

.jack-response-text {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 500;
    color: #333;
    line-height: 1.4;
}

.jack-action-buttons {
    margin-top: 10px;
}

.jack-close-btn,
.jack-close-wrong-btn {
    background-color: #FF6B35;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.jack-close-btn:hover,
.jack-close-wrong-btn:hover {
    background-color: #E55A2B;
}

.jack-close-wrong-btn {
    background-color: #9E9E9E;
}

.jack-close-wrong-btn:hover {
    background-color: #757575;
}

/* Адаптивність для мобільних */
@media (max-width: 768px) {
    .jack-command-panel {
        padding: 20px;
        margin: 20px;
    }
    
    .jack-command-panel h3 {
        font-size: 18px;
    }
    
    .jack-command-btn {
        padding: 14px 18px;
        font-size: 15px;
    }
    
    .jack-response-text {
        font-size: 15px;
    }
    
    .happy-cat img {
        width: 35px;
        height: 35px;
    }
    
    .cat-happy-content p {
        font-size: 15px;
    }
    
    .cat-happy-message {
        padding: 22px;
        margin: 18px;
    }
}

@media (max-width: 480px) {
    .jack-command-panel {
        padding: 18px;
        margin: 15px;
    }
    
    .jack-command-panel h3 {
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    .jack-command-btn {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .jack-response-text {
        font-size: 14px;
    }
    
    .happy-cat img {
        width: 30px;
        height: 30px;
    }
    
    .cat-happy-content p {
        font-size: 14px;
    }
    
    .cat-happy-message {
        padding: 20px;
        margin: 15px;
    }
}
