/* master_print.css — shared @media print layout for every 7-column calendar view.
   Load last (style.css → page.css → master_print.css) so print rules win over screen offsets. */

.calendar-grid .day-cell.rosh-chodesh,
.hebmonth-grid .day-cell.rosh-chodesh {
    border-inline-start-width: 2px;
}

@media print {
    @page {
        size: auto;
        margin: 15mm 12mm 10mm;
    }

    html,
    body {
        height: 100%;
        margin: 0;
    }

    .container,
    .weekly-container {
        width: 100%;
        height: 100%;
        min-height: 0;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
    }

    .calendar-container,
    .weekly-calendar-container {
        width: 100%;
        max-width: none;
        margin: 0;
        margin-inline: 0;
        zoom: 1;
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
        padding: 0;
    }

    .month-title-nav,
    .month-title-nav-line,
    .month-title-subline {
        width: 100%;
        justify-content: center;
    }

    [dir="rtl"] .month-title-subline,
    [dir="ltr"] .month-title-subline {
        padding: 0;
        padding-inline: 0;
    }

    .calendar-header,
    .week-nav-header {
        flex: 0 0 auto;
        margin-top: 0;
        padding: 1mm 0 30px;
    }

    .month-title-subline {
        margin-bottom: 10px;
    }

    .calendar-grid,
    .hebmonth-grid,
    .weekly-grid,
    .blank-grid {
        flex: 1 1 0;
        min-height: 0;
        height: auto;
        max-height: none;
        grid-template-rows: auto repeat(var(--calendar-week-rows, 6), 1fr);
    }

    .day-header {
        height: auto;
        align-self: start;
        font-size: 14px;
    }

    .day-cell {
        min-height: 0;
        height: 100%;
        padding: 8px;
        box-sizing: border-box;
    }

    .gregorian-date {
        font-size: 12px;
    }

    .calendar-container.is-loading .calendar-grid,
    .calendar-container.is-loading .hebmonth-grid,
    .calendar-container.is-loading .calendar-header {
        filter: none;
        opacity: 1;
    }

    /* These were fixed at 186mm/273mm — A4's own printable width (210/297mm
       minus its side margins) — so a larger sheet kept the A4 content size
       and just grew dead margin around it. 100% computes to the same pixel
       value on A4 (it already fit exactly) but now tracks whatever paper
       size the print dialog actually picked. */
    html[data-print-orientation="portrait"] .container,
    html[data-print-orientation="portrait"] .weekly-container {
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
    }

    html[data-print-orientation="portrait"] .calendar-container,
    html[data-print-orientation="portrait"] .weekly-calendar-container {
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        padding-right: 0;
        padding-left: 0;
    }

    html[data-print-orientation="portrait"] .calendar-grid,
    html[data-print-orientation="portrait"] .hebmonth-grid,
    html[data-print-orientation="portrait"] .weekly-grid,
    html[data-print-orientation="portrait"] .blank-grid {
        width: 100%;
        min-width: 0;
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }

    html[data-print-orientation="portrait"] .day-cell,
    html[data-print-orientation="portrait"] .day-header {
        width: auto;
        min-width: 0;
    }

    html[data-print-orientation="portrait"] .calendar-header,
    html[data-print-orientation="portrait"] .week-nav-header {
        flex: 0 0 auto;
        padding-top: 1mm;
        padding-bottom: 30px;
    }

    html[data-print-orientation="landscape"] .container,
    html[data-print-orientation="landscape"] .weekly-container {
        width: 100%;
        max-width: 100%;
        margin-inline: auto;
    }

    html[data-print-orientation="landscape"] .calendar-container,
    html[data-print-orientation="landscape"] .weekly-calendar-container {
        width: 100%;
        max-width: 100%;
        margin-inline: auto;
        height: auto;
        min-height: 0;
        max-height: none;
        flex: 1 1 0;
        padding-top: 0;
        padding-bottom: 0;
        overflow: hidden;
    }

    html[data-print-orientation="landscape"] .calendar-header,
    html[data-print-orientation="landscape"] .week-nav-header {
        flex: 0 0 auto;
        padding-top: 1mm;
        padding-bottom: 30px;
    }

    html[data-print-orientation="landscape"] .calendar-grid,
    html[data-print-orientation="landscape"] .hebmonth-grid,
    html[data-print-orientation="landscape"] .weekly-grid,
    html[data-print-orientation="landscape"] .blank-grid {
        flex: 1 1 0;
        min-height: 0;
    }

    html[data-print-orientation="landscape"] .day-cell {
        min-height: 0;
        padding: 8px;
    }
}
