<style>
.foundera-toc {
background: #faf9f6;
border-left: 4px solid #ffcd00;
padding: 22px 26px;
margin: 28px 0;
border-radius: 10px;
font-family: inherit;
line-height: 1.5;
}
.foundera-toc__title {
font-size: 14px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 1.2px;
color: #888;
margin: 0 0 14px 0;
}
.foundera-toc__list {
list-style: none;
margin: 0;
padding: 0;
counter-reset: toc;
}
.foundera-toc__list li {
margin: 6px 0;
padding: 0;
counter-increment: toc;
display: flex;
align-items: baseline;
}
.foundera-toc__list li::before {
content: counter(toc, decimal-leading-zero);
font-size: 12px;
font-weight: 700;
color: #ffcd00;
margin-right: 12px;
min-width: 24px;
}
.foundera-toc__list a {
color: #1a1a1a;
text-decoration: none;
font-size: 16px;
font-weight: 500;
border-bottom: 1px solid transparent;
transition: color .2s ease, border-color .2s ease;
}
.foundera-toc__list a:hover {
color: #b8930b;
border-bottom-color: #ffcd00;
}
html { scroll-behavior: smooth; }
@media (max-width: 600px) {
.foundera-toc { padding: 18px 20px; }
.foundera-toc__list a { font-size: 15px; }
}
</style>
<div class="foundera-toc" aria-label="Table of contents">
<p class="foundera-toc__title">Table of Contents</p>
<ul class="foundera-toc__list" id="foundera-toc-list"></ul>
</div>
<script>
(function () {
function ready(fn) {
if (document.readyState !== 'loading') fn();
else document.addEventListener('DOMContentLoaded', fn);
}
function slugify(text) {
return text
.toLowerCase()
.replace(/[‘’']/g, '')
.replace(/[^\w\s-]/g, '')
.trim()
.replace(/\s+/g, '-')
.replace(/-+/g, '-')
.replace(/^-|-$/g, '');
}
ready(function () {
var list = document.getElementById('foundera-toc-list');
if (!list) return;
var headings = document.querySelectorAll('h2');
var added = 0;
var used = {};
headings.forEach(function (h2) {
if (h2.closest('.foundera-toc')) return;
var text = (h2.textContent || '').trim();
if (!text) return;
var id = h2.id;
if (!id) {
id = slugify(text) || 'section';
var base = id, n = 2;
while (used[id] || (document.getElementById(id) && document.getElementById(id) !== h2)) {
id = base + '-' + n++;
}
h2.id = id;
}
used[id] = true;
var li = document.createElement('li');
var a = document.createElement('a');
a.href = '#' + id;
a.textContent = text;
li.appendChild(a);
list.appendChild(li);
added++;
});
if (!added) {
var toc = document.querySelector('.foundera-toc');
if (toc) toc.style.display = 'none';
}
});
})();
</script>