/* =========================================================
   motion.css — スクロール連動演出の基底スタイル（homepage-neo-lab）

   読み込み: <link rel="stylesheet" href="./assets/css/motion.css">（style.css の後）
   併用 JS : ./assets/js/motion.js（type="module"）

   設計
   - 既定は「静的レイアウト」。JS 無効・古いブラウザ・prefers-reduced-motion では
     シーンが縦に積まれ、内容は全て読める。
   - motion.js が <html> に js-motion を付け、reduced でないときだけ
     `.js-motion:not(.motion-reduced)` の規則で sticky と重ね合わせを有効にする。
   - 動かす値は motion.js が書く CSS 変数（--p / --scene-p / --scene-opacity / --scene-y /
     --scene-scale / --rail-x / --py / --track-bg）。ここでは transform と opacity だけを動かす。
   - 高さは svh を使い、iOS のアドレスバー伸縮で揺れないようにする。
   - z-index はヘッダー 100・スマホ CTA バー 80 より下に置く。
   ========================================================= */

/* ---------- 共通 ---------- */
.motion-track {
  position: relative;
  background: var(--track-bg, transparent);
  transition: background-color 0.5s ease;
}
.motion-stage { position: relative; }
[data-motion-scene] {
  position: relative;
  background: var(--scene-bg, transparent);
}

/* ---------- MOTION-01 ピン留めストーリー：シーン内レイアウト（静的・動的共通） ---------- */
.scene {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 40px;
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding: 72px var(--gutter);
  min-height: 60vh;
}
.scene__media img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.scene__label {
  display: block;
  font-family: var(--f-disp);
  font-size: 13px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--c-primary);
  margin-bottom: 12px;
}
.scene__title {
  font-size: clamp(26px, 4.6vw, 44px);
  line-height: 1.3;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.scene__lead {
  margin-top: 18px;
  color: var(--c-text-muted);
  font-size: 15px;
  line-height: 1.9;
}
.scene__actions { margin-top: 28px; display: flex; gap: 12px; flex-wrap: wrap; }

/* シーン切替のドット。静的モードでは不要なので隠す。 */
.motion-dots { display: none; }

/* ---------- 動的モード（motion.js が js-motion を付け、reduced でないとき） ---------- */
.js-motion:not(.motion-reduced) .motion-track:not([data-motion-type]),
.js-motion:not(.motion-reduced) .motion-track[data-motion-type="story"] {
  /* 1 シーンあたりのスクロール量。長いほどゆっくり切り替わる。 */
  --scene-length: 120svh;
  height: calc(100vh + var(--scenes, 1) * 120vh);
  height: calc(100svh + var(--scenes, 1) * var(--scene-length));
}
.js-motion:not(.motion-reduced) .motion-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}
.js-motion:not(.motion-reduced) [data-motion-scene] {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-top: var(--header-h);
  background: transparent;
  opacity: var(--scene-opacity, 0);
  transform: translate3d(0, var(--scene-y, 0px), 0) scale(var(--scene-scale, 1));
  pointer-events: none;
  will-change: opacity, transform;
}
.js-motion:not(.motion-reduced) [data-motion-scene].is-active { pointer-events: auto; }
.js-motion:not(.motion-reduced) [data-motion-scene] .scene { min-height: 0; padding-top: 0; padding-bottom: 0; }

/* シーン内部の小さな動き。--scene-p は 0→1 でそのシーンの滞在進捗。 */
.js-motion:not(.motion-reduced) .scene__media {
  transform: translate3d(0, calc((0.5 - var(--scene-p, 0.5)) * 48px), 0);
  will-change: transform;
}
.js-motion:not(.motion-reduced) .scene__text {
  transform: translate3d(calc((var(--scene-p, 0.5) - 0.5) * -28px), 0, 0);
  will-change: transform;
}

.js-motion:not(.motion-reduced) .motion-dots {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 12px;
  z-index: 3;
}
.motion-dots__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c-border);
  transition: background 0.2s, transform 0.2s;
}
.motion-dots__dot[aria-current="true"] {
  background: var(--c-primary);
  transform: scale(1.35);
}
.motion-dots__dot:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 3px; }

/* ---------- MOTION-02 パララックス ---------- */
.parallax-frame { position: relative; overflow: hidden; border-radius: var(--radius); }
.parallax-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.js-motion:not(.motion-reduced) [data-parallax] {
  transform: translate3d(0, var(--py, 0px), 0);
  will-change: transform;
}
/* 枠の中で動かす画像は少し大きくして、移動しても余白が見えないようにする。 */
.js-motion:not(.motion-reduced) .parallax-frame [data-parallax] {
  scale: 1.18;
}

/* ---------- MOTION-03 SVG ルート描画＋マーカー追従 ---------- */
.route { position: relative; }
.route svg { width: 100%; height: auto; display: block; overflow: visible; }
.route [data-route-path] {
  fill: none;
  stroke: var(--c-border);
  stroke-width: 3;
  stroke-dasharray: 6 8;
  stroke-linecap: round;
}
.route [data-route-reveal] {
  fill: none;
  stroke: var(--c-primary);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.route__hint {
  margin-top: 12px;
  text-align: center;
  font-size: 14px;
  color: var(--c-text-muted);
}
.route__hint--arrived { display: none; }
.route.is-arrived .route__hint--walking { display: none; }
.route.is-arrived .route__hint--arrived { display: block; }
/* 静的モードでは道を全部描く。マーカーは HTML 初期値の transform（ゴール位置）に置く。 */
html:not(.js-motion) .route [data-route-reveal],
.motion-reduced .route [data-route-reveal] {
  stroke-dasharray: none !important;
  stroke-dashoffset: 0 !important;
}
html:not(.js-motion) .route__hint--walking,
.motion-reduced .route__hint--walking { display: none; }
html:not(.js-motion) .route__hint--arrived,
.motion-reduced .route__hint--arrived { display: block; }

/* ---------- MOTION-04 横スクロールギャラリー ---------- */
.hgallery-rail {
  display: flex;
  gap: 24px;
  padding: 8px var(--gutter) 24px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.hgallery-rail > * {
  flex: 0 0 min(72vw, 420px);
  scroll-snap-align: start;
}
.hgallery-card {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.hgallery-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.hgallery-card__body { padding: 18px 20px 22px; }
.hgallery-card__title { font-weight: 600; font-size: 17px; }
.hgallery-card__text { margin-top: 8px; font-size: 14px; color: var(--c-text-muted); }

.js-motion:not(.motion-reduced) .motion-track[data-motion-type="hgallery"] {
  height: calc(100vh + 150vh);
  height: calc(100svh + var(--track-extra, 150vh));
}
.js-motion:not(.motion-reduced) .motion-track[data-motion-type="hgallery"] .motion-stage {
  display: grid;
  align-content: center;
  gap: 32px;
  padding-top: var(--header-h);
}
.js-motion:not(.motion-reduced) .hgallery-rail {
  overflow: visible;
  scroll-snap-type: none;
  transform: translate3d(var(--rail-x, 0px), 0, 0);
  will-change: transform;
}

/* ---------- MOTION-05 スクロール連動動画 ---------- */
.motion-track[data-motion-type="video"] .motion-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}
.motion-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.motion-video__caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 32px var(--gutter);
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.6), rgba(0,0,0,0));
}
.motion-video__caption h2 { font-size: clamp(22px, 3.6vw, 34px); }
.motion-video__caption p { margin-top: 8px; font-size: 14px; opacity: 0.9; }
.js-motion:not(.motion-reduced) .motion-track[data-motion-type="video"] {
  --video-length: 200svh;
  height: calc(100vh + 200vh);
  height: calc(100svh + var(--video-length));
}
.js-motion:not(.motion-reduced) .motion-track[data-motion-type="video"] .motion-stage {
  aspect-ratio: auto;
}

/* ---------- レスポンシブ ---------- */
@media (max-width: 768px) {
  .scene { grid-template-columns: 1fr; gap: 20px; padding: 48px var(--gutter); }
  .scene__media { order: -1; }
  .scene__media img { aspect-ratio: 16 / 10; max-height: 36svh; }
  .js-motion:not(.motion-reduced) .motion-track:not([data-motion-type]),
  .js-motion:not(.motion-reduced) .motion-track[data-motion-type="story"] {
    --scene-length: 100svh;
  }
  .js-motion:not(.motion-reduced) [data-motion-scene] {
    /* スマホ下部の CTA バー（60px）と重ならないように少し上へ寄せる */
    padding-bottom: 64px;
  }
  .js-motion:not(.motion-reduced) .motion-dots { right: 10px; gap: 10px; }
  .hgallery-rail > * { flex-basis: 78vw; }
}

/* ---------- 動きを抑える設定 ---------- */
@media (prefers-reduced-motion: reduce) {
  .motion-track { transition: none; }
  .motion-dots__dot { transition: none; }
}
