/*
 * Supplement for the Hugo theme.
 *
 * css/neo.css is copied verbatim from the neo site and is the whole visual
 * style for the home page. This file only adds the font declaration and the
 * layout/typography needed for Hugo content pages.
 */

@font-face {
    font-family: "roboto";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/Roboto/roboto-v30-latin-regular.woff2") format("woff2"),
         url("../fonts/Roboto/roboto-v30-latin-regular.woff") format("woff");
}

html,
body {
    overflow-x: hidden;
}

/* Content pages: the drive artwork sits in the left margin on wide screens. */
.page {
    box-sizing: border-box;
    max-width: 46rem;
    margin: 0 0 0 30rem;
    padding: 2rem 2rem 6rem;
    line-height: 1.75;
}

.page-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    margin: 1rem 1.5rem 0;
    font-size: 0.9em;
}

@media (min-width: 1200px) {
    .page {
        max-width: min(46rem, calc(100vw - 40rem));
    }

    .page-nav {
        display: none;
    }

    /* neo.css scales every .drive up on large screens; keep the side art
       at its natural size so it stays clear of the content column. */
    .drive.side {
        scale: 1;
    }
}

@media (max-width: 1199px) {
    .page {
        margin: 0 auto;
        padding: 1.5rem 1.25rem 5rem;
        font-size: 1.05em;
        line-height: 1.85;
    }

    .drive.side {
        display: none;
    }

    .page p {
        margin: 1.35em 0;
    }

    .page ul,
    .page ol {
        margin: 1.35em 0;
        padding-left: 1.6em;
    }

    .page li {
        margin: 0.35em 0;
    }

    .page h1 {
        font-size: 2.2rem;
    }

    .page h2 {
        font-size: 1.6rem;
        margin-top: 1.6em;
    }

    .page h3 {
        font-size: 1.35rem;
        margin-top: 1.4em;
    }

    .page .toc {
        margin: 1.75em 0;
    }
}

/*
 * neo.css places the drive artwork with fixed 800px coordinates and lets it
 * hang off the left edge of the screen. On phones, use the disk as a dim
 * background instead so the name and links are visible immediately.
 */
@media (max-width: 380px) {
    body {
        margin: 0;
    }

    .drive {
        position: relative;
        z-index: 0;
        left: auto;
        top: auto;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        justify-content: center;
        width: 100%;
        max-width: 100%;
        min-height: 100vh;
        min-height: 100svh;
        margin: 0;
        padding: 1.5rem 1.25rem;
        overflow: hidden;
    }

    .drive::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        background-image: url("../neo/disc.png");
        background-position: center;
        background-repeat: no-repeat;
        background-size: cover;
        opacity: 0.2;
        pointer-events: none;
    }

    .drive .disk {
        display: none;
    }

    .drive .author-name {
        position: static;
        max-width: none;
        margin: 0 0 0.75rem;
        font-size: 1.2em;
    }

    .drive a {
        position: static;
        display: block;
        padding: 0.2rem 0;
        font-size: 1em;
    }

    .drive .arm {
        display: none;
    }
}

/* Content typography */
.page h1,
.page h2,
.page h3,
.page h4,
.page h5,
.page h6 {
    line-height: 1.2;
    margin: 2rem 0 0.75rem;
}

.page h1 {
    font-size: 2rem;
    margin-top: 0;
}

.page h2 {
    font-size: 1.5rem;
}

.page h3 {
    font-size: 1.25rem;
}

.page p,
.page ul,
.page ol,
.page blockquote,
.page pre,
.page table,
.page figure {
    margin: 1rem 0;
}

.page ul,
.page ol {
    padding-left: 1.5rem;
}

.page img {
    width: auto;
    max-width: min(100%, 100vw);
    height: auto;
}

.page video {
    max-width: 100%;
    height: auto;
}

/* Keep the height declared on embeds (e.g. Desmos); height: auto would
   override the attribute and collapse them to the default 150px. */
.page iframe {
    max-width: 100%;
    border: 0;
}

.page pre {
    max-width: 100%;
    overflow-x: auto;
    padding: 0.9rem 1rem;
    background-color: #f4f4f4;
}

.page code {
    font-size: 0.9em;
}

.page pre code {
    font-size: 1em;
}

/* Keep MathJax and long tables from pushing the whole page sideways. */
.page .MathJax,
.page code.has-jax,
.page mjx-container {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

.page table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    width: 100%;
    border-collapse: collapse;
}

.page blockquote {
    padding-left: 1rem;
    border-left: 5px solid #c4c8cc;
}

.page th,
.page td {
    padding: 0.35rem 0.6rem;
    border: 1px solid #c4c8cc;
}

.page hr {
    border: 0;
    border-top: 1px solid #c4c8cc;
}

.page-list {
    list-style: none;
    padding-left: 0;
}

.page-list li {
    margin: 0.5rem 0;
}

.page .toc {
    margin: 1.5rem 0;
    padding: 0.75rem 1rem;
    background-color: #edecec;
}

.page .toc ul {
    margin: 0.5rem 0 0;
}

.page-nav a {
    text-decoration: none;
}

@media (prefers-color-scheme: dark) {
    /* neo.css inverts the drive artwork in dark mode. Blog images should keep
       their real colours, so opt content images out of that filter. */
    .page img,
    .page object,
    .page video {
        filter: none;
    }

    .drive::before {
        filter: invert(1) brightness(0.8);
    }

    .page pre {
        background-color: #1e1e1e;
    }

    .page blockquote {
        border-left-color: #4a4d56;
    }

    .page th,
    .page td,
    .page hr {
        border-color: #4a4d56;
    }

    .page .toc {
        background-color: #323232;
    }

    .page-nav a {
        color: #e8e6e3;
    }
}
