/* 印刷専用スタイル。index.htmlから media="print" でのみ読み込まれる。
   方針: ナビ・フィルターバー・ドッキングパネル・浮動ボタン等の操作用UIは全て非表示にし、
   本文（データ・チャート・テーブル）だけを白背景・黒文字で印刷する（余計な情報・背景を排除）。 */

@page {
  margin: 16mm 12mm;
}

* {
  box-shadow: none !important;
  text-shadow: none !important;
}

html, body {
  background: #fff !important;
  color: #000 !important;
  zoom: 1 !important; /* 設定の文字サイズ拡縮（--user-font-scale）は印刷に持ち込まない */
}

/* ---- ナビゲーション・フッター・浮動UI（操作専用、印刷不要） ---- */
#app-nav,
#app-footer,
#scroll-top-btn,
#print-btn,
#nav-drawer,
#nav-drawer-backdrop,
#settings-panel,
#settings-panel-backdrop,
#bs-root,
#consent-banner,
#shared-toast,
.filter-bar,
.map-filter-row,
#map-side-panel-close,
.panel-resize-handle,
.ranking-tab-bar,
.ranking-toc-wrap,
.ranking-detail-back-btn,
.maplibregl-control-container,
.nav-user-dropdown {
  display: none !important;
}

/* ---- 地図ページ: ドッキングパネル・凡例外の操作系は非表示、地図本体は残す ---- */
#boundary-panel, #hazard-panel, #historical-panel, #pro-panel, #locate-panel,
#boundary-panel-resize-handle, #hazard-panel-resize-handle,
#historical-panel-resize-handle, #pro-panel-resize-handle, #locate-panel-resize-handle {
  display: none !important;
}

/* ---- ページ内の操作用ボタン・フォーム部品は基本非表示（データ表示自体は残す） ---- */
button:not(.rank-badge),
select,
input[type="range"],
input[type="search"],
.sortable-th-sort-icon,
[data-fp-toggle] .fs-11px,
.drawer-accordion-chevron {
  display: none !important;
}

/* テーブルヘッダーのソート用ボタン等は上のbutton非表示ルールに巻き込まれるため、
   見出しテキスト自体は通常のth表示のまま維持されるよう明示しておく */
th, td { display: table-cell !important; }

/* ---- カード・パネルの装飾（背景色・角丸・影）を印刷では簡素化 ---- */
.card, .fp-wrap, .ranking-card-wrapper, .focus-card, [class*="bg-surface"], [class*="bg-bg-stripe"] {
  background: #fff !important;
  border: 1px solid #ccc !important;
}

/* ---- リンクの下線・色は残しつつ、装飾的な背景付きバッジ類は簡素化 ---- */
a { color: #000 !important; }

/* ---- 横スクロール前提のテーブル・グラフは印刷幅に収まるよう強制的に折り返す ---- */
.ranking-cards-container,
.analysis-layout {
  display: block !important;
  height: auto !important;
  overflow: visible !important;
}
table { width: 100% !important; }

/* ---- 地図ページ: #map-containerはdisplay:flexのまま（子の#map-viewportがflex:1で幅・高さを
   取っているため）、高さだけ印刷用の固定値に差し替える。上記と同じくheight:autoにすると、
   パーセント指定の子孫（#map-viewport）が0高さに潰れてcanvasが真っ白で印刷される不具合があった。 */
#map-container {
  height: 650px !important;
  overflow: visible !important;
}

/* ---- 印刷タイトル（表示中地域＋重ね合わせ中の指標名）。画面表示では常に非表示、
   印刷直前（各ビューのbeforeprintハンドラ）にのみ内容が入る ---- */
.print-only-title {
  display: none;
}
.print-only-title:not(:empty) {
  display: block !important;
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 10px;
}

/* ---- 地図キャンバス・チャートは高さ固定を維持しつつ改ページ時に分断されないようにする ---- */
#maplibre-map, canvas, [id$="-chart"], [id^="focus-"] {
  break-inside: avoid;
}
