/* Foundations extend the existing public algorithm reading surface. */
.algorithm-learning { min-width: 0; }
.algorithm-foundations { padding-bottom: 28px; margin-bottom: 28px; border-bottom: 1px solid var(--stroke); min-width: 0; }
.algorithm-foundations h2 { font-size: var(--text-title-sm); margin: 0 0 12px; }
.algorithm-foundations p { max-width: 75ch; line-height: var(--leading-body); }
.complexity-explanation { margin: 20px 0; }
.complexity-explanation summary { cursor: pointer; font-weight: 600; }
.complexity-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 20px 0 8px; }
.algorithm-foundations select { max-width: 100%; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--radius-sm); padding: 10px; }
.complexity-table-wrap { max-width: 100%; overflow-x: auto; }
.complexity-table { width: 100%; border-collapse: collapse; font-size: var(--text-body-sm); font-variant-numeric: tabular-nums; }
.complexity-table caption { text-align: left; color: var(--muted); padding: 12px 0; line-height: var(--leading-body); }
.complexity-table th, .complexity-table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--stroke); }
.complexity-table th { font-weight: 600; }
.complexity-table th[scope="row"] { white-space: nowrap; }
.complexity-table td:nth-last-child(-n+2) { text-align: right; white-space: nowrap; }
.efficiency-lab { margin-top: 28px; }
.efficiency-code { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 20px 0; }
.efficiency-code section { min-width: 0; }
.efficiency-code h4 { margin: 0 0 10px; }
.efficiency-code pre { margin: 0; overflow: auto; background: var(--code-bg); border: 1px solid var(--code-border); border-radius: var(--radius-sm); padding: 14px; }
.efficiency-code code, .efficiency-code .hljs { background: transparent; color: var(--code-text); padding: 0; font: 14px/1.65 "IBM Plex Mono", monospace; }
.efficiency-code .hljs-title, .efficiency-code .hljs-params { color: var(--code-text); }
.efficiency-code .hljs-keyword, .efficiency-code .hljs-built_in, .efficiency-code .hljs-type {
  color: color-mix(in srgb, var(--code-keyword) 50%, var(--code-text)) !important;
}
.efficiency-note { font-size: var(--text-body-sm); color: var(--muted); }
.efficiency-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
#efficiency-results { overflow-x: auto; }
.algorithm-foundations [hidden] { display: none !important; }
.algorithm-foundations :focus-visible { outline: 2px solid var(--accent-3); outline-offset: 3px; }
@media (max-width: 700px) { .efficiency-code { grid-template-columns: minmax(0, 1fr); } .complexity-table th, .complexity-table td { padding: 10px 6px; } }
