/* ============================================================
   Harvest Calendar — Print Styles (v2)
   Designed to match the reference paper calendar:
     • Big bold sans-serif "Month Year" in upper right
     • Serif/condensed church wordmark in upper left
     • Clean 7-column grid with thin borders
     • Days outside this month shown gray
     • Italic notes (e.g. "Easter Sunday")
     • Italic footer line
   Uses safe system fonts (no Freight) for reliable printing.
   ============================================================ */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body.hc-print {
    padding: 24px 28px 32px 28px;
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    color: #000;
    background: #ffffff;
    font-size: 12px;
    line-height: 1.35;
}

/* ---------- Toolbar (screen only) ---------- */
.hc-print-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #cdd5e0;
}
.hc-print-btn {
    padding: 9px 18px;
    background: #0f98d6;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: Arial, sans-serif;
}
.hc-print-btn:hover { background: #0a7fb5; }
.hc-print-toolbar-note {
    font-size: 12px;
    color: #b45309;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---------- Page wrap ---------- */
.hc-print-page {
    max-width: 1100px;
    margin: 0 auto;
}

/* ---------- Proof label (anchored just right of the wordmark) ---------- */
.hc-print-header-left {
    display: flex;
    align-items: flex-end;
    gap: 18px;
}
.hc-print-proof-label {
    margin-bottom: 4px;
    background: #fef3c7;
    color: #78350f;
    padding: 6px 16px;
    border: 1px solid #fbbf24;
    border-radius: 999px;
    font-family: Arial, "Helvetica Neue", sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ---------- Header (wordmark + month/year) ---------- */
.hc-print-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding: 8px 0 24px 0;
}

.hc-print-wordmark {
    line-height: 1;
}
.hc-print-wordmark-name {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-weight: 700;
    font-size: 36px;
    letter-spacing: 0.04em;
    color: #000;
    border-bottom: 1.5px solid #000;
    padding-bottom: 3px;
}
.hc-print-wordmark-sub {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-weight: 400;
    font-size: 14px;
    letter-spacing: 0.32em;
    color: #000;
    margin-top: 6px;
    padding-left: 2px;
}
.hc-print-wordmark-tag {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-style: italic;
    font-size: 11px;
    color: #000;
    margin-top: 4px;
    padding-left: 2px;
    letter-spacing: 0.01em;
}

.hc-print-monthyear {
    font-family: Arial, "Helvetica Neue", sans-serif;
    font-weight: 700;
    font-size: 60px;
    line-height: 1;
    letter-spacing: -0.01em;
    color: #000;
    text-align: right;
    white-space: nowrap;
}

/* ---------- Grid ---------- */
.hc-print-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    border-top: 1.5px solid #000;
    border-bottom: 1.5px solid #000;
}

.hc-print-grid th {
    padding: 8px 10px 10px 10px;
    background: #ffffff;
    color: #000;
    font-family: Arial, "Helvetica Neue", sans-serif;
    font-weight: 700;
    font-size: 13px;
    text-align: left;
    border-bottom: 1px solid #000;
    letter-spacing: 0;
    width: 14.2857%;
}

.hc-print-cell {
    vertical-align: top;
    height: 110px;
    padding: 0;
    border: 1px solid #cdd5e0;
    background: #ffffff;
    position: relative;
}

.hc-print-cell-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Default top padding leaves room for the date number (~22px). When
       bars cover this cell, padding-top grows to push events below them. */
    padding: 22px 7px 7px 7px;
}

/* Date number row is rendered as a direct child of <td>, NOT inside
   cell-inner, and absolutely positioned so it always stays anchored to
   the top of the cell — even when bars start in or cross this cell. */
.hc-print-daynum-row {
    position: absolute;
    top: 5px;
    left: 7px;
    right: 7px;
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
    z-index: 3; /* above the bar (z=2) */
}

/* Multi-day spanning bar. Inline `width` (set by PHP as a percentage of
   the parent cell) spans this cell plus the next N-1 cells. The bar is
   absolutely positioned so it can extend past the cell's right edge
   without being affected by cell-inner padding. */
.hc-print-multiday-bar {
    position: absolute;
    top: 22px; /* Just below the daynum row. */
    left: 0;
    height: 16px;
    background: #d4d4d8;
    /* Flexbox vertically centers single-line text reliably. */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
    z-index: 2;
    /* width is set inline */
}

/* Reserve top padding inside cell-inner so events don't sit under the bar.
   `data-bar-cover` is set on every cell a bar passes through (start, middle,
   or end of a run), not just the start cell. */
.hc-print-cell[data-bar-cover="1"] .hc-print-cell-inner { padding-top: 42px; }
.hc-print-cell[data-bar-cover="2"] .hc-print-cell-inner { padding-top: 60px; }
.hc-print-cell[data-bar-cover="3"] .hc-print-cell-inner { padding-top: 78px; }

/* Subsequent bars stack vertically (only happens on the starting cell). */
.hc-print-multiday-bar + .hc-print-multiday-bar { top: 40px; }
.hc-print-multiday-bar + .hc-print-multiday-bar + .hc-print-multiday-bar { top: 58px; }

.hc-print-multiday-title {
    font-family: Arial, "Helvetica Neue", sans-serif;
    font-size: 9.5px;
    font-weight: 700;
    color: #000;
    letter-spacing: 0.01em;
    padding: 0 6px;
}

body.hc-print-mode-handout .hc-print-multiday-bar { height: 14px; }
body.hc-print-mode-handout .hc-print-multiday-title { font-size: 8.5px; }
body.hc-print-mode-handout .hc-print-cell[data-bar-cover="1"] .hc-print-cell-inner { padding-top: 38px; }
body.hc-print-mode-handout .hc-print-cell[data-bar-cover="2"] .hc-print-cell-inner { padding-top: 54px; }
body.hc-print-mode-handout .hc-print-cell[data-bar-cover="3"] .hc-print-cell-inner { padding-top: 70px; }

.hc-print-cell-empty {
    background: #e5e7eb;
}

.hc-print-daynum {
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: #000;
    line-height: 1;
    flex-shrink: 0;
}

.hc-print-holiday-label {
    font-family: Arial, sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: #000;
    line-height: 1.1;
}

.hc-print-events {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* AM events stick to the top (just below the day number).
   PM events get pushed to the bottom of the cell with margin-top: auto.
   This mirrors the old Word-doc behaviour of leaving vertical space
   between morning and evening events. */
.hc-print-events-am {
    /* Default flow — sits right under the daynum */
}
.hc-print-events-pm {
    margin-top: auto;
    padding-top: 6px;
}

.hc-print-event {
    font-family: Arial, sans-serif;
    font-size: 10.5px;
    line-height: 1.35;
    padding: 1px 0;
    color: #000;
}

.hc-print-event.is-main {
    font-weight: 700;
}

.hc-print-event.is-holiday {
    font-style: italic;
    font-weight: 600;
}

.hc-print-event.is-canceled {
    color: #6b7280;
    text-decoration: line-through;
}

.hc-print-event.is-rescheduled {
    color: #6b7280;
    text-decoration: line-through;
    text-decoration-style: wavy;
}

.hc-print-time {
    font-weight: 400;
    /* Keep the number and AM/PM together so they never split across lines. */
    white-space: nowrap;
}

.hc-print-tag {
    font-style: italic;
    font-size: 9.5px;
    color: #6b7280;
}

/* ---------- Handout mode: tighter sizing to fit single page ---------- */
body.hc-print-mode-handout .hc-print-cell { height: 96px; }
body.hc-print-mode-handout .hc-print-cell-inner { padding: 20px 6px 5px 6px; }
body.hc-print-mode-handout .hc-print-event { font-size: 9.5px; line-height: 1.3; }
body.hc-print-mode-handout .hc-print-daynum { font-size: 11px; }
body.hc-print-mode-handout .hc-print-holiday-label { font-size: 10px; }
body.hc-print-mode-handout .hc-print-daynum-row { margin-bottom: 3px; }
body.hc-print-mode-handout .hc-print-events-pm { padding-top: 4px; }

.hc-print-toolbar-note-info {
    color: #0f98d6;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 12px;
}

/* ---------- Footer ---------- */
.hc-print-footer {
    padding: 14px 0 0 0;
    text-align: center;
    font-family: Arial, sans-serif;
    font-size: 11.5px;
    color: #000;
}
.hc-print-footer em {
    font-style: italic;
    font-weight: 400;
}

/* ============================================================
   PRINT MEDIA
   ============================================================ */

@media print {
    body.hc-print {
        padding: 0;
        font-size: 11px;
    }
    .hc-print-toolbar { display: none; }
    /* Trimmed padding so the calendar fits a single landscape letter page
       comfortably even for 6-row months. The @page margin below provides
       the actual printer-safe edge buffer. */
    .hc-print-page { max-width: none; padding: 0; }
    .hc-print-cell { height: 84px; }
    .hc-print-header { padding: 0 0 10px 0; }
    .hc-print-monthyear { font-size: 44px; }
    .hc-print-wordmark-name { font-size: 28px; }
    .hc-print-wordmark-sub { font-size: 11px; letter-spacing: 0.28em; }
    .hc-print-wordmark-tag { font-size: 9.5px; }
    .hc-print-event { font-size: 9.5px; line-height: 1.3; }
    .hc-print-daynum { font-size: 11px; }
    .hc-print-grid th { font-size: 11px; padding: 5px 8px 6px 8px; }
    .hc-print-footer { padding-top: 8px; font-size: 10px; }

    /* Handout: same tight sizing as public — both modes need single-page fit. */
    body.hc-print-mode-handout .hc-print-page { padding: 0; }
    body.hc-print-mode-handout .hc-print-header { padding: 0 0 12px 0; }
    body.hc-print-mode-handout .hc-print-monthyear { font-size: 44px; }
    body.hc-print-mode-handout .hc-print-wordmark-name { font-size: 28px; }
    body.hc-print-mode-handout .hc-print-wordmark-sub { font-size: 11px; letter-spacing: 0.28em; }
    body.hc-print-mode-handout .hc-print-wordmark-tag { font-size: 9.5px; }
    body.hc-print-mode-handout .hc-print-cell { height: 86px; }
    body.hc-print-mode-handout .hc-print-cell-inner { padding: 18px 5px 4px 5px; }
    body.hc-print-mode-handout .hc-print-event { font-size: 9px; line-height: 1.25; }
    body.hc-print-mode-handout .hc-print-daynum { font-size: 10px; }
    body.hc-print-mode-handout .hc-print-holiday-label { font-size: 9px; }
    body.hc-print-mode-handout .hc-print-daynum-row { margin-bottom: 2px; }
    body.hc-print-mode-handout .hc-print-grid th { font-size: 11px; padding: 5px 8px 6px 8px; }
    body.hc-print-mode-handout .hc-print-footer { padding-top: 8px; font-size: 10px; }

    /* Force background colors to print (gray empty cells, banners). */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Critical: keep the entire calendar grid on a single page. Without
       these, the browser is free to break between rows whenever it thinks
       content might not fit, even by a small margin. */
    .hc-print-grid,
    .hc-print-grid thead,
    .hc-print-grid tbody,
    .hc-print-grid tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    .hc-print-page {
        page-break-after: avoid;
        break-after: avoid;
    }

    @page {
        size: letter landscape;
        margin: 0.3in;
    }
}

/* ---------- Smaller screens (so the screen view doesn't cramp) ---------- */
@media (max-width: 720px) {
    .hc-print-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .hc-print-monthyear {
        font-size: 38px;
        text-align: left;
    }
    .hc-print-cell {
        height: auto;
        min-height: 50px;
    }
    .hc-print-event { font-size: 11px; }
}
