@import url('reset.css');

@font-face {
    font-family: 'TeX Gyre Schola';
    font-weight: normal;
    font-style: normal;
    src: url('https://florida.moe/assets/r7rs/fonts/schola/texgyreschola-regular.woff2') format('woff2');
}
@font-face {
    font-family: 'TeX Gyre Schola';
    font-weight: normal;
    font-style: italic;
    src: url('https://florida.moe/assets/r7rs/fonts/schola/texgyreschola-italic.woff2') format('woff2');
}
@font-face {
    font-family: 'TeX Gyre Schola';
    font-weight: bold;
    font-style: normal;
    src: url('https://florida.moe/assets/r7rs/fonts/schola/texgyreschola-bold.woff2') format('woff2');
}
@font-face {
    font-family: 'TeX Gyre Schola';
    font-weight: bold;
    font-style: italic;
    src: url('https://florida.moe/assets/r7rs/fonts/schola/texgyreschola-bolditalic.woff2') format('woff2');
}
@font-face {
    font-family: 'TeX Gyre Schola Math';
    font-weight: normal;
    font-style: normal;
    src: url('https://florida.moe/assets/r7rs/fonts/schola/texgyreschola-math.woff2') format('woff2');
}
@font-face {
    font-family: 'Anonymous Pro';
    font-weight: normal;
    font-style: normal;
    src: url('https://florida.moe/assets/r7rs/fonts/anonymous-pro/anonymous-pro-r.woff2') format('woff2');
}

:root {
    --nav-width: 18rem;
    --max-text-width: 40rem;

    --background-color: #fff;
    --text-color: #444;
    --sidebar-background-color: #f5f5f5;
    --link-color: #2d73a0;
    --link-hover-color: #4388b6;
    --visited-color: #7c5c99;
    --visited-hover-color: #9170af;
    --active-color: #9e5357;
    --issue-color: #fdcfd0; }

@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #222;
        --text-color: #eee;
        --sidebar-background-color: #2a2a2a;
        --link-color: #62a7d7;
        --link-hover-color: #81c6f8;
        --visited-color: #b08ecf;
        --visited-hover-color: #cfadf0;
        --active-color: #d68588;
        --issue-color: #80393e;} }

html {
    font-family: 'TeX Gyre Schola', serif;
    font-size: 18px;
    line-height: 30px;
    color: var(--text-color);
    background-color: var(--background-color);

    & body {
        font-size: inherit;
        line-height: inherit;
        display: relative;

        & > aside.draft-only {
            position: sticky;
            top: 0;
            z-index: 1000;
            background-color: var(--issue-color);
            display: block;
            width: 100%;
            text-align: center;
            font-weight: bold;
        }
        
        & > nav#contents {
            background-color: var(--sidebar-background-color);
            left: max(0px, calc(0px - (((var(--nav-width) + var(--max-text-width)) / 2) + 1rem - 50vw)));
            top: 0;
            width: var(--nav-width);
            height: 100vh;
            position: fixed;
            overflow-x: hidden;
            overflow-y: scroll;
            box-sizing: border-box;
            padding: 1rem;
            @media (max-width: 54rem) {
                position: relative;
                width: 100%;
                height: 100%;
            }

            .draft-only ~ & {
                padding-top: 3rem;
            }

            & h2 {
                text-align: center;
                text-transform: uppercase;
                letter-spacing: 0.05rem; }

            & > ol {
                counter-reset: chapter appendix;

                & > li {
                    counter-reset: section; }
                
                & > li:not(.unnumbered):not(.appendix)::before {
                    counter-increment: chapter;
                    content: counter(chapter) ". "; }

                & > li.unnumbered { margin: 0.5rem 0; }

                & > li:not(.appendix) + li.appendix { margin-top: 0.5rem; }

                & > li:not(.appendix):not(.unnumbered) > ol > li:not(.entry)::before {
                    counter-increment: section;
                    content: counter(chapter) "." counter(section) ". "; }
                & > li.appendix > ol > li::before {
                    counter-increment: section;
                    content: counter(appendix, upper-latin) "." counter(section) ". "; }
                & > li.appendix::before {
                    counter-increment: appendix;
                    content: counter(appendix, upper-latin) ". "; }

                & > li li { margin-left: 1rem; } } }

        & > main {
            max-width: var(--max-text-width);
            margin-top: 1rem;
            margin-bottom: 1rem;
            margin-left: max(calc(var(--nav-width) + 1rem), calc(50vw - (((var(--nav-width) + 2rem) / 2) + 1rem)));
            margin-right: 1rem;
            box-sizing: border-box;
            counter-reset: section;
            @media (max-width: 54rem) {
                max-width: 100%;
                margin: 1rem;
            }
            > header:not(.cover-header) {
                margin: 1rem;
                > h1 {
                    text-align: center;
                    text-transform: uppercase;
                    letter-spacing: 0.04rem;
                    font-weight: bold; } }

            > header.cover-header {
                margin-bottom: 2rem;
                & hgroup p {
                    text-transform: inherit;
                    letter-spacing: inherit;
                    font-size: 24px;
                    line-height: 36px;
                    margin: 0.5rem 0;
                    hyphens: none;
                    -webkit-hyphens: none;
                }
                & h1 {
                    font-size: 72px;
                    line-height: 96px;
                    text-wrap: balance;
                    margin: 1rem 0 2rem 0; }

                > address {
                    font-style: italic;
                    .name {
                        font-style: normal;
                        font-variant: small-caps;
                        letter-spacing: 0.03em;
                    }
                    .connective {
                        font-style: normal;
                    }
                }
            }

            & h2 {
                font-size: 30px;
                line-height: 36px; }
            & hgroup p {
                text-transform: uppercase;
                letter-spacing: 0.05rem;
                margin: 0;
                font-size: 16px;
                line-height: 30px; }
            & > hgroup, & > h2 {
                margin: 0.5rem 0; }
            & h3 {
                font-size: 24px;
                line-height: 30px;
                margin: 1rem 0;

                &:is(main.chapter *) {
                    &::before {
                        counter-increment: section;
                        content: counter(chapter) "." counter(section) ". ";
                    } }
            &:is(main.appendix *) {
                    &::before {
                        counter-increment: section;
                        content: counter(appendix, upper-latin) "." counter(section) ". ";
                    } } }

            & hr {
                border: none;
                margin: 1rem 0;
            }

            & ul {
                list-style-type: disc;
                margin-left: 2rem;
            }

            & pre:not(.example *) {
                margin: 1rem 0;
            }

            & dl dd {
                margin-left: 1rem;
            }

            & article.entry {
                margin: 1rem 0;
                & > header {
                    & dl {
                        display: flex;
                        flex-direction: row;
                        flex-wrap: wrap;

                        & dt {
                            flex-grow: 1;
                            & code {
                                white-space: pre-wrap;
                            }
                        }
                        & dd {
                            text-align: right;
                            flex-grow: 0;
                        }
                    }
                }
            }
            
            & section.requirements, & section.note, & section.rationale, & section.issue {
                font-size: 0.88em;
            }

            & section.todo {
                padding: 0.5rem 1rem;
                background-color: var(--issue-color);
            }

            & .example {
                display: flex;
                flex-wrap: wrap;
                margin: 1em 0;
                & .example-input {
                    flex-basis: 100%;
                }
                & .example-arrow {
                    font-family: 'TeX Gyre Schola Math';
                    flex-basis:1.5rem;
                    flex-grow: 0;
                }
                & .example-output {
                    flex-grow: 1;
                }
            }

            &.bibliography .csl-entry {
                margin-left: 1.5em;
                text-indent: -1.5em;
                hyphens: auto;
                -webkit-hyphens: auto; } } }

    & small { font-size: 0.88em; line-height: inherit; } }

a:link, a:visited, a:hover, a:active { text-decoration: none; }
a:link { color: var(--link-color); }
a:link[rel=self] { color: inherit; }

a:visited { color: var(--visited-color); }
a:hover { color: var(--link-hover-color); }
a:visited:hover { color: var(--visited-hover-color); }
a:active, a:visited:active { color: var(--active-color); }

p {
    margin: 1em 0;
    hyphens: auto;
    -webkit-hyphens: auto;
}

code {
    font-family: 'Anonymous Pro', monospace;
    hyphens: none;
    -webkit-hyphens: none;
}

var, code var {
    font-family: 'TeX Gyre Schola', serif;
    font-style: italic;
    -webkit-hyphens: none;
}
var.stx, code var.stx {
    font-family: 'TeX Gyre Schola', serif;
    font-style: normal;
    -webkit-hyphens: none;

    &::before {
        font-family: 'TeX Gyre Schola Math';
        content: '⟨';
    }
    &::after {
        font-family: 'TeX Gyre Schola Math';
        content: '⟩';
    }
}

sup, sub {
    vertical-align: baseline;
    position: relative;
    top: -0.4em;
    font-size: 0.8em;
}
sub { 
    top: 0.4em; 
}
pre {
    overflow-x: scroll;
}

i, em, cite {
    font-style: italic;
}

.entry-sec-title {
    font-style: italic;
}

blockquote {
    margin: 0 1rem;
}

math {
    font-family: 'TeX Gyre Schola Math', "Latin Modern Math", "STIX Two Math", "XITS Math", "STIX Math", "Libertinus Math", "TeX Gyre Termes Math", "TeX Gyre Bonum Math", "DejaVu Math TeX Gyre", "TeX Gyre Pagella Math", "Asana Math", "Cambria Math", "Lucida Bright Math", "Minion Math", STIXGeneral, STIXSizeOneSym, Symbol, "Times New Roman", serif;
}

@media print {
    :root {
        --background-color: inherit;
        --text-color: black;
        --sidebar-background-color: inherit;
        --link-color: black;
        --link-hover-color: black;
        --visited-color: black;
        --visited-hover-color: black;
        --active-color: black;
        --issue-color: inherit; }

    html {
        & body {
            & > nav#contents {
                width: 100%;
                height: 100%;
                position: relative;
                background-color: inherit;
                &:not(main:has(.cover-header) + *) {
                    display: none;
                }
            }
            & > main {
                max-width: 100%;
                margin: 1rem;

                & section.todo {
                    border: 1px solid black;
                }

                & a:link, & a:visited, & a:hover, & a:active {
                    border-bottom: 1px dotted black;
                }
            }
        }
    }
}
