/************************************************************************/
/* CSS reset based on https://www.joshwcomeau.com/css/custom-css-reset/ */
/************************************************************************/

/* 1. Use a more-intuitive box-sizing model */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* 2. Remove default margin */
*:not(dialog) {
    margin: 0;
}

/* 3. Enable keyword animations */
@media (prefers-reduced-motion: no-preference) {
    html {
        interpolate-size: allow-keywords;
    }
}

body {
    /* 4. Increase line-height */
    line-height: 1.5;
    /* 5. Improve text rendering */
    -webkit-font-smoothing: antialiased;
}

/* 6. Improve media defaults */
img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
}

/* 7. Inherit fonts for form controls */
input,
button,
textarea,
select {
    font: inherit;
}

/* 8. Avoid text overflows */
/* 9. Improve line wrapping */
p,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
    text-wrap: pretty;
}


/*
  10. Create a root stacking context
*/
#root,
#__next {
    isolation: isolate;
}


/************************************************************************/
/* TYPOGRAPHY AND VERTICAL RHYTHM */
/************************************************************************/

:root {
    --medium: 100%;

    --xxxx-large: calc(var(--medium) * pow(2, 1.25));
    --xxx-large: calc(var(--medium) * pow(2, 1));
    --xx-large: calc(var(--medium) * pow(2, 0.75));
    --x-large: calc(var(--medium) * pow(2, 0.5));
    --large: calc(var(--medium) * pow(2, 0.25));

    --small: calc(var(--medium) / pow(2, 0.25));
    --x-small: calc(var(--medium) / pow(2, 0.5));
    --xx-small: calc(var(--medium) / pow(2, 0.75));
    --xxx-small: calc(var(--medium) / pow(2, 1));
}

body {
    color: canvasText;
    font-size: var(--medium);
    font-family: system-ui;
}


* {
    line-height: calc(1.5cap + 12px);
}


h1, h2, h3, h4, h5, h6, dt {
    font-weight: bold;
}


h1 {
    font-size: var(--xxx-large);
    margin-block: 1lh;
}

h2, h3, h4, h5, h6 {
    margin-block: 1lh .5lh;

    &.first-in-column {
        margin-block-start: 0;
    }
}

h2 {
    font-size: var(--xx-large);
}

h3 {
    font-size: var(--x-large);
}


ul, 
ol, 
dl {
    margin-block: .75lh;
}

dt, 
dd, 
li {
    margin-block: .375lh;
}

dd + dt {
    margin-block-start: 1lh;
}

p {
    margin-block: .5lh;
}

h1, 
h2, 
h3, 
h4, 
h5, 
h6, 
p, 
li, 
dt, 
dd, 
figcaption {
    max-inline-size: 70ch;
}



/************************************************************************/
/* COLOR */
/************************************************************************/

:root {
    --border-color: oklch(from CanvasText l c h / 15%);
    --grey-text: oklch(from CanvasText l c h / 70%);
}


/************************************************************************/
/* LAYOUT */
/************************************************************************/

:root {
    --margin-for-text: 2ch;
}


body {
    margin-inline: auto;
    padding-inline: var(--margin-for-text);
    width: min(100%, 1000px);

    display: flex;
    flex-direction: column;
    min-height: 100vh;

    .top-area, .bottom-area {
        flex-grow: 0;
    }

    .content-area {
        flex-grow: 1;
    }
}




div.primary-nav {
    margin: 0 calc(50% - 50vw);
    padding-block: .5lh;
    padding-inline: var(--margin-for-text);

    display: flex;
    justify-content: space-between;
    align-items: baseline;

    background-color: CanvasText;
    color: Canvas;

    a {
        color: Canvas;
    }

    .site-name {
        font-size: var(--large);
        font-weight: bold;

        a {
            text-decoration: none;
        }
    }

}



/************************************************************************/
/* LINK STYLES */
/************************************************************************/

:root {
    --text-underline-offset: .5ex;
}

summary {
    text-decoration: underline dotted oklch(from LinkText l c h / 30%);
    text-underline-offset: var(--text-underline-offset);
}

a {
    text-decoration: underline solid oklch(from LinkText l c h / 20%);
    text-underline-offset: var(--text-underline-offset);
}


/************************************************************************/
/* SITE SEARCH */
/************************************************************************/

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.site-search {
    position: relative;
    display: inline-block;
    margin-inline-start: 2ch;
    vertical-align: baseline;

    input {
        inline-size: min(40vw, 28ch);
        padding: .1667lh .75ch;

        background-color: Field;
        color: FieldText;
        border: 1px solid var(--border-color);
        border-radius: .25lh;
    }

    /* Results panel (the aria-live region populated by search.js). */
    [role="region"] {
        position: absolute;
        inset-inline-start: 0;
        inset-block-start: calc(100% + .25lh);
        z-index: 10;

        inline-size: max(100%, min(90vw, 44ch));
        max-block-size: 70vh;
        overflow-y: auto;

        background-color: Canvas;
        color: CanvasText;
        border: 1px solid var(--border-color);
        border-radius: .25lh;
        padding: .5lh 1ch;
        box-shadow: 0 .25lh 1lh oklch(from CanvasText l c h / 20%);

        /* Result-count / status summary line. */
        p {
            font-size: var(--small);
            color: var(--grey-text);
            margin-block: 0 .25lh;
        }

        ul {
            list-style: none;
            margin-block: 0;
            padding-inline-start: 0;
        }

        li {
            margin-block: 0;
            max-inline-size: none;
        }

        a {
            display: block;
            padding: .1667lh .5ch;

            color: LinkText;
            text-decoration: none;
            border-radius: .25lh;

            &:hover,
            &:focus {
                background-color: oklch(from CanvasText l c h / 8%);
            }
        }

        code {
            color: var(--grey-text);
            margin-inline-start: .5ch;
        }
    }
}


/************************************************************************/
/* PAGE-FOOTER */
/************************************************************************/

.page-footer {

    margin: 0 calc(50% - 50vw);
    padding-block: .5lh;
    padding-inline: var(--margin-for-text);

    background-color: CanvasText;
    color: Canvas;

    a {
        color: Canvas;
    }    
}



/************************************************************************/
/* BODY.TERM */
/************************************************************************/

body.term {

    .page-header {
        p.scope-note {
            font-size: var(--large);
        }
    }

    h1 {
        code {
            color: var(--grey-text);
            margin-inline-start: 1ch;
        }

        span.term-type {
            margin-inline-start: 1ch;

            color: var(--grey-text);
            font-size: var(--xxx-small);
            font-weight: normal;
            vertical-align: text-bottom;
            white-space: nowrap;

            border: 1px solid var(--border-color);
            border-radius: .25lh;
            padding: .25lh .3333lh;
        }
    }    

    nav.perspective {

        margin-block: 1lh;

        header {
            font-style: italic;
            font-weight: bold;
        }

        .perspective__current {
            font-weight: bold;
        }

        .perspective__switcher {
            color: var(--grey-text);
        }

        summary {
            cursor: pointer;
            width: fit-content;
        }

        /* Alternative hierarchies, revealed when the disclosure is open. */
        ul {
            display: flex;
            flex-wrap: wrap;
            gap: .25lh 1ch;

            margin-block: .5lh 0;
            padding-inline-start: 0;
            list-style: none;
        }

        li {
            margin-block: 0;
            max-width: none;
        }

        a {
            display: inline-block;
            padding: .1667lh .75ch;

            border: 1px solid ButtonBorder;
            border-radius: .25lh;

            background-color: ButtonFace;
            color: ButtonText;
            text-decoration: none;
        }
    }


    nav.breadcrumbs {
        margin-block: 1lh;

        header {
            font-style: italic;
            font-weight: bold;
        }

        code {
            margin-inline-start: .5ch;
        }
    }


    .footnotes {
        font-size: var(--small);
        margin-block: 1.5lh;

        color: var(--grey-text);

        details {
            margin-block: 0;
        }
        details + details {
            margin-block-start: .375lh;
        }

        summary {
            cursor: pointer;
        }

        p {
            font-style: italic;
            margin-block: .375lh .75lh;
        }
    }

    a.footnote-ref,
    a.footnote-backref {
        text-decoration: none;
    }

    /* Flags a facet link (descriptor or associated term) that leaves the current hierarchy. */
    .out-of-hierarchy-marker {
        color: var(--grey-text);
        font-size: var(--x-small);
    }

    .section-header {
        p.note {
            font-size: var(--small);
            font-style: italic;
            margin-block-start: -.25lh;        }
    }

    div.terms {

        margin-block: 2lh;

        display: flex;
        flex-wrap: wrap;
        gap: 0 3ch;
        justify-content: space-between;

        code {
            margin-inline-start: .5ch;
        }

        div.main {
            flex-basis: 55ch;
        }

        div.sidebar {

            flex-basis: 36ch;

            border-left: 1px solid var(--border-color);
            padding-left: 3ch;

        }

    }

    section.metadata {

        border-top: 1px solid #eee;

        font-size: var(--small);

        margin-block: 2lh;

        columns: 20ch;
        column-gap: 3ch;

        h2 {
            column-span: all;
        }

        dl {
            margin-block: 0;

            dt {
                margin-block-end: 0;

                &:first-child {
                    margin-block-start: 0;
                }
            }

            dd {
                break-before: avoid-column;
                margin-block: 0;
            }
        }

    }

}


/************************************************************************/
/* BODY.INDEX */
/************************************************************************/

body.index {

    .page-header {

        margin-block: 2lh;

        .intro {
            font-size: var(--x-large);
        }

    }

}






