/* ========================================
   分解ロゴ固定背景
   ======================================== */

.c-logo-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.c-logo-background__element {
  position: absolute;
  opacity: 0;
  transition: all 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.c-logo-background__element img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  position: relative;
  z-index: 1;
}

@keyframes walking-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes footstep-pulse {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }
  15% {
    opacity: 0.8;
    transform: scale(1.2);
  }
  35% {
    opacity: 0.25;
    transform: scale(0.9);
  }
  60% {
    opacity: 0;
    transform: scale(0.7);
  }
  100% {
    opacity: 0;
    transform: scale(0.7);
  }
}

@keyframes footstep-drift-left {
  /* X移動は「時間に比例」させて速度を一定にする */
  0% {
    opacity: 0;
    transform: translate3d(var(--footstep-x-offset, 0px), 0, 0) translateY(-50%)
      scale(0.9) rotate(var(--footstep-rotate, 0deg));
  }
  10% {
    opacity: var(--footstep-opacity);
    transform: translate3d(
        calc(var(--footstep-x-offset, 0px) - var(--footstep-travel) * 0.1),
        calc(-1 * var(--footstep-bob)),
        0
      )
      translateY(-50%) scale(1.12) rotate(var(--footstep-rotate, 0deg));
  }
  25% {
    opacity: calc(var(--footstep-opacity) * 0.95);
    transform: translate3d(
        calc(var(--footstep-x-offset, 0px) - var(--footstep-travel) * 0.25),
        var(--footstep-bob),
        0
      )
      translateY(-50%) scale(1.05) rotate(var(--footstep-rotate, 0deg));
  }
  50% {
    opacity: calc(var(--footstep-opacity) * 0.8);
    transform: translate3d(
        calc(var(--footstep-x-offset, 0px) - var(--footstep-travel) * 0.5),
        calc(-0.5 * var(--footstep-bob)),
        0
      )
      translateY(-50%) scale(0.98) rotate(var(--footstep-rotate, 0deg));
  }
  75% {
    opacity: calc(var(--footstep-opacity) * 0.6);
    transform: translate3d(
        calc(var(--footstep-x-offset, 0px) - var(--footstep-travel) * 0.75),
        0,
        0
      )
      translateY(-50%) scale(0.92) rotate(var(--footstep-rotate, 0deg));
  }
  90% {
    opacity: calc(var(--footstep-opacity) * 0.35);
    transform: translate3d(
        calc(var(--footstep-x-offset, 0px) - var(--footstep-travel) * 0.9),
        calc(0.25 * var(--footstep-bob)),
        0
      )
      translateY(-50%) scale(0.88) rotate(var(--footstep-rotate, 0deg));
  }
  100% {
    opacity: 0;
    transform: translate3d(
        calc(var(--footstep-x-offset, 0px) - var(--footstep-travel)),
        0,
        0
      )
      translateY(-50%) scale(0.85) rotate(var(--footstep-rotate, 0deg));
  }
}

@keyframes footstep-drift-left-dog {
  /* 犬は4つ同時に見える時間を長くする */
  0% {
    opacity: 0;
    transform: translate3d(var(--footstep-x-offset, 0px), 0, 0) translateY(-50%)
      scale(0.95) rotate(var(--footstep-rotate, 0deg));
  }
  5% {
    opacity: var(--footstep-opacity);
    transform: translate3d(
        calc(var(--footstep-x-offset, 0px) - var(--footstep-travel) * 0.05),
        calc(
          -1 * var(--footstep-bob) + var(--footstep-zig-sign, 1) *
            var(--footstep-zig, 0px)
        ),
        0
      )
      translateY(-50%) scale(1.05) rotate(var(--footstep-rotate, 0deg));
  }
  25% {
    opacity: var(--footstep-opacity);
    transform: translate3d(
        calc(var(--footstep-x-offset, 0px) - var(--footstep-travel) * 0.25),
        calc(
          var(--footstep-bob) - var(--footstep-zig-sign, 1) *
            var(--footstep-zig, 0px)
        ),
        0
      )
      translateY(-50%) scale(1.02) rotate(var(--footstep-rotate, 0deg));
  }
  50% {
    opacity: calc(var(--footstep-opacity) * 0.9);
    transform: translate3d(
        calc(var(--footstep-x-offset, 0px) - var(--footstep-travel) * 0.5),
        calc(var(--footstep-zig-sign, 1) * var(--footstep-zig, 0px)),
        0
      )
      translateY(-50%) scale(0.98) rotate(var(--footstep-rotate, 0deg));
  }
  75% {
    opacity: calc(var(--footstep-opacity) * 0.85);
    transform: translate3d(
        calc(var(--footstep-x-offset, 0px) - var(--footstep-travel) * 0.75),
        calc(
          0.5 * var(--footstep-bob) - var(--footstep-zig-sign, 1) *
            var(--footstep-zig, 0px)
        ),
        0
      )
      translateY(-50%) scale(0.94) rotate(var(--footstep-rotate, 0deg));
  }
  95% {
    opacity: calc(var(--footstep-opacity) * 0.7);
    transform: translate3d(
        calc(var(--footstep-x-offset, 0px) - var(--footstep-travel) * 0.95),
        calc(var(--footstep-zig-sign, 1) * var(--footstep-zig, 0px)),
        0
      )
      translateY(-50%) scale(0.9) rotate(var(--footstep-rotate, 0deg));
  }
  100% {
    opacity: 0;
    transform: translate3d(
        calc(var(--footstep-x-offset, 0px) - var(--footstep-travel)),
        0,
        0
      )
      translateY(-50%) scale(0.88) rotate(var(--footstep-rotate, 0deg));
  }
}

.c-logo-background__footsteps {
  position: absolute;
  left: auto;
  right: 48%;
  /* 全体的に少し下へ */
  bottom: -20px;
  /* 上下の間隔を詰める */
  height: 70px;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  width: 1px;
  overflow: visible;

  /* 種別ごとに上書きされる */
  --footstep-duration: 8s;
  --footstep-delay-step: 0.6s;
  --footstep-w: 12px;
  --footstep-h: 6px;
  --footstep-travel: 180px;
  --footstep-opacity: 0.55;
  /* 足跡自体は上下に動かさない */
  --footstep-bob: 0px;
}

.c-logo-background.is-walking .c-logo-background__footsteps {
  opacity: 1;
}

/* 犬が振り向いている間は足跡生成なし（全足跡を停止・非表示） */
.c-logo-background.is-footsteps-paused .c-logo-background__footsteps {
  opacity: 0;
}

.c-logo-background.is-footsteps-paused .c-logo-background__footsteps-dot {
  animation: none !important;
}

.c-logo-background__footsteps-dot {
  position: absolute;
  right: 0;
  top: 50%;
  width: var(--footstep-w);
  height: var(--footstep-h);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translate3d(0, 0, 0) translateY(-50%) scale(0.9);
}

.c-logo-background.is-walking .c-logo-background__footsteps-dot {
  animation-name: footstep-drift-left;
  animation-duration: var(--footstep-duration);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  /* 負のdelayで「最初から複数が動いている」状態にする */
  animation-delay: calc(-1 * var(--i, 0) * var(--footstep-delay-step));
}

.c-logo-background.is-walking
  .c-logo-background__footsteps--dog
  .c-logo-background__footsteps-dot {
  animation-name: footstep-drift-left-dog;
}

/* 次々に出るように遅延を段階付け（変数で一括調整） */
.c-logo-background__footsteps-dot:nth-child(1) {
  --i: 0;
}
.c-logo-background__footsteps-dot:nth-child(2) {
  --i: 1;
}
.c-logo-background__footsteps-dot:nth-child(3) {
  --i: 2;
}
.c-logo-background__footsteps-dot:nth-child(4) {
  --i: 3;
}
.c-logo-background__footsteps-dot:nth-child(5) {
  --i: 4;
}
.c-logo-background__footsteps-dot:nth-child(6) {
  --i: 5;
}
.c-logo-background__footsteps-dot:nth-child(7) {
  --i: 6;
}
.c-logo-background__footsteps-dot:nth-child(8) {
  --i: 7;
}
.c-logo-background__footsteps-dot:nth-child(9) {
  --i: 8;
}
.c-logo-background__footsteps-dot:nth-child(10) {
  --i: 9;
}

/* 犬のロゴ要素 - 右に大きく */
.c-logo-background__element--dog {
  bottom: 6rem;
  right: 5%;
  width: 10%;
  height: auto;
  transform: translateX(-20px) scaleX(1);
  overflow: visible;
}

/* 犬の足跡は小さめ */
.c-logo-background__footsteps--dog {
  right: 52%;
  /* 4つを等間隔で回し、途切れを防ぐ */
  /* 人と同じ1周速度に合わせる（ただし犬は4足なので位相は4分割） */
  /* 4つの塊（1周）を1.5倍速に */
  --footstep-duration: 2s;
  /* 4足を均等に（duration/4） */
  --footstep-delay-step: 0.5s;
  /* 肉球っぽく見えるよう正方形寄り */
  --footstep-w: 14px;
  --footstep-h: 14px;
  /* 残る距離: 現在の約3倍 */
  --footstep-travel: 270px;
  --footstep-opacity: 0.68;
  --footstep-bob: 0px;
  /* ジグザグ量（0で無効化） */
  --footstep-zig: 0px;
}

.c-logo-background__footsteps--dog .c-logo-background__footsteps-dot {
  background: none;
  border-radius: 0;
  display: grid;
  place-items: center;
}

.c-logo-background__footsteps--dog .c-logo-background__footsteps-dot::before {
  content: "pets";
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: calc(var(--footstep-w) * 1.25);
  line-height: 1;
  color: rgba(0, 0, 0, 0.22);
  display: inline-block;
  transform: rotate(90deg);
  transform-origin: 50% 50%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 犬: 4つの足（前2・後2）をそれぞれ別要素として配置＆個別に動かす */
.c-logo-background__footsteps--dog .c-logo-background__footsteps-dot--dog-1 {
  /* 交互に上下へ（上） */
  top: 56%;
  --footstep-x-offset: 0px;
  --footstep-rotate: -10deg;
  --footstep-zig-sign: 1;
}

.c-logo-background__footsteps--dog .c-logo-background__footsteps-dot--dog-2 {
  /* 交互に上下へ（下） */
  top: 70%;
  --footstep-x-offset: 26px;
  --footstep-rotate: 8deg;
  --footstep-zig-sign: -1;
}

.c-logo-background__footsteps--dog .c-logo-background__footsteps-dot--dog-3 {
  /* 交互に上下へ（上） */
  top: 60%;
  --footstep-x-offset: 52px;
  --footstep-rotate: -8deg;
  --footstep-zig-sign: 1;
}

.c-logo-background__footsteps--dog .c-logo-background__footsteps-dot--dog-4 {
  /* 交互に上下へ（下） */
  top: 74%;
  --footstep-x-offset: 78px;
  --footstep-rotate: 10deg;
  --footstep-zig-sign: -1;
}

.c-logo-background__element--dog.is-fade-in {
  transform: translateX(0) scaleX(1);
  opacity: 0.8;
}

.c-logo-background__element--dog.is-moved-right {
  transform: translateX(20px) scaleX(1);
  opacity: 0.8;
}

.c-logo-background__element--dog.is-looking-left {
  transform: translateX(20px) scaleX(-1);
  opacity: 0.8;
}

.c-logo-background__element--dog.is-complete {
  transform: translateX(20px) scaleX(1);
  opacity: 0.8;
}

/* 歩行地面アニメーション要素 */
.c-logo-background__walking-ground {
  /* 要望: 動く地面の線を削除（地面要素ごと非表示） */
  display: none;
}

.c-logo-background__walking-ground.is-active {
  display: none;
}

.c-logo-background__walking-ground-track {
  width: 200%;
  height: 100%;
  display: flex;
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

.c-logo-background__walking-ground.is-active
  .c-logo-background__walking-ground-track {
  animation: walking-ground-slide 40s linear infinite;
}

/* SVG地面の線 */
.c-logo-background__ground-svg {
  flex: 0 0 50%;
  width: 50%;
  height: 100%;
  display: block;
}

.c-logo-background__ground-path {
  fill: none;
  stroke: rgba(130, 130, 130, 0.25);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes walking-ground-slide {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

@keyframes ground-bump-breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* 下部にスクロールしたら非表示 */
.c-logo-background__walking-ground.is-hidden {
  opacity: 0;
  animation: none;
}

/* 人のロゴ要素 - 左下に大きく */
.c-logo-background__element--human {
  bottom: 6rem;
  left: 5%;
  width: 10%;
  height: auto;
  transform: translateX(-20px) scaleX(1);
  overflow: visible;
}

/* 人の足跡は大きめ */
.c-logo-background__footsteps--human {
  /* 残る距離を伸ばすと見切れやすいので、開始位置を少し右寄せ */
  right: 30%;
  /* 2つを交互に回し、途切れを防ぐ */
  /* ペース: 2倍（1周と間隔を半分に） */
  --footstep-duration: 3s;
  --footstep-delay-step: 1.5s;
  /* 人: 要望により3倍 */
  --footstep-w: 42px;
  --footstep-h: 21px;
  /* 足元付近に2つが同時に見えるよう、移動距離は短め */
  /* 残る距離: 現在の約3倍 */
  --footstep-travel: 360px;
  --footstep-opacity: 0.58;
  --footstep-bob: 0px;
}

/* 人: 2つ（左右っぽく上下2レーン） */
.c-logo-background__footsteps--human
  .c-logo-background__footsteps-dot--human-1 {
  /* 交互に上下へ（上） */
  top: 60%;
  --footstep-x-offset: 0px;
}

.c-logo-background__footsteps--human
  .c-logo-background__footsteps-dot--human-2 {
  /* 交互に上下へ（下） */
  top: 74%;
  --footstep-x-offset: 34px;
}

.c-logo-background__footsteps--human .c-logo-background__footsteps-dot {
  background: rgba(0, 0, 0, 0.16);
}

/* 地面表示タイミングから上下ボブ開始（transform競合を避けてimg側に適用） */
.c-logo-background.is-walking .c-logo-background__element--dog img {
  animation: walking-bob 2.4s ease-in-out infinite;
}

/* 振り向き演出中は「歩き」を止める（足跡停止と同期） */
.c-logo-background.is-walk-paused .c-logo-background__element--dog img {
  animation-play-state: paused;
}

.c-logo-background.is-walking .c-logo-background__element--human img {
  animation: walking-bob 2.8s ease-in-out infinite;
  animation-delay: 0.2s;
}

.c-logo-background__element--human.is-entering {
  transform: translateX(0) scaleX(1);
  opacity: 0.8;
}

/* メインテキスト - 右下に大きめに */
.c-logo-background__element--main-text {
  bottom: 4%;
  right: 5%;
  width: 20vw;
  height: auto;
}

/* サブテキスト - 左下に */
.c-logo-background__element--sub-text {
  bottom: 5%;
  left: 8%;
  width: 280px;
  height: auto;
}

/* アニメーション用クラス */
.c-logo-background__element.is-visible {
  opacity: 0.2;
}

.c-logo-background__element.is-animated {
  transform: scale(1.05);
  opacity: 0.25;
}

/* スクロールアニメーション：フェードアウト */
.c-logo-background__element--dog.is-fade-out-right {
  transform: translateX(100px) scaleX(1);
  opacity: 0;
}

.c-logo-background__element--human.is-fade-out-left {
  transform: translateX(0) scaleX(-1);
  opacity: 0;
}

/* スクロールアニメーション：位置変更前のフェードアウト */
.c-logo-background__element--dog.is-position-fade-out {
  opacity: 0;
}

.c-logo-background__element--human.is-position-fade-out {
  opacity: 0;
}

/* スクロールアニメーション：画面下部での再登場 */
.c-logo-background__element--dog.is-reenter-bottom {
  bottom: 6rem;
  right: 5%;
  transform: translateX(20px) scaleX(-1);
  opacity: 0;
}

.c-logo-background__element--dog.is-reenter-bottom-visible {
  top: 70%;
  right: 5%;
  transform: translateX(20px) scaleX(-1);
  opacity: 0.8;
}

.c-logo-background__element--human.is-reenter-bottom {
  top: 70%;
  left: 5%;
  transform: translateX(0) scaleX(1);
  opacity: 0;
}

.c-logo-background__element--human.is-reenter-bottom-visible {
  bottom: 5%;
  top: auto;
  left: 5%;
  transform: translateX(0) scaleX(1);
  opacity: 0.8;
}

/* レスポンシブ */
@media screen and (max-width: 768px) {
  .c-logo-background__footsteps {
    bottom: -18px;
    height: 64px;
  }

  .c-logo-background__walking-ground {
    bottom: 10%;
    height: 60px;
  }

  .c-logo-background__element--dog {
    width: 140px;
    height: auto;
    bottom: 15%;
    right: 8%;
    transform: translateX(-10px) scaleX(1);
  }

  .c-logo-background__element--dog.is-fade-in {
    transform: translateX(0) scaleX(1);
  }

  .c-logo-background__element--dog.is-moved-right {
    transform: translateX(10px) scaleX(1);
  }

  .c-logo-background__element--dog.is-looking-left {
    transform: translateX(10px) scaleX(-1);
  }

  .c-logo-background__element--dog.is-complete {
    transform: translateX(10px) scaleX(1);
  }

  .c-logo-background__element--dog.is-fade-in,
  .c-logo-background__element--dog.is-moved-right,
  .c-logo-background__element--dog.is-looking-left,
  .c-logo-background__element--dog.is-complete {
    opacity: 0.6 !important;
  }

  .c-logo-background__element--human {
    width: 130px;
    height: auto;
    bottom: 6rem;
    left: 3%;
  }

  .c-logo-background__element--human.is-entering {
    opacity: 0.6 !important;
  }

  .c-logo-background__element--main-text {
    width: 280px;
    height: auto;
    bottom: 12%;
    right: 5%;
  }

  .c-logo-background__element--sub-text {
    width: 200px;
    height: auto;
    bottom: 10%;
    left: 5%;
  }

  /* スクロールアニメーション：画面下部 */
  .c-logo-background__element--dog.is-reenter-bottom-visible {
    top: 70%;
    width: 200px;
  }

  .c-logo-background__element--human.is-reenter-bottom-visible {
    top: 70%;
    width: 180px;
  }
}

@media screen and (max-width: 480px) {
  .c-logo-background__footsteps {
    bottom: -16px;
    height: 60px;
  }

  .c-logo-background__walking-ground {
    bottom: 12%;
    height: 40px;
  }

  .c-logo-background__element {
    opacity: 0;
  }

  .c-logo-background__element.is-visible,
  .c-logo-background__element.is-fade-in,
  .c-logo-background__element.is-entering,
  .c-logo-background__element.is-complete {
    opacity: 0.15;
  }

  .c-logo-background__element--dog {
    width: 20%;
    height: auto;
    bottom: 6rem;
    right: 10%;
    transform: translateX(-6px) scaleX(1);
  }

  .c-logo-background__element--dog.is-fade-in {
    transform: translateX(0) scaleX(1);
  }

  .c-logo-background__element--dog.is-moved-right {
    transform: translateX(6px) scaleX(1);
  }

  .c-logo-background__element--dog.is-looking-left {
    transform: translateX(6px) scaleX(-1);
  }

  .c-logo-background__element--dog.is-complete {
    transform: translateX(6px) scaleX(1);
  }

  .c-logo-background__element--human {
    width: 75px;
    height: auto;
    bottom: 6rem;
    left: 2%;
  }

  .c-logo-background__element--main-text {
    width: 200px;
    height: auto;
    bottom: 10%;
    right: 3%;
  }

  .c-logo-background__element--sub-text {
    width: 160px;
    height: auto;
    bottom: 8%;
    left: 3%;
  }

  /* スクロールアニメーション：画面下部 */
  .c-logo-background__element--dog.is-reenter-bottom-visible {
    top: 70%;
    width: 140px;
    opacity: 0.15;
  }

  .c-logo-background__element--human.is-reenter-bottom-visible {
    top: 70%;
    width: 130px;
    opacity: 0.15;
  }
}
