/*
 * よくある質問ページの会話型チャット（assets/js/faq-chat.js が組み立てる部品）。
 * 本文に入っている旧チャットの指定より後から効くよう、.is-assistant を付けて詳しく指定する。
 * スマホでも14px未満の文字は使わない。
 */
.fw-faq-shell.is-assistant { width: min(420px, calc(100% - 40px)); }
.fw-faq-shell.is-assistant .fw-faq-chat {
  display: flex;
  flex-direction: column;
  height: min(640px, calc(100vh - 112px));
  height: min(640px, calc(100dvh - 112px));
  max-height: none;
  padding: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid #d9e3f2;
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(7, 26, 61, .22);
}

/* 上の帯 */
.fw-faq-shell.is-assistant .fw-faq-chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  margin: 0;
  padding: 14px 14px 14px 18px;
  border-bottom: 0;
  background: linear-gradient(135deg, #0758d6, #0a3f9e);
  color: #fff;
}
.fw-faq-shell.is-assistant .fw-faq-chat__avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff url("../img/logo_mark.webp") center / 70% no-repeat;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .35);
}
.fw-faq-shell.is-assistant .fw-faq-chat__heading { flex: 1 1 auto; min-width: 0; }
.fw-faq-shell.is-assistant .fw-faq-chat__header h2 {
  margin: 0;
  color: #fff;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
}
.fw-faq-shell.is-assistant .fw-faq-chat__sub {
  margin: 2px 0 0;
  color: rgba(255, 255, 255, .86);
  font-size: 14px;
  line-height: 1.4;
}
.fw-faq-shell.is-assistant .fw-faq-chat__close {
  width: 44px;
  height: 44px;
  border: 0;
  background: rgba(255, 255, 255, .16);
  color: #fff;
}
.fw-faq-shell.is-assistant .fw-faq-chat__close:hover { background: rgba(255, 255, 255, .26); }

/* 会話 */
.fw-faq-shell.is-assistant .fw-faq-chat__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #f4f7fc;
}
.fw-faq-shell.is-assistant .fw-faq-chat__bubble {
  width: fit-content;
  max-width: 88%;
  margin: 0;
  padding: 11px 14px;
  border: 0;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.8;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.fw-faq-shell.is-assistant .fw-faq-chat__bubble--question {
  align-self: flex-end;
  background: #0758d6;
  color: #fff;
  font-weight: 600;
  border-bottom-right-radius: 4px;
}
.fw-faq-shell.is-assistant .fw-faq-chat__bubble--answer {
  width: fit-content;
  background: #fff;
  color: #071a3d;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(7, 26, 61, .08);
}
.fw-faq-shell.is-assistant .fw-faq-chat__hint {
  margin: 4px 0 0;
  color: #42526b;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

/* 入力中の点 */
.fw-faq-shell.is-assistant .fw-faq-chat__bubble.is-typing { padding: 14px 16px; }
.fw-faq-shell.is-assistant .fw-faq-chat__dots { display: inline-flex; gap: 5px; vertical-align: middle; }
.fw-faq-shell.is-assistant .fw-faq-chat__dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8fa3c2;
  animation: fwFaqDot 1s infinite ease-in-out;
}
.fw-faq-shell.is-assistant .fw-faq-chat__dots i:nth-child(2) { animation-delay: .15s; }
.fw-faq-shell.is-assistant .fw-faq-chat__dots i:nth-child(3) { animation-delay: .3s; }
@keyframes fwFaqDot {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* 選べる質問・リンク */
.fw-faq-shell.is-assistant .fw-faq-chat__chips { display: flex; flex-wrap: wrap; gap: 8px; max-width: 100%; }
.fw-faq-shell.is-assistant .fw-faq-chat__chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  max-width: 100%;
  margin: 0;
  padding: 8px 14px;
  border: 1px solid #b9cdef;
  border-radius: 999px;
  background: #fff;
  color: #0758d6;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  text-align: left;
  text-decoration: none;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.fw-faq-shell.is-assistant .fw-faq-chat__chip:hover { background: #eef4ff; border-color: #0758d6; }
.fw-faq-shell.is-assistant .fw-faq-chat__chip--link { border-style: dashed; }
.fw-faq-shell.is-assistant .fw-faq-chat__chip--line { border-color: #06c755; background: #06c755; color: #fff; }
.fw-faq-shell.is-assistant .fw-faq-chat__chip--line:hover { background: #05b04b; border-color: #05b04b; }

/* 入力欄 */
.fw-faq-shell.is-assistant .fw-faq-chat__composer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid #d9e3f2;
  background: #fff;
}
.fw-faq-shell.is-assistant .fw-faq-chat__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.fw-faq-shell.is-assistant .fw-faq-chat__input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 46px;
  margin: 0;
  padding: 10px 16px;
  border: 1px solid #c9d6ea;
  border-radius: 999px;
  background: #f7f9fc;
  color: #071a3d;
  font: inherit;
  font-size: 16px; /* iPhoneで入力時に画面が拡大されないよう16px */
  line-height: 1.4;
}
.fw-faq-shell.is-assistant .fw-faq-chat__input::placeholder { color: #7a8aa3; }
.fw-faq-shell.is-assistant .fw-faq-chat__input:focus { outline: 0; border-color: #0758d6; background: #fff; box-shadow: 0 0 0 3px rgba(7, 88, 214, .18); }
.fw-faq-shell.is-assistant .fw-faq-chat__send {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #0758d6;
  color: #fff;
  cursor: pointer;
}
.fw-faq-shell.is-assistant .fw-faq-chat__send:disabled { background: #c3cfe2; cursor: default; }
.fw-faq-shell.is-assistant :is(button, a, input):focus-visible { outline: 3px solid #0758d6; outline-offset: 2px; }
.fw-faq-shell.is-assistant .fw-faq-chat__close:focus-visible { outline-color: #fff; }

/* スマホ・横向きの低い画面では、開いたら画面いっぱいに使う */
@media (max-width: 600px), (max-width: 960px) and (max-height: 500px) {
  .fw-faq-shell.is-assistant {
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: min(460px, calc(100% - 16px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  }
  .fw-faq-shell.is-assistant .fw-faq-chat {
    height: calc(100vh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border-radius: 18px;
  }
  .fw-faq-shell.is-assistant .fw-faq-chat__header { padding: 10px 10px 10px 14px; }
  .fw-faq-shell.is-assistant .fw-faq-chat__close { width: 48px; height: 48px; }
  .fw-faq-shell.is-assistant .fw-faq-chat__bubble { font-size: 16px; }
  .fw-faq-shell.is-assistant .fw-faq-chat__chip { min-height: 44px; font-size: 15px; }
}
@media (max-width: 960px) and (max-height: 500px) {
  .fw-faq-shell.is-assistant .fw-faq-chat__sub { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .fw-faq-shell.is-assistant .fw-faq-chat__dots i { animation: none; opacity: .7; }
}

/* 会話らしさ（2026-10-14 追加）：返事の横の小さなアイコン、考え中の表示、文字が出ていく途中のカーソル、声かけの吹き出し */
.fw-faq-shell.is-assistant .fw-faq-chat__sub { display: flex; align-items: center; gap: 6px; }
.fw-faq-shell.is-assistant .fw-faq-chat__status {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3ddc84;
  box-shadow: 0 0 0 3px rgba(61, 220, 132, .25);
}
.fw-faq-shell.is-assistant .fw-faq-chat__turn {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  width: 100%;
}
.fw-faq-shell.is-assistant .fw-faq-chat__mini {
  width: 30px;
  height: 30px;
  margin-top: 2px;
  border-radius: 50%;
  background: #fff url("../img/logo_mark.webp") center / 70% no-repeat;
  box-shadow: 0 0 0 1px #d9e3f2;
}
.fw-faq-shell.is-assistant .fw-faq-chat__stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}
.fw-faq-shell.is-assistant .fw-faq-chat__stack > .fw-faq-chat__bubble { max-width: 100%; }
.fw-faq-shell.is-assistant .fw-faq-chat__bubble.is-typing { display: inline-flex; align-items: center; gap: 10px; }
.fw-faq-shell.is-assistant .fw-faq-chat__thinking { color: #5b6b85; font-size: 14px; line-height: 1.5; }
.fw-faq-shell.is-assistant .fw-faq-chat__bubble.is-streaming::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: #0758d6;
  animation: fwFaqCaret .8s steps(1) infinite;
}
@keyframes fwFaqCaret { 50% { opacity: 0; } }
.fw-faq-shell.is-assistant .fw-faq-chat__bubble--question { animation: fwFaqIn .22s ease-out; }
.fw-faq-shell.is-assistant .fw-faq-chat__turn { animation: fwFaqIn .22s ease-out; }
.fw-faq-shell.is-assistant .fw-faq-chat__chips { animation: fwFaqIn .25s ease-out; }
@keyframes fwFaqIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 声かけの吹き出し（閉じているときだけ） */
.fw-faq-shell.is-assistant .fw-faq-teaser {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  max-width: min(300px, 100%);
  padding: 4px 4px 4px 0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(7, 26, 61, .2);
  animation: fwFaqIn .3s ease-out;
}
.fw-faq-shell.is-assistant .fw-faq-teaser[hidden] { display: none; }
.fw-faq-shell.is-assistant .fw-faq-teaser__open {
  flex: 1 1 auto;
  margin: 0;
  padding: 10px 4px 10px 14px;
  border: 0;
  background: transparent;
  color: #071a3d;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
  text-align: left;
  cursor: pointer;
}
.fw-faq-shell.is-assistant .fw-faq-teaser__close {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #5b6b85;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.fw-faq-shell.is-assistant:has([data-fw-faq-panel]:not([hidden])) .fw-faq-teaser { display: none; }
@media (prefers-reduced-motion: reduce) {
  .fw-faq-shell.is-assistant .fw-faq-chat__bubble.is-streaming::after,
  .fw-faq-shell.is-assistant .fw-faq-chat__bubble--question,
  .fw-faq-shell.is-assistant .fw-faq-chat__turn,
  .fw-faq-shell.is-assistant .fw-faq-chat__chips,
  .fw-faq-shell.is-assistant .fw-faq-teaser { animation: none; }
}
