/* The formatting of a source page, see HtmlHighlighter.

   Only a source page links to this stylesheet, and it does so after `styles.css`, which colors its
   tokens: the rules for the classes of `HtmlHighlighter.cssClass` are there, so that any page can
   use them. */

/* BEGIN PAGE */
/* A source page has no sidebar, and gives the width it frees to the code. */
main:has(> .source-code) {
    padding: 1rem 2rem;
}
main:has(> .source-code) > h1 {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    overflow-wrap: anywhere;
}
@media screen and (max-width: 800px) {
    main:has(> .source-code) {
        padding: 1rem 0.5rem;
    }
    /* The menu shows the sidebar, which a source page does not have. */
    body:not(:has(nav)) #menu-toggle {
        display: none;
    }
}
/* END PAGE */



/* BEGIN CODE */
.source-code {
    margin: 0 0 3rem 0;
    padding: 0.5rem 0;
    overflow-x: auto;

    box-shadow: 0 0 10px 0 var(--shadow-color);
    background-color: var(--bg-color-1);
    border: var(--border);
    border-radius: 0.2rem;

    font-size: 0.85rem;
    line-height: 1.5;
    tab-size: 4;
}
.source-code > code {
    counter-reset: line;
}
/* Each line is a `<span>` with the id `L<n>` that is followed by a newline.
   A line is as wide as the code at least, so the mark of a selected line spans the whole of it. */
.source-code > code > span {
    display: inline-block;
    min-width: 100%;
    padding-right: 1rem;

    /* Keep the line clear of the sticky header, with some of the code before it for context. */
    scroll-margin-top: calc(var(--header-height) + 4.5em);
}
/* The line numbers are generated, so they are not part of the text that is selected and copied. */
.source-code > code > span::before {
    counter-increment: line;
    content: counter(line);

    display: inline-block;
    min-width: 4ch;
    margin: 0 1.5ch 0 1ch;
    text-align: right;
    color: var(--faded-text-color);
    user-select: none;
}
.source-code > code > span.selected,
.source-code > code > span:target {
    background-color: var(--selected-line-color);
}
/* END CODE */



/* BEGIN TOKENS */
/* The colors of the tokens are in `styles.css`. A keyword has the color of plain text, so in code
   its weight sets it apart. */
.source-code .kw {
    font-weight: 700;
}
/* END TOKENS */
