/* ==========================================================================
   のし紙・表書き作成ツール 専用CSS
   すべてのセレクタは .noshi-maker-tool / .nm-lead / .nm-doc-section 以下に限定
   ========================================================================== */

/* 表書き・贈り主名を楷書体で表示するための埋め込みフォント（Yuji Syuku）。
   OFLライセンス（fonts/OFL-Yuji.txt）でWeb埋め込み・商用利用が許可されている
   ため、閲覧環境にフォントが入っていなくても同じ見た目で表示できる。
   ファイルサイズが大きい（約4MB）ため、このページを開いたときだけ読み込まれる */
@font-face {
  font-family: "Yuji Syuku";
  src: url("../fonts/YujiSyuku-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

.noshi-maker-tool {
  --nm-main: #295596;
  --nm-main-dark: #21467b;
  --nm-bg: #f5f7fa;
  --nm-border: #d9dee5;
  --nm-warn-bg: #fff7e6;
  --nm-warn-text: #8a5a00;
  --nm-btn-reset: #666666;
}

/* ---------------------------------------------------------------------- */
/* 導入文                                                                    */
/* ---------------------------------------------------------------------- */

.nm-lead-intro {
  font-size: 0.95rem;
  line-height: 1.8;
  color: #374151;
  margin: 0 0 10px;
}

.nm-lead-features {
  font-size: 0.9rem;
  line-height: 1.8;
  color: #374151;
  margin: 0 0 10px;
  padding-left: 1.3em;
}

.nm-lead-features li { margin-bottom: 4px; }

/* ---------------------------------------------------------------------- */
/* メッセージ・注意書き                                                       */
/* ---------------------------------------------------------------------- */

.noshi-maker-tool [hidden] { display: none !important; }

.nm-message {
  min-height: 1.2em;
  font-size: 0.9rem;
  padding: 0 2px;
  margin-bottom: 4px;
}

.nm-message.is-success { color: #1a7f37; font-weight: 600; }
.nm-message.is-error { color: #b91c1c; font-weight: 600; }

.nm-save-status {
  font-size: 0.8rem;
  color: #6b7280;
  margin: 0 0 12px;
}

.nm-hint {
  font-size: 0.8rem;
  color: #6b7280;
  margin: 4px 0 0;
  line-height: 1.6;
}

.nm-note-inline {
  font-size: 0.85rem;
  color: #4b5563;
  margin-top: 10px;
}

.nm-caution {
  font-size: 0.8rem;
  color: var(--nm-warn-text);
  background: var(--nm-warn-bg);
  border: 1px solid #f3d38a;
  border-radius: 6px;
  padding: 6px 10px;
  margin: 8px 0 0;
  line-height: 1.6;
}

.nm-caution-box {
  background: var(--nm-warn-bg);
  border: 1px solid #f3d38a;
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 10px;
}

.nm-caution-lead {
  font-size: 0.82rem;
  color: var(--nm-warn-text);
  font-weight: 700;
  margin: 0 0 6px;
}

.nm-caution-list {
  margin: 0;
  padding-left: 1.2em;
  font-size: 0.8rem;
  color: var(--nm-warn-text);
  line-height: 1.7;
}

.nm-advice-text {
  font-size: 0.88rem;
  color: #374151;
  line-height: 1.7;
  margin: 0;
}

/* ---------------------------------------------------------------------- */
/* プレビューへスクロール（モバイル用）                                          */
/* ---------------------------------------------------------------------- */

.nm-scroll-preview-btn {
  display: none;
  margin: 0 0 14px;
}

@media (max-width: 1023px) {
  .nm-scroll-preview-btn { display: inline-flex; }
}

/* ---------------------------------------------------------------------- */
/* 操作ボタン                                                                */
/* ---------------------------------------------------------------------- */

.noshi-maker-tool button.nm-btn {
  font: inherit;
  cursor: pointer;
  background: #f3f4f6;
  color: #1f2937;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.noshi-maker-tool button.nm-btn:hover { background: #e5e7eb; }

.noshi-maker-tool button.nm-btn:focus-visible {
  outline: 2px solid var(--nm-main);
  outline-offset: 2px;
}

.noshi-maker-tool button.nm-btn-primary {
  background: var(--nm-main);
  border-color: var(--nm-main-dark);
  color: #fff;
}

.noshi-maker-tool button.nm-btn-primary:hover { background: var(--nm-main-dark); }

.noshi-maker-tool button.nm-btn-reset {
  background: #fff;
  border-color: var(--nm-btn-reset);
  color: var(--nm-btn-reset);
}

.noshi-maker-tool button.nm-btn-reset:hover { background: #f3f4f6; }

.nm-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.nm-btn-group .nm-btn { flex: 1 1 auto; min-width: 150px; }

@media (max-width: 640px) {
  .nm-btn-group { flex-direction: column; }
  .nm-btn-group .nm-btn { width: 100%; }
}

/* ---------------------------------------------------------------------- */
/* レイアウト（PC 2カラム／モバイル 縦並び）                                    */
/* ---------------------------------------------------------------------- */

.nm-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  margin-top: 6px;
  align-items: start;
}

.nm-panel {
  background: #fff;
  border: 1px solid var(--nm-border);
  border-radius: 10px;
  padding: 18px 18px 20px;
  margin-bottom: 20px;
}

.nm-panel:last-child { margin-bottom: 0; }

.nm-panel h2 {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 0 0 14px;
  color: #111827;
}

@media (min-width: 1024px) {
  .nm-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
  }

  .nm-preview-column {
    position: sticky;
    top: 16px;
    align-self: start;
  }
}

/* ---------------------------------------------------------------------- */
/* フォーム部品共通                                                          */
/* ---------------------------------------------------------------------- */

.nm-field {
  margin-bottom: 14px;
}

.nm-field:last-child { margin-bottom: 0; }

.noshi-maker-tool label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}

.noshi-maker-tool fieldset.nm-field {
  border: none;
  padding: 0;
  margin: 0 0 16px;
}

.noshi-maker-tool fieldset.nm-field legend {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
  padding: 0;
}

.noshi-maker-tool input[type="text"],
.noshi-maker-tool input[type="number"],
.noshi-maker-tool select {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.9rem;
  padding: 9px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #111827;
}

.noshi-maker-tool input[type="number"] { max-width: 100px; }

.noshi-maker-tool input:focus-visible,
.noshi-maker-tool select:focus-visible,
.noshi-maker-tool button:focus-visible,
.noshi-maker-tool input[type="radio"]:focus-visible,
.noshi-maker-tool input[type="checkbox"]:focus-visible,
.noshi-maker-tool input[type="range"]:focus-visible {
  outline: 2px solid var(--nm-main);
  outline-offset: 2px;
}

.nm-radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
}

.nm-radio-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 0.88rem;
  color: #1f2937;
  margin: 0;
}

.noshi-maker-tool .nm-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.88rem;
  color: #1f2937;
  margin: 0;
}

.noshi-maker-tool input[type="radio"],
.noshi-maker-tool input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--nm-main);
  flex: none;
}

.noshi-maker-tool input[type="range"] {
  width: 100%;
  accent-color: var(--nm-main);
  display: block;
  margin-bottom: 6px;
}

.nm-name-input-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

/* ---------------------------------------------------------------------- */
/* 選択カード（水引の結び方）                                                  */
/* ---------------------------------------------------------------------- */

.nm-choice-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.nm-choice-card {
  display: block;
  position: relative;
  border: 2px solid var(--nm-border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.nm-choice-card input[type="radio"] {
  position: absolute;
  top: 12px;
  right: 12px;
  margin: 0;
}

.nm-choice-card:has(input:checked) {
  border-color: var(--nm-main);
  background: var(--nm-bg);
}

.nm-choice-card:has(input:focus-visible) {
  outline: 2px solid var(--nm-main);
  outline-offset: 2px;
}

.nm-choice-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 24px;
}

.nm-choice-card-title {
  font-weight: 700;
  font-size: 0.98rem;
  color: #111827;
}

.nm-choice-card-desc {
  font-size: 0.78rem;
  color: #6b7280;
  line-height: 1.5;
}

/* ---------------------------------------------------------------------- */
/* 印刷位置調整                                                              */
/* ---------------------------------------------------------------------- */

.nm-adjust-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 18px;
}

/* ---------------------------------------------------------------------- */
/* プレビュー領域                                                            */
/* ---------------------------------------------------------------------- */

.nm-preview-panel { background: var(--nm-bg); }

.nm-printer-note {
  font-size: 0.78rem;
  color: #6b7280;
  margin: 0 0 10px;
  line-height: 1.6;
}

.nm-paper-scale-wrap {
  overflow: auto;
  padding: 4px 0 6px;
}

.nm-paper-stage {
  position: relative;
}

.nm-paper {
  position: absolute;
  top: 0;
  left: 0;
  background: #fff;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.15);
  transform-origin: top left;
  overflow: hidden;
  font-family: "Yuji Syuku", "HG行書体", "HGP行書体", "游明朝", "Yu Mincho", "ヒラギノ明朝 ProN", "Hiragino Mincho ProN", "MS Pゴシック", serif;
}

.nm-paper[data-size="a4"] { width: 297mm; height: 210mm; }
.nm-paper[data-size="b5"] { width: 257mm; height: 182mm; }

/* ---------------------------------------------------------------------- */
/* のし飾り                                                                  */
/* ---------------------------------------------------------------------- */

/* 水引(.nm-mizuhiki)を基準に配置する。水引の右側の輪の少し上にくるよう、
   右端からのオフセットで位置を合わせている */
.nm-noshi-kazari {
  position: absolute;
  bottom: 100%;
  right: calc(29.64% + 7.5mm);
  margin-bottom: 3mm;
  width: 29.25mm;
  z-index: 3;
  transform: translateY(11.25mm);
}

/* 結び切りは輪の形が違う（先が上に広がる）ため、飾りの位置を蝶結びより
   1個分上・半個分左にずらして、結び目の空きに収まるようにしている */
.nm-mizuhiki[data-type="musubikiri"] .nm-noshi-kazari {
  right: calc(29.64% + 15mm);
  transform: translateY(0mm);
}

.nm-noshi-kazari-svg {
  width: 100%;
  height: auto;
  display: block;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}


/* ---------------------------------------------------------------------- */
/* のし紙本体（表書き・水引・贈り主名）                                          */
/* ---------------------------------------------------------------------- */

.nm-noshi-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6mm;
  transform: translate(var(--nm-pos-x, 0mm), var(--nm-pos-y, 0mm)) scale(var(--nm-pos-scale, 1));
}

.nm-omotegaki {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.18em;
  color: #1a1a1a;
  line-height: 1.1;
  min-height: 1em;
  /* flexアイテムとして高さが縮められると、縦書きテキストが折り返されて
     複数列になってしまうため、内容サイズを維持する */
  flex: none;
  /* のし飾りの有無・水引の色（紅白／黒白）によらず表書きの位置を揃えるため、
     常に同じ量だけ下げる（1em = 文字1個分） */
  transform: translateY(calc(20mm + 1.5em));
}

/* 「志」のような1文字の表書きは、下げ幅が同じだと相対的に低く見えすぎるため、
   文字1個分（1em）上に戻す */
.nm-omotegaki.nm-omotegaki--single {
  transform: translateY(calc(20mm + 1em));
}

/* フォントサイズは文字数に応じてJSがインラインstyleで指定する（はみ出し防止のため） */

/* ---------------------------------------------------------------------- */
/* 水引（SVG）                                                               */
/* ---------------------------------------------------------------------- */

.nm-mizuhiki {
  position: relative;
  width: 96.25%;
  flex: none;
  /* のし飾りの有無によらず表書きとの間隔を揃えるため、常に同じ余白を確保する */
  margin-top: 22mm;
}

.nm-mizuhiki-svg {
  width: 100%;
  height: auto;
  display: block;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.nm-mizuhiki-svg path,
.nm-mizuhiki-svg line,
.nm-mizuhiki-svg ellipse { stroke-linecap: round; }

.nm-mizuhiki[data-color="red"] { --nm-strand-a: #d93a43; }
.nm-mizuhiki[data-color="black"] { --nm-strand-a: #33363c; }

/* 8本の細い線が束になって見えるのが元デザインの持ち味なので、線を太くしすぎて
   隣の線とくっつけない（間隔より太さが大きくなると、8本の束ではなく
   1本の塗りつぶしに見えてしまう） */
.nm-strand-a, .nm-loop-a, .nm-tail-a, .nm-ring-a {
  fill: none;
  stroke: var(--nm-strand-a);
  stroke-width: 4;
}

.nm-strand-b, .nm-loop-b, .nm-tail-b, .nm-ring-b {
  fill: none;
  stroke: #bdb7b1;
  stroke-width: 4;
}

.nm-knot-mask { pointer-events: none; }

.nm-knot { display: none; }
.nm-mizuhiki[data-type="chomusubi"] .nm-knot-chomusubi { display: block; }
.nm-mizuhiki[data-type="musubikiri"] .nm-knot-musubikiri { display: block; }

.nm-wrap {
  fill: #f8f7f5;
  stroke: #c7c2bc;
  stroke-width: 4;
}

.nm-wrap-stripe {
  fill: none;
  stroke: #bdb7b1;
  stroke-width: 4;
}

/* ---------------------------------------------------------------------- */
/* 贈り主名                                                                  */
/* ---------------------------------------------------------------------- */

.nm-names {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 5mm;
  color: #1a1a1a;
  flex: none;
  max-width: 100%;
}

.nm-names[data-layout="yokonarabi"] { flex-direction: row; justify-content: center; gap: 6mm; }
.nm-names[data-layout="kintou"] { flex-direction: row; justify-content: space-evenly; width: 62%; max-width: 190mm; }
.nm-names[data-layout="migikara"] { flex-direction: row-reverse; justify-content: center; gap: 4mm; }
.nm-names[data-layout="hidarikara"] { flex-direction: row; justify-content: center; gap: 4mm; }
.nm-names[data-layout="chuo"] { flex-direction: row; justify-content: center; align-items: center; gap: 5mm; }

.nm-name-col {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.1em;
  line-height: 1.15;
  white-space: nowrap;
  flex: none;
}

.nm-names[data-layout="company"] { flex-direction: row-reverse; justify-content: center; align-items: center; gap: 4mm; }

.nm-company-name {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.1em;
  line-height: 1.1;
  flex: none;
}

.nm-company-sub {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.08em;
  line-height: 1.2;
  color: #333;
  flex: none;
}

.nm-company-person {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.1em;
  line-height: 1.1;
  flex: none;
}

.nm-upright {
  text-orientation: upright;
}

/* ---------------------------------------------------------------------- */
/* ドキュメントセクション（使い方・FAQなど）                                    */
/* ---------------------------------------------------------------------- */

.nm-doc-section { margin-top: 40px; margin-bottom: 40px; }

.nm-doc-section h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 40px 0 14px;
  color: #111827;
  border-left: 4px solid var(--nm-main, #295596);
  padding-left: 10px;
}

.nm-doc-section h2:first-of-type { margin-top: 0; }

.nm-doc-section p,
.nm-doc-section li {
  font-size: 0.92rem;
  line-height: 1.85;
  color: #374151;
}

.nm-doc-section ul { padding-left: 1.3em; }

.nm-steps {
  list-style: none;
  counter-reset: nm-step;
  padding: 0;
  margin: 0;
}

.nm-steps li {
  position: relative;
  padding: 10px 0 14px 34px;
  border-bottom: 1px solid #f3f4f6;
}

.nm-steps li:last-child { border-bottom: none; }

.nm-steps li::before {
  counter-increment: nm-step;
  content: counter(nm-step);
  position: absolute;
  left: 0;
  top: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #295596;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nm-doc-box {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 18px;
}

.nm-doc-box p:last-child { margin-bottom: 0; }

.nm-faq-item {
  border-bottom: 1px solid #f3f4f6;
  padding: 12px 0;
}

.nm-faq-item h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #295596;
  margin: 0 0 6px;
}

.nm-faq-item h3::before { content: "Q. "; }

.nm-faq-item p { margin: 0; }
.nm-faq-item p::before { content: "A. "; font-weight: 700; color: #6b7280; }

/* 関連リンク */
ul.related-links {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
ul.related-links li a {
  display: block;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 14px;
  color: #1d4ed8;
  text-decoration: none;
  font-size: 0.875rem;
  background: #fff;
}
ul.related-links li a:hover { background: #eff6ff; }

/* ---------------------------------------------------------------------- */
/* モバイル調整                                                              */
/* ---------------------------------------------------------------------- */

@media (max-width: 640px) {
  .nm-panel { padding: 14px 14px 16px; }
  .nm-mizuhiki { width: 80%; }
  .nm-names[data-layout="kintou"] { width: 80%; }
}

/* ---------------------------------------------------------------------- */
/* 印刷用スタイル                                                            */
/* ---------------------------------------------------------------------- */

/* 印刷専用の入れ物。画面上は常に非表示。印刷直前にJSがのし紙要素をこの中へ
   実際に移動し、印刷時は body 直下の「この入れ物以外すべて」を問答無用で
   非表示にする */
.nm-print-root {
  display: none;
}

@media print {

  body > *:not(.nm-print-root) {
    display: none !important;
  }

  html, body {
    background: #fff;
    margin: 0;
    padding: 0;
  }

  .nm-print-root {
    display: block !important;
    margin: 0;
    padding: 0;
  }

  .nm-print-root .nm-paper {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    box-shadow: none !important;
    overflow: hidden;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  * {
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
  }
}
