#toc { float: right; margin: 1rem 0 1.5rem 1.5rem; /* 23rem is the width of the words 'table of contents' in my header font */ /* yes, it's a bit hacky */ width: min(calc(100% - 1.5rem), 23rem); } @media (max-width: 850px) { #toc { float: unset; margin-top: 2rem; margin-left: .5rem; width: calc(100% - .5rem); } } #toc details { border: thick solid var(--color-pink); border-radius: 1rem; margin-top: 1rem; background-color: var(--color-bg); } #toc summary { position: relative; top: -1.5rem; left: -.75rem; width: fit-content; background: var(--color-bg); border-radius: .5rem; cursor: pointer; } #toc summary:focus-visible { outline: .15rem solid var(--color-teal); } #toc summary::marker { font-size: 2.35rem; } #toc h2 { margin-top: 0; display: inline; line-height: normal; } #toc nav { position: relative; top: -1.25rem; } /* `tree` style toc */ #toc nav > ol { margin-left: 1rem; } #toc ol { margin: 0; } #toc li { position: relative; padding-inline-start: 1em; list-style: none; margin-block: 0; margin-left: .35rem; } #toc li::before, #toc li::after { display: block; position: absolute; box-sizing: border-box; inset-block: 0 auto; inset-inline: 0 auto; inline-size: .75em; border-inline-start: .1rem solid var(--color-pink); } #toc li::before { block-size: .5lh; border-block-end: .1rem solid var(--color-pink); content: ""; } #toc li:not(:last-child)::after { block-size: 100%; content: ""; } /* underlines are unnecessary in this context */ #toc a { text-decoration: none; color: var(--color-blue); font-weight: bold; } #toc a:focus-visible { outline-color: var(--color-pink); }