/* 既刊全点FAX注文書 専用スタイルシート
 * - サイトの style.css とは独立。@page で A4 固定の帳票レイアウトとして使う。
 * - CSP でインライン <style> がブロックされる将来に備えて外部ファイル化。
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #ddd;
  color: #000;
  font-family: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Meiryo', sans-serif;
  font-size: 10pt;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

/* 印刷時に隠す案内文（画面でのみ表示） */
.print-instruction {
  max-width: 210mm;
  margin: 12px auto 0;
  padding: 0.5rem 1rem;
  font-size: 10pt;
  color: #c33;
  font-weight: bold;
}

.sheet {
  width: 210mm;
  height: 297mm;
  margin: 12px auto;
  padding: 12mm;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  /* 改ページ。最終ページは破線ルールで打ち消し */
  break-after: page;
  page-break-after: always;
}

.sheet:last-of-type {
  break-after: auto;
  page-break-after: auto;
}

.sheet-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ===== ヘッダー: 三段組 ===== */
.head {
  display: grid;
  grid-template-columns: 1fr auto 70mm;
  gap: 6mm;
  align-items: flex-start;
  margin-bottom: 2mm;
}

.publisher {
  line-height: 1.45;
}

.publisher-logo {
  display: block;
  width: 55mm;
  height: auto;
  margin-bottom: 1.5mm;
}

.publisher small {
  font-size: 8.5pt;
}

.publisher .contact-link {
  font-size: 8pt;
  margin-top: 0.5mm;
  color: #000;
  word-break: break-all;
}

.title-block {
  text-align: center;
  align-self: center;
}

.title-block .title {
  font-size: 18pt;
  font-weight: bold;
  letter-spacing: 0.3em;
  margin: 0;
}

.title-block .subtitle {
  margin: 1mm 0 0;
  font-size: 11pt;
  letter-spacing: 0.15em;
}

.title-block .page-no {
  margin: 1mm 0 0;
  font-size: 9pt;
  color: #333;
}

.issue-area {
  display: flex;
  justify-content: flex-end;
}

.stamp-row {
  display: flex;
  gap: 2mm;
  align-items: flex-end;
}

.stamp-box {
  border: 1px solid #000;
  position: relative;
}

.stamp-box::before {
  position: absolute;
  top: 0.8mm;
  left: 0.8mm;
  font-size: 7pt;
  color: #000;
}

.stamp-box--banshen {
  width: 42mm;
  height: 30mm;
}

.stamp-box--banshen::before {
  content: '貴店番線印';
  font-size: 8pt;
}

.stamp-box--tantou {
  width: 22mm;
  height: 24mm;
}

.stamp-box--tantou::before {
  content: 'ご担当者(印)';
  font-size: 6.5pt;
}

/* ===== ISBNプリフィクス表示・凡例 ===== */
.isbn-prefix-bar {
  margin: 2mm 0 2mm;
  padding: 1mm 3mm;
  font-size: 9pt;
  letter-spacing: 0.05em;
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 3mm;
}

.isbn-prefix-bar .legend {
  font-size: 8pt;
  letter-spacing: 0;
  color: #333;
}

/* ===== 書籍テーブル ===== */
table.books {
  width: 100%;
  border-collapse: collapse;
  font-size: 9pt;
}

table.books th,
table.books td {
  border: 0.4mm solid #000;
  padding: 1.2mm 1.5mm;
  vertical-align: middle;
}

/* 各行を2行分の高さで固定（書名が短くても長くても同じ高さに揃える） */
table.books tbody td {
  height: 11mm;
  line-height: 1.3;
}

/* 書名は2行以内に収める。3行目以降は省略表示。 */
table.books td.title .title-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  word-break: break-all;
}

/* 空行（書籍が15冊に満たない場合のプレースホルダ） */
table.books tbody tr.empty td {
  /* 内容は空。高さだけ確保する。 */
}

table.books thead th {
  background: #000;
  color: #fff;
  font-weight: bold;
  text-align: center;
  letter-spacing: 0.05em;
  padding: 1mm 1.5mm;
}

table.books td.title {
  text-align: left;
}

table.books td.isbn,
table.books th.isbn {
  text-align: center;
  font-family: 'Courier New', 'Hiragino Kaku Gothic ProN', monospace;
  white-space: nowrap;
  font-weight: bold;
  font-size: 10pt;
}

table.books td.price {
  text-align: right;
  font-weight: bold;
  font-size: 10pt;
}

table.books td.qty,
table.books td.stock {
  text-align: center;
}

table.books td.stock {
  font-size: 12pt;
  font-weight: bold;
}

table.books col.col-title {
  width: auto;
}
table.books col.col-isbn {
  width: 20mm;
}
table.books col.col-price {
  width: 16mm;
}
table.books col.col-stock {
  width: 14mm;
}
table.books col.col-qty {
  width: 16mm;
}

table.books tbody tr {
  page-break-inside: avoid;
}

/* ===== フッター: 必須記載事項と問い合わせ ===== */
.terms {
  margin-top: 3mm;
  padding: 2mm 3mm;
  border: 0.4mm solid #000;
  font-size: 9pt;
  line-height: 1.55;
}

.terms .terms-head {
  display: inline-block;
  background: #000;
  color: #fff;
  padding: 0.5mm 2mm;
  margin-right: 2mm;
  font-weight: bold;
  letter-spacing: 0.1em;
}

.terms ul {
  margin: 1mm 0 0;
  padding-left: 5mm;
}

.terms li {
  margin: 0;
}

.contact-line {
  margin-top: 3mm;
  text-align: center;
  font-size: 10pt;
  letter-spacing: 0.05em;
  line-height: 1.4;
}

.contact-line .label {
  font-weight: bold;
  margin-right: 1mm;
}

.contact-line .fax-primary {
  font-size: 20pt;
  font-weight: bold;
  letter-spacing: 0.15em;
  margin: 0 1mm;
  color: #000;
}

.contact-line .fax-primary-name {
  font-size: 11pt;
  font-weight: bold;
  margin-right: 1mm;
}

.contact-line .sep {
  display: inline-block;
  width: 2mm;
}

.contact-line .fax-secondary {
  font-size: 11pt;
  margin: 0 0.5mm;
}

.contact-line .fax-secondary-name {
  font-size: 9pt;
  color: #333;
}

.empty-message {
  text-align: center;
  padding: 8mm;
  font-size: 10pt;
  color: #666;
}

/* ===== 画面表示用 ===== */
@media screen {
  body {
    padding-bottom: 2rem;
  }
}

/* ===== 印刷: A4固定 ===== */
@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html,
  body {
    background: #fff;
  }

  .print-instruction {
    display: none;
  }

  .sheet {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    box-shadow: none;
    padding: 12mm;
  }
}
