/* Loaded only for posts, with media="print". Keep screen styling in its own layers. */
@page {
    size: auto;
    margin: 15mm;
}

body.layout-post {
    /* Undo Bootstrap's print minimum width so A4 and Letter use their actual width. */
    min-width: 0 !important;
    margin: 0;
    background: #fff;
    color: #111;
    font-size: 11pt;
    line-height: 1.6;
}

.layout-post .site-header,
.layout-post .site-footer,
.layout-post .entry-media,
.layout-post .entry-footer,
.layout-post .post-navigation,
.layout-post .comments-area-wrapper {
    display: none !important;
}

/* The imported theme has highly specific split-layout rules and inline padding.
   Limit !important to these resets rather than reproducing its selector chains. */
.layout-post .site-inner,
.layout-post .entry-inner {
    float: none !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.layout-post .site-content {
    padding: 0 !important;
}

.layout-post .entry-header {
    position: static !important;
    width: auto !important;
    /* Original 5 mm gap plus approximately one extra line of body text. */
    padding: 0 0 11mm !important;
    border: 0 !important;
    background: transparent !important;
    color: #111 !important;
    font-style: normal;
    text-align: left !important;
    break-inside: avoid;
    break-after: avoid;
}

/* A compact primary photo beside the title; image-free headers keep full width. */
.layout-post .entry-header.has-print-image {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30%;
    grid-template-rows: auto auto 1fr;
    column-gap: 6mm;
    align-items: start;
}

.layout-post .entry-header.has-print-image > :not(.print-post-image) {
    grid-column: 1;
}

.layout-post .entry-header .print-post-image {
    display: block;
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: center;
    width: 100%;
    height: auto;
    max-height: 45mm;
    object-fit: contain;
}

.layout-post .entry-header h1 {
    margin: 0 0 2mm !important;
    color: #111 !important;
    font-size: 22pt;
}

.layout-post .entry-header a {
    color: inherit !important;
    letter-spacing: normal !important;
    text-transform: none !important;
}

.layout-post .entry-meta {
    position: static !important;
}

.layout-post .entry-meta .cat-links,
.layout-post .entry-posted {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    color: #444 !important;
    font-size: 9pt !important;
    letter-spacing: normal;
}

.layout-post .posted-info {
    float: none !important;
}

/* Only the article body flows into columns; the title and byline span the page. */
.layout-post .entry-content {
    padding: 0 !important;
    column-count: 2;
    column-gap: 8mm;
    overflow-wrap: anywhere;
    widows: 3;
    orphans: 3;
}

.layout-post .entry-content p {
    padding-bottom: 0.7em;
}

.layout-post .entry-content :is(h2, h3, h4, h5, h6) {
    break-inside: avoid;
    break-after: avoid;
}

.layout-post .entry-content h2 {
    font-size: 14pt;
}

.layout-post .entry-content :is(h3, h4, h5, h6) {
    font-size: 12pt;
}

.layout-post .entry-content a {
    text-decoration: underline;
}

.layout-post .entry-content img {
    float: none;
    display: block;
    max-width: 100% !important;
    /* Leave caption room on Letter as well as A4, even for a tall full-width image. */
    max-height: 230mm;
    height: auto;
    margin: 0 auto;
    break-inside: avoid;
}

/* Keep Markdown photo/caption paragraphs together, not ordinary prose paragraphs. */
.layout-post .entry-content :is(p:has(> img), p:has(> a > img), figure) {
    break-inside: avoid;
}

.layout-post .entry-content > .print-full-width {
    column-span: all;
    margin: 3mm 0;
}

.layout-post .entry-content pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Legacy decorative separators and code icons have no role on paper. */
.layout-post :is(.entry-inner, .entry-content, pre)::before,
.layout-post .entry-inner::after {
    display: none !important;
}

/* Bootstrap appends link destinations in print; long photo URLs overwhelm columns. */
.layout-post a[href]::after,
.layout-post abbr[title]::after {
    content: none !important;
}
