/* @page rules apply to the print context via the media="print" link attribute */
@page {
    margin: 2cm 2.5cm;
    orphans: 3;
    widows: 3;
}

@media print {

    /* --- Hide screen-only chrome --- */
    .header,
    .post-nav,
    .pagination,
    .socials,
    .reading-time,
    .featured .endlink {
        display: none !important;
    }

    /* --- Reset all backgrounds and colors to black on white --- */
    *,
    *::before,
    *::after {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.5;
        margin: 0;
    }

    main {
        margin-top: 0;
        padding: 0;
    }

    /* --- Article: full-width, strip decoration --- */
    article {
        max-width: 100%;
        margin: 0;
        padding: 0;
        border-radius: 0;
    }

/* --- Links: show external URLs inline --- */
    a[href^="http"]::after,
    a[href^="https"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #555 !important;
        word-break: break-all;
    }

    /* suppress URL display for footnote anchors and pure anchors */
    a[href^="#"]::after,
    a.footnote::after {
        content: "";
    }

    /* --- Code blocks: monospace with a simple border --- */
    pre.code, pre.shell, pre.text {
        border: 1pt solid #999;
        border-radius: 0;
        padding: 6pt 8pt;
        font-size: 9pt;
        white-space: pre-wrap;
        page-break-inside: avoid;
    }

    pre.code code::before {
        color: #999 !important;
    }

    pre.shell code::before,
    pre.shell kbd::before {
        color: #999 !important;
    }

    /* --- Syntax highlight: grayscale --- */
    .hl.com, .hl.slc { color: #666 !important; font-style: italic; }
    .hl.str, .hl.esc, .hl.pps { color: #333 !important; }
    .hl.num, .hl.ipl { color: #333 !important; }
    .hl.kwa, .hl.kwb, .hl.kwc,
    .hl.kwd, .hl.kwe, .hl.kwf { color: black !important; font-weight: bold; }
    .hl.opt, .hl.lin { color: #555 !important; }
    .hl.ppc { color: #555 !important; }

    /* --- Alerts: strip color, keep border and label --- */
    .alert {
        border: 1pt solid black !important;
        border-radius: 0;
        padding: 6pt;
        page-break-inside: avoid;
    }

    .alert hr {
        border: none;
        border-top: 1pt solid black;
    }

    /* --- Figures --- */
    figure img {
        border-radius: 0;
        max-width: 80%;
    }

    figure > picture { display: none; }
    figure > .plot-print { display: block; }

    figure.quote {
        border-left: 2pt solid black;
    }

    /* --- Lists (.posts, .links) --- */
    .posts li, .links li {
        border: 1pt solid #ccc;
        border-radius: 0;
        margin: 6pt 0;
        padding: 4pt;
        page-break-inside: avoid;
    }

    /* --- Homepage sections --- */
    .me {
        border: 1pt solid #ccc;
        border-radius: 0;
        flex-direction: column;
    }

    .me .picture {
        display: none;
    }

    .me .bio {
        width: 100%;
        padding: 0;
    }

    .featured {
        flex-direction: column;
    }

    .featured .papers,
    .featured .posts {
        width: 100%;
        border: 1pt solid #ccc;
        border-radius: 0;
        margin: 6pt 0;
        padding: 6pt;
    }

    .featured .papers ul li,
    .featured .posts ul li {
        border: 1pt solid #ccc;
        border-radius: 0;
        margin: 3pt 0;
    }

    /* --- Page break hints --- */
    h1, h2, h3, h4 { page-break-after: avoid; }
    article, figure, table { page-break-inside: avoid; }

    /* --- Site footer --- */
    footer {
        border-top: 1pt solid black;
        padding-top: 6pt;
        font-size: 9pt;
    }
}
