/* ============================================================
   monocosmelab 香りコンシェルジュ ヒーローセクション
   トップページ最上部に固定表示するインライン型チャットUI
   ============================================================ */

/* --- CSS カスタムプロパティ（mch- プレフィックスで衝突防止） --- */
#monocosme-hero {
  --mch-primary: #c4917b;
  --mch-primary-light: #FEF5EE;
  --mch-primary-dark: #a0725e;
  --mch-accent: #c2956b;
  --mch-bg: #fdfbf9;
  --mch-bg-card: #ffffff;
  --mch-text: #3d3333;
  --mch-text-light: #8a7a7a;
  --mch-text-inverse: #ffffff;
  --mch-border: #e8ddd6;
  --mch-radius: 12px;
  --mch-radius-sm: 8px;
  --mch-font: "Noto Sans JP", "Hiragino Sans", sans-serif;
  --mch-font-serif: "Noto Serif JP", "Yu Mincho", "游明朝", serif;
  --mch-font-display: "Montserrat", "Lato", sans-serif;

  font-family: var(--mch-font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--mch-text);
  box-sizing: border-box;
}
#monocosme-hero *, #monocosme-hero *::before, #monocosme-hero *::after {
  box-sizing: border-box;
  margin: 0;
}

/* --- ヘッダー（キャッチコピー）は SEO 目的で WordPress 側に移設したため CSS も削除 --- */

/* --- コンテナ --- */
.mch-container {
  display: grid;
  grid-template-columns: 380px 1fr; /* 左コンシェルジュをやや広く、右チャットをやや狭く */
  width: 100%;
  min-height: 500px;
  background: var(--mch-bg);
}

/* --- フッター: ボトムの余白帯（タグライン文は WordPress 側に移設） ---
   背景をサイト背景色（#FEF5EE = --mch-primary-light）に合わせ、上ボーダーも外して
   ウィジェット下端をページにシームレスに溶け込ませる（スッキリ見せる）。 */
.mch-footer-bar {
  padding: 14px 28px;
  background: var(--mch-primary-light);
}

/* ============================================================
   左カラム: コンシェルジュ（人物画像 + 吹き出し）
   ============================================================ */
.mch-concierge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: linear-gradient(180deg, var(--mch-primary-light) 0%, #fff8f3 100%);
  padding: 24px 24px 20px;
  position: relative;
  overflow: hidden;
}

.mch-avatar-wrap {
  flex-shrink: 0;
}

.mch-avatar {
  width: 220px;
  max-width: 100%;
  height: auto;
  display: block;
  transition: opacity 0.7s ease; /* ゆったりとしたフェード */
}
.mch-avatar.fade-out {
  opacity: 0;
}

/* --- 吹き出し --- */
.mch-speech-bubble {
  position: relative;
  background: var(--mch-bg-card);
  border: 2px solid var(--mch-primary);
  border-radius: 16px;
  padding: 18px 22px;
  margin-top: 14px;
  width: 100%;
  max-width: 345px; /* 広げた左カラムに合わせて吹き出しもやや広く */
  font-size: 14px;  /* セリフをやや大きく（PC/モバイル共通の基準値） */
  line-height: 1.8;
  color: var(--mch-text);
  min-height: 60px;
  max-height: 230px;
  overflow-y: auto;
}

.mch-speech-bubble::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--mch-primary);
}
.mch-speech-bubble::after {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--mch-bg-card);
}

.mch-speech-text {
  display: inline;
  white-space: pre-wrap;
}

/* --- 次のセリフ プログレスバー --- */
.mch-progress-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.mch-progress-wrap.visible {
  opacity: 1;
}
.mch-progress-bar {
  flex: 1;
  height: 3px;
  background: #ffffff;
  border-radius: 2px;
  overflow: hidden;
}
.mch-progress-fill {
  height: 100%;
  width: 100%;
  background: var(--mch-border);
  border-radius: 2px;
  transform-origin: left;
  transform: scaleX(1);
}
.mch-progress-fill.running {
  animation: mch-progress-shrink 10s linear forwards;
}
@keyframes mch-progress-shrink {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}
.mch-progress-next {
  font-size: 10px;
  color: var(--mch-border);
  font-weight: 700;
  letter-spacing: -1px;
  flex-shrink: 0;
  line-height: 1;
}
.mch-speech-link {
  color: var(--mch-primary-dark);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px dotted var(--mch-primary);
  transition: color 0.15s, border-color 0.15s;
}
.mch-speech-link:hover {
  color: var(--mch-primary);
  border-bottom-style: solid;
}

/* カーソル点滅 */
.mch-cursor {
  display: inline-block;
  color: var(--mch-primary);
  font-weight: 700;
  animation: mch-blink 0.6s step-end infinite;
}
.mch-cursor.hidden {
  display: none;
}

@keyframes mch-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ============================================================
   右カラム: チャットエリア
   ============================================================ */
.mch-chat {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--mch-border);
  background: var(--mch-bg);
  overflow: hidden;
  min-height: 0;
}

/* --- チップス（チャット入力欄のすぐ上に配置） --- */
.mch-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 24px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.mch-chips.visible {
  opacity: 1;
}

.mch-chip {
  font-family: var(--mch-font);
  font-size: 12.5px;
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--mch-bg-card);
  border: 1px solid var(--mch-border);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  color: var(--mch-text);
}
.mch-chip:hover {
  background: var(--mch-primary-light);
  border-color: var(--mch-primary);
}

/* --- インラインチップ（メッセージエリア内に表示） --- */
.mch-inline-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: 44px;
  max-width: calc(100% - 44px);
  animation: mch-fadeIn 0.25s ease;
  padding: 4px 0;
}

/* --- チップナビゲーション（パンくず + 戻るボタン） --- */
.mch-chip-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.mch-chip-back {
  font-family: var(--mch-font);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 14px;
  background: transparent;
  border: 1px solid var(--mch-text-light);
  color: var(--mch-text-light);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.mch-chip-back:hover {
  color: var(--mch-text);
  border-color: var(--mch-text);
}
.mch-chip-tag {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--mch-primary-light);
  color: var(--mch-primary-dark);
  border: 1px solid var(--mch-primary);
  white-space: nowrap;
}

/* --- リセットボタン --- */
.mch-chip-reset {
  border-style: dashed;
}

/* --- チャット継続ヒント --- */
.mch-chip-hint {
  width: 100%;
  font-size: 12px;
  color: var(--mch-text-light);
  padding: 2px 0;
  line-height: 1.5;
}

/* --- メッセージエリア --- */
.mch-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  max-height: 390px;
}

/* Slack/Discord スタイル メッセージ */
.mch-msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 6px 0;
  animation: mch-fadeIn 0.2s ease;
}

@keyframes mch-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mch-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}
.mch-msg-avatar-user {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--mch-border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mch-msg-avatar-user svg {
  width: 18px;
  height: 18px;
  fill: var(--mch-text-light);
}
.mch-msg-content {
  flex: 1;
  min-width: 0;
}
.mch-msg-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}
.mch-msg-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--mch-text);
}
.mch-msg-badge {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 4px;
  background: linear-gradient(135deg, #c4917b, #a07090);
  color: var(--mch-text-inverse);
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.4;
}
.mch-msg-time {
  font-size: 11px;
  color: var(--mch-text-light);
}
.mch-msg-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--mch-text);
  word-break: break-word;
  white-space: pre-wrap;
}

/* メッセージエリアの初期テキスト */
.mch-messages-empty {
  text-align: center;
  color: var(--mch-text-light);
  font-size: 13px;
  padding: 24px;
}

/* --- ローディング --- */
.mch-msg-loading {
  animation: mch-fadeIn 0.2s ease;
}
.mch-loading {
  display: flex;
  gap: 5px;
  padding: 8px 0;
}
.mch-loading .dot {
  width: 8px;
  height: 8px;
  background: var(--mch-primary);
  border-radius: 50%;
  animation: mch-bounce 1.2s infinite;
}
.mch-loading .dot:nth-child(2) { animation-delay: 0.15s; }
.mch-loading .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes mch-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* --- 商品カード --- */
.mch-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  margin-left: 44px;
  max-width: calc(100% - 44px);
}
.mch-card {
  background: var(--mch-bg-card);
  border: 1px solid var(--mch-border);
  border-radius: var(--mch-radius-sm);
  padding: 16px;
  animation: mch-fadeIn 0.25s ease;
  transition: border-color 0.15s;
}
.mch-card:hover {
  border-color: var(--mch-primary);
}
.mch-card.primary {
  border-color: var(--mch-accent);
  border-width: 2px;
}
.mch-card-badge {
  display: inline-block;
  background: var(--mch-accent);
  color: var(--mch-text-inverse);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.mch-card-body {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.mch-card-thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--mch-border);
}
.mch-card-info {
  flex: 1;
  min-width: 0;
}
.mch-card-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.mch-card-reason {
  font-size: 12.5px;
  color: var(--mch-text-light);
  line-height: 1.6;
  margin-bottom: 8px;
}
.mch-card-link {
  display: inline-block;
  font-size: 12.5px;
  color: var(--mch-primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s;
}
.mch-card-link:hover {
  color: var(--mch-primary-dark);
  text-decoration: underline;
}

/* --- エラー --- */
.mch-error {
  align-self: center;
  font-size: 12px;
  color: #c0392b;
  background: #fdecea;
  padding: 10px 18px;
  border-radius: var(--mch-radius-sm);
  text-align: center;
}

/* --- 入力エリア --- */
.mch-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--mch-border);
  background: var(--mch-bg-card);
  flex-shrink: 0;
}

.mch-input {
  flex: 1;
  font-family: var(--mch-font);
  font-size: 14px;
  border: 1px solid var(--mch-border);
  border-radius: 20px;
  padding: 12px 18px;
  outline: none;
  transition: border-color 0.15s;
  background: var(--mch-bg);
  color: var(--mch-text);
}
.mch-input:focus {
  border-color: var(--mch-primary);
}
.mch-input::placeholder {
  color: var(--mch-text-light);
}

.mch-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--mch-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}
.mch-send:hover { background: var(--mch-primary-dark); }
.mch-send:disabled { opacity: 0.4; cursor: default; }
.mch-send svg {
  width: 18px;
  height: 18px;
  fill: var(--mch-text-inverse);
}

/* ============================================================
   モバイル（768px未満）
   ============================================================ */
@media (max-width: 767px) {
  .mch-container {
    display: flex;
    flex-direction: column;
    min-height: auto;
    max-height: none;
  }

  .mch-concierge {
    flex-direction: column;
    align-items: center;
    padding: 16px 20px;
    gap: 10px;
  }

  .mch-avatar-wrap {
    flex-shrink: 0;
  }

  .mch-avatar {
    width: 150px; /* モバイルのコンシェルジュ画像をさらに大きく */
  }

  .mch-speech-bubble {
    margin-top: 0;
    max-width: none;
    width: 100%;
    flex: none;
    height: 130px;
    max-height: 130px;
  }

  /* モバイルでは吹き出しの三角を上向き（人物の下を指す） */
  .mch-speech-bubble::before {
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: var(--mch-primary);
    border-right-color: transparent;
  }
  .mch-speech-bubble::after {
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: var(--mch-bg-card);
    border-right-color: transparent;
  }

  .mch-chat {
    border-left: none;
    border-top: 1px solid var(--mch-border);
  }

  .mch-messages {
    max-height: 300px;
    padding: 12px 16px;
  }

  /* モバイルではアバター分のインデントを縮小 */
  .mch-inline-chips,
  .mch-cards {
    margin-left: 0;
    max-width: 100%;
  }

  .mch-chip-nav {
    flex-wrap: wrap;
  }

  .mch-footer-bar {
    padding: 12px 16px;
  }
}
