/* Shared print rules — applied on every page via base.html.
 *
 * Strips app chrome (nav bar, buttons, sticky headers) that only makes sense
 * on screen, and lets content flow full-width on the page instead of staying
 * boxed into the `max-w-7xl` centered column. Combined, this is enough for a
 * single Wellness/Vocal encounter detail page to print cleanly on letter
 * paper without any per-page print styling.
 */
@media print {
    @page {
        size: letter;
        margin: 0.5in;
    }

    .no-print {
        display: none !important;
    }

    nav {
        display: none !important;
    }

    main {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    * {
        position: static !important;
        box-shadow: none !important;
    }

    a {
        color: inherit !important;
        text-decoration: none !important;
    }

    /* Grayscale — no color ink on printed records (mono laser printers,
     * archival binders). Applied broadly, then the two header bands below
     * re-assert their gray fills so the section/encounter boundaries stay
     * visible. */
    * {
        color: #000 !important;
    }
    .bg-indigo-50, .bg-indigo-100, .bg-amber-100, .bg-gray-50, .bg-white {
        background: transparent !important;
    }

    /* Mirror of `.no-print`: content that only makes sense in print (e.g. a
     * compact encounter header replacing the screen-only title/buttons). */
    .print-only {
        display: block !important;
    }

    /* Collated "print all" report: break *before* each packet/encounter
     * section rather than after every `.print-page`, so the rule survives
     * nesting (a student packet followed by several per-encounter pages). */
    .print-page {
        break-before: page;
    }

    .print-page.first-page {
        break-before: avoid;
    }

    /* Hide empty leaf fields (marked by the `dash`/`dash_yesno` template
     * filters) without touching screen rendering or section-level `{% if %}`
     * guards, which already hide whole sections with no data. */
    dl > div:has(.ev),
    li:has(.ev) {
        display: none !important;
    }

    /* ── Density layer ──────────────────────────────────────────────── */
    body {
        font-size: 9pt !important;
    }

    .text-2xl { font-size: 12pt !important; }
    .text-lg { font-size: 10.5pt !important; }
    .text-base { font-size: 10pt !important; }
    .text-sm { font-size: 8.5pt !important; }
    .text-xs { font-size: 7.5pt !important; }

    .p-6, .p-5, .p-4 {
        padding: 0.15rem !important;
    }
    .mt-8, .mt-6 {
        margin-top: 0.35rem !important;
    }
    .mt-4, .mt-3 {
        margin-top: 0.2rem !important;
    }
    .mb-6 {
        margin-bottom: 0.35rem !important;
    }
    .gap-y-4, .gap-y-3 {
        row-gap: 0.15rem !important;
    }
    .gap-x-8 {
        column-gap: 0.6rem !important;
    }

    dl.grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
    dl.grid > .sm\:col-span-2 {
        grid-column: span 3 / span 3 !important;
    }

    table {
        font-size: 7.5pt !important;
    }
    td, th {
        padding: 1px 4px !important;
    }

    .rounded-lg {
        border-radius: 0 !important;
    }

    /* Break control — keep labels with their values, avoid orphaned rows. */
    dl > div, tr, li {
        break-inside: avoid;
    }
    h1, h2, h3 {
        break-after: avoid;
    }

    /* Wellness/Vocal encounters flow continuously within a student's packet
     * — no page is spent on either boundary. `.section-title` marks which
     * record type follows (Wellness vs Vocal); `.encounter-header` marks
     * where a new encounter starts within that section. Both are grayscale
     * fills so the boundary stays obvious without spending color ink. */
    .section-title {
        margin-top: 0 !important;
        padding: 0.2rem 0.3rem !important;
        background: #d1d5db !important;
        border-top: 1.5pt solid #111827 !important;
        border-bottom: 1.5pt solid #111827 !important;
        letter-spacing: 0.04em;
        break-after: avoid !important;
    }

    .encounter-header {
        margin-top: 0 !important;
        padding: 0.12rem 0.3rem !important;
        background: #e5e7eb !important;
        border-top: 1.5pt solid #111827 !important;
        border-bottom: 0.5pt solid #9ca3af !important;
        break-after: avoid !important;
    }
}
