/* Print styles for mdbook - allows code blocks to split across pages */

/* Hide navigation elements */
#sidebar,
#menu-bar,
.nav-chapters,
.mobile-nav-chapters,
.nav-wrapper,
.buttons,
.left-buttons,
.right-buttons {
    display: none !important;
}

#page-wrapper.page-wrapper {
    transform: none !important;
    margin-inline-start: 0px;
    overflow-y: initial;
}

#content {
    max-width: none;
    margin: 0;
    padding: 20px;
}

.page {
    overflow-y: initial;
}

/* Typography */
body {
    font-size: 11pt;
    line-height: 1.5;
}

h1 { font-size: 24pt; page-break-before: always; }
h2 { font-size: 18pt; }
h3 { font-size: 14pt; }
h4 { font-size: 12pt; }

/* Keep headings with following content */
h1, h2, h3, h4, h5, h6 {
    page-break-inside: avoid;
    page-break-after: avoid;
    break-inside: avoid;
    break-after: avoid;
}

/* First h1 should not have page break before */
.content > h1:first-child,
#content > h1:first-child,
main > h1:first-child {
    page-break-before: auto;
}

/* Links */
a, a:visited, a:active, a:hover {
    color: #4183c4;
    text-decoration: none;
}

/* Hide font awesome icons */
.fa {
    display: none !important;
}

/* CRITICAL: Allow code blocks to break across pages */
pre,
pre.playground,
pre.playpen,
pre pre,
code,
pre code,
.hljs,
.language-rust,
.ace_editor,
pre > code {
    page-break-inside: auto !important;
    break-inside: auto !important;
    page-break-before: auto !important;
    page-break-after: auto !important;
    break-before: auto !important;
    break-after: auto !important;
    white-space: pre-wrap !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
}

/* Code block styling */
pre {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    margin: 10px 0;
    font-size: 10pt;
    line-height: 1.4;
}

code {
    font-family: 'Source Code Pro', 'Consolas', 'Monaco', monospace;
    font-size: 10pt;
}

/* Inline code */
:not(pre) > code {
    background-color: #f5f5f5;
    padding: 2px 4px;
    border-radius: 3px;
}

/* Hide playground buttons for print */
pre > .buttons,
.playpen-button,
.clip-button,
.copy-button,
.play-button,
.test-button {
    display: none !important;
}

@media print {
    @page {
        margin: 2cm;
        size: A4;
    }

    body {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    /* Force all elements to allow page breaks */
    * {
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* But keep headings together with next content */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    /* Code blocks should split */
    pre,
    pre.playground,
    pre.playpen,
    code,
    .hljs {
        page-break-inside: auto !important;
        break-inside: auto !important;
        orphans: 3;
        widows: 3;
    }

    /* Tables can split */
    table, tr, td, th {
        page-break-inside: auto !important;
    }

    /* Avoid breaking inside list items */
    li {
        page-break-inside: avoid;
    }
}
