/* ==========================================
   Busy Beaver - Page-specific Styles
   ========================================== */

.tape-example {
    margin: 10px 0;
    padding: 5px;
    background-color: #f0f0f0;
    border: 1px dashed #ccc;
    border-radius: 3px;
}

.tape-example .tape-viz {
    font-family: var(--font-mono);
    font-weight: bold;
    color: var(--color-danger);
}

.mermaid {
    text-align: center;
    margin-bottom: 20px;
}

.step-by-step-diagrams {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
    justify-content: center;
}

.diagram-step {
    border: 1px solid #ddd;
    padding: 15px;
    border-radius: 5px;
    background-color: #f9f9f9;
    flex: 1 1 300px;
    min-width: 280px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.05);
}

.diagram-step p {
    margin-top: 0;
    font-size: 0.95em;
    text-align: center;
}

.diagram-step .mermaid {
    margin-bottom: 0;
    padding: 5px;
    background-color: #fff;
    border-radius: 3px;
}

.machine-info {
    font-size: 0.9rem;
    color: var(--color-text-light);
    font-style: italic;
}

/* Transition Table */
.transition-table {
    width: 100%;
    max-width: 400px;
    border-collapse: collapse;
    margin-bottom: 12px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.transition-table th,
.transition-table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: center;
}

.transition-table thead th {
    background-color: var(--color-primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
}

.transition-table .state-cell {
    font-weight: 700;
    background-color: var(--color-surface-alt);
    color: var(--color-primary);
}

.transition-table .rule-cell {
    transition: background-color 0.2s, color 0.2s;
}

.transition-table tr.active-row .state-cell {
    background-color: #e7f3fe;
    color: #1565c0;
}

.transition-table .rule-cell.active-rule {
    background-color: #007bff;
    color: #fff;
    font-weight: 700;
}

/* Turing Machine Simulator */
#turing-machine {
    border: 1px solid #ccc;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: var(--radius-sm);
}

/* Tape container with scroll indicators (4.2) */
#tape-container {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 15px;
    padding: 10px 0;
    background-color: #e0e0e0;
    border: 1px solid #ccc;
    border-radius: 3px;
    position: relative;
    -webkit-mask-image: linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent);
    mask-image: linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent);
}

#tape {
    display: flex;
    min-width: fit-content;
    padding: 0 24px;
}

.tape-cell {
    min-width: 30px;
    height: 30px;
    border: 1px solid #bbb;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
    background-color: #fff;
    margin-right: 2px;
}

.tape-cell.active {
    border: 2px solid var(--color-info);
    font-weight: bold;
    background-color: #e6f2ff;
}

.tape-cell.written {
    animation: flash-write 0.5s ease-out;
}

@keyframes flash-write {
    0% { background-color: #a8d8ff; }
    50% { background-color: #6cbaff; }
    100% { background-color: #fff; }
}

/* Controls - uses shared .ctrl-btn styles */
#controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

#info p {
    margin: 5px 0;
    font-size: 1.1em;
}

#info span {
    font-weight: bold;
}

#current-rule-display {
    margin-top: 15px;
    padding: 10px;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    transition: border-color 0.3s, background-color 0.3s;
}

#current-rule-display p {
    margin: 0;
}

#current-rule-display #rule-text {
    font-family: var(--font-mono);
    color: #007bff;
}

/* Halt Animation (5.2) */
#turing-machine.halted #info {
    animation: halt-flash 0.6s ease-out;
}

#turing-machine.halted #current-rule-display {
    border-color: var(--color-success);
    background-color: #e8f5e9;
}

@keyframes halt-flash {
    0% { background-color: transparent; }
    30% { background-color: #c8e6c9; }
    100% { background-color: transparent; }
}

/* Responsive */
@media (max-width: 640px) {
    #controls {
        flex-direction: column;
        align-items: stretch;
    }

    #controls .control-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    #controls .speed-control {
        width: 100%;
    }

    .transition-table {
        font-size: 0.8rem;
    }
}
