/*
 * 公式イラスト・画面オーバーレイ検証版
 * 本番CSSから独立させ、PC/SPの画面前面で有効化する。
 */

.illustration-stage {
  position: fixed;
  z-index: 90;
  inset: 0;
  display: block;
  overflow: hidden;
  pointer-events: none;
  contain: layout paint;
}

.illustration-stage__figure {
  position: absolute;
  margin: 0;
  /* 出入りは移動だけで表現し、画面の端で切れるまで透明にしない。 */
  opacity: 1;
  pointer-events: none;
  will-change: transform;
  transition: transform 360ms cubic-bezier(0.4, 0, 0.6, 1);
}

.illustration-stage__figure.is-present {
  transition: transform 500ms cubic-bezier(0.18, 0.88, 0.32, 1.10);
}

.illustration-stage__figure img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 18px 18px rgba(70, 42, 17, 0.2));
  user-select: none;
  -webkit-user-drag: none;
}

/*
 * PC初回：画面の右半分で登場。閾値による出入りと、小さな動きは別レイヤー。
 * ヘッダーより下のz-indexに置き、メニュー操作は常に手前へ残す。
 */
.illustration-stage__figure--welcome {
  right: 2vw;
  bottom: -4vh;
  width: min(46vw, 780px, 82vh);
  --welcome-center-x: 0%;
  transform: translate3d(var(--welcome-center-x), calc(112% + 100px), 0);
}

.illustration-stage__figure--welcome.is-present {
  transform: translate3d(var(--welcome-center-x), 0, 0);
}

.illustration-stage__entrance {
  position: relative;
}

.illustration-stage__scroll-cue {
  position: absolute;
  z-index: 1;
  bottom: calc(100% + 26px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border: 2px solid #73572c;
  border-radius: 999px;
  background: #fff9e9;
  color: #4a371e;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(115, 87, 44, 0.14);
}

/* 長い休止のあと、小さく2回跳ねる。スクロール位置を動かす親とは分離。 */
.illustration-stage__play {
  --playful-nudge: 0px;
  transform-origin: 50% 90%;
  animation: remonchi-playful-peek 6.2s ease-in-out 1.05s infinite;
  animation-play-state: paused;
}

.illustration-stage__figure.is-in-view .illustration-stage__play {
  animation-play-state: running;
}

.illustration-stage__figure--profile .illustration-stage__play {
  --playful-nudge: 7px;
  animation-duration: 6.8s;
  animation-delay: 0.4s;
}

.illustration-stage__figure--movie .illustration-stage__play {
  --playful-nudge: -7px;
  animation-duration: 7.2s;
  animation-delay: 0.8s;
}

@keyframes remonchi-playful-peek {
  0%, 56%, 84%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  61% { transform: translate3d(0, 5px, 0) rotate(-0.6deg); }
  66% { transform: translate3d(var(--playful-nudge), -14px, 0) rotate(1deg); }
  71% { transform: translate3d(0, 1px, 0) rotate(0deg); }
  76% { transform: translate3d(var(--playful-nudge), -7px, 0) rotate(-0.6deg); }
}

/* 右向きの腕組み：左端から半分より少し深く（55%）覗く。 */
.illustration-stage__figure--profile {
  left: 0;
  bottom: 6vh;
  width: min(34vw, 440px);
  /* 小さな跳ね・傾き・影も、最後まで画面外へ抜ける余裕を取る。 */
  transform: translate3d(calc(-100% - 96px), 0, 0) rotate(-3deg);
}

.illustration-stage__figure--profile.is-present {
  transform: translate3d(-45%, 0, 0);
}

/* 左向きの料理姿：右端から半分より少し深く（55%）覗く。 */
.illustration-stage__figure--movie {
  top: 17vh;
  right: 0;
  width: min(36vw, 460px);
  transform: translate3d(calc(100% + 96px), 0, 0) rotate(3deg);
}

.illustration-stage__figure--movie.is-present {
  transform: translate3d(45%, 0, 0);
}

@media (max-width: 760px) {
  .illustration-stage {
    z-index: 120;
  }

  /*
   * 初回：HEROの子要素ではなく、画面下端からviewport全体へせり上がる。
   * 横幅は画面の108%。頭が両端に少しだけはみ出す大きさ。
   */
  .illustration-stage__figure--welcome {
    left: 50%;
    right: auto;
    bottom: -5vh;
    --welcome-center-x: -50%;
    width: 108vw;
    /* 高さの短い画面でも、頭上の案内とヘッダーの間に余裕を残す。 */
    width: min(108vw, calc((100svh - 160px) * 1.1));
  }

  /* PCと同じく、左右とも55%が見える位置で止める。 */
  .illustration-stage__figure--profile {
    right: auto;
    left: 0;
    bottom: max(4vh, env(safe-area-inset-bottom));
    width: min(74vw, 300px);
  }

  /* ブラウザバーの伸縮でfixed領域の下端が動いても、左の登場位置は動かさない。
   * 小さいviewportの上端基準にし、画像自体の高さだけ上へ戻す。
   * svh非対応ブラウザは上記のbottom配置を維持する。 */
  @supports (height: 100svh) {
    .illustration-stage__figure--profile {
      top: calc(100svh - max(4svh, env(safe-area-inset-bottom)));
      bottom: auto;
      transform: translate3d(calc(-100% - 96px), -100%, 0) rotate(-3deg);
    }

    .illustration-stage__figure--profile.is-present {
      transform: translate3d(-45%, -100%, 0);
    }
  }

  /* 左向きなので右端から、体の左半分より少し深く覗く。 */
  .illustration-stage__figure--movie {
    top: 22vh;
    right: 0;
    left: auto;
    width: min(78vw, 320px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .illustration-stage__figure,
  .illustration-stage__figure.is-present,
  .illustration-stage__play,
  .illustration-stage__entrance {
    animation: none !important;
    transition: none !important;
  }

  .illustration-stage__play,
  .illustration-stage__entrance {
    transform: none;
  }

  .illustration-stage__figure--profile,
  .illustration-stage__figure--movie {
    display: none;
  }
}
