/* ==========================================
   butler.css — MAXプラン AI音声コンシェルジュ（執事）常駐UI
   ★親ページ(aaa-ai-apps.com)側で動く。GAS iframe の上に重なる。
   出所: voice_concierge/concierge_ui.css（実証済み）の移植。
   状態: dock（右下常駐・ロボットくんFABと同じ足あとに重なる=置き換え） / expanded（全画面）
   ========================================== */

.aaa-concierge {
  position: fixed;
  z-index: 2147483000;  /* iframe(全画面)より上。親ページの最前面 */
  overflow: hidden;
  background: #14060a;
  transition: right .42s cubic-bezier(.22,.9,.3,1),
              bottom .42s cubic-bezier(.22,.9,.3,1),
              width .42s cubic-bezier(.22,.9,.3,1),
              height .42s cubic-bezier(.22,.9,.3,1),
              border-radius .42s ease,
              box-shadow .3s ease;
}

/* --- 右下に小さく常駐（ロボットくんFAB=64px円と同位置・同サイズ＝視覚的な置き換え） --- */
.aaa-concierge.dock {
  right: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.85);
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  cursor: pointer;
}
.aaa-concierge.dock:hover {
  box-shadow: 0 8px 22px rgba(0,0,0,.5);
  transform: scale(1.06);
}
.aaa-concierge { transform-origin: 100% 100%; }

/* --- 画面全体へ展開 --- */
.aaa-concierge.expanded {
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  box-shadow: none;
  background: radial-gradient(65% 75% at 50% 38%, #5d1017 0%, #2a070c 55%, #14060a 100%);
}
.aaa-concierge.expanded::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 20%, rgba(0,0,0,0) 40%, rgba(0,0,0,.55) 100%);
  pointer-events: none;
  z-index: 2;
}

/* 映像／静止画の置き場 */
.aaa-c-stage { position: absolute; inset: 0; }
.aaa-concierge.dock .aaa-c-stage > video,
.aaa-concierge.dock .aaa-c-stage > img {
  object-fit: cover !important;
  object-position: 50% 16% !important;
  transform: scale(1.4);
  transform-origin: 50% 20%;
}
.aaa-concierge.expanded .aaa-c-stage > video,
.aaa-concierge.expanded .aaa-c-stage > img {
  object-fit: contain !important;
  object-position: 50% 50% !important;
}

/* --- 聞き取り中の波形リング（--lv 0〜1） --- */
.aaa-c-ring {
  position: absolute;
  left: 50%; bottom: 8%;
  width: 84px; height: 84px;
  margin-left: -42px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.85);
  box-shadow: 0 0 0 calc(var(--lv, 0) * 22px) rgba(255,255,255,.13);
  transform: scale(calc(1 + var(--lv, 0) * .28));
  transition: transform .08s linear, box-shadow .08s linear;
  z-index: 4;
  pointer-events: none;
}
.aaa-concierge.dock .aaa-c-ring { display: none; }
.aaa-c-ring::after {
  content: '';
  position: absolute; inset: -10px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.28);
  animation: aaa-c-pulse 2.4s ease-out infinite;
}
@keyframes aaa-c-pulse {
  0%   { transform: scale(.9);  opacity: .8; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* --- 字幕（会話の文字起こし） --- */
.aaa-c-caption {
  position: absolute;
  left: 50%; bottom: 22%;
  transform: translateX(-50%);
  max-width: min(760px, 82vw);
  padding: 14px 22px;
  border-radius: 14px;
  background: rgba(8,4,6,.72);
  color: #fff;
  font-size: 21px;
  line-height: 1.7;
  text-align: center;
  z-index: 5;
  backdrop-filter: blur(6px);
}
.aaa-concierge.dock .aaa-c-caption { display: none; }

/* --- 右上の操作列（閉じる・キャラ切替・テキストで質問） --- */
.aaa-c-controls {
  position: absolute;
  right: 22px; top: 22px;
  z-index: 6;
  display: flex;
  gap: 8px;
  align-items: center;
}
.aaa-c-controls button {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.38);
  background: rgba(0,0,0,.42);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.aaa-c-controls button:hover { background: rgba(0,0,0,.62); }
.aaa-c-controls button.on { background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.8); }
.aaa-concierge.dock .aaa-c-controls { display: none; }

/* --- 初回のみ: マイク有効化の小さな案内（dockの上に出る吹き出し） --- */
.aaa-c-optin {
  position: fixed;
  right: 24px; bottom: 96px;
  z-index: 2147483001;
  background: #fff;
  color: #1b1f27;
  border: 1px solid #e3e7ee;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  max-width: 260px;
}
.aaa-c-optin button {
  margin-top: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: #1a73e8;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .aaa-concierge, .aaa-c-ring { transition: none; }
  .aaa-c-ring::after { animation: none; }
}
