/* Grid-specific styles for Jeans-Zip Game */

#grid-container {
    position: relative;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-lg);
    min-height: 400px;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    pointer-events: none;
    border-radius: var(--radius-md);
}

#game-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 2px;
    background: rgba(0, 0, 0, 0.3);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    border: 3px solid var(--brass-light);
    /* Jeans background image */
    background-image: url('../assets/images/jeans-texture.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Override for when jeans image is available */
#game-grid.has-jeans-bg {
    background-color: transparent;
}

#game-grid.has-jeans-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-lg);
    z-index: -1;
}

/* Remove old grid size variations since we're using fixed 6x6 */

/* Grid cells */
.grid-cell {
    width: 60px;
    height: 60px;
    background: transparent;
    border: 3px solid var(--grid-contrast);
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: crosshair;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    font-family: var(--font-mono);
    font-weight: bold;
    font-size: 1.4rem;
    color: var(--white);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
    user-select: none;
}

/* Denim texture for cells */
.grid-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 1px 1px, rgba(255,255,255,0.15) 0.5px, transparent 0),
        linear-gradient(30deg, transparent 40%, rgba(0,0,0,0.1) 40%, rgba(0,0,0,0.1) 60%, transparent 60%);
    background-size: 8px 8px, 16px 16px;
    pointer-events: none;
    z-index: 1;
}

.grid-cell span {
    position: relative;
    z-index: 2;
}

/* Cell states */
.grid-cell.numbered {
    background: linear-gradient(135deg, var(--brass-dark) 0%, var(--brass-light) 100%);
    border-color: var(--cream);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(245, 158, 11, 0.8);
    }
}

.grid-cell.visited {
    background: linear-gradient(135deg, var(--denim-light) 0%, var(--denim-blue) 100%);
    border-color: var(--cream);
    animation: none;
}

.grid-cell.current {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    border-color: var(--white);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.7);
    animation: current-pulse 1s ease-in-out infinite;
}

@keyframes current-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 15px rgba(16, 185, 129, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 25px rgba(16, 185, 129, 0.9);
    }
}

.grid-cell.invalid {
    background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.grid-cell.hint {
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
    border-color: var(--white);
    animation: hint-pulse 1.5s ease-in-out infinite;
}

@keyframes hint-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Cell hover effects */
.grid-cell:hover:not(.visited):not(.invalid) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--white);
}

.grid-cell:active {
    transform: translateY(0);
}

/* Grid visibility options */
.grid-high-contrast .grid-cell {
    border-width: 3px;
    border-color: var(--white);
}

.grid-high-contrast .grid-cell.numbered {
    border-color: #FFFF00;
}

.grid-minimal .grid-cell {
    border-width: 1px;
    border-color: rgba(255, 255, 255, 0.3);
}

/* Responsive grid sizing for 6x6 */
@media (max-width: 768px) {
    .grid-cell {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
        border-width: 2px;
    }
    
    #grid-container {
        padding: var(--spacing-md);
        min-height: 350px;
    }
    
    #game-grid {
        padding: var(--spacing-sm);
    }
}

@media (max-width: 480px) {
    .grid-cell {
        width: 35px;
        height: 35px;
        font-size: 1rem;
        border-width: 2px;
    }
    
    #game-grid {
        gap: 1px;
        padding: var(--spacing-xs);
    }
}

/* Grid loading animation */
.grid-cell.loading {
    animation: cell-load 0.6s ease-out forwards;
    opacity: 0;
    transform: scale(0.8);
}

@keyframes cell-load {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Stagger loading animation for cells */
.grid-cell:nth-child(1) { animation-delay: 0.1s; }
.grid-cell:nth-child(2) { animation-delay: 0.15s; }
.grid-cell:nth-child(3) { animation-delay: 0.2s; }
.grid-cell:nth-child(4) { animation-delay: 0.25s; }
.grid-cell:nth-child(5) { animation-delay: 0.3s; }
.grid-cell:nth-child(6) { animation-delay: 0.35s; }
.grid-cell:nth-child(7) { animation-delay: 0.4s; }
.grid-cell:nth-child(8) { animation-delay: 0.45s; }
.grid-cell:nth-child(9) { animation-delay: 0.5s; }
/* Continue pattern for larger grids */

/* Path preview */
.grid-cell.path-preview {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3) 0%, rgba(5, 150, 105, 0.3) 100%);
    border-color: rgba(16, 185, 129, 0.6);
}

/* Victory animation */
.victory-animation .grid-cell {
    animation: victory-sparkle 2s ease-in-out infinite;
}

@keyframes victory-sparkle {
    0%, 100% {
        filter: brightness(1);
    }
    25% {
        filter: brightness(1.3) hue-rotate(90deg);
    }
    50% {
        filter: brightness(1.5) hue-rotate(180deg);
    }
    75% {
        filter: brightness(1.3) hue-rotate(270deg);
    }
}
