/* ABOUTME: Print stylesheet — applied via <link media="print"> from base.html. */
/* ABOUTME: Tuned for foundation detail / agency / state landing pages (#48). */

/* Strip global chrome that has no place in a printed page. The save buttons,
   HTMX controls, header nav, and footer are interactive surfaces that read as
   noise on paper. Keep the main content stream + the foundation header. */
@media print {
    nav,
    aside,
    footer,
    .save-btn,
    button,
    [hx-get],
    [hx-post],
    [hx-target],
    [data-debug-toolbar],
    #djDebug,
    .grants-pagination,
    .htmx-indicator {
        display: none !important;
    }

    /* Force a white background and dark ink so printers do not waste toner on
       the cream / burgundy palette. The design system is decorative; the content
       is the contract. */
    html,
    body,
    main,
    article,
    section {
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
    }

    body {
        font-family: Georgia, "Times New Roman", serif;
        font-size: 11pt;
        line-height: 1.45;
        margin: 0;
    }

    main {
        padding: 0 !important;
    }

    /* Foundation / agency / category headers should anchor the page break. The
       opening header is allowed to break before; subsequent sections must not
       split a stat strip or a recipient row across two pages. */
    header,
    h1,
    h2,
    h3 {
        page-break-after: avoid;
        break-after: avoid;
    }

    section,
    table,
    .stat-strip,
    .recipient-row {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Show external link targets next to the anchor text so a printed copy
       still carries the citation. Skip JS / mailto / tel URLs which add noise. */
    a[href^="http"]::after,
    a[href^="https"]::after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #555555;
        word-break: break-all;
    }

    a[href^="#"]::after,
    a[href^="javascript:"]::after,
    a[href^="mailto:"]::after,
    a[href^="tel:"]::after {
        content: "";
    }

    /* Editorial typography: tighter margins, generous leading, no decorative
       hover transitions that printers cannot honour anyway. */
    a {
        color: #000000 !important;
        text-decoration: underline;
    }

    h1 {
        font-size: 22pt;
        margin: 0 0 0.5em;
    }

    h2 {
        font-size: 14pt;
        margin: 1em 0 0.4em;
    }

    h3 {
        font-size: 12pt;
        margin: 0.8em 0 0.3em;
    }

    p,
    li {
        orphans: 3;
        widows: 3;
    }

    /* Stat strip: render the four numbers as a clean horizontal row with light
       rules. The on-screen version uses gold accents; print reduces to ink-only. */
    .stat-strip {
        display: flex;
        gap: 1.5em;
        border-top: 1px solid #cccccc;
        border-bottom: 1px solid #cccccc;
        padding: 0.5em 0;
        margin: 0.8em 0;
    }

    /* Grants table: tighter rows, no zebra striping, ink-friendly borders. */
    table {
        width: 100%;
        border-collapse: collapse;
    }

    th,
    td {
        padding: 0.25em 0.5em;
        border-bottom: 1px solid #dddddd;
        text-align: left;
    }

    /* The "How to apply" callout is the most actionable block on the page —
       keep its left rule but in ink instead of gold. */
    .callout-apply {
        border-left: 3px solid #000000;
        background: transparent !important;
        padding: 0.5em 0.8em;
        margin: 1em 0;
    }
}
