/* ============================================================
   cassiopeia_hz —— 文章打印样式（JS 隔离方案配套）
   隔离策略：打印时 JS 把 #jartPrintRoot 移到 body 末尾，
   这里再用 body > *:not(#jartPrintRoot){display:none} 干净隐藏所有框架。
   页眉/页码走 @page 页边距盒（Chrome/Edge 稳）；
   Firefox/Safari 不支持时自动降级（无装饰页眉，正文仍正常）。
   ============================================================ */

/* ---------- 0. 屏幕态 ---------- */
.jart-print-root,
#jartPrintHeader,
#jartPrintFooter { display: none !important; }

.article-tools-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;   /* 工具栏右对齐，紧跟标题下方 */
    gap: .5rem;
    margin: 0 0 1.25rem;
    flex-wrap: wrap;
}
.hz-print-btn,
.hz-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 14px;
    border-radius: 3px;
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s;
}
/* 打印：品牌红白字 */
.hz-print-btn {
    background: #D90000;
    color: #fff;
}
.hz-print-btn:hover { background: #b30000; }
/* 分享：描边按钮 */
.hz-share-btn {
    background: #fff;
    color: #D90000;
    border-color: #D90000;
}
.hz-share-btn:hover { background: #fff5f5; }

/* ---------- 1. 打印总控 ---------- */
@media print {
    html, body {
        background: #fff !important;
        color: #000 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 1.1 干净隔离：隐藏 body 下除打印根容器外的所有直接子级（框架/模块/导航/页脚等） */
    body > *:not(#jartPrintRoot) {
        display: none !important;
    }

    /* 1.2 打印根容器接管整页（已在 JS 中 move 到 body 末尾） */
    #jartPrintRoot {
        display: block !important;
        position: static !important;
        width: auto !important; height: auto !important;
        margin: 0 !important;
        padding-top: 5mm !important;
        padding-right: 0 !important;
        padding-bottom: 0 !important;
        padding-left: 0 !important;
        overflow: visible !important;
        background: #fff; color: #000;
        box-sizing: border-box;
    }

    /* 1.3 ===== @page 页边距盒：页眉 Logo + 红色分隔线 + 底部页码 ===== */
    @page {
        size: A4 portrait;
        margin: 14mm 18mm 12mm 18mm;   /* 上/下留白给页眉页脚 */

        /* 顶部页眉：网站 Logo（高度 30px，整体下移 8px）
           用 background-image + background-position:left bottom，
           让 Logo 贴在 38px 高度的底部，上方自然空出 8px。
           默认 fallback：/images/hengdinglogo.png；JS 会根据 data-logo 动态覆盖。 */
        @top-left {
            content: "";
            height: 30px;
            vertical-align: top;
            background-image: url('/images/hengdinglogo.png');
            background-size: auto 30px;
            background-repeat: no-repeat;
            background-position: left top;
            border-bottom: 5px solid #D90000;
        }


        /* 底部左/右：仅保留红色分隔线，形成贯穿红线 */
        @bottom-left {
            content: "";
            border-top: 3px solid #D90000;
        }

        /* 底部中：页码（居中）
           padding-top 在部分浏览器中可能不生效，属于 CSS Paged Media 限制；
           已尽量用 @page margin-bottom 保证页码不压正文。 */
        @bottom-center {
            content: "第 " counter(page) " 页 / 共 " counter(pages) " 页";
            font-size: 9pt;
            font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
            color: #444;
            border-top: 3px solid #D90000;
            padding-top: 5px;
        }

        @bottom-right {
            content: "";
            border-top: 3px solid #D90000;
        }
    }

    /* 1.4 正文排版（只打标题 + 正文图文） */
    #jartPrintRoot {
        font: 11pt/1.75 "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
        
    }
    .jart-p-title {
        font-size: 19pt; font-weight: 700; line-height: 1.35;
        margin: 0 0 4mm 0; color: #000;
        text-align: center;                  /* 标题居中 */
        page-break-after: avoid; break-after: avoid;
    }
    .jart-p-meta {
        font-size: 9pt; color: #444; margin-bottom: 8mm;
        text-align: center;                  /* 发布日期/作者居中 */
        border-bottom: 0.5pt solid #ccc; padding-bottom: 3mm;
    }
    .jart-p-body {
        line-height: 1.6;                    /* 与屏幕端正文行高一致 */
        letter-spacing: .13em;               /* 与屏幕端字间距一致 */
        text-align: justify;                 /* 两端对齐 */
    }
    .jart-p-body p {
        text-indent: 2em;                    /* 与屏幕端首行缩进一致 */
        margin: 0 0 .6em 0;
        orphans: 3; widows: 3;
    }
    .jart-p-body img {
        max-width: 100% !important; height: auto !important;
        max-height: 210mm; object-fit: contain;
        page-break-inside: avoid; break-inside: avoid;
    }
    .jart-p-body figure { page-break-inside: avoid; margin: 5mm 0; }
    .jart-p-body figcaption { font-size: 9pt; color: #555; text-align: center; margin-top: 2mm; }
    .jart-p-body h2, .jart-p-body h3, .jart-p-body h4 {
        font-size: 13pt; margin: 7mm 0 3mm 0; page-break-after: avoid;
    }
    .jart-p-body table { width: 100%; border-collapse: collapse; page-break-inside: avoid; font-size: 9.5pt; }
    .jart-p-body th, .jart-p-body td { border: 0.5pt solid #999; padding: 1.5mm 2mm; text-align: left; }
    .jart-p-body pre, .jart-p-body blockquote { page-break-inside: avoid; border-left: 2pt solid #aaa; padding-left: 3mm; }
    .jart-p-body ul, .jart-p-body ol { page-break-inside: avoid; }
    .jart-p-body a { color: #000; text-decoration: none; }
    .jart-p-body a[href^="#"]:after { content: ""; }

    /* 图片并排：打印时保持浮动并排（与屏幕端 .pic-left-2/.pic-left-3 一致） */
    /* 图片并排：打印时覆盖屏幕端固定 px 宽度 */
    .jart-p-body .pic-left,
    .jart-p-body .pic-right {
        float: left !important;
        width: 46% !important;
        margin: 0 3% 4mm 0 !important;
        box-sizing: border-box;
        break-inside: avoid; page-break-inside: avoid;
    }
    .jart-p-body .pic-left-2 {
        float: left !important;
        width: 47% !important;            /* 2 图并排：每张约一半宽 */
        margin: 0 3% 4mm 0 !important;
        box-sizing: border-box;
        break-inside: avoid; page-break-inside: avoid;
    }
    .jart-p-body .pic-left-3 {
        float: left !important;
        width: 31% !important;            /* 3 图并排：每张约三分之一宽 */
        margin: 0 2% 4mm 0 !important;
        box-sizing: border-box;
        break-inside: avoid; page-break-inside: avoid;
    }


    /* 强制打印背景色/线条/红色装饰 */
    *, *::before, *::after {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
