/* ============================================================
 * Print · A4 横版导出 / 屏幕高分辨率 / 减少动效
 * ============================================================ */

@media print {
  @page {
    size: A4 landscape;
    margin: 16mm 16mm 18mm 16mm;
  }

  :root {
    --grid-margin:   0;
    --t-body:        11pt;
    --t-lead:        13pt;
    --t-caption:     9pt;
    --t-meta:        9pt;
    --t-data:        9pt;
    --t-micro:       8pt;
    --t-h3:          12pt;
    --t-h2:          18pt;
    --t-h1:          36pt;
    --t-display:     96pt;
  }

  html, body {
    background: white;
    color: black;
    font-family: var(--font-serif);
  }

  /* 隐藏交互组件 */
  .toc,
  .topbar,
  .fn-popup,
  .no-print,
  .chapter-nav {
    display: none !important;
  }

  .with-toc {
    padding-left: 0 !important;
  }

  .magazine {
    max-width: 100%;
    padding: 0;
  }

  /* 章节扉页强制分页 */
  .chapter-cover {
    page-break-after: always;
    page-break-inside: avoid;
    min-height: auto;
    height: 200mm;
  }

  /* block 内不分页 */
  .block,
  .pullquote,
  .takeaways,
  .chart,
  .itable-wrap,
  .svg-figure,
  .callout,
  .boxquote,
  .formula {
    page-break-inside: avoid;
  }

  .section-title,
  .block-title,
  .section-head {
    page-break-after: avoid;
  }

  /* 链接显式 URL */
  .body a[href]::after,
  .footnotes-list a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #666;
  }

  /* 不打印背景色（节省墨水），保留语义色 */
  .datacard,
  .datacard-header,
  .datacard-foot,
  .itable thead,
  .itable tbody tr.section-row td,
  .callout,
  .boxquote,
  .counters,
  .formula {
    background: white !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* 语义色保留 */
  .bignum-val,
  .cover-number,
  .conf,
  .red-press,
  .up,
  .down,
  .datacard-val--up,
  .datacard-val--down {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* SVG 矢量优化 */
  svg {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* 表格在打印时用细边框 */
  .itable {
    font-size: 9pt;
  }

  .itable tbody td,
  .itable thead th {
    height: auto;
    padding: 4px 8px;
  }
}

/* ============================================================
 * 屏幕高分辨率优化
 * ============================================================ */

@media (min-resolution: 2dppx) {
  body {
    -webkit-font-smoothing: antialiased;
  }
}

/* ============================================================
 * 减少动效 偏好
 * ============================================================ */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ============================================================
 * Forced colors 模式（高对比 / 屏读器）
 * ============================================================ */

@media (forced-colors: active) {
  .pullquote,
  .callout,
  .boxquote,
  .datacard,
  .itable-wrap {
    border: 1px solid CanvasText;
  }

  .bignum-val,
  .cover-number,
  .red-press {
    color: LinkText;
  }
}
