/* PDF-specific style overrides for mkdocs-with-pdf.
   The Material slate theme uses dark backgrounds and light text. WeasyPrint
   renders all CSS (not just @media print), so we must explicitly force a
   light colour scheme for the generated PDF but only inside @media print
   so we don't break the live website. */

@media print {

    /* Override the slate colour scheme variables */
    [data-md-color-scheme="slate"],
    :root {
        --md-default-fg-color: #1a1a1a;
        --md-default-fg-color--light: #333;
        --md-default-fg-color--lighter: #555;
        --md-default-fg-color--lightest: #777;
        --md-default-bg-color: #fff;
        --md-default-bg-color--light: #f5f5f5;
        --md-default-bg-color--lighter: #fafafa;
        --md-default-bg-color--lightest: #fff;
        --md-code-fg-color: #1a1a1a;
        --md-code-bg-color: #f5f5f5;
        --md-typeset-color: #1a1a1a;
    }

    /* Ensure body and content areas use light backgrounds */
    body,
    .md-content,
    .md-typeset,
    .md-main__inner {
        color: #1a1a1a !important;
        background-color: #fff !important;
    }

    /* Code blocks */
    code,
    pre,
    .md-typeset code,
    .md-typeset pre {
        color: #1a1a1a !important;
        background-color: #f5f5f5 !important;
        border: 1px solid #ddd;
    }

    /* Admonitions */
    .admonition {
        background-color: #f5f5f5 !important;
        color: #1a1a1a !important;
    }

    /* Tables */
    .md-typeset table:not([class]) th,
    .md-typeset table:not([class]) td {
        color: #1a1a1a !important;
        background-color: #fff !important;
        border-color: #ddd !important;
    }

    /* Keep images within page bounds */
    img {
        max-width: 100%;
    }

    /* Avoid page breaks inside headings and their following content */
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    .md-typeset h1,
    .md-typeset h2,
    .md-typeset h3,
    .md-typeset h4,
    .md-typeset h5,
    .md-typeset h6 {
        page-break-after: avoid;
    }

    h2,
    h3,
    h4,
    h5,
    h6,
    .md-typeset h2,
    .md-typeset h3,
    .md-typeset h4,
    .md-typeset h5,
    .md-typeset h6 {
        color: #1a1a1a !important;
    }

    /* WeasyPrint doesn't support background-clip: text, so H1 gets a gradient block background. 
       Force the text color to white to contrast with the gradient block. */
    h1,
    .md-typeset h1 {
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
    }

    /* Make links darker/nicer to look at in the PDF instead of blinding cyan */
    a,
    .md-typeset a {
        color: #05889e !important;
    }

    /* Force chapter title boxes to span the full page width */
    .md-typeset h1,
    article h1,
    section h1 {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Cover page layout — use fixed margins (vh/flexbox unreliable in WeasyPrint paged media) */
    #doc-cover {
        text-align: center;
    }

    #doc-cover h1 {
        margin-top: 8cm;
        font-size: 3rem;
        font-weight: 800;
        margin-bottom: 0.5rem;
        color: #1a1a1a !important;
        -webkit-text-fill-color: #1a1a1a !important;
    }

    #doc-cover h2 {
        font-size: 1.4rem;
        font-weight: 400;
        color: #555;
        margin-bottom: 6cm;
    }

    #doc-cover #author,
    #doc-cover #copyright {
        font-size: 0.85rem;
        color: #777;
        margin-top: 0.25rem;
        font-style: normal;
    }
}