/* ===========================================
   ADAPTIVE TACTICS - Board Stylesheet
   =========================================== */

/* Board Container */
#board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-md);
    overflow: auto;
}

/* Game Board Grid */
#game-board {
    display: grid;
    grid-template-columns: repeat(15, var(--tile-size));
    grid-template-rows: repeat(15, var(--tile-size));
    gap: 1px;
    background: var(--border-dim);
    border: 2px solid var(--border-mid);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Individual Tile Cell */
.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    position: relative;
    background-color: var(--bg-cell);
    background-size: cover;
    background-position: center;
    cursor: pointer;
    transition: box-shadow 0.15s ease;
}

/* Tile Types */
.tile--floor {
    background-image: url('../assets/tiles/dark_stone_floor_tile.png');
}

.tile--bush {
    background-image: url('../assets/tiles/mossy_bush_floor_tile.png');
    background-color: var(--bg-cell-bush);
}

.tile--blocked {
    background-image: url('../assets/tiles/cracked_wall_blocked_tile.png');
    background-color: var(--bg-cell-block);
    cursor: not-allowed;
}

.tile--throne {
    background-image: url('../assets/tiles/eerie_throne_tile.png');
    background-color: var(--bg-cell-throne);
}

/* Tile Overlays */
.tile--move-range {
    box-shadow: inset 0 0 0 2px var(--blue-move-bdr);
    background-color: var(--blue-move);
}

.tile--move-range::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(26, 37, 53, 0.4);
    pointer-events: none;
}

.tile--attack-range {
    box-shadow: inset 0 0 0 2px var(--red-attack-bdr);
}

.tile--attack-range::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(42, 21, 16, 0.4);
    pointer-events: none;
}

.tile--heal-range {
    box-shadow: inset 0 0 0 2px var(--gold-muted);
}

.tile--heal-range::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--ivory-heal);
    pointer-events: none;
}

.tile--selected {
    box-shadow: inset 0 0 0 2px var(--gold);
}

.tile--targeted {
    box-shadow: inset 0 0 0 2px var(--gold);
}

.tile--targeted::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gold-target);
    pointer-events: none;
}

.tile--threat {
    box-shadow: inset 0 0 0 1px var(--crimson);
}

.tile--threat::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(138, 42, 42, 0.2);
    pointer-events: none;
}

/* Tile Hover */
.tile:hover:not(.tile--blocked) {
    box-shadow: inset 0 0 0 2px var(--gold-muted);
}

/* Unit Sprite Container */
.unit-sprite {
    position: absolute;
    width: var(--sprite-size);
    height: var(--sprite-size);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background-size: contain;
    background-position: center bottom;
    background-repeat: no-repeat;
    z-index: 10;
    pointer-events: none;
}

/* Player unit sprites */
.unit-sprite--player {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

/* Enemy unit sprites */
.unit-sprite--enemy {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

/* Special handling for sprites with black backgrounds */
.unit-sprite--blend {
    mix-blend-mode: screen;
}

/* Unit HP Bar */
.unit-hp-bar {
    position: absolute;
    bottom: 2px;
    left: 4px;
    right: 4px;
    height: var(--hp-bar-height);
    background: rgba(0, 0, 0, 0.6);
    border-radius: 1px;
    overflow: hidden;
    z-index: 15;
}

.unit-hp-fill {
    height: 100%;
    background: var(--green-hp);
    transition: width 0.2s ease;
}

.unit-hp-fill--low {
    background: #a85a3a;
}

.unit-hp-fill--critical {
    background: var(--crimson);
}

/* Unit Selection Indicator */
.unit-selected-indicator {
    position: absolute;
    inset: 0;
    border: 2px solid var(--gold);
    pointer-events: none;
    z-index: 5;
    animation: pulse-gold 1.5s ease-in-out infinite;
}

@keyframes pulse-gold {
    0%, 100% {
        box-shadow: inset 0 0 4px var(--gold);
    }
    50% {
        box-shadow: inset 0 0 8px var(--gold), 0 0 4px var(--gold);
    }
}

/* Unit Acted Indicator */
.unit-sprite--acted {
    opacity: 0.6;
    filter: grayscale(50%) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

/* Unit Death Animation */
.unit-sprite--dying {
    animation: unit-death 0.5s ease-out forwards;
}

@keyframes unit-death {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* Combat Flash Effect */
.tile--combat-flash {
    animation: combat-flash 0.3s ease;
}

@keyframes combat-flash {
    0% {
        background-color: rgba(255, 255, 255, 0.3);
    }
    100% {
        background-color: transparent;
    }
}

/* Damage Number Popup */
.damage-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--crimson);
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
    z-index: 100;
    pointer-events: none;
    animation: damage-float 0.8s ease-out forwards;
}

.damage-popup--heal {
    color: var(--green-hp);
}

.damage-popup--miss {
    color: var(--text-muted);
    font-style: italic;
}

@keyframes damage-float {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -100%);
    }
}

/* Board Coordinate Labels (optional, hidden by default) */
.board-label-row,
.board-label-col {
    display: none;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-dim);
}
