/* =========================================================
   LINE風チャット お問い合わせモーダル — chat.css
   全ページ共通（index / turnip / retime）。CF7（フォームID 39）連携。
   「お問い合わせ」ボタン(.js-contact-open)で、押した場所（data-chat）の
   シナリオに応じたチャットがモーダルで再生され、最後にフォームが出る。
   見た目の正は price.html（LINE風トークLP）。DOMは chat.js が生成する。

   ・完全自己完結（色・フォントはこのファイル内に定義。styles.css 非依存）
   ・クラスは全て chm- プレフィックス（既存ページのクラスと衝突させない）
   ・スクロールロックは body.chm-open、z-index は 9000
   ・メディアクエリは 1000px → 820px の順（後勝ちで狭い画面が上書き）
   ========================================================= */

@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700;900&family=Shippori+Mincho:wght@700&display=swap");

/* box-sizing はモーダル配下だけに閉じる（ホスト側リセットに依存しない） */
.chm-modal,
.chm-modal *,
.chm-modal *::before,
.chm-modal *::after {
  box-sizing: border-box;
}

/* スクロールロック */
body.chm-open {
  overflow: hidden;
}

/* ===== モーダル（backdrop ＋ センタリング） ===== */
.chm-modal {
  --chm-talk-bg: #7494c0;
  --chm-header-bg: #283142;
  --chm-text: #1d2430;
  --chm-bubble-them: #fff;
  --chm-bubble-me: #8de055;
  --chm-meta: #dfe6f0;
  --chm-sender: #e8edf5;
  --chm-note: #7a828f;
  --chm-line-green: #06c755;
  --chm-card-border: #ecedf1;
  --chm-input-bg: #f1f2f6;
  --chm-input-text: #9aa2b1;
  --chm-input-icon: #8a94a6;
  --chm-avatar-bg: #e7decb;

  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px; /* 上下は余白なし＝ダイアログが全高を使う */
  overflow: hidden;
  font-family: "Noto Sans JP", system-ui, sans-serif;
  color: var(--chm-text);
}
.chm-modal[hidden] {
  display: none;
}

.chm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(29, 36, 48, 0.62);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/* ===== チャットダイアログ（上下いっぱいに使う） ===== */
.chm-phone {
  position: relative;
  z-index: 1;
  width: min(560px, 100vw - 32px);
  height: 100vh; /* フォールバック */
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--chm-talk-bg);
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(29, 36, 48, 0.45);
  animation: chm-in 0.24s ease;
}
@keyframes chm-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ===== トークヘッダー ===== */
.chm-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--chm-header-bg);
  color: #fff;
  padding: 13px 12px 13px 16px;
}
.chm-header__name {
  flex: 1;
  min-width: 0;
  font: 700 14px "Noto Sans JP", sans-serif;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chm-close {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  cursor: pointer;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  border-radius: 8px;
  opacity: 0.85;
}
.chm-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
}

/* ===== チャットエリア（スクロール領域） ===== */
.chm-chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

/* 日付チップ */
.chm-date-chip {
  align-self: center;
  background: rgba(29, 36, 48, 0.28);
  color: #fff;
  font: 500 10.5px "Noto Sans JP", sans-serif;
  padding: 4px 13px;
  border-radius: 999px;
}

/* --- 相手メッセージ行 --- */
.chm-msg--them {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.chm-avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--chm-avatar-bg);
  overflow: hidden;
}
.chm-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 12%;
  transform: scale(1.9);
  transform-origin: 50% 14%;
}
.chm-msg-body {
  max-width: 78%;
  min-width: 0;
}
.chm-sender {
  font: 500 10px "Noto Sans JP", sans-serif;
  color: var(--chm-sender);
  margin: 0 0 3px 2px;
}

/* 吹き出し行 */
.chm-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 5px;
}
.chm-bubble-row + .chm-bubble-row {
  margin-top: 6px;
}
.chm-bubble {
  font: 400 12.5px/1.75 "Noto Sans JP", sans-serif;
  padding: 9px 12px;
  border-radius: 14px;
  min-width: 0;
  word-break: auto-phrase;
  overflow-wrap: anywhere;
}
.chm-bubble b {
  font-weight: 700;
}
.chm-bubble--them {
  background: var(--chm-bubble-them);
  border-top-left-radius: 4px;
}
.chm-bubble--me {
  background: var(--chm-bubble-me);
  border-top-right-radius: 4px;
}
.chm-time {
  flex: none;
  font: 400 9px "Noto Sans JP", sans-serif;
  color: var(--chm-meta);
}

/* --- 自分メッセージ行 --- */
.chm-msg--me {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  align-items: flex-end;
}
.chm-msg--me .chm-bubble {
  max-width: 74%;
}
.chm-read {
  flex: none;
  font: 400 9px/1.5 "Noto Sans JP", sans-serif;
  color: var(--chm-meta);
  text-align: right;
}

/* --- 画像バブル（料金早見表を包む白フチ） --- */
.chm-image-bubble {
  background: #fff;
  border-radius: 14px;
  padding: 6px;
}

/* 料金早見表ミニグラフィック */
.chm-rate-card {
  width: 212px;
  border-radius: 10px;
  background: #eef2f8;
  color: var(--chm-text);
  padding: 11px 13px 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chm-rate-card__title {
  font: 700 10.5px "Noto Sans JP", sans-serif;
  letter-spacing: 0.06em;
  color: #41506a;
  padding-bottom: 5px;
  border-bottom: 1px solid #d5deec;
}
.chm-rate-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.chm-rate-row__label {
  font: 500 9.5px "Noto Sans JP", sans-serif;
  color: #2c3647;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chm-rate-row__price {
  flex: none;
  font: 900 12px "Noto Sans JP", sans-serif;
  color: #1d2430;
  white-space: nowrap;
}
.chm-rate-row__price small {
  font: 700 8px "Noto Sans JP", sans-serif;
}
.chm-rate-card__note {
  font: 400 8px "Noto Sans JP", sans-serif;
  color: var(--chm-note);
  text-align: right;
}

/* --- オファーカード（Flex Message風） --- */
.chm-offer {
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  width: 232px;
}
.chm-offer__top {
  padding: 13px 15px 10px;
}
.chm-offer__plan {
  font: 700 13px "Noto Sans JP", sans-serif;
}
.chm-offer__price {
  font: 900 24px "Noto Sans JP", sans-serif;
  line-height: 1.15;
  margin-top: 2px;
}
.chm-offer__unit {
  font: 700 12px "Noto Sans JP", sans-serif;
}
.chm-offer__unit--pre {
  margin-right: 1px;
}
.chm-offer__note {
  font: 400 10.5px/1.7 "Noto Sans JP", sans-serif;
  color: var(--chm-note);
  margin-top: 4px;
}

/* --- フォームカード（チャットに馴染むカード） --- */
/* フォーム行はバブルの幅制限（78%）を外して広く使う */
.chm-msg--form .chm-msg-body {
  flex: 1 1 auto;
  max-width: 100%;
}
.chm-formcard {
  background: #fff;
  border-radius: 14px;
  border-top-left-radius: 4px;
  padding: 18px 18px 20px;
  width: 100%;
}
.chm-formcard__title {
  font: 700 15px "Noto Sans JP", sans-serif;
  color: #2c3647;
  margin: 0 0 12px;
}
.chm-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.chm-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.chm-label {
  font: 700 12px "Noto Sans JP", sans-serif;
  color: #2c3647;
}
.chm-req {
  color: #c0392b;
  font-weight: 700;
  margin-left: 3px;
}
.chm-input {
  width: 100%;
  min-width: 0;
  font: 400 15px "Noto Sans JP", sans-serif;
  color: var(--chm-text);
  background: var(--chm-input-bg);
  border: 1px solid var(--chm-card-border);
  border-radius: 10px;
  padding: 12px 13px;
}
.chm-input:focus {
  outline: 2px solid var(--chm-line-green);
  outline-offset: 1px;
  background: #fff;
}
.chm-input:disabled {
  opacity: 0.6;
}
.chm-textarea {
  resize: vertical;
  min-height: 140px;
}
.chm-alert {
  font: 400 13px/1.6 "Noto Sans JP", sans-serif;
  border-radius: 10px;
  padding: 9px 11px;
}
.chm-alert[hidden] {
  display: none;
}
.chm-alert.is-ng {
  background: #fdecec;
  color: #b02a2a;
}
.chm-submit {
  margin-top: 2px;
  background: var(--chm-line-green);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 13px;
  font: 700 15px "Noto Sans JP", sans-serif;
  cursor: pointer;
}
.chm-submit:hover {
  opacity: 0.9;
}
.chm-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ===== 入力バー（装飾のみ・機能なし） ===== */
.chm-input-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  padding: 10px 14px;
}
.chm-input-bar__plus {
  font-size: 18px;
  color: var(--chm-input-icon);
}
.chm-input-bar__field {
  flex: 1;
  min-width: 0;
  background: var(--chm-input-bg);
  border-radius: 999px;
  padding: 8px 14px;
  font: 400 12px "Noto Sans JP", sans-serif;
  color: var(--chm-input-text);
}
.chm-input-bar__send {
  font-size: 15px;
  color: var(--chm-input-icon);
}

/* ===== タイピングインジケータ ===== */
.chm-typing {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.chm-typing__bubble {
  background: var(--chm-bubble-them);
  border-radius: 14px;
  border-top-left-radius: 4px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chm-typing__bubble span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b9c0cc;
  display: block;
  animation: chm-typing-blink 1.2s infinite ease-in-out;
}
.chm-typing__bubble span:nth-child(2) {
  animation-delay: 0.2s;
}
.chm-typing__bubble span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes chm-typing-blink {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* 出現アニメ（各メッセージ） */
.chm-msg,
.chm-typing {
  animation: chm-msg-in 0.26s ease-out both;
}
@keyframes chm-msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ===== タブレット（広い方を先に記述） ===== */
@media (max-width: 1000px) {
  .chm-phone {
    width: min(420px, 100vw - 24px);
  }
}

/* ===== スマホ（ほぼ全画面） ===== */
@media (max-width: 820px) {
  .chm-modal {
    padding: 0;
  }
  .chm-phone {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    border-radius: 0;
    box-shadow: none;
  }
  /* iOSのフォーカス時自動ズームを防ぐ（16px未満だとズームされる） */
  .chm-input {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chm-phone,
  .chm-msg,
  .chm-typing {
    animation: none;
  }
  .chm-typing__bubble span {
    animation: none;
  }
}
