/* Reguły wspólne dla wydruku strony WWW i mkdocs-with-pdf.
   styles.scss wczytuje je ponownie po domyślnych stylach pluginu. */
@media print {
    @page {
        size: A4 portrait;
        margin: 20mm 15mm;
    }

    html, body, article, .md-typeset {
        font-family: "DejaVu Sans", sans-serif !important;
        font-size: 10pt !important;
        line-height: 1.45 !important;
        color: #222;
    }

    article {
        min-height: 0;
    }

    .md-typeset h1, .md-typeset h2, .md-typeset h3,
    .md-typeset h4, .md-typeset h5, .md-typeset h6 {
        font-family: "DejaVu Sans", sans-serif;
        line-height: 1.25;
        break-after: avoid;
        page-break-after: avoid;
        break-inside: avoid;
    }

    .md-typeset h1 { font-size: 19pt; margin: 0 0 5mm; color: #222; }
    .md-typeset h2 { font-size: 14pt; margin: 5mm 0 2mm; color: #222; }
    .md-typeset h3 { font-size: 11pt; margin: 4mm 0 2mm; color: #222; }

    article#doc-cover h1 { border: none; }

    article#doc-cover .cover-spacer {
        flex: 0 0 10vh;
    }

    article#doc-cover .cover-title {
        flex: 0 0 auto;
    }

    article#doc-cover .cover-renders {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12mm;
        padding: 5mm 8mm 8mm;
    }

    article#doc-cover .cover-renders img {
        display: block;
        width: 72mm;
        max-width: 45%;
        max-height: 68mm;
        height: auto;
        object-fit: contain;
    }

    article#doc-cover .properties p#version {
        margin: 0 0 2mm;
        font-size: 9pt;
        font-weight: 600;
    }

    /* Keep the complete contents list on the first A4 contents page. */
    article#doc-toc {
        min-height: 0 !important;
        height: auto;
        margin: 0 !important;
        padding: 0 0 2mm !important;
        font-size: 8pt !important;
        line-height: 1.05 !important;
        break-inside: avoid;
        page-break-inside: avoid;
        page-break-after: always;
    }

    article#doc-toc > h1 {
        margin: 0 0 3mm !important;
        font-size: 16pt !important;
        line-height: 1.15 !important;
        break-after: avoid;
        page-break-after: avoid;
    }

    article#doc-toc ul {
        margin: 0 0 0 3mm !important;
        padding-left: 0 !important;
        font-size: 7.8pt !important;
        line-height: 1.05 !important;
    }

    article#doc-toc > ul {
        margin-left: 0 !important;
    }

    article#doc-toc li,
    article#doc-toc li > a {
        line-height: 1.05 !important;
    }

    article#doc-toc li > a {
        padding-top: 0.35mm !important;
        padding-bottom: 0.35mm !important;
    }

    .md-typeset p {
        margin: 2mm 0;
        orphans: 3;
        widows: 3;
    }

    .md-typeset .admonition,
    .md-typeset details {
        font-size: 9.5pt;
        line-height: 1.45;
        break-inside: avoid;
        page-break-inside: avoid;
        margin: 3mm 0;
        padding: 0 3mm 1mm;
        box-shadow: none;
    }

    .md-typeset .admonition p {
        margin: 2mm 0;
    }

    /* Prosty tytuł bez nakładających się ikon Material. */
    .md-typeset .admonition > .admonition-title,
    .md-typeset details > summary {
        font-family: "DejaVu Sans", sans-serif;
        font-weight: bold;
        line-height: 1.4;
        margin: 0 -3mm 2mm;
        padding: 2mm 3mm !important;
        position: static;
    }

    .md-typeset .admonition-title::before,
    .md-typeset .admonition-title::after,
    .md-typeset summary::before,
    .md-typeset summary::after {
        display: none;
    }

    .md-typeset code, .md-typeset pre {
        font-family: "DejaVu Sans Mono", monospace;
        font-size: 9pt;
    }

    .md-typeset :not(pre) > code {
        white-space: nowrap;
    }

    .md-typeset pre {
        white-space: pre-wrap;
    }

    .md-typeset table:not([class]) {
        width: 100%;
        min-width: 0;
        font-size: 9pt;
        line-height: 1.4;
        border-collapse: collapse;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .md-typeset table:not([class]) th,
    .md-typeset table:not([class]) td {
        padding: 2mm;
        border: 0.2mm solid #ccc;
        vertical-align: top;
    }

    .md-typeset table:not([class]) th {
        background: #eee;
        color: #222;
    }

    .md-typeset thead { display: table-header-group; }
    .md-typeset tr { break-inside: avoid; }
    .md-typeset .md-typeset__table { display: block; }
    .md-typeset .md-typeset__scrollwrap { margin: 0; overflow: visible; }

    .md-typeset img {
        display: block;
        max-width: 100%;
        max-height: 65mm;
        width: auto;
        height: auto;
        margin: 2mm auto;
        object-fit: contain;
        break-inside: avoid;
    }

    .md-typeset img.device-photo {
        width: 52mm;
        max-width: 100%;
        max-height: none;
    }

    .md-typeset img.device-front {
        width: 100%;
        max-width: 170mm;
        max-height: none;
    }

    .md-typeset img.panel-screenshot {
        max-height: 90mm;
        max-width: 100%;
        margin: 3mm auto;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .md-typeset img.users-screenshot {
        max-height: 85mm;
    }

    .md-typeset img.panel-layout-screenshot {
        max-height: 95mm;
    }

    .md-typeset img.monitoring-events-screenshot {
        max-height: 70mm;
    }

    .md-typeset .status-screenshots {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 5mm;
        margin: 3mm 0;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .md-typeset .status-screenshots img {
        display: block;
        flex: 0 0 auto;
        width: auto;
        height: auto;
        margin: 0;
        max-width: none !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .md-typeset .status-screenshots .status-detail {
        width: 102mm;
        max-height: 90mm;
    }

    .md-typeset .status-screenshots .status-overview {
        width: 70mm;
        max-height: 40mm;
    }

    .md-typeset h3.reset-procedure {
        break-before: avoid;
        page-break-before: avoid;
    }

    /* The Status section starts with two related screenshots and its table. */
    .md-typeset h2.status-start {
        break-before: page;
        page-break-before: always;
    }

    /* Keep sections with a full panel screenshot together. These breaks are
       limited to sections that otherwise leave an orphan heading and path at
       the bottom of the preceding A4 page. */
    .md-typeset h2.monitoring-start,
    .md-typeset h2.dns-start,
    .md-typeset h2.mtu-start,
    .md-typeset h2.information-start,
    .md-typeset h2.devices-start,
    .md-typeset h2.wireguard-start,
    .md-typeset h2.serial-start,
    .md-typeset h2.panel-users-start,
    .md-typeset h2.update-start {
        break-before: page;
        page-break-before: always;
    }

    .md-typeset h2.lte-devices-start {
        break-before: page;
        page-break-before: always;
    }

    .md-typeset h2.factory-reset-start {
        break-before: page;
        page-break-before: always;
    }

    .md-typeset h2.work-conditions-start {
        break-before: page;
        page-break-before: always;
    }

    /* Długie procedury mogą przechodzić na kolejną stronę. */
    .md-typeset ol, .md-typeset ul {
        margin: 2mm 0;
        break-inside: auto;
        page-break-inside: auto;
    }

    .md-typeset li {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* Keep the Monitoring filter label, list and explanatory sentence together. */
    .md-typeset p.monitoring-filters-intro,
    .md-typeset p.monitoring-filters-intro + ul,
    .md-typeset p.monitoring-filters-intro + ul + p {
        break-before: avoid;
        break-after: avoid;
        break-inside: avoid;
        page-break-before: avoid;
        page-break-after: avoid;
        page-break-inside: avoid;
    }

    /* The Stored events block does not fit below Overview. Start it on the
       next page so its heading, description and screenshot stay together. */
    .md-typeset h3.stored-events-start {
        break-before: page;
        page-break-before: always;
        break-after: avoid;
        page-break-after: avoid;
    }

    .md-typeset h3.stored-events-start + p,
    .md-typeset h3.stored-events-start + p + p {
        break-before: avoid;
        break-inside: avoid;
        page-break-before: avoid;
        page-break-inside: avoid;
    }

    .md-typeset h3.update-installation {
        break-before: page;
        page-break-before: always;
    }

    /* Start the complete APN section on a new page in the English PDF. */
    .md-typeset h2.apn-start {
        break-before: page;
        page-break-before: always;
    }

    .md-typeset h2.lan-start {
        break-before: page;
        page-break-before: always;
    }

    /* Keep the APN procedure and its warning as one local block. */
    .md-typeset h3.apn-procedure {
        break-after: avoid;
        page-break-after: avoid;
    }

    .md-typeset h3.apn-procedure + ol,
    .md-typeset h3.apn-procedure + ol + .admonition {
        break-before: avoid;
        break-after: avoid;
        break-inside: avoid;
        page-break-before: avoid;
        page-break-after: avoid;
        page-break-inside: avoid;
    }
}
