/* Tutorial Container - Max width 800px */
.tutorial-container {
    font-family: 'Courier New', monospace;
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.stages-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.stage-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center align content horizontally */
}

.stage-header {
    font-weight: bold;
    margin-bottom: 10px;
    color: #555;
    font-family: 'Courier New', monospace;
}

/* Grids */
.grid-container {
    display: grid;
    gap: 2px;
    margin: 0 auto;
    background: #ccc;
    border: 1px solid #999;
    padding: 2px;
    justify-content: center; /* Center align the grid */
}

.grid-8 { 
    grid-template-columns: repeat(8, 30px); 
}

.grid-6 { 
    grid-template-columns: repeat(6, 30px); 
}

.grid-3 { 
    grid-template-columns: repeat(3, 40px); 
}

.cell {
    position: relative; /* Add this for pseudo-element positioning */
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #ccc;
    cursor: default;
    transition: background 0.2s, transform 0.2s;
    font-family: 'Courier New', monospace;
}

/* User Input Grid (8x8) */
.grid-8 .cell { 
    cursor: pointer; 
    height: 30px; 
}

.grid-8 .cell.active { 
    background: #333; 
    color: white; 
}

/* Output Grids */
.grid-6 .cell { 
    height: 30px; 
    font-weight: bold; 
    color: #333; 
}

.grid-3 .cell { 
    height: 40px; 
    font-weight: bold; 
    color: #333; 
    font-size: 12px; 
}

/* Gradient color coding for output cells */
.cell.has-value {
    transition: background-color 0.3s ease;
}

/* Color gradient: low values = light blue, high values = dark blue */
.cell.value-0 { background-color: #f0f8ff; color: #333; }
.cell.value-1 { background-color: #d0e8ff; color: #333; }
.cell.value-2 { background-color: #b0d8ff; color: #333; }
.cell.value-3 { background-color: #90c8ff; color: #333; }
.cell.value-4 { background-color: #70b8ff; color: #333; }
.cell.value-5 { background-color: #50a8ff; color: #333; }
.cell.value-6 { background-color: #3098ff; color: #fff; }
.cell.value-7 { background-color: #1088ff; color: #fff; }
.cell.value-8 { background-color: #0078ff; color: #fff; }
.cell.value-9 { background-color: #0068ee; color: #fff; }
.cell.value-10 { background-color: #0058dd; color: #fff; }
.cell.value-high { background-color: #0044cc; color: #fff; } /* For values > 10 */

/* Process Info (Arrows and Kernel) */
.process-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-direction: column;
}

.arrow {
    font-size: 24px;
    color: #666;
}

.kernel-box {
    text-align: center;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.kernel-box .label {
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 5px;
    font-family: 'Courier New', monospace;
}

.kernel-box .sub-label {
    font-size: 10px;
    color: #666;
    margin-bottom: 5px;
    font-family: 'Courier New', monospace;
}

/* Kernel Display */
.kernel-grid {
    display: grid;
    grid-template-columns: repeat(3, 20px);
    gap: 1px;
    background: #666;
    margin: 5px auto;
    padding: 1px;
}

.kernel-cell {
    width: 20px; 
    height: 20px;
    background: #fff;
    font-size: 9px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

/* Animation Highlights */
/* The sliding window on the source grid */
.cell.highlight-source {
    /* Removed background-color - now using ::after pseudo-element */
    border: 2px solid #ffc107 !important;
    z-index: 5;
}

/* Semi-transparent yellow overlay that sits on top of the cell content */
.cell.highlight-source::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 193, 7, 0.5); /* This sits ON TOP of the black pixel */
    pointer-events: none; /* Allows clicks to pass through if necessary */
    z-index: 1; /* Above the cell background but below the border */
}

/* The target cell being calculated */
.cell.highlight-target {
    background-color: #28a745 !important; /* Green */
    color: white !important;
    transform: scale(1.1);
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.6);
    z-index: 10;
    border: 2px solid #1e7e34 !important;
}

/* Controls */
.tutorial-controls {
    display: flex;
    justify-content: space-between;
    background: #eee;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.control-group { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
}

.control-group label {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 12px;
}

.form-select {
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background: white;
    cursor: pointer;
}

.btn { 
    padding: 6px 12px; 
    cursor: pointer; 
    border: 1px solid #ccc; 
    border-radius: 4px; 
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background: white;
    transition: background 0.2s;
}

.btn:hover {
    background: #f0f0f0;
}

.btn-primary { 
    background: #007bff; 
    color: white; 
    border: none; 
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-danger { 
    background: #dc3545; 
    color: white; 
    border: none; 
}

.btn-danger:hover {
    background: #c82333;
}

#speedRange {
    width: 150px;
}

/* Math Panel */
.math-panel {
    background: #1e1e1e;
    color: #0f0;
    font-family: 'Courier New', monospace;
    padding: 15px;
    border-radius: 6px;
    min-height: 80px;
    margin-top: 20px;
    border: 2px solid #0f0;
}

.math-panel h4 {
    color: #0f0;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
}

.math-content { 
    font-size: 13px; 
    line-height: 1.6; 
    white-space: pre-wrap; 
    color: #0f0;
    font-family: 'Courier New', monospace;
}

/* Responsive adjustments */
@media (max-width: 850px) {
    .stages-wrapper {
        flex-direction: column;
    }
    
    .process-info {
        flex-direction: row;
    }
    
    .arrow {
        transform: rotate(90deg);
    }
}

