/* Pathfinding visualizer — grid, node states, and legend
   (controls come from visualizer.css, page shell from projects.css) */

.grid-container {
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 20px;
    width: 100%;
    height: 500px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pathfinding-grid {
    display: grid;
    gap: 1px;
    background: var(--border);
    padding: 1px;
    width: max-content;
    height: max-content;
}

.grid-node {
    background: var(--surface);
    border: 1px solid rgba(160, 180, 170, 0.06);
    cursor: pointer;
    transition: background 0.3s ease;
    box-sizing: border-box;
}

.grid-node:hover:not(.start-node):not(.end-node):not(.wall-node):not(.visited-node):not(.path-node) {
    background: var(--surface-hover);
}

/* Node states */
.start-node {
    background: #34d399 !important;
    animation: node-pulse 1s infinite;
}

.end-node {
    background: #f87171 !important;
    animation: node-pulse 1s infinite;
}

.wall-node {
    background: #93a3ae !important;
    animation: wall-in 0.3s ease;
}

.visited-node {
    background: #0f5c46 !important;
    animation: visited-in 0.5s ease;
}

.visiting-node {
    background: #00e99f !important;
    animation: visiting-in 0.5s ease;
}

.path-node {
    background: #fbbf24 !important;
    animation: path-in 0.5s ease;
}

/* Animations */
@keyframes node-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes wall-in {
    0% { transform: scale(0.3); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes visited-in {
    0% { transform: scale(0.3); border-radius: 50%; }
    100% { transform: scale(1); border-radius: 0; }
}

@keyframes visiting-in {
    0% { transform: scale(0.5); }
    100% { transform: scale(1); }
}

@keyframes path-in {
    0% { transform: scale(0.3); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Legend */
.legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    padding: 16px 20px;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.legend-color {
    width: 18px;
    height: 18px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 1200px) {
    .grid-container {
        height: 450px;
    }
}

@media (max-width: 768px) {
    .grid-container {
        height: 400px;
        padding: 14px;
    }

    .legend {
        gap: 14px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .grid-container {
        height: 350px;
        padding: 10px;
    }
}
