/* ==========================================================================
   サイト全体のアニメーション（motion.js とセット）
   世界観：ゆずの実が枝で実り、やわらかな日ざしの中でゆれる
   SEO・表示速度への配慮
   - 動かすのは opacity / transform / clip-path / translate だけ（レイアウトがずれない＝CLSなし）
   - 隠す処理は JS が「最初の画面より下」の要素にだけ付ける。最初の画面（LCP）とJSなしの閲覧では何も隠れない
   - 「動きを減らす」設定の人には一切動かさない
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {

  /* --- 1. スクロールで現れる（ふわっと下から） --------------------------- */
  .yz-reveal {
    opacity: 0;
    transform: translate3d(0, 32px, 0) scale(0.98);
    transition:
      opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: calc(var(--yz-i, 0) * 90ms);
  }
  .yz-reveal.is-in {
    opacity: 1;
    transform: none;
  }

  /* --- 2. 見出し：にじんだ筆あとが左から定まるように現れる --------------- */
  .yz-reveal-heading {
    opacity: 0;
    transform: translate3d(-28px, 0, 0);
    filter: blur(8px);
    transition:
      opacity 1s cubic-bezier(0.22, 1, 0.36, 1),
      transform 1s cubic-bezier(0.22, 1, 0.36, 1),
      filter 1s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .yz-reveal-heading.is-in {
    opacity: 1;
    transform: none;
    filter: none;
  }

  /* --- 3. ゆずの実のカード（トップ「4つの診療方法」）：枝から実がなるように
         ぽんっと弾んで現れ、葉の付け根を支点に小さくゆれて止まる ------------ */
  .yz-reveal-fruit {
    opacity: 0;
    transform: translate3d(0, -36px, 0) rotate(-10deg) scale(0.7);
    transform-origin: 78% 12%;
  }
  /* 現れる途中でホバーしても、ゆれ（yuzu-swing）に上書きされて消えないよう詳細度を上げる。終わったら JS がクラスを外す */
  .yz-reveal-fruit.is-in,
  .bl_MedicalInformation .bl_section_content .bl_card.yz-reveal-fruit.is-in:hover {
    animation: yz-fruit-in 1.15s cubic-bezier(0.34, 1.4, 0.64, 1) both;
    animation-delay: calc(var(--yz-i, 0) * 140ms);
  }
  @keyframes yz-fruit-in {
    0%   { opacity: 0; transform: translate3d(0, -36px, 0) rotate(-10deg) scale(0.7); }
    55%  { opacity: 1; transform: translate3d(0, 4px, 0) rotate(4deg) scale(1.03); }
    78%  { transform: translate3d(0, -2px, 0) rotate(-2deg) scale(0.995); }
    100% { opacity: 1; transform: none; }
  }

  /* --- 5. 背景のゆずの模様：ゆっくり浮かんでゆれる（装飾・aria-hidden） ---
         インラインの rotate（transform）を残すため、独立した translate で動かす */
  .bl_yuzu_bg img {
    animation: yz-drift 14s ease-in-out infinite alternate;
  }
  .bl_yuzu_bg img:nth-child(3n + 1) { animation-duration: 17s; animation-delay: -4s; }
  .bl_yuzu_bg img:nth-child(3n + 2) { animation-duration: 12s; animation-delay: -8s; animation-direction: alternate-reverse; }
  @keyframes yz-drift {
    0%   { translate: 0 0; }
    50%  { translate: 6px -14px; }
    100% { translate: -4px 8px; }
  }

  /* --- 6. H1（ページの大見出し）：読み込み直後に1回だけ。JSを使わずCSSだけで動かす --------
         下層ページ・記事は、文字を最初のフレームから描画する（透明度0から始めない）→ LCP に影響しない
         トップの縦書きだけは上から書き下ろす演出。トップの LCP は背景の写真なので影響しない（確認済み） */

  /* 6-1. トップ（縦書き「暮らしにとけ込む医療を。」）：筆で上から書き下ろすように現れる */
  .bl_text_box .bl_vertical_text {
    animation: yz-h1-brush 1.5s cubic-bezier(0.65, 0, 0.35, 1) 0.1s both;
  }
  @keyframes yz-h1-brush {
    0%   { clip-path: inset(0 0 92% 0); filter: blur(4px); }
    60%  { filter: blur(0); }
    100% { clip-path: inset(0 0 -10% 0); filter: none; }
  }

  /* 6-2. 下層ページ（当院について・料金など）：小見出しの線が伸び、見出しが立ち上がり、
          ゆず色のマーカーが左から引かれる */
  .el_pageTitle__sub::before {
    transform-origin: left center;
    animation: yz-h1-line 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.05s both;
  }
  @keyframes yz-h1-line {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
  }
  .el_pageTitle__main {
    width: fit-content;
    max-width: 100%;
    background: linear-gradient(transparent 64%, rgba(236, 208, 60, 0.55) 64%, rgba(236, 208, 60, 0.55) 92%, transparent 92%) no-repeat left bottom / 0% 100%;
    animation:
      yz-h1-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both,
      yz-h1-marker 0.8s cubic-bezier(0.65, 0, 0.35, 1) 0.55s both;
  }
  @keyframes yz-h1-marker {
    to { background-size: 100% 100%; }
  }

  /* 6-3. 記事タイトル・その他のH1：やわらかく立ち上がる */
  .bl_single_post_title,
  .page-title,
  .sec_diagnosisArchive__title,
  .page-thanks h1,
  main h1.u-fs-h4 {
    animation: yz-h1-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  @keyframes yz-h1-rise {
    from { opacity: 0.35; transform: translate3d(0, 0.45em, 0); }
    to   { opacity: 1; transform: none; }
  }
}
