/* The following needs to be DUPLICATED, once for disable_ui (can also happen on the web) and once for printing (but disable_ui might not be set) */

pluto-editor.disable_ui > main {
    margin-top: 20px;
    cursor: auto;
}

pluto-editor.disable_ui header#pluto-nav,
pluto-editor.disable_ui preamble > button,
pluto-editor.disable_ui pluto-cell > button,
pluto-editor.disable_ui pluto-input > button,
/* Hide the shoulder by default (when not inspecting hidden code) */
pluto-editor.disable_ui:not(.inspecting_hidden_code) pluto-shoulder,
/* And in any case, hide the shoulder for cells with folded code */
pluto-editor.disable_ui pluto-cell:not(.code_folded) > pluto-shoulder,
pluto-editor.disable_ui footer,
pluto-editor.disable_ui pluto-runarea,
pluto-editor.disable_ui jlerror .doclink,
pluto-editor.disable_ui .dont-panic,
pluto-editor.disable_ui #helpbox-wrapper,
pluto-editor.disable_ui .fix-with-ai {
    display: none !important;
}

/* AND NOW THE SAME AGAIN FOR PRINT */

@media print {
    pluto-editor > main {
        margin-top: 20px;
        cursor: auto;
    }

    pluto-editor header#pluto-nav,
    pluto-editor preamble > button,
    pluto-editor pluto-cell > button,
    pluto-editor pluto-input > button,
    pluto-editor pluto-shoulder,
    pluto-editor footer,
    pluto-editor pluto-runarea,
    pluto-editor jlerror .doclink,
    pluto-editor .dont-panic,
    pluto-editor #helpbox-wrapper,
    pluto-editor .fix-with-ai {
        display: none !important;
    }
}

/* These next rules only apply to @media print, i.e. the PDF export. We want to hide these items in the PDF, but not in a static HTML. */
@media print {
    .pluto-frontmatter,
    .edit_or_run,
    .loading-bar,
    .floating_back_button,
    .outline-frame,
    .outline-frame-actions-container,
    pkg-status-mark,
    .MJX_ToolTip,
    .MJX_HoverRegion,
    .MJX_LiveRegion,
    nav#undo_delete,
    .language-picker {
        display: none !important;
    }
    body:not(.___) pluto-editor:not(._____) > main {
        padding-bottom: 0;
        padding-left: 6px;
        padding-right: 6px;
    }
    pluto-input .cm-editor {
        border-left: 1px solid var(--normal-cell-color);
        border-radius: 4px !important;
    }

    pluto-cell {
        break-inside: avoid;
    }
    /* Cells with simple prose content should be allowed to break. Here is a hearistic for that: (we could check for the `.markdown` class generated by the Markdown stdlib but we also want to fully support alternatives) */
    pluto-cell.code_folded:has(p) {
        break-inside: auto;
    }

    /* When printing, hr should act like a page break */
    pluto-output > div > div.markdown > hr,
    pluto-output > div > div > hr {
        height: 0;
        margin: 0;
        visibility: hidden;
        break-after: page;
    }

    pluto-output h1 {
        break-before: page;
    }
    pluto-cell:first-of-type pluto-output h1 {
        break-before: avoid;
    }
    pluto-output :is(.admonition, .pluto-docs-binding, blockquote) h1 {
        break-before: avoid;
    }

    /* pluto-cell:has(h1) + pluto-cell {
        break-inside: auto;
    } */

    pluto-output :is(h1, h2, h3, h4) {
        break-after: avoid;
    }
}

@page {
    widows: 2;
}
