/* Helios Open Reader — Print Stylesheet */

@page {
    margin: 1.5cm 2cm;
}

@media print {
    /* Hide navigation chrome */
    aside,
    #site-header,
    footer,
    .mobile-nav-overlay,
    .mobile-nav-panel,
    #htmx-prev-next,
    .prev-next-nav--top,
    .hor-sticky-nav,
    #hor-resume-reading,
    #htmx-loading,
    #htmx-breadcrumbs,
    .hor-section-list {
        display: none !important;
    }

    /* Reset colors for print — covers both light and dark themes */
    body {
        background: white !important;
    }
    * {
        color: black !important;
        border-color: #ccc !important;
        box-shadow: none !important;
    }

    /* Collapse sidebar offset so content fills the page */
    :root {
        --helios-sidebar-width: 0px;
    }

    /* Full-width content layout */
    #toc-layout {
        display: block !important;
        max-width: 100% !important;
    }

    /* Show absolute URLs inline after links — skips relative paths and anchor links */
    #htmx-article a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #000;
    }

    /* Avoid page breaks inside cards, callouts, objectives blocks, and common content blocks */
    .doc-card,
    .callout,
    .hor-objectives,
    .md-alert,
    img,
    figure,
    pre,
    blockquote,
    table {
        break-inside: avoid;
    }

    /* Prevent figures and their images from overflowing the print area */
    figure {
        max-width: 100% !important;
    }

    figure img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Avoid breaking inside lists and individual list items */
    ul, ol, li {
        break-inside: avoid;
    }

    /* Keep headings attached to the content that follows them */
    h1, h2, h3, h4, h5, h6 {
        break-after: avoid;
    }

    /* Page break before each reader page's title when printing multiple pages. On section pages the
       break goes before the header, so the "Section N" label stays with the title (a break before the
       h1 itself left the label alone on a blank first page) */
    article h1 {
        break-before: page;
    }

    article header h1 {
        break-before: auto;
    }

    article header {
        break-before: page;
    }

    /* Repeat table header row on each printed page */
    thead {
        display: table-header-group;
    }

    /* Prevent single orphaned/widowed lines at page breaks */
    p, li {
        orphans: 3;
        widows: 3;
    }

    /* Prevent code blocks from overflowing page width */
    pre, code {
        white-space: pre-wrap;
        word-wrap: break-word;
    }

    /* OER attribution block — show in print output */
    .hor-attribution {
        display: block !important;
        margin-top: 2rem;
        padding-top: 1rem;
        border-top: 1px solid #ccc;
        font-size: 0.85em;
        text-align: center;
    }

    /* Utility class: hide elements from print output */
    .no-print {
        display: none !important;
    }
}
