/* =====================================================================
 * 動き（2026-11 に追加。stylus・webpack のビルドとは別に直接書いている。functions/css_js.php で main.css のあとに読み込む）
 * 整体院らしく、静かにふっと整う感じ。派手にしない
 * - header.php の先頭のスクリプトが html に ai-js を付け、幕（#ai-veil）を出す。motion.js が準備できたら ai-ready を付けて幕を上げる
 * - 幕はヘッダー（z-index 999）の下。サイトの中でページを移るときはヘッダーが消えずに残る（sessionStorage の ai-nav → header.php が ai-keep）
 * - テーマの html{opacity:0}（Web フォント待ち。_body.styl）は ai-js のあいだ外し、代わりに幕で隠す（幕は Web フォントを最大 2.5 秒待つ）
 * ===================================================================== */

/* ------------------------------------------------------------ 幕 */
#ai-veil { display: none; }
html.ai-js #ai-veil {
	display: block;
	position: fixed;
	inset: 0;
	z-index: 998;
	background: #fff;
	pointer-events: none;
	opacity: 1;
	visibility: visible;
}
html.ai-js.ai-ready #ai-veil {
	opacity: 0;
	visibility: hidden;
	transition: opacity .7s cubic-bezier(.33, 0, .2, 1), visibility 0s .7s;
}
html.ai-js.ai-leave #ai-veil {
	opacity: 1;
	visibility: visible;
	transition: opacity .38s ease;
}
/* 待ちの印：中央で小さな丸が深呼吸するようにふくらんでしぼむ（遅いときだけ見える） */
#ai-veil span {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 12px;
	height: 12px;
	margin: -6px 0 0 -6px;
	border-radius: 50%;
	background: #C39586;
	opacity: 0;
	animation: ai-breathe 2.4s ease-in-out .5s infinite;
}
#ai-veil span::after {
	content: '';
	position: absolute;
	inset: -10px;
	border-radius: 50%;
	border: 1px solid #C39586;
	opacity: 0;
	animation: ai-ring 2.4s ease-out .5s infinite;
}
html.ai-ready #ai-veil span,
html.ai-ready #ai-veil span::after { animation-play-state: paused; }
@keyframes ai-breathe {
	0%, 100% { transform: scale(.55); opacity: .3; }
	50% { transform: scale(1); opacity: .85; }
}
@keyframes ai-ring {
	0% { transform: scale(.5); opacity: 0; }
	40% { opacity: .5; }
	100% { transform: scale(1.6); opacity: 0; }
}

/* テーマの html{opacity:0}（Web フォント待ち）を外す。代わりに幕で隠す */
html.ai-js { opacity: 1 !important; }

/* ------------------------------------------------------------ ヘッダー（最初のページだけふわっと下りる。サイトの中で移ったときは残ったまま） */
html.ai-js:not(.ai-keep):not(.ai-ready) .main-header { opacity: 0; }
html.ai-js.ai-ready:not(.ai-keep) .main-header { animation: ai-fade-down .9s cubic-bezier(.22, 1, .36, 1) backwards; }
@keyframes ai-fade-down {
	from { opacity: 0; translate: 0 -10px; }
}

/* ------------------------------------------------------------ トップの写真・下層ページのカバー：少し寄った状態から静かに落ち着く */
html.ai-js .first-cover,
html.ai-js .acf-page-cover { overflow: hidden; }
html.ai-js.ai-ready .first-cover .wp-block-cover__image-background,
html.ai-js.ai-ready .acf-page-cover > img {
	animation: ai-settle 2.6s cubic-bezier(.22, 1, .36, 1) backwards;
}
@keyframes ai-settle {
	from { scale: 1.06; }
}
html.ai-js:not(.ai-ready) .first-cover h2,
html.ai-js:not(.ai-ready) .first-cover .scroll-down,
html.ai-js:not(.ai-ready) .acf-page-cover__jp-title,
html.ai-js:not(.ai-ready) main > .page-title { opacity: 0; }
html.ai-js.ai-ready .first-cover h2,
html.ai-js.ai-ready .acf-page-cover__jp-title,
html.ai-js.ai-ready main > .page-title {
	animation: ai-rise 1.4s cubic-bezier(.22, 1, .36, 1) .35s backwards;
}
html.ai-js.ai-ready .first-cover .scroll-down { animation: ai-fade 1.2s ease 1.3s backwards; }
@keyframes ai-rise {
	from { opacity: 0; translate: 0 14px; letter-spacing: .2em; }
}
@keyframes ai-fade {
	from { opacity: 0; }
}

/* ------------------------------------------------------------ スクロールで出す（motion.js が ai-up を付け、見えたら ai-in。出終わったらクラスを外す） */
html.ai-js .ai-up {
	opacity: 0;
	translate: 0 18px;
}
html.ai-js .ai-up.ai-flat { translate: none; }
html.ai-js .ai-up.ai-in {
	opacity: 1;
	translate: 0 0;
	transition: opacity 1s cubic-bezier(.33, 0, .2, 1), translate 1.1s cubic-bezier(.22, 1, .36, 1);
	transition-delay: var(--ai-d, 0s);
}

/* 施療の流れ：ステップが浮かんだあと、次の丸への点線が上から伸びる */
html.ai-js .acf-flow > li.ai-up::after { transform: scaleY(0); }
html.ai-js .acf-flow > li.ai-up.ai-in::after {
	transform: scaleY(1);
	transition: transform 1s cubic-bezier(.65, 0, .35, 1) calc(var(--ai-d, 0s) + .45s);
}

/* ------------------------------------------------------------ ヘッダーのカレントの項目（ホバーの下線を出したままに） */
@media only screen and (min-width: 1151px) {
	.main-header__nav > li.ai-current:not(:last-child) > a { color: #956859; }
	.main-header__nav > li.ai-current:not(:last-child) > a::after { transform: scaleX(1); }
	.main-header__nav > li.ai-current:last-child > a { background-color: #956859; }
}
@media only screen and (max-width: 1150px) {
	.main-header__nav > li.ai-current > a { color: #956859; }
}

/* ------------------------------------------------------------ 「動きを減らす」設定 */
@media (prefers-reduced-motion: reduce) {
	html.ai-js #ai-veil { display: none; }
	html.ai-js .main-header,
	html.ai-js .first-cover *,
	html.ai-js .acf-page-cover *,
	html.ai-js main > .page-title { animation: none !important; opacity: 1 !important; }
	html.ai-js .ai-up { opacity: 1; translate: none; }
}
