/* ============================================================
   トップページ（top.html）の演出
   ------------------------------------------------------------
   検討資料 docs/proposals/top-motion-20261023.md の推奨の組み合わせ。
     1-C 棒グラフの輪郭（ヒーローの下の縁）
     2-A 現在地を示す案内とヘッダーの状態 ／ 2-C 移動先のラベルの知らせ
     3-B 強調の下地が引かれる（.hl-underline）
     4-A 39 問が 3つの実感にまとまる図 ／ 4-C 3 ステップの流れ線の印
   決まり
     ・止まらない動きは足さない（どれも、入る時か操作の時に一度だけ）
     ・動きは prefers-reduced-motion: no-preference のときだけ。基本の状態が最終の見た目
     ・色はトークンだけ。透明度は color-mix
     ・@keyframes の名前は gs-lp- で始める（ほかの CSS と重ねない）
   ============================================================ */

/* ---------- 1-C 棒グラフの輪郭（ヒーローの下の縁） ---------- */
/* ロゴの棒グラフの形を、輪郭だけで置く。消しても意味は変わらない背景。
   絵は HTML の要素（SVG ではない）で、縦横 32px を超える線の図形だけ。塗らない。 */
.lp-hero-bars {
  position: absolute; right: 0; bottom: 0; z-index: 0;
  width: min(46vw, 520px); height: 104px;
  pointer-events: none;
}
@media (min-width: 640px) { .lp-hero-bars { height: 150px; } }
.lp-hero-bars span {
  position: absolute; bottom: 0; width: 8%; box-sizing: border-box;
  height: var(--h); left: var(--x);
  border: 1px solid color-mix(in srgb, var(--gs-primary) 42%, transparent);
  border-bottom: 0; border-radius: 2px 2px 0 0;
  transform-origin: 50% 100%;
}

/* ---------- 2-A 現在地を示す案内とヘッダーの状態 ---------- */
.lp-spy a { position: relative; }
.lp-spy a::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 2px; height: 2px;
  background: var(--gs-primary-strong);
  transform: scaleX(0); transform-origin: left center;
}
.lp-spy a[aria-current="true"] { color: var(--gs-primary-strong) !important; }
.lp-spy a[aria-current="true"]::after { transform: scaleX(1); }
.lp-header.is-scrolled { border-bottom-color: var(--lp-rule-strong); }

/* ---------- 4-A 39 問が 3つの実感にまとまる図 ---------- */
.lp-info { margin: 0 0 20px; max-width: 420px; }
.lp-info svg { display: block; width: 100%; height: auto; }
.lp-info text { font-family: inherit; font-size: 12px; font-weight: 700; fill: var(--gs-text); }
.lp-info .lp-info__sub { font-size: 10px; font-weight: 600; fill: var(--gs-text-3); }
.lp-info__tick { fill: none; stroke: var(--gs-text-3); stroke-width: 2; stroke-linecap: round; }
.lp-info__arrow { fill: none; stroke: var(--gs-rule-strong); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lp-info__track { stroke: var(--gs-surface-3); stroke-width: 12; }
.lp-info__bar { fill: none; stroke-width: 12; }
.lp-info__bar--competence { stroke: var(--gs-need-competence); }
.lp-info__bar--autonomy { stroke: var(--gs-need-autonomy); }
.lp-info__bar--relatedness { stroke: var(--gs-need-relatedness); }

/* ---------- 4-C 3 ステップの流れ線の印 ---------- */
.flow-track { display: none; }
@media (min-width: 640px) {
  .flow-track {
    display: block; position: absolute; top: 3rem; left: 16.6667%; right: 16.6667%;
    height: 0; z-index: -10; pointer-events: none;
  }
  .flow-marker {
    position: absolute; left: 0; top: 0; width: 10px; height: 10px; margin: -5px 0 0 -5px;
    background: var(--gs-primary-strong); border-radius: 2px;
    transform: rotate(45deg); opacity: 0;
  }
}

/* ============================================================
   動き（動きを減らす設定が無いときだけ）
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {

  /* 1-C 下から順に、一度だけ立ち上がる */
  .lp-hero-bars span {
    animation: gs-lp-bar-up 900ms var(--gs-ease-out) both;
    animation-delay: calc(350ms + var(--i) * 90ms);
  }
  @keyframes gs-lp-bar-up { from { transform: scaleY(0); } to { transform: scaleY(1); } }

  /* 2-A 下線は、いまの項目へ切り替わる（一本の線が伸び縮みする） */
  .lp-spy a::after { transition: transform var(--gs-dur-enter) var(--gs-ease-out); }

  /* 2-C 案内で移った先のラベルが、淡く光って戻る */
  section[id]:target .section-label { animation: gs-lp-hit 1200ms var(--gs-ease-out) both; }
  @keyframes gs-lp-hit {
    from { background: var(--gs-primary-tint); transform: scale(1.08); }
    to   { background: var(--lp-surface-2);    transform: scale(1); }
  }

  /* 3-B 見出しの強調が、左から引かれる（文字は最初から読める） */
  /* 静止したときの見た目は、もとの指定（transparent 64% から下に色）と同じ。引いている間だけ、繰り返さず左に寄せる */
  .animate-on-scroll .hl-underline { background-repeat: no-repeat; background-position: 0 0; }
  .animate-on-scroll:not(.is-visible) .hl-underline { background-size: 0 100%; }
  .animate-on-scroll.is-visible .hl-underline { animation: gs-lp-sweep 800ms var(--gs-ease-out) 250ms both; }
  @keyframes gs-lp-sweep { from { background-size: 0 100%; } to { background-size: 100% 100%; } }

  /* 4-A 縦線が順に濃くなり、矢印が引かれ、3 本の棒が満ちる。JavaScript が is-armed と is-on を付ける */
  .lp-info.is-armed .lp-info__tick { opacity: .12; }
  .lp-info.is-armed .lp-info__arrow { stroke-dasharray: 40; stroke-dashoffset: 40; }
  .lp-info.is-armed .lp-info__bar { stroke-dasharray: 120; stroke-dashoffset: 120; }
  .lp-info.is-armed .lp-info__mark { opacity: 0; }
  .lp-info.is-on .lp-info__tick { animation: gs-lp-fade 300ms var(--gs-ease-out) both; animation-delay: calc(var(--i) * 140ms); }
  .lp-info.is-on .lp-info__arrow { animation: gs-lp-draw 450ms var(--gs-ease-out) 650ms both; }
  .lp-info.is-on .lp-info__bar { animation: gs-lp-draw 700ms var(--gs-ease-out) both; animation-delay: calc(1000ms + var(--i) * 140ms); }
  .lp-info.is-on .lp-info__mark { animation: gs-lp-fade 300ms var(--gs-ease-out) both; animation-delay: calc(900ms + var(--i) * 140ms); }
  @keyframes gs-lp-fade { to { opacity: 1; } }
  @keyframes gs-lp-draw { to { stroke-dashoffset: 0; } }

  /* 4-C 線が伸びたあと、ひし形の印が 01 から 03 へ進み、番号が順に弾む（広い画面だけ） */
  @media (min-width: 640px) {
    .flow-connector.is-visible ~ .flow-track .flow-marker { animation: gs-lp-travel 1600ms ease-in-out 300ms both; }
    .flow-connector.is-visible ~ .lp-step .step-head__num {
      animation: gs-lp-pop 500ms var(--gs-ease-commit) both;
      animation-delay: calc(300ms + var(--step-i) * 800ms);
    }
  }
  @keyframes gs-lp-travel { from { opacity: 1; left: 0; } to { opacity: 1; left: 100%; } }
  @keyframes gs-lp-pop { 0%, 100% { transform: none; } 40% { transform: scale(1.18); } }
}
