/*
  スクロール連動の動きとページ切り替え（方針書 2-6）。
  src/styles/global.css ではなくこのファイルに置き、圧縮処理を通さずにそのまま配信する。
  （圧縮処理が animation-timeline を animation の一括指定にまとめると、ブラウザがその宣言を無視するため）
  文字は動かさない。動かすのは罫線と図の線だけ。すべて CSS だけで動き、JS は使わない。
  対応していないブラウザでは線が最初から引かれた状態で表示され、崩れない。
  色は src/styles/global.css のデザイントークンを参照する。
*/

@media (prefers-reduced-motion: no-preference) {
  /* ページ間の移動を、なめらかに切り替える（対応ブラウザのみ）。位置は動かさず、薄れて現れるだけ */
  @view-transition {
    navigation: auto;
  }

  ::view-transition-old(root) {
    animation: aige-fade-out 0.3s ease both;
  }

  ::view-transition-new(root) {
    animation: aige-fade-in 0.45s ease both;
  }

  @supports (animation-timeline: view()) {
    /* 見出しや各項目の上の罫線を、画面に入るにつれて左から引く */
    .rule-draw {
      transform-origin: left;
      animation-name: aige-draw-x;
      animation-timing-function: linear;
      animation-fill-mode: both;
      animation-timeline: view();
      animation-range: entry 10% cover 35%;
    }

    /* 事業内容の図の円を、画面に入るにつれて描く（pathLength="1" を前提にする） */
    .draw-line {
      stroke-dasharray: 1;
      animation-name: aige-draw-stroke;
      animation-timing-function: linear;
      animation-fill-mode: both;
      animation-timeline: view();
      animation-range: entry 0% cover 45%;
    }

    .draw-delay-1 {
      animation-range: entry 10% cover 50%;
    }

    .draw-delay-2 {
      animation-range: entry 20% cover 55%;
    }
  }
}

@keyframes aige-fade-out {
  to {
    opacity: 0;
  }
}

@keyframes aige-fade-in {
  from {
    opacity: 0;
  }
}

@keyframes aige-draw-x {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@keyframes aige-draw-stroke {
  from {
    stroke-dashoffset: 1;
  }
  to {
    stroke-dashoffset: 0;
  }
}

@media print {
  .rule-draw,
  .draw-line {
    animation: none !important;
  }
}
