/* ============================================================
   ПЕЧАТЬ ДОКУМЕНТА
   body > #GBVP_VIEWER > #print-page
   ============================================================ */

@page {
    size: A4 portrait;
    margin: 18mm;
}


@media print {

    /* =========================================================
       1. ОСВОБОЖДАЕМ БРАУЗЕР ОТ ЭКРАННОГО VIEWPORT
       ========================================================= */

    html,
    body {
        width: auto !important;

        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;

        margin: 0 !important;
        padding: 0 !important;

        overflow: visible !important;

        position: static !important;

        background: #fff !important;

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


    /* =========================================================
       2. В BODY ОСТАВЛЯЕМ ТОЛЬКО GBVP_VIEWER
       ========================================================= */

    body > * {
        display: none !important;
    }

    body > #GBVP_VIEWER {
        display: block !important;

        position: static !important;

        width: auto !important;

        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;

        margin: 0 !important;
        padding: 0 !important;

        overflow: visible !important;

        inset: auto !important;

        transform: none !important;
        translate: none !important;

        contain: none !important;

        background: #fff !important;

        box-sizing: border-box !important;
    }


    /* =========================================================
       3. ВНУТРИ GBVP_VIEWER ОСТАВЛЯЕМ ТОЛЬКО PRINT-PAGE
       ========================================================= */

    body > #GBVP_VIEWER > * {
        display: none !important;
    }


    /* =========================================================
       4. ГЛАВНЫЙ ПЕЧАТНЫЙ КОНТЕЙНЕР

       ВАЖНО:
       экранный CSS задает:
       #GBVP_VIEWER > * { position:absolute; }

       поэтому здесь обязательно position:static
       ========================================================= */

    body > #GBVP_VIEWER > #print-page {
        display: block !important;

        position: static !important;

        inset: auto !important;
        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;

        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;

        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;

        margin: 0 !important;
        padding: 0 !important;

        overflow: visible !important;
        overflow-x: visible !important;
        overflow-y: visible !important;

        transform: none !important;
        translate: none !important;

        contain: none !important;

        flex: none !important;

        box-sizing: border-box !important;

        background: #fff !important;
        color: #000 !important;

        border: none !important;
        box-shadow: none !important;

        font-family:
            "Times New Roman",
            "KZ Times New Roman",
            serif !important;

        font-size: 12pt !important;
        line-height: 1 !important;

        text-align: justify;
    }


    /* =========================================================
       5. ЕСЛИ ВНУТРИ PRINT-PAGE ЕСТЬ ОСНОВНЫЕ ОБЕРТКИ
       ========================================================= */

    #print-page > .content,
    #print-page > .container,
    #print-page > .wrapper,
    #print-page > .page-content,
    #print-page > .print-content {
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;

        overflow: visible !important;

        position: static !important;

        transform: none !important;
        contain: none !important;
    }


    /* =========================================================
       6. ОСНОВНОЙ ТЕКСТ
       ========================================================= */

    #print-page p {
        margin: 0;
        padding: 0;

        font: inherit;
        text-indent: 1.25cm;
        text-align: justify;

        orphans: 3;
        widows: 3;
    }


    /* =========================================================
       7. ЗАГОЛОВКИ
       ========================================================= */

    /* =========================================================
   H1 / H2 — ВАШИ ВНЕКОНТЕКСТНЫЕ ЗАГОЛОВКИ
   ========================================================= */

#print-page h1,
#print-page h2 {
    font: inherit;
    margin: 0.8em 0;
    padding: 0;

    text-align: center;
    text-indent: 0;

    break-after: avoid-page;
    page-break-after: avoid;

    break-inside: avoid;
    page-break-inside: avoid;
}
#print-page h1{
    font-size: calc(1em + 2pt);
    font-weight: 700;
}
#print-page h2{
    font-weight: normal;
    text-align: justify;
    text-indent: 1.25cm;
}

/* Обычные структурные заголовки */
#print-page h3,
#print-page h4,
#print-page h5,
#print-page h6 {
    font-family: "Times New Roman", "KZ Times New Roman", serif;
    font-size: 14pt;
    font-weight: 700;

    text-align: left;
    text-indent: 0;

    margin: 4mm 0 2mm 0;

    break-after: avoid-page;
    page-break-after: avoid;
}


#print-page h3,
#print-page h4 {
    font: inherit;
    font-weight: 700;
    margin: 1em 0;
    padding: 0;
    text-indent: 1.25cm;
    break-inside: avoid;
    page-break-inside: avoid;
}

/* =========================================================
   НАЗВАНИЕ ТАБЛИЦЫ
   ========================================================= */

#print-page .table-title,
#print-page caption {
    font-family: "Times New Roman", "KZ Times New Roman", serif;

    font-size: 12pt;
    font-weight: 700;

    text-align: center;
    text-indent: 0;

    margin: 3mm 0 1.5mm 0;
    padding: 0;

    caption-side: top;

    break-after: avoid-page;
    page-break-after: avoid;
}


/* =========================================================
   ТАБЛИЦА
   ========================================================= */

#print-page table {
    width: 100% !important;
    max-width: 100% !important;

    margin: 1em 0;
    padding: 0;

    border-collapse: collapse;
    border-spacing: 0;

    table-layout: auto;

    font: inherit;
    font-size: 10pt;

    break-inside: avoid;
    page-break-inside: avoid;
}


/* =========================================================
   ГОЛОВКА ТАБЛИЦЫ
   ========================================================= */

#print-page thead {
    display: table-header-group;
    break-after: avoid;
    page-break-after: avoid;
}

#print-page thead tr:last-child th,
#print-page thead tr:last-child td,
#print-page tbody > tr:first-child:has(> th) > th,
#print-page tbody > tr:first-child:has(> th) > td {
    /*
     * СТ РК 1.5-2019:
     * головка отделяется двойной линией
     */
    border-bottom: 0.8mm double #000 !important;
}


/* =========================================================
   СТРОКИ И ЯЧЕЙКИ
   ========================================================= */

#print-page tbody {
    display: table-row-group;
}

#print-page tr {
    min-height: 8mm;

    break-inside: avoid;
    page-break-inside: avoid;
}

#print-page th,
#print-page td {
    height: 8mm;
    border: 0.5px solid #000;

    padding: 1px;
    font: inherit;

    vertical-align: middle;

    text-indent: 0;

    overflow-wrap: anywhere;
    white-space: normal;
    word-break: normal;

    min-width: 0;
}

#print-page th {
    font-size: 9pt;
    font-weight: 700;
    text-align: center;
}

/* =========================================================
   ТИПЫ ЯЧЕЕК ТАБЛИЦЫ
   ========================================================= */

/* Числовое значение */
#print-page td.number,
#print-page th.number,
#print-page .number {
    text-align: center !important;
    vertical-align: middle !important;

    font-size: 9pt;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Обозначение / символ / формула */
#print-page td.symbol,
#print-page th.symbol,
#print-page .symbol {
    text-align: center !important;
    vertical-align: middle !important;

    white-space: normal;

    font-style: italic;
}

/* =========================================================
   CAPTION ВНУТРИ TABLE
   ========================================================= */

#print-page table > caption {
    display: table-caption;

    caption-side: top;

    font: inherit;
    font-weight: 700;

    text-align: center;

    margin: 0;
    padding: 0 0 1em;
}


/* =========================================================
   НЕ ДАВАТЬ ТАБЛИЦЕ ВЫЛЕЗАТЬ ЗА ШИРИНУ
   ========================================================= */

#print-page table,
#print-page th,
#print-page td {
    box-sizing: border-box;
}


    /* =========================================================
       9. НАЗВАНИЕ ТАБЛИЦЫ
       Таблица Б.1 — Наименование
       ========================================================= */

    #print-page .table-title {
        margin: 4mm 0 2mm 0;
        padding: 0;

        font-size: 14pt;
        font-weight: 400;

        text-align: left;
        text-indent: 0;

        break-after: avoid-page;
        page-break-after: avoid;
    }

    #print-page .table-title + table {
        margin-top: 0;
    }


    /* =========================================================
       10. РИСУНКИ
       ========================================================= */

    #print-page figure,
    #print-page .figure {
        display: block;

        margin: 5mm 0;

        text-align: center;

        break-inside: avoid;
        page-break-inside: avoid;
    }


    #print-page figure img,
    #print-page figure svg,
    #print-page .figure img,
    #print-page .figure svg {
        display: block;

        width: auto;
        height: auto !important;

        max-width: 100% !important;
        max-height: 220mm;

        margin: 0 auto;

        break-inside: avoid;
        page-break-inside: avoid;
    }


    #print-page figcaption,
    #print-page .figure-title {
        margin: 2mm 0 0 0;
        padding: 0;

        font-size: 14pt;
        font-weight: 400;

        text-align: center;
        text-indent: 0;

        break-before: avoid-page;
        page-break-before: avoid;
    }


    /* =========================================================
       11. ФОРМУЛЫ
       ========================================================= */

    #print-page .formula,
    #print-page p.calc,
    #print-page .equation,
    #print-page .math-block {
        display: block;

        position: relative;

        width: 100%;

        margin: 1em 0;

        text-align: center;
        text-indent: 0;

        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    #print-page .formula,
    #print-page p.calc,
    #print-page .equation,
    #print-page .math-block,
    #print-page .symbol {
        font-style: italic;
    }

    #print-page math,
    #print-page .MathJax,
    #print-page .katex {
        font-size: 14pt;
    }


    #print-page .equation-number {
        position: absolute;

        right: 0;

        text-align: right;
        text-indent: 0;
    }


    /* =========================================================
       12. ПОЯСНЕНИЕ ПОСЛЕ ФОРМУЛЫ
       ========================================================= */

    #print-page .formula-explanation,
    #print-page .where {
        margin: 2mm 0 0 0;

        text-align: left;
        text-indent: 10mm;
    }


    #print-page .formula-explanation p,
    #print-page .where p {
        text-align: left;
    }


    /* =========================================================
       13. СПИСКИ
       ========================================================= */

    #print-page ul,
    #print-page ol {
        margin-top: 2mm;
        margin-bottom: 2mm;

        padding-left: 10mm;
    }


    #print-page li {
        margin: 0;
        padding: 0;

        text-align: justify;

        break-inside: avoid;
        page-break-inside: avoid;
    }


    /* список с дефисами */

    #print-page ul.standard-list {
        list-style: none;

        margin-left: 0;
        padding-left: 10mm;
    }


    #print-page ul.standard-list > li {
        position: relative;
    }


    #print-page ul.standard-list > li::before {
        content: "–";

        position: absolute;
        left: -6mm;
    }


    /* =========================================================
       14. ПРИМЕЧАНИЯ
       ========================================================= */

    #print-page .note,
    #print-page .remark {
        margin: 3mm 0;

        font-size: 12pt;
        line-height: 1.1;

        text-align: justify;

        break-inside: avoid;
        page-break-inside: avoid;
    }


    /* =========================================================
       15. ОБЫЧНЫЕ ИЗОБРАЖЕНИЯ / SVG / CANVAS
       ========================================================= */

    #print-page img,
    #print-page svg,
    #print-page canvas {
        max-width: 100% !important;

        break-inside: avoid;
        page-break-inside: avoid;
    }


    /* =========================================================
       16. УПРАВЛЕНИЕ ПЕРЕНОСАМИ
       ========================================================= */

    #print-page .page-break,
    #print-page .page-break-before {
        break-before: page;
        page-break-before: always;
    }


    #print-page .page-break-after {
        break-after: page;
        page-break-after: always;
    }


    #print-page .avoid-break,
    #print-page .keep-together {
        break-inside: avoid;
        page-break-inside: avoid;
    }


    #print-page .keep-with-next {
        break-after: avoid-page;
        page-break-after: avoid;
    }


    /* =========================================================
       17. ССЫЛКИ
       ========================================================= */

    #print-page a {
        color: #000 !important;
        text-decoration: none !important;
    }


    #print-page a[href]::after {
        content: none !important;
    }


    /* =========================================================
       18. НЕ ПЕЧАТАТЬ ЭЛЕМЕНТЫ УПРАВЛЕНИЯ
       ========================================================= */

    #print-page button,
    #print-page input,
    #print-page select,
    #print-page textarea,
    #print-page .no-print,
    #print-page .screen-only,
    #print-page .toolbar,
    #print-page .controls {
        display: none !important;
    }


    /* =========================================================
       19. УБИРАЕМ ТОЛЬКО ДЕКОРАТИВНЫЕ ТЕНИ
       ========================================================= */

    #print-page * {
        color: #000 !important;
        background: transparent !important;
        border-color: #000 !important;
        text-shadow: none !important;
        box-shadow: none !important;
    }

    /* Математические матрицы и векторы: без цвета, пригодны для формул. */
    #print-page .formula:has(> table.matrix, > table.vector) {
        margin: 1em 0;
        text-align: center;
        text-indent: 0;
        font-style: italic;
    }

    #print-page table.matrix,
    #print-page table.vector {
        position: relative;
        display: inline-block !important;
        width: auto !important;
        max-width: 100% !important;
        margin: 0 0.3em !important;
        padding: 0.2em 0.65em !important;
        border: 0 !important;
        border-collapse: separate !important;
        border-spacing: 0.45em 0.16em !important;
        color: #000 !important;
        background: transparent !important;
        vertical-align: middle;
        line-height: 1.15;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    #print-page table.matrix::before,
    #print-page table.matrix::after,
    #print-page table.vector::before,
    #print-page table.vector::after {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        width: 0.42em;
    }

    #print-page table.matrix::before,
    #print-page table.vector::before {
        left: 0;
        border-left: 0.75pt solid #000;
        border-radius: 50% 0 0 50%;
    }

    #print-page table.matrix::after,
    #print-page table.vector::after {
        right: 0;
        border-right: 0.75pt solid #000;
        border-radius: 0 50% 50% 0;
    }

    #print-page table.matrix tr,
    #print-page table.vector tr {
        min-height: 0;
    }

    #print-page table.matrix td,
    #print-page table.vector td {
        min-width: 1.8em;
        height: auto;
        padding: 0.12em 0.22em;
        border: 0 !important;
        color: #000 !important;
        background: transparent !important;
        text-align: center !important;
        vertical-align: middle !important;
        white-space: nowrap;
        font: inherit;
        font-variant-numeric: tabular-nums;
    }
}
