/*
 * chatbot.css - 右下チャットボット（分岐＋検索＋問い合わせ）Phase1
 *
 * 配置に関する注意（2026-09-04、本番スマホ実機スクショで確認）:
 * 本番に #back-to-top の固定ボタンは表示されていない（実機確認済み）ため、
 * 衝突回避のための高いオフセットは不要。ランチャーはPC bottom:24px / SP bottom:16px に設定。
 * z-index は引き続き控えめ（サイトヘッダーの100より下）にする。
 */

#hcm-chatbot-root {
  --hcm-chat-moss: #2b4a2f;
  --hcm-chat-moss-dark: #1e3522;
  --hcm-chat-clay: #b06a3b;
  --hcm-chat-paper: #f7f6f2;
  --hcm-chat-ink: #1f2419;
  --hcm-chat-line: #d9d6cd;
  --hcm-chat-muted: #4a5e4d;
  --hcm-map-active: #8fa8c8;
  --hcm-map-active-ink: #274058;

  position: fixed;
  right: 20px;
  bottom: 24px; /* 2026-09-04: #back-to-top非表示を実機確認、高いオフセット不要に */
  z-index: 90;  /* .site-header(100)より下、通常コンテンツより上 */
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  color: var(--hcm-chat-ink);
}

.hcm-chat-launcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  background: var(--hcm-chat-moss);
  color: #fff;
  padding: 12px 18px;
  min-height: 48px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  box-shadow: 0 10px 24px rgba(30, 53, 34, 0.28);
  cursor: pointer;
  max-width: 220px;
  text-align: left;
}

.hcm-chat-launcher:hover,
.hcm-chat-launcher:focus-visible {
  background: var(--hcm-chat-moss-dark);
}

.hcm-chat-launcher__icon {
  flex: none;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

/* SP専用の短縮ラベル。PCでは常に非表示（切替はCSSブレークポイントのみ、
   スクロール連動の縮小ギミックは入れない） */
.hcm-chat-launcher__text--short {
  display: none;
}

.hcm-chat-launcher.is-open {
  display: none;
}

.hcm-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 24px; /* 2026-09-04: ランチャーの新位置(bottom:24px)に合わせる */
  width: min(360px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 140px));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--hcm-chat-line);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(30, 53, 34, 0.24);
  overflow: hidden;
}

.hcm-chat-panel[hidden] {
  display: none !important;
}

/* Phase3: 背景写真選択時。半透明オーバーレイはJS側でinline linear-gradientとして
   background-imageに含めて設定する（--hcm-chat-paperを85%不透明で重ねる）。
   ヘッダー(.hcm-chat-panel__header)は独自のbackground(--hcm-chat-moss)で
   常に不透明なため、この背景写真の影響を受けず可読性は変わらない。 */
.hcm-chat-panel.has-bg-photo {
  background-repeat: no-repeat;
}

.hcm-chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  background: var(--hcm-chat-moss);
  color: #fff;
}

.hcm-chat-panel__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.hcm-chat-panel__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hcm-chat-icon-btn {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
}

.hcm-chat-icon-btn:hover,
.hcm-chat-icon-btn:focus-visible {
  background: rgba(255, 255, 255, 0.3);
}

.hcm-chat-icon-btn.is-active {
  background: rgba(255, 255, 255, 0.42);
}

/* Phase3: 背景写真ピッカー（ヘッダー直下のドロワー） */
.hcm-chat-bg-picker {
  padding: 12px 16px;
  border-bottom: 1px solid var(--hcm-chat-line);
  background: var(--hcm-chat-paper);
}

.hcm-chat-bg-picker[hidden] {
  display: none !important;
}

.hcm-chat-bg-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.hcm-chat-bg-thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  padding: 0;
  border-radius: 10px;
  border: 2px solid var(--hcm-chat-line);
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  min-height: 44px;
}

.hcm-chat-bg-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hcm-chat-bg-thumb--none {
  font-size: 12px;
  color: var(--hcm-chat-muted);
  background: var(--hcm-chat-paper);
}

.hcm-chat-bg-thumb:hover,
.hcm-chat-bg-thumb:focus-visible {
  border-color: var(--hcm-chat-clay);
}

.hcm-chat-bg-thumb.is-selected {
  border-color: var(--hcm-chat-clay);
  box-shadow: 0 0 0 2px rgba(176, 106, 59, 0.28);
}

.hcm-chat-panel__body {
  padding: 14px 16px 16px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.hcm-chat-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.hcm-chat-crumbs__label {
  font-size: 11px;
  color: var(--hcm-chat-muted);
  margin: 0 0 4px;
}

.hcm-chat-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--hcm-chat-paper);
  border: 1px solid var(--hcm-chat-line);
  font-size: 12px;
  color: var(--hcm-chat-ink);
}

.hcm-chat-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.hcm-chat-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--hcm-chat-line);
  background: #fff;
  color: var(--hcm-chat-ink);
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
}

.hcm-chat-option:hover,
.hcm-chat-option:focus-visible {
  border-color: var(--hcm-chat-clay);
  background: #fbf3ec;
}

.hcm-chat-option--muted {
  color: var(--hcm-chat-muted);
  font-size: 13px;
  border-style: dashed;
}

/* アクセシビリティ: 視覚的に隠すラベル用ユーティリティ（検索入力のlabelに使用） */
.hcm-chat-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 「3手目で文字を打ちたくなる」原則:
   2手目(第2階層)では入力欄を薄く・小さく表示するだけにとどめる */
.hcm-chat-search--dim {
  opacity: 0.62;
  transform: scale(0.98);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.hcm-chat-search--dim:focus-within {
  opacity: 1;
  transform: none;
}

/* 3手目: 入力欄を主役に（min-height 44px + 常時ごく薄い影） */
.hcm-chat-search--primary {
  opacity: 1;
}

.hcm-chat-search {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 4px;
}

.hcm-chat-search__field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.hcm-chat-search__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  color: var(--hcm-chat-muted);
  pointer-events: none;
}

.hcm-chat-search__input {
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px 8px 34px;
  border-radius: 12px;
  border: 1px solid var(--hcm-chat-line);
  background: #fff;
  color: var(--hcm-chat-ink);
  font-size: 14px;
}

.hcm-chat-search__input::placeholder {
  color: var(--hcm-chat-muted);
  opacity: 1;
}

.hcm-chat-search__input:focus-visible {
  outline: none;
  border-color: var(--hcm-chat-moss);
  box-shadow: 0 0 0 1px var(--hcm-chat-moss);
}

/* 3手目（主役化）は44pxの主要入力に + ごく薄い常時影。フォーカス時は影を保ったまま枠線をmossに */
.hcm-chat-search--primary .hcm-chat-search__input {
  min-height: 44px;
  box-shadow: 0 2px 6px rgba(31, 36, 25, 0.1);
}

.hcm-chat-search--primary .hcm-chat-search__input:focus-visible {
  border-color: var(--hcm-chat-moss);
  box-shadow: 0 2px 6px rgba(31, 36, 25, 0.1), 0 0 0 1px var(--hcm-chat-moss);
}

.hcm-chat-search__btn {
  flex: none;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 12px;
  border: none;
  background: var(--hcm-chat-clay);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.hcm-chat-search--primary .hcm-chat-search__btn {
  min-height: 44px;
}

.hcm-chat-search__btn:hover,
.hcm-chat-search__btn:focus-visible {
  filter: brightness(0.94);
}

/* 結果カード（検索結果・近い記事で共用）。区切りは細線、個々のボーダーボックスにはしない */
.hcm-chat-results {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--hcm-chat-line);
  border-radius: 12px;
  overflow: hidden;
}

.hcm-chat-results li + li {
  border-top: 1px solid var(--hcm-chat-line);
}

.hcm-chat-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  min-height: 44px;
  color: var(--hcm-chat-ink);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.4;
}

.hcm-chat-result:hover,
.hcm-chat-result:focus-visible {
  background: var(--hcm-chat-paper);
  outline: none;
}

.hcm-chat-result__title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hcm-chat-result__cat {
  flex: none;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 8px;
  border: 1px solid var(--hcm-chat-line);
  border-radius: 999px;
  background: var(--hcm-chat-paper);
  color: var(--hcm-chat-muted);
  font-size: 11px;
}

.hcm-chat-result__arrow {
  flex: none;
  display: inline-flex;
  color: var(--hcm-chat-muted);
}

/* 近い記事の見出し（小さなキャップ表記）。共通の.hcm-chat-crumbs__labelは
   パンくず（選んだ内容）用のため触らず、この節専用クラスとして独立させる */
.hcm-chat-near-label {
  margin: 0 0 4px;
  color: var(--hcm-chat-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hcm-chat-empty {
  margin: 12px 0 0;
  padding: 14px;
  border-radius: 10px;
  background: var(--hcm-chat-paper);
  text-align: left;
  font-size: 13px;
}

.hcm-chat-empty p {
  margin: 0 0 10px;
}

/* サイト内検索への誘導は控えめなテキストリンク（ボタン化しない） */
.hcm-chat-text-link {
  color: var(--hcm-chat-moss);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hcm-chat-text-link:hover,
.hcm-chat-text-link:focus-visible {
  color: var(--hcm-chat-moss-dark);
}

/* 「それでも見つからない」は控えめなゴーストボタン */
.hcm-chat-ghost-btn {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 4px;
  border: none;
  background: none;
  color: var(--hcm-chat-muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.hcm-chat-ghost-btn:hover,
.hcm-chat-ghost-btn:focus-visible {
  color: var(--hcm-chat-ink);
}

/* 問い合わせCTA（clay）。「それでも見つからない」を押した後にのみ表示される */
.hcm-chat-empty .hcm-chat-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--hcm-chat-clay);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

/* 地図（③借りられる場所） */
.hcm-chat-map {
  margin-top: 4px;
}

.hcm-chat-map__svg-wrap {
  width: 100%;
  aspect-ratio: 491.3 / 460;
  max-height: 320px;
}

.hcm-chat-map__svg-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.hcm-map-outline {
  fill: none;
  stroke: #9ca3af;
}

.hcm-map-region {
  fill: transparent;
  stroke: #9ca3af;
  stroke-width: 1;
  cursor: pointer;
  transition: fill 0.12s ease;
}

.hcm-map-region:hover,
.hcm-map-region:focus-visible {
  fill: rgba(143, 168, 200, 0.35);
  outline: none;
}

.hcm-map-region.is-active {
  fill: var(--hcm-map-active);
  stroke: var(--hcm-map-active-ink);
}

.hcm-map-region--disabled {
  cursor: default;
  fill: transparent;
}

.hcm-map-region--disabled:hover {
  fill: transparent;
}

.hcm-chat-map-pin {
  pointer-events: none;
}

.hcm-chat-map-pin__dot {
  fill: #fff;
  stroke: var(--hcm-chat-moss-dark);
  stroke-width: 1.6;
}

.hcm-chat-map-pin__line {
  stroke: var(--hcm-chat-moss-dark);
  stroke-width: 1.2;
}

/* SVGのユーザー単位はコンテナ幅で拡縮されるため、実画面サイズの目安はPC(パネル幅約320px)
   基準。SPはフルスクリーンでSVGの実描画幅が広がる分、ユーザー単位を落として釣り合わせる
   （下の @media 600px 以下のオーバーライドを参照）。 */
.hcm-chat-map-pin__label {
  font-size: 18px;
  fill: var(--hcm-chat-ink);
  font-family: "Hiragino Mincho ProN", "Noto Serif JP", serif;
}

.hcm-chat-map__legend {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--hcm-chat-muted);
}

.hcm-chat-map__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.hcm-chat-map__fallback {
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  background: var(--hcm-chat-paper);
  font-size: 13px;
}

.hcm-chat-map__fallback p {
  margin: 0 0 8px;
}

@media (max-width: 600px) {
  #hcm-chatbot-root {
    right: 12px;
    bottom: 16px; /* 2026-09-04: 本文への食い込みを避けるため引き下げ（実機スクショで確認） */
    /* フルスクリーン化したパネルが .site-header(z-index:100) の下に隠れないよう、
       このブレークポイントに限って#hcm-chatbot-root自体のスタッキングコンテキストを引き上げる。
       子要素(.hcm-chat-panel)側のz-indexだけを上げても、親のコンテキストの外へは出られないため。 */
    z-index: 150;
  }

  .hcm-chat-panel {
    position: fixed;
    inset: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-height: none;
    max-width: 100vw;
    border-radius: 0;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .hcm-chat-panel__body {
    overflow-x: hidden;
  }

  /* ボタン・タグの文言は折り返し可（横スクロールの原因にしない） */
  .hcm-chat-option,
  .hcm-chat-tag,
  .hcm-chat-crumbs {
    white-space: normal;
    word-break: break-word;
  }

  /* パネル表示中はランチャーを完全に隠す（.is-openで既にdisplay:noneだが、
     フルスクリーン化に伴い重なり得る位置関係も含めて明示しておく） */
  .hcm-chat-launcher.is-open {
    display: none;
  }

  .hcm-chat-launcher {
    max-width: none;
    padding: 10px 14px;
    font-size: 13px;
  }

  /* SPは横幅を抑えるため短縮ラベルに切り替える（表示のみ・ロジック不変） */
  .hcm-chat-launcher__text--full {
    display: none;
  }

  .hcm-chat-launcher__text--short {
    display: inline;
  }

  /* SPはフルスクリーンでSVGの実描画幅がPCパネルより広がるため、
     同じ見た目の文字サイズに近づけるようユーザー単位を落とす */
  .hcm-chat-map-pin__label {
    font-size: 12px;
  }

  /* 検索欄+ボタンが1行に収まらない場合は縦積み（PC/タブレットは強制しない） */
  .hcm-chat-search {
    flex-wrap: wrap;
  }

  .hcm-chat-search__field {
    flex: 1 1 160px;
    min-width: 140px;
  }

  .hcm-chat-search__btn {
    flex: 0 0 auto;
  }
}
