/* ========================================================== */
/*           5. 新しいアイコンスタイル          */
/* ========================================================== */

/* --- ランチャーの基本レイアウト調整 --- */
#magatama-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999998;
  cursor: pointer;
  transition:
    transform 0.2s ease-in-out,
    opacity 0.2s ease-in-out;
  /* サイズは中の要素に任せる */
  width: auto;
  height: auto;
  padding-bottom: 0;
  background-image: none;
  /* JSで直接要素に設定するため不要に */
}

#magatama-chat-launcher:hover {
  transform: scale(1.05);
  /* ホバー時の拡大率 */
  background-image: none;
  /* JSで直接要素に設定するため不要に */
}

/* --- 5a. 「画像のみ」の場合のスタイル --- */
.magatama-icon-image-only {
  width: 250px;
  /* 基準となる横幅を指定 */
  height: auto;
  /* 高さは自動で調整 */
  aspect-ratio: 1068 / 1077;
  /* 元画像のアスペクト比を指定 */
  /* ▲▲▲ 修正箇所 ▲▲▲ */
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

/* 「画像のみ」Sサイズ用のスタイル */
#magatama-chat-launcher.size-s {
  transform: scale(0.8);
  transform-origin: bottom right;
}

#magatama-chat-launcher.size-s:hover {
  transform: scale(0.85);
  /* ホバー時の拡大率も調整 */
}

/* --- 5b. 「画像＋テキスト」の場合のスタイル --- */
.magatama-icon-container {
  display: flex;
  align-items: flex-end;
  /* アイコンと吹き出しを下に揃える */
  gap: 8px;
  /* アイコンと吹き出しの間隔 */
}

/* ========================================================== */
/*           5b. 「画像＋テキスト」レイアウト（最終版）        */
/* ========================================================== */

/* --- コンテナ全体の制御 --- */
.magatama-icon-image-text-wrapper {
  display: flex;
  align-items: center;
  /* 要素を垂直方向に中央揃え */
}

/* --- アイコン画像のスタイル --- */
.magatama-icon-image {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease-in-out;
  flex-shrink: 0;
  /* 縮まないようにする */
  position: relative;
  z-index: 2;
  /* しっぽより手前 */

  /* ★吹き出しに重なるようにネガティブマージンを設定★ */
  /* margin-left: -20px;  */
}

/* 「画像＋テキスト」ホバー時の画像エフェクト */
#magatama-chat-launcher:hover .magatama-icon-image {
  transform: scale(1.1);
}

/* 既存のモバイル用スタイルを上書きする場合の考慮 */
@media (max-width: 767px) {
  /* 「画像のみ」の場合のモバイルでのサイズ調整 */
  .magatama-icon-image-only {
    width: 180px;
    /* モバイルでは少し小さめに */
  }

  /* 「画像＋テキスト」の場合のレイアウト調整 */
  .magatama-icon-container {
    /* 必要に応じてモバイル用のスタイルを追加 */
  }
}

/* ========================================================== */
/*           6. アイコン表示位置とレイアウト（詳細度UP版）       */
/* ========================================================== */

/* --- 6a. 表示位置の制御 --- */
/*
   IDセレクタ(#)とクラスセレクタを組み合わせることで、
   単なるIDセレクタよりも詳細度を高くし、優先的に適用させる
*/

/* 右下（デフォルト） */
#magatama-chat-launcher.position-right_bottom {
  right: 24px !important;
  /* 念のため !important を追加 */
  bottom: 24px !important;
  left: auto !important;
  transform-origin: bottom right;
}

/* 左下 */
#magatama-chat-launcher.position-left_bottom {
  left: 24px !important;
  bottom: 24px !important;
  right: auto !important;
  transform-origin: bottom left;
}

/* --- 6b. 縦横レイアウトの制御 --- */
/* 横並び */
#magatama-chat-launcher.layout-horizontal .magatama-icon-image-text-wrapper {
  flex-direction: row !important;
}

/* 縦並び */
#magatama-chat-launcher.layout-vertical .magatama-icon-image-text-wrapper {
  flex-direction: column !important;
  gap: 10px !important;
}

#magatama-chat-launcher.layout-vertical .magatama-icon-image {
  order: 2;
  margin-left: 0;
}

#magatama-chat-launcher.layout-vertical .magatama-icon-text-bubble {
  order: 1;
}

/* --- 6c. モバイル表示の調整 --- */
@media (max-width: 767px) {
  #magatama-chat-launcher.position-right-bottom {
    right: 16px !important;
    bottom: 16px !important;
  }

  #magatama-chat-launcher.position-left-bottom {
    left: 16px !important;
    right: auto !important;
    bottom: 16px !important;
  }
}

/* ========================================================== */
/*           8. アイコン左右反転スタイル (追加)                */
/* ========================================================== */

/* is-reversedクラスが付与されたら、要素の並び順を逆にする */
#magatama-chat-launcher.is-reversed .magatama-icon-image-text-wrapper {
  flex-direction: row-reverse !important;
}
