/* Racine AIチャットボット ウィジェット
 * 色は index.html のブランドトークンに合わせてある（--rose-deep / --milk / --shell / --brown）。
 * HPのCSSには一切触れず、この中だけで完結させている（#rcb-root 配下のみを指定） */

#rcb-root {
  --rcb-primary: #B2786D;      /* 濃ローズ（HPの --rose-deep） */
  --rcb-primary-dark: #A06459; /* ホバー時（HPのCTA帯グラデ終端色） */
  --rcb-bg: #FBF7F2;           /* 乳白（HPの --milk） */
  --rcb-user-bubble: #F5EAE3;  /* 桜貝（HPの --shell） */
  --rcb-gold: #E2CDB9;         /* 金茶（HPの --gold） */
  --rcb-text: #4A3A33;         /* 焦茶（HPの --brown） */
  position: fixed;
  right: 20px;
  bottom: 20px;
  font-family: 'Zen Kaku Gothic New', "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  letter-spacing: .03em;
}

/* ---- FABボタン ----
   白地＋ブランド色の枠。中の絵が一番見える組み合わせ。
   ゆっくり光らせて視線を集める（置いてあるだけでは押されないため）。 */
#rcb-fab {
  position: relative;
  width: 68px;
  height: 68px;
  border: 3px solid var(--rcb-primary);
  border-radius: 50%;
  background: #fff;
  color: var(--rcb-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  transition: transform .2s ease, box-shadow .2s ease;
  animation: rcb-pulse 2.4s ease-in-out infinite;
}
#rcb-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 26px rgba(178, 120, 109, .45);
  animation: none;
}
#rcb-fab:active { transform: scale(.96); }
#rcb-fab:focus-visible { outline: 2px solid var(--rcb-primary); outline-offset: 3px; }

/* 一度開いたら、光る演出も吹き出しもバッジも止める */
#rcb-root.rcb-noticed #rcb-fab { animation: none; }
#rcb-root.rcb-noticed #rcb-fab-tip,
#rcb-root.rcb-noticed #rcb-fab-badge { display: none; }

@keyframes rcb-pulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(178, 120, 109, .32); }
  50%      { box-shadow: 0 6px 28px rgba(178, 120, 109, .5), 0 0 0 8px rgba(178, 120, 109, .12); }
}

/* ---- 「AIチャット 24時間対応！」の吹き出し ---- */
#rcb-fab-tip {
  position: absolute;
  right: calc(68px + 14px); /* ボタンの左隣に置く */
  bottom: 18px;
  background: #fff;
  color: var(--rcb-text);
  font-size: 13.5px;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 20px;
  box-shadow: 0 3px 14px rgba(74, 58, 51, .18);
  white-space: nowrap;
  pointer-events: none;
  animation: rcb-tip-fade 3s ease-in-out infinite;
}
/* 吹き出しの尻尾（ボタンの方を指す三角） */
#rcb-fab-tip::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -6px;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: #fff;
  border-right: none;
}
@keyframes rcb-tip-fade {
  0%, 100% { opacity: 1; }
  50%      { opacity: .72; }
}

/* ---- 通知バッジ（未読1件の見た目） ---- */
#rcb-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  background: #E05C55;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: rcb-badge-bounce 1.6s ease-in-out infinite;
}
@keyframes rcb-badge-bounce {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

/* 動きを減らす設定にしている人には点滅させない（酔い・不快感への配慮） */
@media (prefers-reduced-motion: reduce) {
  #rcb-fab, #rcb-fab-tip, #rcb-fab-badge { animation: none; }
}

/* アイコン（福井開人さん作「吹き出し＋芽」）。
   PNGは形だけを取り出したマスクなので、色は下の background で決まる。
   これによりサロンのブランド色に合わせられる。 */
.rcb-fab-icon {
  display: block;
  width: 32px;
  height: 32px;
  background: currentColor;
  -webkit-mask: url("../img/chatbot/chat-fab-mask.png") no-repeat center / contain;
  mask: url("../img/chatbot/chat-fab-mask.png") no-repeat center / contain;
}
/* マスクが効いている環境では、中に入れた予備のSVGは隠す */
@supports ((-webkit-mask-image: url("")) or (mask-image: url(""))) {
  .rcb-fab-icon svg { display: none; }
}
/* マスク非対応の環境では従来の吹き出しSVGがそのまま出る（アイコンが消えないための保険） */
@supports not ((-webkit-mask-image: url("")) or (mask-image: url(""))) {
  .rcb-fab-icon { background: none; width: auto; height: auto; }
}

/* ---- チャットウィンドウ ---- */
#rcb-window {
  position: absolute;
  right: 0;
  bottom: 82px;
  width: 360px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 110px);
  background: var(--rcb-bg);
  border-radius: 18px;
  box-shadow: 0 10px 34px rgba(74, 58, 51, .22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* ★必須: 上の display:flex は ID指定なので、ブラウザ標準の [hidden]{display:none} より
   優先度が高い。この1行が無いと hidden 属性が効かず、最初からチャットが開いた状態で
   表示されてしまう（2026-08-13に実際に発生）。閉じた状態を保つための指定。 */
#rcb-window[hidden] {
  display: none;
}

.rcb-header {
  background: var(--rcb-primary);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rcb-title { font-size: 14px; font-weight: 500; letter-spacing: .1em; }
.rcb-close {
  border: none;
  background: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}

.rcb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  /* 回答が来たとき「直前の質問が上に来る位置」までスクロールする処理が、
     子要素の offsetTop をこの要素からの距離として測るために必要。
     これが無いと基準がページ全体になり、位置がずれる。 */
  position: relative;
}

/* ---- メッセージバブル ---- */
.rcb-msg { margin-bottom: 10px; display: flex; }
.rcb-msg-user { justify-content: flex-end; }
.rcb-msg-bot { justify-content: flex-start; }
.rcb-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--rcb-text);
  word-break: break-word;
}
.rcb-msg-bot .rcb-bubble { background: #fff; border-bottom-left-radius: 4px; box-shadow: 0 1px 4px rgba(74,58,51,.10); }
.rcb-msg-user .rcb-bubble { background: var(--rcb-user-bubble); border-bottom-right-radius: 4px; }

/* 入力中インジケータ */
.rcb-typing .rcb-bubble span {
  display: inline-block;
  width: 6px; height: 6px;
  margin: 0 2px;
  border-radius: 50%;
  background: #aaa;
  animation: rcb-blink 1.2s infinite;
}
.rcb-typing .rcb-bubble span:nth-child(2) { animation-delay: .2s; }
.rcb-typing .rcb-bubble span:nth-child(3) { animation-delay: .4s; }
@keyframes rcb-blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ---- CTAバナー ---- */
.rcb-banner-wrap { justify-content: flex-start; }
.rcb-banner {
  display: block;
  width: 88%;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--rcb-primary);
  color: #fff;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 4px 12px rgba(74,58,51,.16);
  transition: opacity .15s ease;
}
.rcb-banner:hover { opacity: .88; }
.rcb-banner-label { display: block; font-size: 14px; font-weight: 600; }
.rcb-banner-sub { display: block; font-size: 11.5px; margin-top: 3px; opacity: .9; }

/* ---- クイック返信 ---- */
.rcb-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.rcb-suggestion {
  border: 1px solid var(--rcb-gold);
  background: #fff;
  color: var(--rcb-primary-dark);
  font-family: inherit;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .15s ease;
}
.rcb-suggestion:hover { background: var(--rcb-user-bubble); }

/* ---- 免責・入力欄 ---- */
.rcb-disclaimer {
  font-size: 10px;
  color: #8A7568;
  text-align: center;
  padding: 4px 10px 2px;
  background: #fff;
}
.rcb-inputbar {
  display: flex;
  gap: 8px;
  padding: 8px 10px 10px;
  background: #fff;
  border-top: 1px solid #F0E6DD;
}
.rcb-input {
  flex: 1;
  border: 1px solid #E7DCD3;
  border-radius: 10px;
  padding: 9px 12px;
  /* ★16px未満にしないこと。iPhone/iPadのSafariは、文字が16pxより小さい入力欄を
     タップすると「小さくて読めないだろう」と判断して画面を勝手に拡大する。
     拡大されると元の倍率に戻らず、ページ全体が横にはみ出して非常に使いにくくなる
     （2026-08-14にオーナーのiPhoneで発生）。viewportで拡大禁止にする手もあるが、
     それは弱視の方のピンチ操作まで奪うので採らない。 */
  font-size: 16px;
  resize: none;
  outline: none;
  font-family: inherit;
}
.rcb-input:focus { border-color: var(--rcb-primary); }
.rcb-send {
  border: none;
  background: var(--rcb-primary);
  color: #fff;
  border-radius: 10px;
  padding: 0 16px;
  font-size: 13px;
  font-family: inherit;
  letter-spacing: .08em;
  cursor: pointer;
}
.rcb-send:disabled { opacity: .5; cursor: default; }

/* ---- スマホ ---- */
@media (max-width: 480px) {
  #rcb-window {
    width: calc(100vw - 16px);
    right: -12px;
    height: 72vh;
  }
  /* 画面が狭いので、ボタンと吹き出しを少しだけ小さくする */
  #rcb-fab { width: 62px; height: 62px; }
  #rcb-fab-tip {
    right: calc(62px + 12px);
    bottom: 16px;
    font-size: 12.5px;
    padding: 8px 13px;
  }
  #rcb-window { bottom: 76px; }
  /* 開いた時点で .rcb-noticed が付き、吹き出しとバッジは上の指定で消える。
     :has() などの新しい書き方に頼らず、JS側のクラスだけで完結させている。 */
}
