/* `variables.css` is linked from index.html, which trunk fingerprints. An
   @import here would ask for the unhashed name, 404, and block the first
   paint while it did so. */

html {
    box-sizing: border-box;
    /* the top bar is sticky: whatever is scrolled or tabbed to lands below it */
    scroll-padding-top: 64px;
    background-color: var(--bg);
    background-image: radial-gradient(
        color-mix(in srgb, var(--rule) 30%, transparent) 10%,
        transparent 10%
    );
    background-size: 12px 12px;
    background-attachment: fixed;
    transition:
        background-color 0.2s ease,
        color 0.2s ease;
}
*,
*:before,
*:after {
    box-sizing: inherit;
}

body {
    margin: 0;
    /* at least one screen, so the sheet reaches the bottom of a short page;
       dvh follows a phone's toolbar as it slides away */
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    color: var(--fg);
    font-family: var(--f-body);
    font-size: 1rem;
    line-height: 1.72;
}

/* App shell: the document scrolls under a sticky top bar. `main` fills at
   least the rest of the screen and grows with whichever page is routed in.
   No `overflow` on html or body — that would break the sticky bar. */
main {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

main > * {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

/* A page that scrolls a part of itself instead (the index, whose stair is
   driven by its own scroller) is marked `.pinned`. The shell then holds at
   exactly one screen and the page decides which part scrolls. */
body:has(.pinned) {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

body:has(.pinned) main,
main > .pinned {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* A short screen (a phone on its side) cannot spare a whole masthead above a
   pinned page's scroller: the kicker and caption step aside, and the title
   shares its row with whatever follows it. */
@media (max-height: 520px) {
    .page.pinned {
        padding-top: 16px;
        padding-bottom: 12px;
    }

    .pinned .head {
        display: flex;
        align-items: center;
        gap: 12px 24px;
        padding-bottom: 12px;
    }

    .pinned .kicker,
    .pinned .caption {
        display: none;
    }

    .pinned .title {
        flex: 0 0 auto;
        margin: 0;
        font-size: 2rem;
    }
}

h1,
h2,
h3,
h4 {
    font-family: var(--f-display);
    font-weight: 600;
    letter-spacing: 0.005em;
    line-height: 1.1;
}

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

/* ---- shared page shell (index & home) ----
   Identical masthead plate used by both pages; each page's own module CSS
   holds everything specific to its own layout below the caption. */

.page {
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    padding: 56px 28px 20px;
    /* An opaque sheet laid on the dotted ground: the texture is for the
       margins, not for reading through. */
    background-color: var(--bg);
    border-inline: 1px solid color-mix(in srgb, var(--rule) 16%, transparent);
}

.head {
    flex: 0 0 auto;
    padding-bottom: 20px;
    border-bottom: 1px solid color-mix(in srgb, var(--rule) 55%, transparent);
}

.kicker {
    margin: 0;
    font-family: var(--f-ui);
    font-size: 0.62rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--fg-muted);
}

.title {
    margin: 6px 0 0;
    font-size: 3.2rem;
    text-align: left;
    text-decoration: none;
    color: var(--fg);
}

.caption {
    margin: 6px 0 0;
    font-size: 0.82rem;
    color: var(--fg-muted);
}

.empty {
    padding: 28px 0;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--fg-muted);
}

@media (max-width: 600px) {
    .page {
        padding: 32px 18px 16px;
        /* the sheet spans the screen — no edge to draw */
        border-inline: 0;
    }

    .title {
        font-size: 2.4rem;
    }
}

/* ---- fenced code ----
   The spans come from src/highlight/mod.rs, so they live outside the css
   modules and are matched globally. Inline `code` is never highlighted. */

pre code .hl-com {
    color: var(--syn-comment);
    font-style: italic;
}
pre code .hl-kw {
    color: var(--syn-keyword);
    font-weight: 500;
}
pre code .hl-ty {
    color: var(--syn-type);
}
pre code .hl-fn {
    color: var(--syn-function);
}
pre code .hl-str {
    color: var(--syn-string);
}
pre code .hl-num {
    color: var(--syn-number);
}
pre code .hl-const {
    color: var(--syn-const);
}
pre code .hl-attr {
    color: var(--syn-attr);
}
pre code .hl-prop {
    color: var(--syn-prop);
}

/* Css has no type names to compete with, so its selectors take the type ink
   and its functions step aside — leaving the blue to say "property". */
pre code.language-css .hl-fn {
    color: var(--syn-type);
}

.green {
    color: green;
}
.blue {
    border-radius: 5px;
    background-color: #0070bb;
    color: white;
    border: 2px solid black;
}

.content {
    box-sizing: border-box;
    margin-left: var(--sidebar-width);
}

h1 {
    text-align: center;
    font-size: 4rem;
}

h2 {
    text-decoration: underline;
    font-size: 2rem;
}

.post {
    max-width: 90%;
    font-size: 1.5rem;
    isolation: isolate;
}

.container {
    width: 90%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-left: var(--sidebar-width);
    margin-right: var(--sidebar-width);
    padding: 20px;
    background: radial-gradient(var(--bg), transparent);
    p {
        font-size: 1.2rem;
    }
}

/* Phone Styles */
@media (max-width: 600px) {
    h1 {
        font-size: 3.2rem;
    }

    h2 {
        font-size: 2rem;
    }

    .container {
        padding: 20px;
        margin: 0;
    }
}
