/* character-chat.css (g-page-v2)
 *
 * 常駐会話キャラ（character × smart-chat 連携）のスタイル。
 * Phaser/GSAP不使用。登退場は CSS transition、吹き出しは4方向矢印。
 * ブランド: #1da1f2 / 白背景・角丸・影。
 */

/* ============ キャラクター本体 ============ */
.gpv2-cchar {
  position: fixed;
  z-index: 99998;
  width: calc(137px * 0.6);
  height: calc(128px * 0.6);
  cursor: grab;
  overflow: visible;
  opacity: 0;
  transform: translateY(20px) scale(0.7);
  transition: opacity 0.3s ease, transform 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
  touch-action: none;
}
.gpv2-cchar.is-show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.gpv2-cchar:active {
  cursor: grabbing;
}
.gpv2-cchar-body {
  position: relative;
  width: 100%;
  height: 100%;
}
.gpv2-cchar-sprite {
  background-repeat: no-repeat;
  background-position: 0 0;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  transform: scale(0.6);
  transform-origin: top left;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.25));
}

/* 最小化時の復帰トグル（右下の丸ボタン） */
.gpv2-cchar-toggle {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #1da1f2;
  color: #fff;
  border: none;
  box-shadow: 0 6px 16px rgba(29, 161, 242, 0.4);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99997;
  transition: transform 0.2s ease, background 0.2s ease;
}
.gpv2-cchar-toggle.is-show {
  display: flex;
}
.gpv2-cchar-toggle:hover {
  background: #1a91da;
  transform: scale(1.05);
}
.gpv2-cchar-toggle i {
  font-size: 20px;
}

/* ============ 吹き出し ============ */
.gpv2-cbubble {
  position: fixed;
  z-index: 99999;
  max-width: 320px;
  min-width: 240px;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
}
.gpv2-cbubble.is-show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.gpv2-cbubble-inner {
  background: #ffffff;
  color: #0f1419;
  border: 1px solid #e1e8ed;
  border-radius: 16px;
  padding: 16px 16px 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16), 0 2px 6px rgba(0, 0, 0, 0.08);
  position: relative;
}
.gpv2-cbubble-close {
  position: absolute;
  top: 4px;
  right: 6px;
  background: transparent;
  border: none;
  color: #8a99a8;
  font-size: 1.4em;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.15s;
}
.gpv2-cbubble-close:hover {
  color: #0f1419;
}
.gpv2-cbubble-text {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.6;
  margin: 0 18px 0 0;
  word-break: break-word;
}
.gpv2-cbubble-text p {
  margin: 0;
}

/* 定型コード（選択肢ボタン等） */
.gpv2-cbubble-code {
  margin-top: 10px;
}
.gpv2-cbubble-code .chat-template-frame {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.gpv2-cbubble-code .btn-template {
  background: #ffffff;
  color: #1da1f2;
  border: 1px solid #1da1f2;
  border-radius: 99px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.gpv2-cbubble-code .btn-template:hover,
.gpv2-cbubble-code .btn-template:focus {
  background: #1da1f2;
  color: #ffffff;
  outline: none;
}
.gpv2-cbubble-code img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* 自由入力欄 */
.gpv2-cbubble-input {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  border-top: 1px solid #eff3f4;
  padding-top: 10px;
}
.gpv2-cbubble-input input {
  flex: 1;
  border: 1px solid #e1e8ed;
  border-radius: 99px;
  padding: 8px 14px;
  font-size: 14px;
  outline: none;
  background: #f7f9fa;
  color: #0f1419;
  font-family: inherit;
}
.gpv2-cbubble-input input:focus {
  border-color: #1da1f2;
  background: #fff;
}
.gpv2-cbubble-input button {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #1da1f2;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}
.gpv2-cbubble-input button:hover {
  background: #1a91da;
}
.gpv2-cbubble-input button i {
  font-size: 14px;
}

/* ============ 矢印 ============ */
.gpv2-cbubble-arrow {
  position: absolute;
  width: 0;
  height: 0;
}
/* バブル下にキャラ（上向き矢印） */
.gpv2-cbubble.arrow-top .gpv2-cbubble-arrow {
  top: -9px;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 9px solid #e1e8ed;
}
.gpv2-cbubble.arrow-top .gpv2-cbubble-arrow::after {
  content: '';
  position: absolute;
  left: -8px;
  top: 1px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #ffffff;
}
/* バブル上にキャラ（下向き矢印） */
.gpv2-cbubble.arrow-bottom .gpv2-cbubble-arrow {
  bottom: -9px;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 9px solid #e1e8ed;
}
.gpv2-cbubble.arrow-bottom .gpv2-cbubble-arrow::after {
  content: '';
  position: absolute;
  left: -8px;
  top: -9px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #ffffff;
}
/* バブル右にキャラ（左向き矢印） */
.gpv2-cbubble.arrow-left .gpv2-cbubble-arrow {
  left: -9px;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-right: 9px solid #e1e8ed;
}
.gpv2-cbubble.arrow-left .gpv2-cbubble-arrow::after {
  content: '';
  position: absolute;
  top: -8px;
  left: 1px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 8px solid #ffffff;
}
/* バブル左にキャラ（右向き矢印） */
.gpv2-cbubble.arrow-right .gpv2-cbubble-arrow {
  right: -9px;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 9px solid #e1e8ed;
}
.gpv2-cbubble.arrow-right .gpv2-cbubble-arrow::after {
  content: '';
  position: absolute;
  top: -8px;
  right: 1px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 8px solid #ffffff;
}

/* ============ モバイル ============ */
@media (max-width: 480px) {
  .gpv2-cbubble {
    max-width: calc(100vw - 24px);
    min-width: 0;
  }
  .gpv2-cchar {
    width: calc(137px * 0.5);
    height: calc(128px * 0.5);
  }
  .gpv2-cchar-sprite {
    transform: scale(0.5);
  }
}
