/* =========================================================
   フェニまるの選択式チャット案内（2026-09-25）
   ・画面右下の相談ボタン（自動では開かない）
   ・初回だけ出す小さな吹き出し（繰り返さない・点滅しない）
   ・スマホでは画面内に収め、中の案内をスクロールする
   ========================================================= */

.jchat {
  position: fixed;
  right: 12px;
  /* スマホは画面下の固定ボタン（.fixbar）の上に置いて重ならないようにする */
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 46;
}
/* 画面下の固定ボタンが無いページ（お問い合わせ）では下げる */
.jchat--nofixbar { bottom: calc(16px + env(safe-area-inset-bottom)); }

/* 案内を開いている間は、ヘッダー（z-index 50）より前に出す */
.jchat.is-open { z-index: 80; }

/* ---------- 起動ボタン ---------- */
.jchat__launch {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 52px;
  margin: 0;
  padding: 4px 14px 4px 6px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--orange, #f0651a);
  box-shadow: 0 6px 18px rgba(19, 41, 75, .28);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
  cursor: pointer;
}
.jchat__launch:hover { background: var(--orange-ink, #c2410c); }
.jchat__launch:focus-visible { outline: 3px solid var(--cta-navy, #1b3560); outline-offset: 3px; }
.jchat__launch-img {
  display: block;
  width: 42px;
  height: auto;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .18));
}
.jchat__launch-label { white-space: nowrap; }

/* ---------- 初回だけの吹き出し ---------- */
.jchat__hint {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  max-width: min(64vw, 260px);
  padding: 10px 8px 10px 12px;
  border: 2px solid var(--orange, #f0651a);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(19, 41, 75, .2);
}
/* 2026-11-15 追加。これが無いと display:flex が [hidden] に勝ってしまい、
   「最初の1回だけ」のはずの吹き出しが、ページを開いた瞬間からずっと出たままになる */
.jchat__hint[hidden] { display: none; }
.jchat__hint::after {
  content: "";
  position: absolute;
  right: 26px;
  bottom: -9px;
  width: 14px;
  height: 14px;
  border-right: 2px solid var(--orange, #f0651a);
  border-bottom: 2px solid var(--orange, #f0651a);
  background: #fff;
  transform: rotate(45deg);
}
.jchat__hint-text {
  margin: 0;
  color: var(--ink, #333);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}
.jchat__hint-close {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  margin: -2px -2px 0 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #f1efec;
  color: #555;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.jchat__hint-close:hover { background: #e3e0dc; }
.jchat__hint-close:focus-visible { outline: 3px solid var(--cta-navy, #1b3560); outline-offset: 2px; }

/* ---------- 案内の画面 ---------- */
.jchat__panel {
  position: fixed;
  right: 8px;
  left: 8px;
  bottom: 8px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  max-height: 82vh;
  max-height: 82svh;
  border: 3px solid var(--orange, #f0651a);
  border-radius: 18px;
  background: var(--cream2, #fff7ec);
  box-shadow: 0 14px 40px rgba(19, 41, 75, .3);
  overflow: hidden;
}
.jchat__panel[hidden] { display: none; }

.jchat__head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  background: var(--orange, #f0651a);
  color: #fff;
}
.jchat__avatar { width: 44px; height: 44px; border-radius: 50%; border: 2px solid #fff; background: #fff; object-fit: cover; }
.jchat__head-text { min-width: 0; }
.jchat__title { margin: 0; font-size: 16px; font-weight: 900; line-height: 1.3; }
.jchat__auto { margin: 2px 0 0; font-size: 11px; font-weight: 700; line-height: 1.3; opacity: .95; }
.jchat__close {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.jchat__close:hover { background: rgba(255, 255, 255, .3); }
.jchat__close:focus-visible, .jchat__nav:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.jchat__body { flex: 1 1 auto; padding: 14px 12px 4px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.jchat__body:focus { outline: none; }
.jchat__steps { display: flex; flex-direction: column; gap: 14px; }

/* お客様が選んだ内容 */
.jchat__picked {
  align-self: flex-end;
  max-width: 82%;
  margin: 0;
  padding: 8px 12px;
  border-radius: 14px 14px 2px 14px;
  background: var(--cta-navy, #1b3560);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

/* フェニまるの案内 */
.jchat__step { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; }
.jchat__step-img { width: 34px; height: 34px; border-radius: 50%; border: 2px solid #fff; background: #fff; box-shadow: 0 1px 4px rgba(19, 41, 75, .18); }
.jchat__bubble {
  margin: 0;
  padding: 12px 14px;
  border: 2px solid #f0e2cf;
  border-radius: 4px 16px 16px 16px;
  background: #fff;
  color: var(--ink, #333);
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-line;
}
.jchat__heading { margin: 0 0 6px; font-size: 15px; font-weight: 900; color: var(--key, #d9480f); }
.jchat__heading:focus { outline: none; }
.jchat__note {
  display: flex;
  gap: 6px;
  margin: 8px 0 0;
  padding: 9px 11px;
  border-radius: 10px;
  background: #fdf3e6;
  color: #6b4a2a;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

/* 料金 */
.jchat__prices { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.jchat__price { padding: 10px 12px; border: 2px solid #f0e2cf; border-radius: 12px; background: #fff; }
.jchat__price-name { display: block; font-size: 13px; font-weight: 700; color: #5c5c5c; }
.jchat__price-main { display: block; margin-top: 2px; color: var(--price, #c8161d); font-size: 20px; font-weight: 900; line-height: 1.2; }
.jchat__price--ask .jchat__price-main { font-size: 15px; }
.jchat__price-note { display: block; margin-top: 2px; font-size: 12px; font-weight: 700; color: #6b4a2a; }
.jchat__price-cond { margin: 6px 0 0; padding-left: 1.1em; font-size: 12px; line-height: 1.6; color: #5c5c5c; }
.jchat__price-lead { margin: 10px 0 0; font-size: 12px; line-height: 1.6; color: #5c5c5c; }

/* 選択肢 */
.jchat__choices { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.jchat__choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  padding: 11px 12px;
  border: 2px solid var(--orange, #f0651a);
  border-radius: 12px;
  background: #fff;
  color: var(--orange-ink, #c2410c);
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
}
.jchat__choice:hover { background: #fff3e8; }
.jchat__choice:focus-visible { outline: 3px solid var(--cta-navy, #1b3560); outline-offset: 2px; }
.jchat__choice::after { content: "›"; font-size: 20px; line-height: 1; }

/* 相談につながるボタン */
.jchat__actions { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.jchat__action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 12px;
  border: 2px solid var(--cta-navy, #1b3560);
  border-radius: 12px;
  background: #fff;
  color: var(--cta-navy, #1b3560);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.4;
  text-decoration: none;
}
.jchat__action:hover { background: #eef2f8; }
.jchat__action:focus-visible { outline: 3px solid var(--orange, #f0651a); outline-offset: 2px; }
.jchat__action b { display: block; }
.jchat__action small { display: block; margin-top: 2px; font-size: 12px; font-weight: 700; opacity: .85; }
.jchat__action::after { content: "›"; font-size: 20px; line-height: 1; }
.jchat__action--primary { border-color: var(--cta-navy, #1b3560); background: var(--cta-navy, #1b3560); color: #fff; }
.jchat__action--primary:hover { background: #142a4c; }
.jchat__action--line { border-color: #06c755; background: #06c755; color: #fff; }
.jchat__action--line:hover { background: #05a948; }
.jchat__action--tel { border-color: var(--orange, #f0651a); color: var(--orange-ink, #c2410c); }
.jchat__action--tel:hover { background: #fff3e8; }

/* 下の操作 */
.jchat__foot {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--orange, #f0651a);
}
.jchat__nav {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 8px 10px;
  border: 2px solid #fff;
  border-radius: 10px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.jchat__nav:hover { background: rgba(255, 255, 255, .28); }
.jchat__nav[hidden] { display: none; }

/* 案内を開いている間は、後ろの本文を動かさない */
body.jchat-open { overflow: hidden; }

.jchat__say { margin: 0; }
.jchat__say + .jchat__say { margin-top: 8px; }

/* 開いている間の背景（スマホ） */
.jchat__scrim {
  position: fixed;
  inset: 0;
  z-index: 69;
  background: rgba(19, 41, 75, .38);
  border: 0;
  padding: 0;
}

/* 画面の狭いスマホでは、本文を隠しすぎないよう少し小さく */
@media (max-width: 420px) {
  .jchat__launch { min-height: 48px; padding: 3px 12px 3px 5px; font-size: 13px; }
  .jchat__launch-img { width: 36px; }
  .jchat__hint { max-width: min(66vw, 230px); padding: 8px 6px 8px 10px; }
  .jchat__hint-text { font-size: 12.5px; }
}

/* ---------- パソコン ---------- */
@media (min-width: 1080px) {
  .jchat { right: 20px; bottom: 20px; }
  .jchat__launch { min-height: 60px; font-size: 15px; }
  .jchat__launch-img { width: 50px; }
  .jchat__hint { max-width: 280px; }
  .jchat__panel { left: auto; right: 20px; bottom: 20px; width: 392px; max-height: min(640px, 84vh); }
  .jchat__scrim { display: none; }
}

/* 画面が低いとき（横向きのスマホなど） */
@media (max-height: 520px) {
  .jchat__panel { max-height: 94svh; }
}

@media (prefers-reduced-motion: no-preference) {
  .jchat__panel { animation: jchat-in .18s ease-out; }
  .jchat__hint { animation: jchat-in .22s ease-out; }
  @keyframes jchat-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

/* 画面の撮影・印刷では出さない */
.is-shot .jchat { display: none; }
@media print { .jchat { display: none; } }
.jchat__loading { margin: 10px 2px; color: var(--muted, #666); font-size: 14px; }

/* ---------- 自動で開いたとき（画面いっぱい）2026-11-15 ----------
   ページを開いて数秒後に自動で開いたときだけ、案内を全画面にする。
   お客様が右下のボタンから自分で開いたときは、今までどおり小さいパネルのまま。 */
.jchat.is-auto .jchat__panel {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: auto;
  max-width: none;
  max-height: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.jchat.is-auto .jchat__head {
  padding: 12px 10px 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.jchat.is-auto .jchat__close { width: 44px; height: 44px; }
.jchat.is-auto .jchat__body { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.jchat.is-auto .jchat__launch,
.jchat.is-auto .jchat__hint { display: none; }

/* パソコンでは、文字が横に広がりすぎないよう中身だけ幅を抑えて中央に置く */
@media (min-width: 1080px) {
  .jchat.is-auto .jchat__steps,
  .jchat.is-auto .jchat__foot { max-width: 760px; margin-left: auto; margin-right: auto; width: 100%; }
  /* 見出しの帯は全幅のまま。中の文字だけ本文と同じ位置にそろえる */
  .jchat.is-auto .jchat__head { padding-left: max(14px, calc((100% - 760px) / 2)); padding-right: max(10px, calc((100% - 760px) / 2)); }
}
