/* SR ("самостоятельная работа") document look — N identical slips tiled on
   one A4 sheet in a rows×cols grid (user-configurable). Sheet size/grid/
   font-scale are all set as inline custom properties by sr-render.js from
   srLayoutMetrics(), so this file only ever multiplies by var(--sr-scale) —
   it never hardcodes a size that would need to change when the grid does. */

.sr-sheet {
    /* Tracks are explicit cm sizes (--sr-cell-w/--sr-cell-h, set inline by
       sr-render.js from srLayoutMetrics), not 1fr fractions of a container
       forced to an exact page-size guess. The sheet's own box is therefore
       intrinsically sized to rows×cols cells — identical on screen and at
       print/PDF time, no separate print-only width/height override needed
       (a prior version tried that with 100vh; print's viewport-unit
       handling is exactly the kind of thing that's inconsistent across
       browsers/printers, which is the class of bug this design avoids). */
    position: relative;
    display: grid;
    /* max-content, not the block default of "fill the container" — the box
       must shrink-wrap exactly to its tracks' cm sizes for the centering
       margin below to mean anything (a full-width box has no room to
       center within). */
    width: max-content;
    margin: 0 auto 28px auto;
    background: #fff;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
    box-sizing: border-box;
    grid-template-columns: repeat(var(--sr-cols, 2), var(--sr-cell-w, 10cm));
    grid-template-rows: repeat(var(--sr-rows, 2), var(--sr-cell-h, 14cm));
}

.sr-slip {
    box-sizing: border-box;
    padding: calc(0.5cm * var(--sr-scale, 1)) calc(0.6cm * var(--sr-scale, 1));
    font-family: var(--sr-font, "Times New Roman", Georgia, serif);
    font-size: calc(10.5pt * var(--sr-scale, 1));
    line-height: 1.25;
    color: #000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sr-slip-header {
    text-align: center;
    margin: 0 0 calc(8px * var(--sr-scale, 1)) 0;
}
.sr-slip-logo {
    display: block;
    max-height: calc(24px * var(--sr-scale, 1));
    max-width: calc(60px * var(--sr-scale, 1));
    margin: 0 auto calc(3px * var(--sr-scale, 1)) auto;
}
.sr-slip-school { font-size: calc(8.5pt * var(--sr-scale, 1)); margin: 0 0 1px 0; }
.sr-slip-title { font-weight: bold; font-size: calc(11.5pt * var(--sr-scale, 1)); margin: 0 0 1px 0; }
.sr-slip-subline { font-size: calc(9pt * var(--sr-scale, 1)); color: #333; margin: 0; }

.sr-slip-fio {
    margin: 0 0 calc(10px * var(--sr-scale, 1)) 0;
    font-size: calc(10pt * var(--sr-scale, 1));
}

.sr-question { margin: 0 0 calc(7px * var(--sr-scale, 1)) 0; }
.sr-question-text { margin: 0 0 2px 0; }
.sr-given { font-size: calc(9.5pt * var(--sr-scale, 1)); margin: 0 0 2px 0; }
.sr-answer-label { font-size: calc(9.5pt * var(--sr-scale, 1)); font-style: italic; color: #333; margin: 0; }
.sr-answer-line {
    height: calc(15px * var(--sr-scale, 1));
    border-bottom: 1px solid #000;
    margin: 0 0 calc(4px * var(--sr-scale, 1)) 0;
}

@media print {
    /* display:none (not visibility:hidden) — visibility keeps the element's
       layout box, silently inflating the print job with a trailing blank
       page when the editor chrome is taller than one printed sheet. */
    .ctrl-topbar,
    .ctrl-databanner,
    #editor-column,
    #ctrl-resizer,
    .ctrl-preview-toolbar {
        display: none !important;
    }
    html, body {
        height: auto !important;
        overflow: visible !important;
    }
    .ctrl-layout, #preview-column, #doc-preview-scroll {
        display: block !important;
        height: auto !important;
        padding: 0 !important;
        /* #preview-column is overflow:hidden on screen (it's a scroll pane);
           a hidden-overflow ancestor is a known source of print-pagination
           clipping bugs in real browsers even when its own height is auto,
           so it's reset explicitly here rather than assumed harmless. */
        overflow: visible !important;
    }
    #doc-preview-scroll {
        background: none;
        border-radius: 0;
    }
    .sr-sheet {
        box-shadow: none;
        margin: 0;
        break-after: page;
        page-break-after: always;
    }
    .sr-sheet:last-child {
        break-after: auto;
        page-break-after: auto;
    }
    .sr-slip { break-inside: avoid; page-break-inside: avoid; }
}
