/*
    The guide's print stylesheet: the December calendar as a document, matching the designer's print comp — white page,
    dark copy, the week bands in the editor's gold with the ring mark hanging off their left edge, and the day cells
    back to a thin-ruled grid.

    **Linked with `media="print"` from `prayer_guide_page.html`, and that attribute is the whole of the scoping** — the
    rules below are plain, not wrapped in `@media print`. Two reasons: the link is what a browser and this project's own
    PDF engine (`WeasyPrint`, via `django-weasyprint`) both read, and WeasyPrint 52 — the version installed here —
    segfaults on *any* `@media print` block, an empty one included, which would have made the sheet impossible to render
    or preview. `test_print_stylesheet.py` fails if the link ever loses its `media="print"`, which is the guarantee the
    wrapper would have given.

    So the screen keeps its olive band and its `lg`-only grid, and this file only ever applies while a page is being
    printed or previewed for print. That is also why it is hand-written CSS rather than Tailwind utilities — a print sheet is a different medium
    with its own units (`mm`, `pt`), page box and break rules, and none of that belongs in the shared, minified
    stylesheet every other page of the site downloads.

    **Print width is not `lg`.** The page box of A4/Letter is ~800px wide, well under the 1024px breakpoint that gives the
    screen its desktop band, so without this file a print would render the *phone* half and drop the calendar entirely.
    The first two rules exist for exactly that: hide the phone's half, show the band.

    The hooks it reaches for are in `prayer_guide_page.html`: `[data-print-calendar]` is the band, and
    `[data-print-hidden]` marks everything that is furniture rather than calendar.
*/

/* The page box: generous margins, and **no forced paper**. The sheet is portrait-shaped on its own, and leaving the paper
   to the reader means a Letter tray and an A4 tray both work. (Setting the orientation alone would be legal CSS, but this
   project's own PDF engine — WeasyPrint 52, which `reading_plans` uses — crashes on it, and "whatever paper the reader
   has" is the honest value anyway.) */
@page {
    margin: 12mm 12mm 14mm;
}

/* ---- the page goes to ink ---------------------------------------------------------------------------------- */

/* Everything on the sheet is black except the title (the band's olive) and the theme rows (white) — PO, 2026-11-13. */
html,
body {
    background: #fff !important;
    color: #000 !important;
}

/* The site's furniture: navigation, the footer menu, the install sheet, the admin bar, and anything the guide's own
   template marks as not-calendar (the phone's half, the two action buttons, the band's speckles and rings). */
#main-navigation,
#footer,
#wagtail-userbar,
.wagtail-userbar,
dialog,
[data-print-hidden] {
    display: none !important;
}

/* ---- the band becomes the sheet ---------------------------------------------------------------------------- */

[data-print-calendar] {
    position: static !important;
    display: block !important;
    overflow: visible !important;
    width: auto !important;
    padding: 0 !important;
    background: none !important;
    color: #000 !important;
}

[data-print-calendar] .max-w-7xl {
    max-width: none !important;
    padding: 0 !important;
}

/* ---- the title --------------------------------------------------------------------------------------------- */

/* "DECEMBER" over "Prayer Calendar": the standfirst light, the display line bold and much larger — the two lines the
   screen already has, at the sizes the comp gives them. Comma Base is named here as well as by the heading's own
   class, so the sheet keeps its face even if the class ever moves. */
/* Both lines of the title take the band's olive (PO, 2026-11-13) — the one text on the sheet that is not black. */
[data-print-calendar] h1 {
    margin: 0 0 4mm;
    color: #444B26 !important;
    font-family: "comma-base", sans-serif;
}

[data-print-calendar] h1 > span:first-child {
    display: block;
    font-size: 21pt;
    font-weight: 400;
    line-height: 1;
    letter-spacing: 0.05em;
}

[data-print-calendar] h1 > span:last-child {
    display: block;
    margin-top: 1mm;
    font-size: 42pt;
    font-weight: 700;
    line-height: 0.92;
}

/* ---- the copy above and below the grid --------------------------------------------------------------------- */

/* The intro above the grid and the calendar footer below it. **The colour has to be set here, on the copy and on
   everything inside it**, not inherited from the band: the column around it carries Tailwind's `.text-white`
   (`.text-white{color:rgb(255 255 255/var(--tw-text-opacity,1))}`), and a declaration on *that* element wins for it and
   for every child that inherits it — an `!important` on an ancestor cannot reach past a direct rule on a descendant's
   parent. On paper that meant white copy on white paper. The `*` covers the rich text's own `<p>`, `<strong>`, `<em>` and
   `<a>`, and the `!important` beats a link colour too. */
[data-print-calendar] .max-w-3xl {
    max-width: 118mm !important;
    margin: 0 0 4mm !important;
    font-size: 8.5pt;
    line-height: 1.45;
}

/* Colour only, on the copy and on everything inside it — the layout above is the container's business, this is not. */
[data-print-calendar] .max-w-3xl,
[data-print-calendar] .max-w-3xl * {
    color: #000 !important;
}

[data-print-calendar] .max-w-3xl p {
    margin: 0 0 2.5mm;
}

/* ---- the grid ---------------------------------------------------------------------------------------------- */

[data-print-calendar] table {
    width: 100%;
    border: 0.4mm solid #222;
    border-collapse: collapse;
    table-layout: fixed;
}

[data-print-calendar] th,
[data-print-calendar] td {
    border: 0.25mm solid #555;
    color: #000 !important;
    font-size: 6.4pt;
    line-height: 1.3;
    padding: 1.1mm;
    vertical-align: top;
}

/* Every day cell is a white box of one height, whatever it holds. The theme rows are excluded: they are gold, and a
   white `!important` here would repaint them. */
[data-print-calendar] td:not([colspan]) {
    height: 20mm;
    background: #fff !important;
}

[data-print-calendar] thead th {
    font-size: 6.4pt;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 1.4mm;
}

/* The theme row: **gold, white caps, and room at the left for the ring that hangs there** (PO, 2026-11-13). The fill is
   stated here rather than left to the editor's inline colour, so a print is the comp's gold whatever colour a given week
   was entered with. */
[data-print-calendar] td[colspan="7"] {
    background: #B18B47 !important;
    color: #fff !important;
    font-size: 7pt;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 1.7mm 1.7mm 1.7mm 7mm;
}

/* The ring mark, at the size and offset the comp shows — 12mm across, its left edge just outside the grid. */
[data-print-calendar] td[colspan="7"] > svg {
    left: -7mm;
    width: 12mm;
    height: 12mm;
}

/* A week band and its days stay on one page: a calendar that breaks between a theme and the prayers under it is a
   calendar a reader has to reassemble. */
[data-print-calendar] tr {
    break-inside: avoid;
    page-break-inside: avoid;
}

[data-print-calendar] thead {
    display: table-header-group;
}
