/**
 * puzzle-print.css
 * Plugin Name: puzzle-print
 * 各パズルゲーム共通印刷プラグイン (スタイルシート)
 */

/* ==========================================================================
   1. 印刷選択モーダル
   ========================================================================== */
.puzzle-print-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  box-sizing: border-box;
  font-family: inherit;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ==========================================================================
   2. モーダルダイアログ
   ========================================================================== */
.puzzle-print-modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.55);
}

.puzzle-print-modal-dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 600px;
  max-height: calc(100vh - 32px);
  padding: 32px;
  box-sizing: border-box;
  border: 2px solid #222222;
  border-radius: 12px;
  background: #ffffff;
  color: #111111;
  font-family: inherit;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   3. モーダル内テキスト
   ========================================================================== */
.puzzle-print-modal-title {
  margin: 0;
  font-family: inherit;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.4;
  color: inherit;
  text-align: center;
}

.puzzle-print-modal-description {
  margin: 16px 0 24px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.7;
  text-align: center;
  white-space: pre-line;
}

/* ==========================================================================
   4. モーダル操作ボタン
   ========================================================================== */
.puzzle-print-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.puzzle-print-modal-button {
  appearance: none;
  width: 100%;
  min-height: 100px;
  padding: 12px 10px;
  box-sizing: border-box;
  border: 2px solid transparent;
  border-radius: 12px;
  font-family: inherit;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
}

.puzzle-print-modal-button-main,
.puzzle-print-modal-button-sub {
  display: block;
  font-family: inherit;
  color: inherit;
  text-align: center;
}

.puzzle-print-modal-button-main {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
}

.puzzle-print-modal-button-sub {
  width: 70%;
  margin: 6px auto 0;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.65);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.puzzle-print-modal-button-primary,
.puzzle-print-modal-button-problem {
  background-color: #1976d2;
  border-color: #1976d2;
  color: #ffffff;
}

.puzzle-print-modal-button-with-secondary,
.puzzle-print-modal-button-with-answer {
  background-color: #237c34;
  border-color: #237c34;
  color: #ffffff;
}

.puzzle-print-modal-button-cancel {
  background-color: #4b5563;
  border-color: #4b5563;
  color: #ffffff;
}

@media (hover: hover) {
  .puzzle-print-modal-button-primary:hover,
  .puzzle-print-modal-button-problem:hover {
    background-color: #125ea8;
    border-color: #125ea8;
  }

  .puzzle-print-modal-button-with-secondary:hover,
  .puzzle-print-modal-button-with-answer:hover {
    background-color: #1d662b;
    border-color: #1d662b;
  }

  .puzzle-print-modal-button-cancel:hover {
    background-color: #374151;
    border-color: #374151;
  }
}

.puzzle-print-modal-button:focus-visible {
  outline: 3px solid #111111;
  outline-offset: 3px;
}

.puzzle-print-modal-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* ==========================================================================
   5. エラー表示
   ========================================================================== */
.puzzle-print-modal-dialog.puzzle-print-error {
  border-width: 3px;
  border-style: solid;
  border-color: #222222;
}

/* ==========================================================================
   6. 共通印刷ルート
   ========================================================================== */
.puzzle-print-root {
  display: none;
}

/* ==========================================================================
   7. 印刷用共通ページ
   ========================================================================== */
.puzzle-print-root,
.puzzle-print-root * {
  box-sizing: border-box;
}

.puzzle-print-page {
  width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  color: #000000;
  break-after: page;
  page-break-after: always;
}

.puzzle-print-primary-page,
.puzzle-print-problem-page {
  background: #ffffff;
}

.puzzle-print-secondary-page,
.puzzle-print-answer-page {
  break-before: page;
  page-break-before: always;
}

.puzzle-print-page:last-child {
  break-after: auto;
  page-break-after: auto;
}

/* ==========================================================================
   8. 共通ヘッダー
   ========================================================================== */
.puzzle-print-header {
  margin: 0 0 6mm;
  padding: 0 0 4mm;
  border-bottom: 0.4mm solid #000000;
  break-inside: avoid;
  page-break-inside: avoid;
}

.puzzle-print-title {
  margin: 0;
  padding: 0;
  font-family: inherit;
  font-size: 18pt;
  font-weight: 700;
  line-height: 1.3;
  color: #000000;
  text-align: center;
}

.puzzle-print-header-details {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3mm 6mm;
  margin-top: 3mm;
}

.puzzle-print-page-label {
  margin: 0;
  padding: 0;
  font-family: inherit;
  font-size: 14pt;
  font-weight: 700;
  line-height: 1.3;
  color: #000000;
}

/* ==========================================================================
   9. メタ情報
   ========================================================================== */
.puzzle-print-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: baseline;
  gap: 2mm 5mm;
  margin: 0;
  padding: 0;
  font-family: inherit;
  font-size: 10pt;
  line-height: 1.4;
  color: #000000;
}

.puzzle-print-meta-item {
  display: flex;
  align-items: baseline;
  gap: 2mm;
  margin: 0;
  padding: 0;
  break-inside: avoid;
}

.puzzle-print-meta-label {
  margin: 0;
  padding: 0;
  font-weight: 600;
}

.puzzle-print-meta-value {
  margin: 0;
  padding: 0;
  font-weight: 400;
}

/* ==========================================================================
   10. 共通コンテンツ領域
   ========================================================================== */
.puzzle-print-content {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  break-inside: avoid;
  page-break-inside: avoid;
}

.puzzle-print-primary,
.puzzle-print-problem {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.puzzle-print-secondary,
.puzzle-print-answer {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ==========================================================================
   11. 印刷時スタイル
   ========================================================================== */
@media print {
  .puzzle-print-modal {
    display: none !important;
  }

  body.puzzle-print-active > *:not(.puzzle-print-root) {
    display: none !important;
  }

  body.puzzle-print-active > .puzzle-print-root {
    display: block !important;
    width: 100%;
    margin: 0;
    padding: 0;
    background: #ffffff;
    color: #000000;
  }

  body.puzzle-print-active {
    margin: 0;
    padding: 0;
    background: #ffffff;
    color: #000000;
  }
}

/* ==========================================================================
   12. モーダルの小画面調整
   ========================================================================== */
@media (max-width: 480px) {
  .puzzle-print-modal-dialog {
    padding: 20px;
  }

  .puzzle-print-modal-title {
    font-size: 24px;
  }

  .puzzle-print-modal-description {
    font-size: 16px;
  }

  .puzzle-print-modal-button {
    min-height: 80px;
    font-size: 22px;
  }

  .puzzle-print-modal-button-main {
    font-size: 22px;
  }

  .puzzle-print-modal-button-sub {
    margin-top: 5px;
    padding-top: 5px;
    font-size: 16px;
  }
}