/* VILLAGE ANIMATIONS CSS */

/* Village Background Layers */
.village-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

/* Sky Layer - Flying Dragons and Clouds */
.sky-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(180deg, #87CEEB 0%, #ADD8E6 50%, #F0F8FF 100%);
}

.flying-dragon {
    position: absolute;
    width: 60px;
    height: 40px;
    background: linear-gradient(45deg, #8B4513, #A0522D);
    border-radius: 50% 20% 50% 20%;
    animation: flyAcross 25s infinite linear;
}

.flying-dragon::before {
    content: '🐉';
    position: absolute;
    top: -5px;
    left: 10px;
    font-size: 30px;
    z-index: 2;
}

.dragon-1 {
    top: 10%;
    animation-delay: 0s;
    animation-duration: 30s;
}

.dragon-2 {
    top: 20%;
    animation-delay: 10s;
    animation-duration: 25s;
}

.dragon-3 {
    top: 15%;
    animation-delay: 20s;
    animation-duration: 35s;
}

@keyframes flyAcross {
    0% {
        left: -100px;
        transform: scale(0.8) rotate(0deg);
    }
    25% {
        transform: scale(1) rotate(5deg);
    }
    50% {
        transform: scale(1.1) rotate(-3deg);
    }
    75% {
        transform: scale(0.9) rotate(2deg);
    }
    100% {
        left: calc(100% + 100px);
        transform: scale(0.8) rotate(0deg);
    }
}

.clouds {
    position: absolute;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50px;
    animation: driftClouds 20s infinite linear;
}

.cloud-1 {
    top: 5%;
    width: 80px;
    height: 30px;
    animation-delay: 0s;
}

.cloud-2 {
    top: 25%;
    width: 120px;
    height: 40px;
    animation-delay: 7s;
}

.cloud-3 {
    top: 15%;
    width: 100px;
    height: 35px;
    animation-delay: 14s;
}

@keyframes driftClouds {
    0% {
        left: -150px;
        opacity: 0.6;
    }
    50% {
        opacity: 0.9;
    }
    100% {
        left: calc(100% + 150px);
        opacity: 0.6;
    }
}

/* Mountains Layer */
.mountains-layer {
    position: absolute;
    top: 30%;
    left: 0;
    width: 100%;
    height: 30%;
    background: linear-gradient(180deg, #DDA0DD 0%, #D8BFD8 100%);
}

.mountain {
    position: absolute;
    bottom: 0;
    background: linear-gradient(135deg, #696969, #A9A9A9);
    clip-path: polygon(0% 100%, 50% 0%, 100% 100%);
}

.mountain-1 {
    left: 10%;
    width: 150px;
    height: 80px;
}

.mountain-2 {
    left: 40%;
    width: 200px;
    height: 100px;
}

.mountain-3 {
    left: 70%;
    width: 180px;
    height: 90px;
}

/* Trees Layer */
.trees-layer {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(180deg, #9ACD32 0%, #228B22 100%);
}

.tree {
    position: absolute;
    bottom: 20%;
    width: 25px;
    height: 60px;
    background: #8B4513;
    border-radius: 5px;
    transform-origin: bottom;
}

.tree::before {
    content: '🌳';
    position: absolute;
    top: -20px;
    left: -10px;
    font-size: 35px;
}

.tree.swaying {
    animation: sway 4s ease-in-out infinite;
}

.tree-1 {
    left: 15%;
    animation-delay: 0s;
}

.tree-2 {
    left: 35%;
    animation-delay: 1s;
}

.tree-3 {
    left: 55%;
    animation-delay: 0.5s;
}

.tree-4 {
    left: 75%;
    animation-delay: 1.5s;
}

.tree-5 {
    left: 90%;
    animation-delay: 2s;
}

@keyframes sway {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(2deg);
    }
    75% {
        transform: rotate(-2deg);
    }
}

/* Village Grid */
.village-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 5px;
    width: 100%;
    max-width: 800px;
    height: 400px;
    margin: 20px auto;
    padding: 20px;
    background: rgba(34, 139, 34, 0.3);
    border-radius: 10px;
    border: 2px solid #228B22;
}

.grid-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px dashed rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    transition: all 0.3s ease;
}

.building-slot {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s ease;
    position: relative;
}

.building-slot.empty {
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed rgba(255, 255, 255, 0.5);
}

.building-slot.empty:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #fff;
    transform: scale(1.05);
}

.building-slot.occupied {
    background: rgba(139, 69, 19, 0.8);
    border: 2px solid #8B4513;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.building-slot.occupied:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.building-slot.occupied.producing {
    animation: pulse 2s ease-in-out infinite;
    box-shadow: 0 4px 8px rgba(255, 215, 0, 0.5);
}

.building-slot .building-sprite {
    width: 80px !important;
    height: 60px !important;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 4px;
}

.building-level {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 8px rgba(255, 215, 0, 0.5);
    }
    50% {
        box-shadow: 0 4px 8px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.3);
    }
}

.building-sprite {
    width: 80%;
    height: 80%;
    object-fit: contain;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
}

.building-fallback {
    font-size: 24px;
    color: #8B4513;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.build-indicator {
    font-size: 32px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.production-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #FFD700;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    animation: glow 1s ease-in-out infinite alternate;
}

@keyframes glow {
    0% {
        box-shadow: 0 0 5px #FFD700;
    }
    100% {
        box-shadow: 0 0 15px #FFD700, 0 0 25px #FFD700;
    }
}

.building-level {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 10px;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: bold;
}

/* Dragon and Hero Cards with Images */
.active-dragon-card, .active-hero-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 10px;
}

.dragon-image, .hero-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dragon-sprite, .hero-sprite {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dragon-fallback, .hero-fallback {
    font-size: 30px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Responsive Design */
@media (max-width: 768px) {
    .village-grid {
        grid-template-columns: repeat(6, 1fr);
        height: 300px;
        gap: 3px;
    }
    
    .building-sprite {
        width: 70%;
        height: 70%;
    }
    
    .flying-dragon {
        width: 40px;
        height: 25px;
    }
    
    .flying-dragon::before {
        font-size: 20px;
    }
    
    .tree::before {
        font-size: 25px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .flying-dragon,
    .clouds,
    .tree.swaying,
    .building-slot.producing {
        animation: none;
    }
}