/**
 * トップの動画：中央を大きく、左右に他の動画が見える表示（お試し。読み込み条件は top-peek.php）
 *
 * 大きさは中央の動画の高さ（--jh-peek-h）から計算する。画面の高さが足りないときは、
 * 下のバーと矢印まで 1 画面に収まるように小さくなる。
 * --jh-peek-reserved は、ヘッダー・上の説明文・バー・下の余白に残す高さ。
 */
body.home {
	overflow-x: clip; /* 画面幅いっぱいに広げた分のスクロールバーを出さない */
}

.jh-peek {
	position: relative;
	width: 100vw;
	margin-left: calc(50% - 50vw);
	padding: 8px 2vw 0;
	box-sizing: border-box;
}

.jh-peek__inner {
	--jh-peek-reserved: 205px;
	--jh-peek-min-h: 280px;
	/* 幅から決まる高さ（画面幅の 42.12%、最大 737px）と、画面の高さから決まる高さの小さいほう */
	--jh-peek-h: min(42.12vw, 737px, max(calc(100vh - var(--jh-peek-reserved)), var(--jh-peek-min-h)));
	--jh-peek-h: min(42.12vw, 737px, max(calc(100svh - var(--jh-peek-reserved)), var(--jh-peek-min-h)));
	--jh-peek-center-w: calc(var(--jh-peek-h) * 16 / 9);
	--jh-peek-near-w: calc(var(--jh-peek-center-w) * 0.0769); /* 中央の次のカード */
	--jh-peek-far-w: calc(var(--jh-peek-center-w) * 0.0385); /* 一番外側のカード */
	--jh-peek-gap: calc(var(--jh-peek-center-w) * 0.0128);
	max-width: 1680px;
	margin-inline: auto;
}

.jh-peek__stage {
	position: relative;
	height: var(--jh-peek-h);
	touch-action: pan-y;
}

.jh-peek__card {
	position: absolute;
	overflow: hidden;
	margin: 0;
	background: #1c1c28;
	box-shadow: 0 10px 28px rgba(20, 20, 40, 0.16);
	transition:
		left 0.6s cubic-bezier(0.22, 0.8, 0.24, 1),
		width 0.6s cubic-bezier(0.22, 0.8, 0.24, 1),
		top 0.6s cubic-bezier(0.22, 0.8, 0.24, 1),
		height 0.6s cubic-bezier(0.22, 0.8, 0.24, 1),
		border-radius 0.6s ease,
		opacity 0.4s ease;
}

/* 並び：中央を基準に左右へ置く。高さは中央 100%、その次 84%、一番外側 68%（上下中央にそろえる） */
.jh-peek__card[data-slot="0"] {
	top: 0;
	left: calc(50% - var(--jh-peek-center-w) / 2);
	width: var(--jh-peek-center-w);
	height: 100%;
	border-radius: 22px;
	z-index: 2;
}

.jh-peek__card[data-slot="-1"],
.jh-peek__card[data-slot="1"] {
	top: 8%;
	width: var(--jh-peek-near-w);
	height: 84%;
	border-radius: 18px;
	opacity: 0.75; /* 白い背景に少し溶け込ませて、中央の動画を目立たせる */
}

.jh-peek__card[data-slot="-1"] {
	left: calc(50% - var(--jh-peek-center-w) / 2 - var(--jh-peek-gap) - var(--jh-peek-near-w));
}

.jh-peek__card[data-slot="1"] {
	left: calc(50% + var(--jh-peek-center-w) / 2 + var(--jh-peek-gap));
}

.jh-peek__card[data-slot="-2"],
.jh-peek__card[data-slot="2"] {
	top: 16%;
	width: var(--jh-peek-far-w);
	height: 68%;
	border-radius: 999px;
	opacity: 0.55; /* 一番目立たせない */
}

/* マウスを乗せる・キーボードで選ぶと濃く戻り、押せることが分かる */
.jh-peek__card:is([data-slot="-2"], [data-slot="-1"], [data-slot="1"], [data-slot="2"]):is(:hover, :focus-within) {
	opacity: 1;
}

.jh-peek__card[data-slot="-2"] {
	left: calc(50% - var(--jh-peek-center-w) / 2 - var(--jh-peek-gap) * 2 - var(--jh-peek-near-w) - var(--jh-peek-far-w));
}

.jh-peek__card[data-slot="2"] {
	left: calc(50% + var(--jh-peek-center-w) / 2 + var(--jh-peek-gap) * 2 + var(--jh-peek-near-w));
}

.jh-peek__card[data-slot="hidden"] {
	top: 16%;
	left: 50%;
	width: var(--jh-peek-far-w);
	height: 68%;
	opacity: 0;
	pointer-events: none;
	visibility: hidden;
}

.jh-peek__poster {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

/* 中央の動画だけにボタンを出す。ポスターの画像に題名が入っているので、題名の文字は読み上げ用にして重ねない */
.jh-peek__info {
	position: absolute;
	inset: auto auto 0 0;
	z-index: 1;
	padding: 0 clamp(16px, 2.4vw, 36px) clamp(14px, 2vw, 30px);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.jh-peek__card[data-slot="0"] .jh-peek__info {
	opacity: 1;
	visibility: visible;
	transition-delay: 0.25s;
}

/* 指で動かしている間は「動画を再生」を隠す */
.jh-peek.is-dragging .jh-peek__card .jh-peek__info {
	opacity: 0;
	visibility: hidden;
	transition-delay: 0s;
}

.jh-peek__title {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.jh-peek__play {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 18px;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.4;
	color: #1c1c28;
	background: #fff;
	border-radius: 999px;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.jh-peek__play::before {
	content: "";
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 5px 0 5px 9px;
	border-color: transparent transparent transparent currentColor;
}

/* カード全体が押せる。左右のカードは中央へ移動、中央のカードは再生 */
.jh-peek__action {
	position: absolute;
	inset: 0;
	z-index: 3;
	width: 100%;
	height: 100%;
	padding: 0;
	cursor: pointer;
	background: transparent;
	border: 0;
	border-radius: inherit;
}

.jh-peek__action:focus-visible {
	outline: 3px solid #fff;
	outline-offset: -5px;
}

/* 下のバー（リニューアルサイトの動画一覧と同じ作り）。中央の動画と同じ幅にそろえる */
.jh-peek__progress {
	display: flex;
	align-items: center;
	gap: 18px;
	width: var(--jh-peek-center-w);
	margin: 22px auto 0;
}

.jh-peek__bar {
	flex: 1;
	height: 2px;
	overflow: hidden;
	background: rgba(28, 28, 40, 0.16);
	border-radius: 2px;
}

.jh-peek__bar span {
	display: block;
	height: 100%;
	background: var(--vk-color-primary, #5b43d6);
	border-radius: 2px;
	transition: transform 0.6s cubic-bezier(0.22, 0.8, 0.24, 1);
}

.jh-peek__num {
	font-size: 13px;
	letter-spacing: 0.14em;
	color: #4a4a58;
	white-space: nowrap;
}

.jh-peek__arrow {
	flex: none;
	width: 44px;
	height: 44px;
	padding: 0;
	font-size: 16px;
	line-height: 1;
	color: #1c1c28;
	cursor: pointer;
	background: transparent;
	border: 1.5px solid rgba(28, 28, 40, 0.3);
	border-radius: 50%;
	transition: background 0.3s, border-color 0.3s;
}

.jh-peek__arrow + .jh-peek__arrow {
	margin-left: -8px;
}

.jh-peek__arrow:hover {
	background: rgba(28, 28, 40, 0.07);
	border-color: rgba(28, 28, 40, 0.6);
}

.jh-peek__arrow:focus-visible {
	outline: 2px solid var(--vk-color-primary, #5b43d6);
	outline-offset: 2px;
}

.jh-peek__frame {
	position: absolute;
	inset: 0;
	z-index: 4;
	width: 100%;
	height: 100%;
	border: 0;
}

.jh-peek__noscript {
	margin: 8px 0 0;
	text-align: center;
}

/* スマホ：中央を画面幅の 81.2% に。左右は画面の端まで使う */
@media (max-width: 767.98px) {
	.jh-peek {
		padding: 4px 0 0;
	}

	.jh-peek__inner {
		--jh-peek-reserved: 190px;
		--jh-peek-min-h: 170px;
		--jh-peek-h: min(45.675vw, max(calc(100vh - var(--jh-peek-reserved)), var(--jh-peek-min-h)));
		--jh-peek-h: min(45.675vw, max(calc(100svh - var(--jh-peek-reserved)), var(--jh-peek-min-h)));
		--jh-peek-near-w: calc(var(--jh-peek-center-w) * 0.0616);
		--jh-peek-far-w: calc(var(--jh-peek-center-w) * 0.0246);
		--jh-peek-gap: calc(var(--jh-peek-center-w) * 0.0148);
	}

	.jh-peek__card[data-slot="0"] { border-radius: 14px; }

	.jh-peek__card[data-slot="-1"],
	.jh-peek__card[data-slot="1"] { border-radius: 10px; }

	.jh-peek__info {
		padding: 0 10px 10px;
	}

	.jh-peek__progress {
		gap: 12px;
		margin-top: 14px;
	}

	.jh-peek__num {
		font-size: 12px;
	}

	.jh-peek__arrow {
		width: 38px;
		height: 38px;
		font-size: 14px;
	}

	.jh-peek__arrow + .jh-peek__arrow {
		margin-left: -4px;
	}

	.jh-peek__play {
		padding: 4px 12px;
		font-size: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.jh-peek__card,
	.jh-peek__info,
	.jh-peek__bar span {
		transition: none;
	}
}
