/* ==========================================================================
   common-print.css
   --------------------------------------------------------------------------
   構造設計 WEB アプリ群の共通スタイル（アプリの画面を印刷するとき）
   準拠仕様: 00_共通仕様/specs/ui-spec.md §10

   計算書は本ファイルを参照しない。計算書のウィンドウは自己完結で、スタイルは
   詳細モードが common-report.js、省略モードが app-template.html の
   _briefReportStyles() に持つ（report-spec.md §15）。

   原本: 00_共通仕様/shared/common-print.css（本ファイル）
   配置: 各アプリは HTML と同じフォルダに本ファイルをコピーして置く。
   読込:
     <link rel="stylesheet" href="common-print.css">
     原本の更新はコピー先に自動反映されない。アプリの改修・リリース時に原本から
     再コピーすること。コピーの新旧は下の「最終更新」で判別する。
     本ファイルを1文字でも変更したら、必ず「最終更新」を更新すること
     （判別の拠り所がこの日付しかないため）。

   最終更新: 261106
     261106: 計算書用の定義を削除（.report-body / .report-cover / .report-toc /
            .report-section / .report-references / .brief-case / @page のフッタ /
            .report-footer-fallback）。いずれも計算書のウィンドウから参照されておらず、
            @page のフッタはアプリ画面の印刷に空の「 | 1 / 3」を出していた。
            用紙の余白を report-spec.md §12-2 の四辺 12mm に合わせた。
     260716: ヘッダコメントを同梱方式に更新（スタイル定義の変更なし）
     260520: 省略モード計算書の本体スタイルは計算書 HTML 内にインライン化したため、
            ここからは .cond-box / .calc-line / .calc-group-head を再削除。
            画面プレビュー用の .brief-case 系のみ残置。
     260519: 初版
   ========================================================================== */

/* ==========================================================================
   @media print: 印刷時の共通調整
   ui-spec.md §10
   ========================================================================== */
@media print {

  /* --- 用紙 --- */
  @page {
    size: A4 portrait;
    margin: 12mm;
  }
  @page landscape {
    size: A4 landscape;
    margin: 12mm;
  }

  /* --- 画面 UI を非表示 --- */
  .toolbar,
  .footer,
  .modal-bg,
  .no-print,
  details > summary {
    display: none !important;
  }

  /* --- 印刷時のみ表示要素 --- */
  .no-screen {
    display: block !important;
  }

  /* --- details は中身だけ表示 --- */
  details {
    display: block !important;
  }
  details > div,
  details > section,
  details > p,
  details > ul {
    display: block !important;
  }

  /* --- 背景・文字色 --- */
  body {
    background: #fff;
    color: #000;
    font-size: 10pt;
    line-height: 1.45;
  }

  /* --- アプリ用ラッパーの余白を削減 --- */
  .app-root {
    margin: 0;
  }

  /* --- パネル：枠線控えめ、影なし、ページ内分断回避 --- */
  .box, .panel, fieldset {
    background: #fff;
    border: 1px solid #888;
    box-shadow: none;
    break-inside: avoid;
  }

  /* --- 2ペインを縦並びに --- */
  .main {
    display: block;
  }
  .col-left, .col-right {
    flex: none;
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  /* --- 見出し --- */
  h1 {
    font-size: 16pt;
    border-bottom-width: 2pt;
  }
  h1 small {
    font-size: 0.6em;
  }
  h2 {
    font-size: 12pt;
    background: #1a3c5e;
    color: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    break-after: avoid;
  }
  h3 {
    font-size: 11pt;
    break-after: avoid;
  }
  h4 {
    font-size: 10pt;
    break-after: avoid;
  }

  /* --- 表 --- */
  table {
    font-size: 9pt;
    break-inside: auto;
  }
  table tr {
    break-inside: avoid;
  }
  table th {
    background: #e6e8f0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* --- 改ページ規則 --- */
  h1                                  { break-before: page; }
  h2                                  { break-after: avoid; }
  h3                                  { break-after: avoid; }
  .formula, .figure, .graph-box,
  .svg-box, .res-summary, .verdict   { break-inside: avoid; }

  /* --- カラー要素は色付きで印刷 --- */
  .pill, .verdict, .res-summary, .ok, .ng, h2 {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* --- 計算式枠 --- */
  .formula {
    background: #f0f2fa;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border-left-width: 2pt;
  }

  /* --- 詳細計算ログ：印刷時はスクロールせず全展開 --- */
  pre.clog {
    max-height: none;
    overflow: visible;
    font-size: 8pt;
    background: #f8f8f8;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* --- KaTeX 印刷時調整 --- */
  .katex {
    font-size: 0.85em !important;
  }
  .katex-display {
    margin: 3mm 0 !important;
    overflow: visible !important;
  }

  /* --- 入力フィールドは値だけ見せる（枠を消す） --- */
  input[type="text"], input[type="number"], select {
    border: none;
    background: transparent;
    padding: 0;
  }
  input[readonly] {
    background: transparent;
  }
}
