Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions apps/web/src/pages/statute/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,31 @@ const readingTimeMin = Math.max(1, Math.round(wordCount / 200));
})();
</script>

<!-- Subsection anchor IDs: (a) → #subsec-a, (a)(1) → #subsec-a-1 -->
<script is:inline>
(function () {
var prose = document.querySelector('.prose');
if (!prose) return;
var items = prose.querySelectorAll('li');
var currentParent = '';
items.forEach(function (li) {
var strong = li.querySelector('strong');
if (!strong) return;
var marker = strong.textContent.trim().replace(/[()]/g, '');
if (!marker) return;
// Determine nesting: top-level (a-z), numeric (1-99), upper (A-Z), roman (i-xx)
if (/^[a-z]$/.test(marker)) {
currentParent = marker;
li.id = 'subsec-' + marker;
} else if (/^\d{1,2}$/.test(marker) && currentParent) {
li.id = 'subsec-' + currentParent + '-' + marker;
} else if (/^[A-Z]$/.test(marker) && currentParent) {
li.id = 'subsec-' + currentParent + '-' + marker;
}
});
})();
</script>

<!-- Keyboard shortcuts: j/k navigate sections -->
<script is:inline>
document.addEventListener('keydown', function (e) {
Expand Down
16 changes: 16 additions & 0 deletions apps/web/src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@
a[href]::after { content: none !important; }
}

/* Subsection anchor highlighting — gold flash when arriving via #subsec-a link */
[id^="subsec-"] {
scroll-margin-top: 4rem;
}

[id^="subsec-"]:target {
background: var(--color-amber-light, #FEF0C8);
border-radius: 0.25rem;
margin: -0.25rem;
padding: 0.25rem;
}

:where(.dark, .dark *) [id^="subsec-"]:target {
background: rgba(194, 133, 12, 0.15);
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
Expand Down
Loading