/* ========================================
   Step-by-Step Mode
   ======================================== */

#section-step {
    display: none;
    padding: 1.5rem;
    height: 100%;
    overflow-y: auto;
}

#section-step.active-section {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.step-header {
    text-align: center;
    margin-bottom: 1rem;
}

.step-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.step-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.step-controls {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
    justify-content: space-between;
}

.step-config {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.step-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.step-info {
    background: var(--bg-tertiary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.step-counter {
    font-size: 1.25rem;
    font-weight: 600;
}

.step-description {
    flex: 1;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.step-stats {
    display: flex;
    gap: 1.5rem;
}

/* Time travel scrubber moved to _controls.css */

/* Split Layout */
.step-split-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 1.5rem;
    margin-bottom: 1rem;
    align-items: stretch;
    flex: 1;
    min-height: 0;
}

.step-vis-pane {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.step-code-pane {
    flex: 0 0 320px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    height: 100%;
    max-height: 500px;
}

/* Pseudocode */
.pseudocode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.pseudocode-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pseudocode-complexity {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--bar-compare);
    background: rgba(245, 200, 66, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.pseudocode-container {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    line-height: 1.8;
}

.pseudocode-line {
    display: flex;
    padding: 0.15rem 1rem;
    transition: background 0.2s, border-color 0.2s;
    border-left: 3px solid transparent;
}

.pseudocode-line.active {
    background: rgba(245, 200, 66, 0.15);
    border-left-color: var(--bar-compare);
}

.pseudocode-line.executed {
    opacity: 0.6;
}

.pseudocode-line.active.executed {
    opacity: 1;
}

.line-number {
    width: 28px;
    color: var(--text-muted);
    user-select: none;
    text-align: right;
    margin-right: 1rem;
    flex-shrink: 0;
}

.line-content {
    flex: 1;
    color: var(--text-primary);
    white-space: pre;
}

.line-content .keyword {
    color: #c678dd;
}

.line-content .function {
    color: #61afef;
}

.line-content .variable {
    color: #e5c07b;
}

.line-content .comment {
    color: var(--text-muted);
    font-style: italic;
}

.line-content .operator {
    color: #56b6c2;
}

/* Fix #26: Additional syntax highlight tokens for all languages */
.line-content .number {
    color: #d19a66;
}

.line-content .string {
    color: #98c379;
}

.line-content .type {
    color: #e5c07b;
}

.line-content .builtin {
    color: #e06c75;
}

.line-content .punctuation {
    color: #abb2bf;
}

[data-theme="light"] .line-content .keyword {
    color: #a626a4;
}

[data-theme="light"] .line-content .function {
    color: #4078f2;
}

[data-theme="light"] .line-content .variable {
    color: #c18401;
}

[data-theme="light"] .line-content .comment {
    color: #a0a1a7;
}

[data-theme="light"] .line-content .operator {
    color: #0184bc;
}

[data-theme="light"] .line-content .number {
    color: #986801;
}

[data-theme="light"] .line-content .string {
    color: #50a14f;
}

[data-theme="light"] .line-content .type {
    color: #c18401;
}

[data-theme="light"] .line-content .builtin {
    color: #e45649;
}

.pseudocode-footer {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.code-legend {
    display: flex;
    gap: 1.5rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.code-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.code-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.code-dot.active {
    background: var(--bar-compare);
}

.code-dot.executed {
    background: var(--text-muted);
    opacity: 0.5;
}

@media (max-width: 1100px) {
    .step-split-container {
        flex-wrap: wrap;
    }

    .step-code-pane {
        flex: 1 1 100%;
        max-width: 100%;
        max-height: 300px;
        order: 2;
    }

    .step-vis-pane {
        flex: 1 1 100%;
        order: 1;
    }

    .step-visualizer {
        min-height: 300px;
    }
}

/* Step Visualizer */
.step-visualizer {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    flex: 1;
    min-height: 350px;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 1.5rem;
    gap: 4px;
    margin-bottom: 1rem;
}

.step-visualizer .bar {
    flex: 1;
    min-width: 8px;
    max-width: 60px;
    background: var(--bar-default);
    border-radius: 4px 4px 0 0;
    transition: all 0.3s ease;
    position: relative;
}

.step-visualizer .bar.compare {
    background: var(--bar-compare) !important;
}

.step-visualizer .bar.swap {
    background: var(--bar-swap) !important;
}

.step-visualizer .bar.sorted {
    background: var(--bar-sorted) !important;
}

.step-visualizer .bar::after {
    content: attr(data-value);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    padding: 2px 4px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.2s;
}

.step-visualizer .bar:hover::after {
    opacity: 1;
}

/* Step Legend */
.step-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.step-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.step-legend .legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.legend-color.comparing {
    background: var(--bar-compare);
}

.legend-color.swapping {
    background: var(--bar-swap);
}

.legend-color.sorted {
    background: var(--bar-sorted);
}

/* Bookmarks */
.step-bookmarks {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.step-bookmarks h4 {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.bookmark-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 0.6rem;
    font-weight: 700;
}



.bookmark-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 0.8rem;
}

.bookmark-step {
    font-weight: 600;
    color: var(--bar-compare);
    min-width: 60px;
}

.bookmark-desc {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bookmark-goto,
.bookmark-remove {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
}

.bookmark-remove {
    color: var(--text-muted);
}

.bookmark-remove:hover {
    color: var(--bar-swap);
}