/* ============================================================
 * multi-service-badge.css v2
 * ------------------------------------------------------------
 * ダークグリーンテック近未来。折りたたみ展開式、グロー、パルス、
 * ホバーシマー、フェード遷移、サービス間スプラッシュ。
 * ============================================================ */

/* ============================================================
 * サービス間スプラッシュオーバーレイ
 * ------------------------------------------------------------
 * 出発側でかぶせ、着地側でも復元してフェードアウト。
 * 体感「外部サイト遷移」を「同じアプリ内のページ切替」に変える。
 * ============================================================ */
/* ぼいラボ統一スプラッシュ（キャラビジュ既存デザインに準拠） */
.msb-splash {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #121516;
  opacity: 0;
  pointer-events: auto;
  transition: opacity 360ms cubic-bezier(0.2, 0, 0, 1);
}

.msb-splash--in {
  opacity: 1;
}

.msb-splash--out {
  opacity: 0;
  transition: opacity 520ms cubic-bezier(0.4, 0, 0.2, 1);
}

.msb-splash__bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(0, 255, 136, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(0, 255, 136, 0.05) 0%, transparent 50%);
  pointer-events: none;
}

.msb-splash__content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transform: scale(0.92);
  opacity: 0;
  animation: msb-splash-pop 540ms cubic-bezier(0.2, 0, 0, 1) 60ms forwards;
}

.msb-splash--out .msb-splash__content {
  animation: msb-splash-zoomout 520ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.msb-splash__logo {
  width: 160px;
  height: auto;
  /* キャラビジュ既存スプラッシュと同じマスクで角を背景と同化 */
  -webkit-mask-image: radial-gradient(circle at center, black 40%, transparent 68%);
  mask-image: radial-gradient(circle at center, black 40%, transparent 68%);
  filter: drop-shadow(0 0 15px rgba(0, 255, 136, 0.35));
}

.msb-splash__brand {
  margin: 0;
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #ffffff;
}

/* 進捗サークル + 数字 */
.msb-splash__progress {
  position: relative;
  width: 80px;
  height: 80px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msb-splash__progress-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* 12時方向から時計回りに進むように回転 */
  transform: rotate(-90deg);
}

.msb-splash__progress-track {
  fill: none;
  stroke: rgba(0, 255, 136, 0.14);
  stroke-width: 4;
}

.msb-splash__progress-fill {
  fill: none;
  stroke: rgba(0, 255, 136, 0.95);
  stroke-width: 4;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(0, 255, 136, 0.5));
  transition: stroke-dashoffset 80ms linear;
}

.msb-splash__progress-num {
  position: relative;
  z-index: 1;
  font-family: 'SF Mono', 'JetBrains Mono', 'Noto Sans JP', monospace;
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.02em;
  text-shadow: 0 0 12px rgba(0, 255, 136, 0.4);
}

.msb-splash__progress-num::after {
  content: '%';
  margin-left: 1px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(0, 255, 136, 0.7);
}

@keyframes msb-splash-pop {
  0%   { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes msb-splash-zoomout {
  0%   { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.08); opacity: 0; }
}

@media (max-width: 600px) {
  .msb-splash__logo { width: 128px; }
  .msb-splash__brand { font-size: 1.3rem; }
  .msb-splash__progress { width: 68px; height: 68px; }
  .msb-splash__progress-num { font-size: 18px; }
}

/* ----- 旧フェードクラス（後方互換のため残す。今は未使用） ----- */
.msb-fade-pre {
  opacity: 0;
}

.msb-fade-in {
  opacity: 1;
  transition: opacity 400ms cubic-bezier(0.2, 0, 0, 1);
}

.msb-fade-out {
  opacity: 0;
  transition: opacity 280ms cubic-bezier(0.4, 0, 0.6, 1);
  pointer-events: none;
}

/* ----- 全体 wrap ----- */
.msb-wrap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9990;
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  pointer-events: auto;
}

/* VoiLog: プロフアイコン (user-btn) に MSB を統合
   - 内蔵トグルは hidden、user-btn クリックでパネル開閉
   - パネルは user-btn の真下に出現 */
.msb-header-slot {
  position: absolute;
  inset: auto 0 auto auto;
  top: 0;
  pointer-events: none;
}
.msb-header-slot .msb-wrap--integrated {
  position: relative;
  bottom: auto;
  right: auto;
  left: auto;
  top: auto;
  z-index: 1;
  pointer-events: auto;
}
.msb-header-slot .msb-toggle {
  display: none !important;
}
.msb-header-slot .msb-panel {
  position: fixed !important;
  top: 56px !important;
  right: 12px !important;
  bottom: auto !important;
  left: auto !important;
  transform-origin: top right !important;
  /* 根本修正 (2026-05-27):
     pointer-events: none はパネル要素自体にのみ適用され、
     CSS では子要素 (.msb-card) へ継承されない。
     そのため不可視のカードがクリックを奪い外部遷移していた。
     visibility: hidden は子要素へ継承されるため完全に遮断できる。
     pointer-events: none は二重防衛として残す。 */
  visibility: hidden !important;
  pointer-events: none !important;
}
.msb-header-slot .msb-wrap--expanded .msb-panel {
  transform: scale(1) translateY(0) !important;
  visibility: visible !important;
  pointer-events: auto !important;
}
.msb-header-slot .msb-panel:not(.msb-wrap--expanded .msb-panel) {
  transform: scale(0.95) translateY(-6px) !important;
}

/* user-btn 右肩に「MSB 連携あり」の小さなインジケータ */
.user-avatar-btn {
  position: relative;
}
.user-msb-indicator {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent, #34d57e);
  border: 2px solid var(--bg-main, #0d1117);
  box-shadow: 0 0 6px rgba(52, 213, 126, 0.6);
  pointer-events: none;
}
.user-avatar-btn[aria-expanded="true"] {
  background: rgba(52, 213, 126, 0.14);
}
.user-avatar-btn[aria-expanded="true"] .user-msb-indicator {
  animation: msb-pulse-dot 1.6s ease-in-out infinite;
}
@keyframes msb-pulse-dot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.4); }
}

/* ----- トグルボタン ----- */
.msb-toggle {
  position: relative;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #0a3d2e 0%, #051010 70%);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(0, 255, 136, 0.3),
    inset 0 0 12px rgba(0, 255, 136, 0.1);
  transition: transform 250ms cubic-bezier(0.2, 0, 0, 1),
              box-shadow 250ms cubic-bezier(0.2, 0, 0, 1);
}

.msb-toggle:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(0, 255, 136, 0.5),
    inset 0 0 16px rgba(0, 255, 136, 0.18);
}

.msb-toggle:active {
  transform: translateY(0) scale(1);
}

.msb-toggle__core {
  position: relative;
  z-index: 2;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #00ff88;
  box-shadow: 0 0 16px rgba(0, 255, 136, 0.8);
  transition: background 200ms ease, transform 200ms ease;
}

.msb-wrap--expanded .msb-toggle__core {
  background: #ffffff;
  transform: scale(0.7);
}

.msb-toggle__ring {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px solid rgba(0, 255, 136, 0.4);
  animation: msb-ring-pulse 2.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes msb-ring-pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* ----- パネル本体 ----- */
.msb-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  min-width: 280px;
  max-width: 320px;
  background: linear-gradient(160deg, rgba(10, 61, 46, 0.95) 0%, rgba(5, 16, 16, 0.95) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 255, 136, 0.25);
  border-radius: 16px;
  padding: 16px;
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(0, 255, 136, 0.1) inset;

  /* 展開アニメーション */
  opacity: 0;
  visibility: hidden; /* 子要素含めクリック完全遮断 (pointer-events は子に継承されないため) */
  transform: translateY(8px) scale(0.96);
  transform-origin: bottom right;
  /* visibility は開く時は即時表示、閉じる時は opacity アニメーション後に非表示 */
  transition: opacity 250ms cubic-bezier(0.2, 0, 0, 1),
              transform 250ms cubic-bezier(0.2, 0, 0, 1),
              visibility 0ms 250ms;
  pointer-events: none;
}

.msb-wrap--expanded .msb-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity 250ms cubic-bezier(0.2, 0, 0, 1),
              transform 250ms cubic-bezier(0.2, 0, 0, 1),
              visibility 0ms 0ms; /* 開く時は即時表示 */
  pointer-events: auto;
}

.msb-panel__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(0, 255, 136, 0.12);
}

.msb-panel__title {
  font-size: 12px;
  font-weight: 700;
  color: #00ff88;
  letter-spacing: 0.16em;
}

.msb-panel__sub {
  font-size: 10px;
  font-weight: 700;
  color: #ffd84a;
  letter-spacing: 0.1em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 216, 74, 0.12);
  border: 1px solid rgba(255, 216, 74, 0.4);
}

/* ----- カード ----- */
.msb-card {
  --msb-hue: 145;
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(0, 255, 136, 0.1);
  text-decoration: none;
  color: #e8f5e9;
  cursor: pointer;
  overflow: hidden;
  transition: background 200ms cubic-bezier(0.2, 0, 0, 1),
              border-color 200ms cubic-bezier(0.2, 0, 0, 1),
              transform 200ms cubic-bezier(0.2, 0, 0, 1);
}

.msb-card:last-child {
  margin-bottom: 0;
}

.msb-card:hover {
  background: rgba(0, 255, 136, 0.08);
  border-color: rgba(0, 255, 136, 0.3);
  transform: translateX(-3px);
}

/* ホバー時のシマーアニメーション */
.msb-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 25%,
    rgba(0, 255, 136, 0.18) 50%,
    transparent 75%
  );
  transform: translateX(-100%);
  pointer-events: none;
}

.msb-card:hover::before {
  animation: msb-shimmer 800ms cubic-bezier(0.2, 0, 0, 1);
}

@keyframes msb-shimmer {
  to { transform: translateX(100%); }
}

/* ----- 現在のサービス ----- */
.msb-card--current {
  background: rgba(0, 255, 136, 0.14);
  border-color: rgba(0, 255, 136, 0.55);
  cursor: default;
  pointer-events: none;
  box-shadow:
    0 0 24px rgba(0, 255, 136, 0.18),
    inset 0 0 12px rgba(0, 255, 136, 0.06);
}

.msb-card--current:hover {
  transform: none;
}

.msb-card--current:hover::before {
  animation: none;
}

.msb-card__pulse {
  position: absolute;
  top: 50%;
  left: -2px;
  width: 4px;
  height: 32px;
  margin-top: -16px;
  border-radius: 4px;
  background: #00ff88;
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.8);
  animation: msb-pulse 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes msb-pulse {
  0%, 100% { opacity: 1; transform: scaleY(1); }
  50% { opacity: 0.5; transform: scaleY(0.6); }
}

/* ----- アイコン ----- */
.msb-card__icon {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msb-card__icon-glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    hsla(var(--msb-hue), 85%, 55%, 0.35) 0%,
    transparent 70%
  );
  filter: blur(8px);
  transition: opacity 200ms ease;
}

.msb-card:hover .msb-card__icon-glow {
  opacity: 1.4;
}

.msb-card__icon-emoji {
  position: relative;
  z-index: 1;
  font-size: 24px;
  line-height: 1;
  filter: drop-shadow(0 0 6px hsla(var(--msb-hue), 85%, 55%, 0.6));
}

/* 各サービスのブランドアイコン（実画像） */
.msb-card__icon-img {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  object-fit: cover;
  filter: drop-shadow(0 0 6px hsla(var(--msb-hue), 85%, 55%, 0.55));
  /* 画像読込中も枠サイズが崩れないよう背景を入れる */
  background: rgba(0, 0, 0, 0.2);
}

/* ----- メタ ----- */
.msb-card__meta {
  flex: 1;
  min-width: 0;
}

.msb-card__name {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 2px;
  letter-spacing: 0.02em;
}

.msb-card__tagline {
  font-size: 10px;
  color: #a8d5b8;
  letter-spacing: 0.04em;
}

/* ----- ステータス ----- */
.msb-card__status {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.msb-st--active {
  background: rgba(0, 255, 136, 0.22);
  color: #00ff88;
  border: 1px solid rgba(0, 255, 136, 0.4);
}

.msb-st--partial {
  background: rgba(255, 216, 74, 0.16);
  color: #ffd84a;
  border: 1px solid rgba(255, 216, 74, 0.4);
}

.msb-st--new {
  background: rgba(255, 255, 255, 0.06);
  color: #a8d5b8;
  border: 1px solid rgba(168, 213, 184, 0.2);
}

.msb-st--dev {
  background: linear-gradient(135deg, #ffd84a 0%, #ff8a00 100%);
  color: #1a1a1a;
  border: 1px solid rgba(255, 216, 74, 0.6);
  box-shadow: 0 0 12px rgba(255, 216, 74, 0.3);
}

/* ----- スマホ最適化 ----- */
@media (max-width: 600px) {
  .msb-wrap {
    bottom: 16px;
    right: 16px;
  }
  .msb-toggle {
    width: 48px;
    height: 48px;
  }
  .msb-panel {
    min-width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
    right: 0;
    left: auto;
    bottom: 60px;
  }
  .msb-card__name {
    font-size: 13px;
  }
  .msb-card__tagline {
    font-size: 9px;
  }
}
