/* ===========================
   サービスカードの線画イラストのアニメーション【第2版・11/27 アニメーション_Claude_v2】
   第1版からの変更：部品が順番に小さく弾んで出る（弾性のあるイージング・拡大縮小の弾み・部品ごとに 60〜120ms ずらした連鎖）
   全体の長さは 1.5 秒以内・常時ループなし・マウスを外すと静かに戻る・動きを減らす設定では動かさない
   構造：.service-category-img（または .card-img）の中に .svc-ill を置き、帯だけの画像 <img> とインライン SVG（.svc-ill-svg）を重ねる
   起点：.service-category-card:hover / .card:hover / .svc-ill-run（JS で付ける class）
   =========================== */

/* --- 重ね方（右側 530/1280 の幅にイラストを絶対配置。画像の比率に追従） --- */
.svc-ill {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s ease;
}
.svc-ill > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.svc-ill-svg {
  position: absolute;
  top: 0;
  right: 0;
  width: 41.40625%; /* 530 / 1280 */
  height: 100%;
  overflow: hidden;
}

/* --- 既存の 1.05 倍の拡大との関係 ---
   A 案（既定）：拡大を img ではなく .svc-ill 全体にかけ、帯とイラストを一緒に拡大する
   B 案：.svc-ill に svc-ill--noscale を付けると拡大を止め、イラストの動きだけにする */
:is(.service-category-card:hover, .card:hover) .svc-ill > img {
  transform: none;
}
:is(.service-category-card:hover, .card:hover) .svc-ill {
  transform: scale(1.05);
}
:is(.service-category-card:hover, .card:hover) .svc-ill.svc-ill--noscale {
  transform: none;
}

/* --- 通常時（止まっている状態は現在の PNG と同じ見た目） --- */
.svc-ill-svg :is(.ia-device, .ia-play, .ia-badge, .ia-note, .ia-block, .ia-clip, .ia-ask, .ia-answer, .ia-viewer, .ia-s2card, .ia-s2dot) {
  transform-box: fill-box;
  transform-origin: 50% 50%;
}
.svc-ill-svg :is(.ia-device, .ia-badge, .ia-viewer, .ia-clip) { transform-origin: 50% 100%; }
.svc-ill-svg .ia-ask { transform-origin: 15% 100%; }   /* 吹き出しの尾のあたり */
.svc-ill-svg .ia-answer { transform-origin: 85% 100%; }
.svc-ill-svg .ia-progress,
.svc-ill-svg .ia-playhead { opacity: 0; }
.svc-ill-svg .ia-progress { stroke-dasharray: 100 101; stroke-dashoffset: 100; }
.svc-ill-svg :is(.ia-text, .ia-answer-text, .ia-sl, .ia-s2line) { stroke-dasharray: 100 101; stroke-dashoffset: 0; }
.svc-ill-svg .ia-hand { transform-box: view-box; transform-origin: 420px 280px; }
.svc-ill-svg .ia-spark { transform-box: view-box; transform-origin: 405px 255px; }
/* サイネージの表示：戻るときは静かに（弾まない） */
.svc-ill-svg .ia-slides { transition: transform 0.45s ease; }

/* --- 動き（動きを減らす設定の端末では一切動かさない） --- */
@media (prefers-reduced-motion: no-preference) {

  /* ショート：スマホ本体 → 再生ボタン → ハート → 横の小さなカードの順に弾む・再生の線が進む */
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="short"] .ia-device { animation: ia-boing 0.55s ease-in-out both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="short"] .ia-play   { animation: ia-press 0.6s ease-out 0.1s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="short"] .ia-badge  { animation: ia-pop 0.55s ease-out 0.22s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="short"] .ia-note   { animation: ia-pop 0.55s ease-out 0.34s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="short"] .ia-progress { animation: ia-progress 0.7s ease-in-out 0.45s both; }

  /* 横：モニター → 再生ボタン → 時計のバッジの順に弾む・針がひと回り・再生の線が進む */
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="wide"] .ia-device { animation: ia-boing 0.55s ease-in-out both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="wide"] .ia-play   { animation: ia-press 0.6s ease-out 0.1s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="wide"] .ia-badge  { animation: ia-pop 0.55s ease-out 0.22s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="wide"] .ia-hand   { animation: ia-spin 0.8s cubic-bezier(.34,1.56,.64,1) 0.4s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="wide"] .ia-progress { animation: ia-progress 0.7s ease-in-out 0.45s both; }

  /* 講座：パソコン → 映像の枠 → タイムラインのクリップ3つが順に弾む・文字の線・再生位置の線・角帽が弾む */
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="course"] .ia-device { animation: ia-boing 0.55s ease-in-out both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="course"] .ia-block  { animation: ia-pop 0.5s ease-out 0.1s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="course"] .ia-clip1  { animation: ia-pop 0.45s ease-out 0.2s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="course"] .ia-clip2  { animation: ia-pop 0.45s ease-out 0.28s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="course"] .ia-clip3  { animation: ia-pop 0.45s ease-out 0.36s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="course"] .ia-text1  { animation: ia-write 0.35s ease-out 0.3s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="course"] .ia-text2  { animation: ia-write 0.3s ease-out 0.42s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="course"] .ia-badge  { animation: ia-pop 0.55s ease-out 0.46s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="course"] .ia-playhead { animation: ia-playhead 0.85s ease-in-out 0.55s both; }

  /* サイネージ：本体が弾む → 表示が弾んで切り替わり、次の表示の部品が順に出る → 人が小さく跳ねる → ピンが弾む */
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="signage"] .ia-device { animation: ia-boing 0.55s ease-in-out both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="signage"] .ia-slides {
    transform: translateY(-212px);
    transition: transform 0.55s cubic-bezier(.34,1.56,.64,1) 0.1s;
  }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="signage"] .ia-s2line  { animation: ia-write 0.3s ease-out 0.2s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="signage"] .ia-s2line2 { animation-delay: 0.28s; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="signage"] .ia-s2card  { animation: ia-pop 0.5s ease-out 0.26s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="signage"] .ia-s2dot   { animation: ia-pop 0.45s ease-out 0.38s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="signage"] .ia-viewer  { animation: ia-jump 0.55s ease-out 0.5s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="signage"] .ia-badge   { animation: ia-pop 0.55s ease-out 0.62s both; }

  /* AI：質問 → 回答の吹き出しが「ぽん、ぽん」と出る・回答の線 → 画面の文字の線が順に書かれる・きらめきが弾んで回る */
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="ai"] .ia-ask    { animation: ia-pop 0.5s ease-out both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="ai"] .ia-answer { animation: ia-pop 0.5s ease-out 0.3s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="ai"] .ia-answer-text { animation: ia-write 0.3s ease-out 0.6s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="ai"] .ia-sl1 { animation: ia-write 0.3s ease-out 0.7s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="ai"] .ia-sl2 { animation: ia-write 0.3s ease-out 0.8s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="ai"] .ia-sl3 { animation: ia-write 0.3s ease-out 0.9s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="ai"] .ia-badge { animation: ia-pop 0.55s ease-out 0.45s both; }
  :is(.service-category-card:hover, .card:hover, .svc-ill-run) [data-ill="ai"] .ia-spark { animation: ia-twinkle 0.6s cubic-bezier(.34,1.56,.64,1) 0.75s both; }
}

/* 本体：少し沈んでから伸びて戻る */
@keyframes ia-boing {
  0%   { transform: scale(1, 1); }
  30%  { transform: scale(1.03, 0.95); }
  65%  { transform: scale(0.98, 1.03); }
  100% { transform: scale(1, 1); }
}
/* 部品が弾んで出る：0.6 → 1.12 → 0.96 → 1 */
@keyframes ia-pop {
  0%   { opacity: 0; transform: scale(0.6); }
  25%  { opacity: 1; }
  45%  { opacity: 1; transform: scale(1.12); }
  72%  { transform: scale(0.96); }
  100% { opacity: 1; transform: scale(1); }
}
/* 再生ボタン：押されてから弾んで戻る */
@keyframes ia-press {
  0%   { transform: scale(1); }
  25%  { transform: scale(0.82); }
  55%  { transform: scale(1.14); }
  78%  { transform: scale(0.96); }
  100% { transform: scale(1); }
}
/* 人：小さく跳ねる（着地で少しつぶれる） */
@keyframes ia-jump {
  0%   { transform: translateY(0) scale(1, 1); }
  20%  { transform: translateY(0) scale(1.04, 0.95); }
  50%  { transform: translateY(-14px) scale(0.98, 1.03); }
  78%  { transform: translateY(0) scale(1.03, 0.97); }
  100% { transform: translateY(0) scale(1, 1); }
}
@keyframes ia-progress {
  0%   { opacity: 1; stroke-dashoffset: 100; }
  100% { opacity: 1; stroke-dashoffset: 0; }
}
@keyframes ia-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes ia-playhead {
  0%   { opacity: 0; transform: translateX(0); }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(206px); }
}
@keyframes ia-write {
  from { stroke-dashoffset: 100; }
  to   { stroke-dashoffset: 0; }
}
@keyframes ia-twinkle {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(45deg) scale(0.75); }
  100% { transform: rotate(90deg) scale(1); }
}

/* --- 11/27 組み込み時の追記（開発部）：みねさん採用＝Claude 第2版の B 案（拡大なし・イラストの動きだけ）
   既存の不具合の修正：.animate-on-scroll.visible の transform がホバーの浮き上がりを打ち消していたため、
   イラスト入りのカードに限って浮き上がりを効かせる --- */
.service-category-card.animate-on-scroll.visible:has(.svc-ill):hover { transform: translateY(-4px); }
.card.animate-on-scroll.visible:has(.svc-ill):hover { transform: translateY(-6px); }
