@layer typography {
    :root {
        --heading-base-size: 16px;
        --heading-factor: 1.25;
    }

    strong {
        font-weight: 600;
    }

    em {
        font-style: italic;
    }

    .text-center {
        text-align: center;
    }

    h1 {
        font-size: calc(var(--heading-base-size) * pow(var(--heading-factor), 4));
    }

    h2 {
        font-size: calc(var(--heading-base-size) * pow(var(--heading-factor), 3));
    }

    h3 {
        font-size: calc(var(--heading-base-size) * pow(var(--heading-factor), 2));
    }

    h4 {
        font-size: calc(var(--heading-base-size) * pow(var(--heading-factor), 1));
    }

    h5 {
        font-size: calc(var(--heading-base-size) * pow(var(--heading-factor), 0));
    }

    h1,
    h2,
    h3,
    h4,
    h5 {
        font-family: var(--font-display);
        font-weight: 700;
    }

    .text {
        h1,
        h2,
        h3,
        h4,
        h5 {
            font-family: var(--font-display);
            font-weight: 700;
            margin-bottom: 0.25rem;
        }

        /* text-align: justify;
         hyphens: auto; */

        &.center {
            text-align: center;
        }

        & {
            line-height: 1.5;
        }

        & > * {
            max-width: 46rem;
        }

        pre,
        code {
            background: color-mix(in lab, var(--card-base-internal, #ededed), #fff 35%) !important;
            /* background: color-mix(in lab, var(--zone-color), #fff 75%) !important;
             background: var(--code-bg, #00000022) !important; */

            font-family: var(--font-mono);
            font-weight: 400;
            font-size: 16px;
        }

        code {
            border-radius: 0.25rem;
            padding: 0.125rem 0.3rem;
        }

        p > code {
            word-break: break-word;
        }

        pre {
            margin: 2rem auto;

            padding: 0.5rem 1rem;

            /* width: 100%; */
            max-width: 80ch;

            width: fit-content;

            line-height: 1.5;

            border-radius: 0.25rem;

            box-shadow: 0.25rem 0.25rem 0 0 #333;
            border: 2px solid #333;

            code {
                padding: 0;
            }
        }

        p {
            line-height: 1.75;
            margin: var(--paragraph-margin, 1rem) auto;
        }

        /* p + p {
             margin-top: 1rem;
         }

         h1 + p,
         h2 + p,
         h3 + p,
         h4 + p {
             margin-top: 1rem;
         }

         p:has(+ h1, + h2, + h3, + h4) {
             margin-bottom: 1rem;
         } */

        p[align='center'] {
            margin: 1.5rem 0;

            a {
                /* background: color-mix(in hsl, var(--card-base-internal, #ededed), #fff 20%); */
                background: hsl(from var(--card-base-internal, #ededed) h calc(s + 10) calc(l - 10));
                padding: 0.5rem;
                border-radius: 0.25rem;
                box-shadow: 0.25rem 0.25rem 0 0 #333;
                border: 2px solid #333;
            }
        }

        img,
        video {
            display: block;
            margin: 0 auto;

            width: 50ch;
            max-width: 100%;

            border: 2px solid #333;
            border-radius: 0.25rem;
            box-shadow: 0.25rem 0.25rem 0 0 #333;
            background: #000;

            &.fill {
                width: 100%;
                max-width: 20rem;
            }

            &.small {
                max-width: 5rem;
            }

            &.flat {
                border: none;
                box-shadow: none;
            }
        }

        video {
            margin: 1rem auto;
        }

        p:first-child {
            margin-top: 0;
        }

        p:last-child {
            margin-bottom: 0;
        }

        strong {
            font-weight: 600;
        }

        em {
            font-style: italic;
        }

        /* @include geometric-headings; */
        /* Inlined geometric-headings mixin */
        /* @for $i from 1 through 5 {
            $factor: pow($heading-scale, 5 - $i);

            h#{$i} {
                font-size: $base-font-size * $factor;
                font-family: var(--font-display);
                font-weight: 700;
                margin-bottom: 0.25rem;
            }

            /* p + h#{$i} {
                 margin-top: 0.75rem * $factor;
             } 
        } */

        h1 {
            margin-bottom: 2rem;
            text-align: center;
        }

        h1,
        h2,
        h3,
        h4 {
            font-weight: 700;
            color: #333;

            /* HACK: Trick to fix anchor links with sticky header */
            padding-top: 7rem;
            margin-top: -6.5rem;
        }

        h1,
        h2,
        h3,
        h4,
        ol,
        ul {
            margin-left: auto;
            margin-right: auto;
        }

        ol,
        ul {
            margin-bottom: var(--paragraph-margin, 1rem);
            padding-left: 1.5rem;

            p {
                --paragraph-margin: 0.5rem;
            }
        }

        li + li {
            margin-top: 0.5rem;
        }

        a,
        a:visited {
            color: var(--zone-color, #1e6733);
            font-weight: 600;

            &:hover {
                text-decoration: underline 2px solid;
            }
        }

        blockquote {
            margin: 1rem auto;
            padding: 0.5rem 1rem;

            border-left: 0.25rem solid #0006;
            background: color-mix(in lab, var(--card-base-internal, #ededed), #fff 35%);

            p {
                margin: 0;
            }
        }

        hr {
            max-width: calc(100vw - 4rem);
            width: 40ch;
            margin: 3rem auto 2.75rem;
            border: none;
            border-top: 2px solid #0003;
        }

        @media screen and (max-width: 1024px) {
            max-width: calc(100vw - 2rem);

            pre {
                margin: 1rem 0;
                width: 100%;
            }

            hr {
                max-width: none;
                margin: 3rem auto;
            }
        }
    }
}
