/*
 * Game-Specific Styles
 * 
 * Tile materials, states, and animations.
 * Uses CSS custom properties for dynamic grid sizing.
 */

/* ============================================
   Game Board Grid
   ============================================ */

.game-board {
    --grid-cols: 10;
    --grid-rows: 10;
    --tile-gap: 2px;
    --board-max-size: min(90vw, 70vh, 500px);

    display: grid;
    grid-template-columns: repeat(var(--grid-cols), 1fr);
    grid-template-rows: repeat(var(--grid-rows), 1fr);
    gap: var(--tile-gap);
    width: var(--board-max-size);
    aspect-ratio: var(--grid-cols) / var(--grid-rows);
    background: rgba(0, 0, 0, 0.3);
    padding: var(--tile-gap);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

/* ============================================
   Tile Base Styles
   ============================================ */

.tile {
    aspect-ratio: 1;
    border-radius: 0.15em;
    cursor: pointer;
    transition: transform var(--transition-fast),
                filter var(--transition-fast),
                box-shadow var(--transition-fast);
    position: relative;
    overflow: hidden;

    /* Minimum touch target size for accessibility */
    min-width: 24px;
    min-height: 24px;
}

.tile:hover {
    transform: scale(1.05);
    z-index: 1;
}

.tile:active {
    transform: scale(0.95);
}

/* ============================================
   Tile States
   ============================================ */

/* Burning State */
.tile--burning {
    animation: burn-pulse 0.4s ease-in-out infinite alternate;
    cursor: pointer !important;
    box-shadow: 
        0 0 10px 2px rgba(255, 100, 0, 0.6),
        0 0 20px 4px rgba(255, 50, 0, 0.3);
}

.tile--burning::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(255, 100, 0, 0.8) 0%,
        rgba(255, 200, 0, 0.6) 30%,
        rgba(255, 50, 0, 0.4) 60%,
        transparent 100%
    );
    animation: fire-flicker 0.2s ease-in-out infinite alternate;
}

.tile--burning::after {
    content: '🔥';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.6rem, 2vw, 1rem);
    animation: fire-emoji 0.3s ease-in-out infinite alternate;
}

/* Burning oil - more intense, indicates unextinguishable */
.tile--oil.tile--burning {
    box-shadow:
            0 0 15px 4px rgba(255, 50, 0, 0.8),
            0 0 30px 8px rgba(255, 0, 0, 0.4);
}

.tile--oil.tile--burning::after {
    content: '🛢️';
}

/* Extinguished State */
.tile--extinguished {
    filter: brightness(0.7) saturate(0.5);
    cursor: default;
}

.tile--extinguished::after {
    content: '🌊';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.5rem, 1.5vw, 0.8rem);
    opacity: 0.7;
}

.tile--extinguished:hover {
    transform: none;
}

/* Destroyed State */
.tile--destroyed {
    cursor: default;
}

.tile--destroyed:hover {
    transform: none;
}

/* ============================================
   Animations
   ============================================ */

@keyframes burn-pulse {
    0% {
        filter: brightness(1.0);
    }
    100% {
        filter: brightness(1.3);
    }
}

@keyframes fire-flicker {
    0% {
        opacity: 0.7;
        transform: scaleY(0.95);
    }
    100% {
        opacity: 1;
        transform: scaleY(1.05);
    }
}

@keyframes fire-emoji {
    0% {
        transform: scale(0.9) rotate(-5deg);
    }
    100% {
        transform: scale(1.1) rotate(5deg);
    }
}

/* Subtle ambient animation for water */

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 480px) {
    .game-board {
        --board-max-size: min(95vw, 60vh, 400px);
    }

    .tile--burning::after,
    .tile--extinguished::after {
        font-size: 0.5rem;
    }
}

@media (min-width: 768px) {
    .game-board {
        --board-max-size: min(80vw, 70vh, 600px);
    }
}

/* ============================================
   Reduced Motion Support
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .tile,
    .tile--burning,
    .tile--burning::before,
    .tile--burning::after,
    .tile--water {
        animation: none;
        transition: none;
    }

    .tile--burning {
        background: linear-gradient(135deg, #ff6600 0%, #ff3300 100%);
    }

    .tile--burning::before {
        display: none;
    }
}
