/* Peasant command panel : shown when any peasant is selected.
   Uses the same 2-column grid as the build toolbar so future command
   buttons (Stop, Repair…) align with the build-grid layout. */
.peasant-commands {
    width: 100%;
    background: rgba(20, 20, 20, 0.7);
    border-radius: 4px;
    padding: 6px 4px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    transition: opacity 0.15s ease;
}

.peasant-commands-hidden {
    opacity: 0;
    display: none;
    pointer-events: none;
}

/* The "Build" command button : text-only, no building-sprite background. */
.peasant-cmd-build {
    background-image: none;
    font-size: 10px;
    color: #f3e2b1;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Build toolbar : appears inside #command-frame when "Build" is clicked. */
.build-toolbar {
    width: 100%;
    background: rgba(20, 20, 20, 0.7);
    border-radius: 4px;
    padding: 6px 4px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    color: #f3e2b1;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 12px;
    transition: opacity 0.15s ease;
}

/* Label and cancel button span both columns */
.build-toolbar-label,
.build-btn-cancel {
    grid-column: 1 / -1;
}

.build-toolbar-hidden {
    opacity: 0;
    display: none;
    pointer-events: none;
}

.build-toolbar-label {
    font-weight: bold;
    color: #f3e2b1;
    margin-right: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 11px;
}

.build-btn {
    width: 100%;
    aspect-ratio: 1;
    height: auto;
    background-color: #2a2a2a;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 80% 80%;
    border: 1px solid #6a4f1a;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    padding: 0;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
}

.build-btn:hover {
    border-color: #f3c14b;
    box-shadow: 0 0 6px rgba(243, 193, 75, 0.6);
}

/* Active state for toggle-style command buttons (e.g. Lumberjack role). */
.peasant-cmd-active,
.peasant-cmd-role-active {
    border-color: #f3c14b;
    background-color: #3d3000;
    box-shadow: 0 0 4px rgba(243, 193, 75, 0.45) inset;
}

.build-btn span {
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    font-size: 9px;
    background: rgba(0, 0, 0, 0.7);
    color: #f3e2b1;
    padding: 1px 2px;
    line-height: 10px;
    text-align: center;
    border-radius: 0 0 3px 3px;
    pointer-events: none;
}

.build-btn-cancel {
    width: 100%;
    height: 32px;
    background-image: none;
    color: #f3e2b1;
    padding: 0 10px;
    font-size: 11px;
}

#building-commands-host {
    width: 100%;
}

.building-commands {
    width: 100%;
    background: rgba(20, 20, 20, 0.72);
    border-radius: 4px;
    padding: 6px 4px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}

.building-cmd-btn {
    min-height: 44px;
    background: #2a2a2a;
    border: 1px solid #6a4f1a;
    border-radius: 4px;
    color: #f3e2b1;
    cursor: pointer;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 11px;
    line-height: 1.2;
    padding: 6px;
}

.building-cmd-btn:hover {
    border-color: #f3c14b;
    box-shadow: 0 0 6px rgba(243, 193, 75, 0.6);
}

.building-cmd-btn:disabled {
    cursor: not-allowed;
    filter: grayscale(0.8);
    opacity: 0.48;
}

/* Ghost building shown during placement. */
.building-ghost {
    position: absolute;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    z-index: 4;
    opacity: 0.65;
    pointer-events: none;
    box-sizing: border-box;
    border: 2px solid transparent;
}

.building-ghost-valid {
    border-color: rgba(40, 200, 40, 0.9);
    box-shadow: 0 0 0 2px rgba(40, 200, 40, 0.4) inset;
}

.building-ghost-invalid {
    border-color: rgba(220, 40, 40, 0.9);
    box-shadow: 0 0 0 2px rgba(220, 40, 40, 0.4) inset;
    filter: grayscale(0.6);
}

/* Road placement ghost : single 16×16 tile cursor. */
.road-ghost {
    position: absolute;
    width: 16px;
    height: 16px;
    background-image: url('/game/assets/tilesets/forest/neutral/buildings/road.png');
    background-size: 256px 16px;
    background-repeat: no-repeat;
    background-position: 0px 0px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    z-index: 50;
    opacity: 0.75;
    pointer-events: none;
    box-sizing: border-box;
    border: 2px solid transparent;
}

.road-ghost-valid {
    border-color: rgba(40, 200, 40, 0.9);
    box-shadow: 0 0 0 2px rgba(40, 200, 40, 0.4) inset;
}

.road-ghost-invalid {
    border-color: rgba(220, 40, 40, 0.9);
    box-shadow: 0 0 0 2px rgba(220, 40, 40, 0.4) inset;
    filter: grayscale(0.6) brightness(0.8);
}

/* Placed buildings. */
.building {
    position: absolute;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    z-index: 2;
}

.building-construction {
    /* Subtle pulse so it's clear it's still being built. */
    animation: building-pulse 1.2s ease-in-out infinite;
}

@keyframes building-pulse {
    0%, 100% { filter: brightness(1.0); }
    50%      { filter: brightness(1.25); }
}

.building-complete {
    animation: building-pop 0.4s ease-out;
}

/* A building can be selected (mouse-click) like a unit. */
.building-clickable {
    cursor: pointer;
}

.building-selected {
    outline: 2px solid #f3c14b;
    outline-offset: -2px;
    box-shadow: 0 0 8px rgba(243, 193, 75, 0.65);
}

@keyframes building-pop {
    0%   { transform: scale(0.92); }
    60%  { transform: scale(1.04); }
    100% { transform: scale(1.0); }
}

/* Training Progress UI */
.training-progress {
    display: flex;
    flex-direction: column;
    padding: 4px;
    gap: 3px;
}

.training-unit-icon {
    width: 32px; height: 32px;
    background-size: contain;
    background-repeat: no-repeat;
    image-rendering: pixelated;
}

.training-bar-track {
    width: 100%;
    height: 6px;
    background: #333;
    border: 1px solid #666;
}

.training-bar-fill {
    height: 100%;
    background: #4caf50;
    transition: width 0.25s linear;
}

.training-queue {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 2px;
}

.training-queue-slot {
    width: 24px; height: 24px;
    padding: 0;
    background-size: contain;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    cursor: pointer;
}
