/**
 * お客様の声: お手紙を 1 通ずつ、スクロールに合わせて見せる。
 *
 * 動きの進み具合は voice-story.js が CSS 変数で渡す。
 *   --vs-in   場面に入った度合い（0 → 1）
 *   --vs-out  場面から去った度合い（0 → 1）
 *   --vs-q    段落が現れた度合い（0 → 1）
 *   --vs-scroll  ページ全体の進み具合（0 → 1）。周りの光の視差に使う
 *
 * **隠す指定・動かす指定は、すべて .vs.is-live の下に置く。** is-live は
 * JavaScript が動き出してから付くので、届かなければ最初から全部見える。
 *
 * 色は淡く明るく。写真（手紙）より周りが前に出ないようにする
 * （運用者の意向。写真は主張させない、ふんわりした雰囲気が好まれる）。
 */

@property --vs-sky-1 {
	syntax: '<color>';
	inherits: true;
	initial-value: #dff5ea;
}

@property --vs-sky-2 {
	syntax: '<color>';
	inherits: true;
	initial-value: #fff3ea;
}

@property --vs-sky-3 {
	syntax: '<color>';
	inherits: true;
	initial-value: #fdf8e4;
}

.vs {
	--vs-text: #4a5551;
	--vs-green: #0d9c6f;
	--vs-green-text: #08704f;

	position: relative;
	/* 画面の幅いっぱいに広げる。はみ出しは clip で切る（sticky を壊さない）。 */
	width: 100vw;
	margin-left: calc(50% - 50vw);
	overflow-x: clip;
	padding: 40px 0 60px;
	color: var(--vs-text);
	background:
		radial-gradient(120% 60% at 15% 10%, var(--vs-sky-1), transparent 70%),
		radial-gradient(100% 60% at 85% 50%, var(--vs-sky-2), transparent 70%),
		radial-gradient(120% 70% at 30% 95%, var(--vs-sky-3), transparent 70%),
		#fbfdfc;
	transition: --vs-sky-1 1.6s ease, --vs-sky-2 1.6s ease, --vs-sky-3 1.6s ease;
}

/* ---------------------------------------------------------------------------
   はじめの一文
   ------------------------------------------------------------------------ */

.vs-intro {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 18px;
	margin: 0 auto 40px;
	padding: 0 20px;
	text-align: center;
}

.vs-intro-lead {
	font-size: 18px;
	letter-spacing: 0.12em;
	line-height: 2;
	color: var(--vs-text);
}

.vs-cue {
	display: none;
}

/* ---------------------------------------------------------------------------
   場面（手紙 1 通ぶん）

   手紙が上、その下に「〇〇様より」とコメント。動かすときは手紙を画面の
   上に留め、その下をコメントが流れていく。コメントを読み終えると、
   手紙ごとスクロールして次の場面へ移る（2026-09-30 運用者の指示）。
   ------------------------------------------------------------------------ */

.vs-scene {
	position: relative;
	z-index: 1;
	max-width: 760px;
	margin: 0 auto 100px;
	padding: 0 40px;
}

.vs-letter {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* 手紙の後ろの柔らかな光。 */
.vs-letter::before {
	content: '';
	position: absolute;
	inset: -12%;
	z-index: -1;
	border-radius: 50%;
	background: radial-gradient(closest-side, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.4) 55%, rgba(255, 255, 255, 0) 100%);
}

.vs-paper {
	--vs-tilt: -2.5deg;

	margin: 0;
	padding: 12px 12px 18px;
	background: #fff;
	border-radius: 3px;
	box-shadow:
		0 24px 60px rgba(60, 100, 85, 0.18),
		0 3px 8px rgba(0, 0, 0, 0.06);
	transform: rotate(var(--vs-tilt));
}

.vs-scene:nth-of-type(even) .vs-paper {
	--vs-tilt: 2.5deg;
}

.vs-paper p {
	margin: 0;
}

.vs-paper img {
	display: block;
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: 46vh;
	border-radius: 1px;
}

/* ---------------------------------------------------------------------------
   代表のコメント
   ------------------------------------------------------------------------ */

.vs-words {
	max-width: 640px;
	margin: 0 auto;
	padding: 36px 0 0;
}

.vs-category {
	margin: 0 0 6px;
	font-size: 13px;
	letter-spacing: 0.1em;
	color: var(--vs-green-text);
}

.vs .vs-from {
	margin: 0 0 22px;
	font-size: 26px;
	font-weight: 600;
	letter-spacing: 0.12em;
	line-height: 1.5;
	color: var(--vs-text);
}

.vs .vs-line {
	margin: 0 0 1.6em;
	font-size: 15px;
	line-height: 2.1;
	letter-spacing: 0.04em;
	text-shadow: 0 0 12px rgba(255, 255, 255, 0.9);
}

/* ---------------------------------------------------------------------------
   周りの演出（JavaScript が中身を置く）
   ------------------------------------------------------------------------ */

.vs-ambience {
	display: none;
}

.vs.is-live .vs-ambience {
	position: sticky;
	top: 0;
	z-index: 0;
	display: block;
	height: 100vh;
	margin-bottom: -100vh;
	overflow: hidden;
	pointer-events: none;
}

.vs-sky {
	position: absolute;
	inset: 0;
}

.vs-glow {
	position: absolute;
	width: 60vmax;
	height: 60vmax;
	border-radius: 50%;
	opacity: 0.8;
	animation: vs-glow-drift 26s ease-in-out infinite alternate;
}

.vs-glow-a {
	top: -20vmax;
	left: -15vmax;
	background: radial-gradient(closest-side, var(--vs-sky-1), transparent);
}

.vs-glow-b {
	top: 20vh;
	right: -25vmax;
	background: radial-gradient(closest-side, var(--vs-sky-2), transparent);
	animation-duration: 32s;
	animation-direction: alternate-reverse;
}

.vs-glow-c {
	bottom: -30vmax;
	left: 20vw;
	background: radial-gradient(closest-side, var(--vs-sky-3), transparent);
	animation-duration: 38s;
}

@keyframes vs-glow-drift {
	from {
		transform: translate(0, 0) scale(1);
	}
	to {
		transform: translate(6vw, 4vh) scale(1.15);
	}
}

/* 光の玉。奥のものほどゆっくり、スクロールに遅れて動く。 */
.vs-bokeh {
	position: absolute;
	border-radius: 50%;
	opacity: var(--vs-alpha);
	background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.45) 45%, rgba(255, 255, 255, 0) 72%);
	box-shadow: 0 0 24px rgba(255, 255, 255, 0.55);
	translate: 0 calc(var(--vs-scroll, 0) * var(--vs-depth) * -45vh);
	animation: vs-float var(--vs-drift) ease-in-out var(--vs-delay) infinite alternate;
}

.vs-bokeh:nth-child(3n) {
	background: radial-gradient(circle at 35% 35%, rgba(233, 250, 241, 1), rgba(196, 236, 216, 0.5) 45%, rgba(196, 236, 216, 0) 72%);
}

.vs-bokeh:nth-child(4n) {
	background: radial-gradient(circle at 35% 35%, rgba(255, 244, 236, 1), rgba(255, 222, 206, 0.5) 45%, rgba(255, 222, 206, 0) 72%);
}

.vs-bokeh:nth-child(5n) {
	background: radial-gradient(circle at 35% 35%, rgba(255, 251, 226, 1), rgba(252, 238, 176, 0.5) 45%, rgba(252, 238, 176, 0) 72%);
}

@keyframes vs-float {
	0% {
		transform: translate(0, 0) scale(1);
	}
	50% {
		transform: translate(18px, -26px) scale(1.06);
	}
	100% {
		transform: translate(-14px, -52px) scale(0.96);
	}
}

/* きらめき。4 つの先をもつ小さな星。 */
.vs-sparkle {
	position: absolute;
	width: var(--vs-size);
	height: var(--vs-size);
	background: linear-gradient(135deg, #fff, #fff6cf);
	clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
	filter: drop-shadow(0 0 4px rgba(255, 246, 200, 0.9));
	animation: vs-twinkle var(--vs-twinkle) ease-in-out var(--vs-delay) infinite;
}

@keyframes vs-twinkle {
	0%,
	100% {
		opacity: 0;
		transform: scale(0.3) rotate(0deg);
	}
	50% {
		opacity: 1;
		transform: scale(1) rotate(45deg);
	}
}

/* ---------------------------------------------------------------------------
   動かすとき（.vs.is-live）
   ------------------------------------------------------------------------ */

.vs.is-live {
	padding-top: 0;
}

.vs.is-live .vs-intro {
	justify-content: center;
	min-height: 70vh;
	margin-bottom: 0;
}

.vs.is-live .vs-cue {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	font-size: 11px;
	letter-spacing: 0.3em;
	color: var(--vs-green-text);
}

.vs.is-live .vs-cue::after {
	content: '';
	width: 1px;
	height: 48px;
	background: linear-gradient(to bottom, currentColor, transparent);
	transform-origin: top;
	animation: vs-cue 2.4s ease-in-out infinite;
}

@keyframes vs-cue {
	0% {
		transform: scaleY(0);
		opacity: 1;
	}
	60% {
		transform: scaleY(1);
		opacity: 1;
	}
	100% {
		transform: scaleY(1);
		opacity: 0;
	}
}

.vs.is-live .vs-scene {
	margin-bottom: 0;
	padding-bottom: 30vh;
}

/* 手紙は画面の上に留まる。場面の終わり（コメントの最後）まで来ると、
   留めが外れて手紙ごと上へ流れていく。 */
.vs.is-live .vs-letter {
	position: sticky;
	top: 3vh;
	height: 50vh;
}

.vs.is-live .vs-words {
	padding-top: 42vh;
}

/* 手紙: 下から傾いて浮かび上がり、ぼかしが解けて止まる。
   去るときはスクロールに乗って上へ流れ、少しずつ薄れる。 */
.vs.is-live .vs-paper {
	opacity: calc(var(--vs-in, 0) * (1 - var(--vs-out, 0) * 0.85));
	transform:
		translate3d(0, calc((1 - var(--vs-in, 0)) * 34vh), 0)
		rotate(calc(var(--vs-tilt) + (1 - var(--vs-in, 0)) * -10deg))
		scale(calc(0.84 + var(--vs-in, 0) * 0.16));
	filter: blur(calc((1 - var(--vs-in, 0)) * 8px));
	will-change: transform, opacity, filter;
}

.vs.is-live .vs-letter::before {
	opacity: calc(var(--vs-in, 0) * (1 - var(--vs-out, 0)));
	transform: scale(calc(0.6 + var(--vs-in, 0) * 0.5));
}

/* コメント: 段落ごとに、ぼかしが解けながら浮かび上がる。 */
.vs.is-live .vs-from,
.vs.is-live .vs-line,
.vs.is-live .vs-category {
	opacity: var(--vs-q, 0);
	transform: translate3d(0, calc((1 - var(--vs-q, 0)) * 28px), 0);
	filter: blur(calc((1 - var(--vs-q, 0)) * 5px));
}

/* 写真に重なるところから消える。段落ごとではなく、写真の下端（--vs-cut）
   の位置で切る。境目は 32px かけて淡くする。 */
.vs.is-live .vs-words {
	-webkit-mask-image: linear-gradient(to bottom, transparent calc(var(--vs-cut, -100px) - 8px), #000 calc(var(--vs-cut, -100px) + 24px));
	mask-image: linear-gradient(to bottom, transparent calc(var(--vs-cut, -100px) - 8px), #000 calc(var(--vs-cut, -100px) + 24px));
}

/* ---------------------------------------------------------------------------
   狭い画面
   ------------------------------------------------------------------------ */

@media (max-width: 767px) {
	.vs-scene {
		padding: 0 20px;
	}

	.vs .vs-from {
		font-size: 22px;
	}

	.vs-intro-lead {
		font-size: 16px;
	}

	/* スマホはヘッダー（高さ 50px）が上に固定されているので、その下に留める。 */
	.vs.is-live .vs-letter {
		top: 58px;
		height: 44vh;
	}

	.vs.is-live .vs-paper img {
		max-height: 40vh;
	}

	.vs.is-live .vs-words {
		padding-top: 36vh;
	}
}
