/* YT Mini Player */

:root {
	/* 位置・サイズはここで調整（テーマの固定フッターと重なる場合は bottom を増やす） */
	--ytmp-right: 16px;
	--ytmp-bottom: 16px;
	--ytmp-width: 400px;
	--ytmp-bottom-sp: 80px;
	--ytmp-width-sp: 60vw;
}

.ytmp-slot {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
}

.ytmp-box {
	position: absolute;
	inset: 0;
}

.ytmp-box iframe {
	position: absolute;
	inset: 0;
	width: 100% !important;
	height: 100% !important;
	border: 0;
}

/* ブロックエディタの埋め込み（16:9の余白トリック）と高さが二重にならないように */
.wp-block-embed__wrapper:has(> .ytmp-slot)::before {
	content: none !important;
	display: none !important;
}

/* 浮いている間、元の位置に残る枠 */
.ytmp-slot.is-floating {
	background: #f3f3f3;
	border-radius: 8px;
}

.ytmp-slot.is-floating .ytmp-box {
	position: fixed;
	inset: auto;
	right: var(--ytmp-right);
	bottom: calc(var(--ytmp-bottom) + env(safe-area-inset-bottom, 0px));
	width: min(var(--ytmp-width), calc(100vw - 32px));
	aspect-ratio: inherit;
	z-index: 99999;
	background: #000;
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.ytmp-slot.is-floating .ytmp-box iframe {
	border-radius: 8px;
}

@media (prefers-reduced-motion: no-preference) {
	.ytmp-slot.is-floating .ytmp-box {
		animation: ytmp-in 0.2s ease-out;
	}
}

@keyframes ytmp-in {
	from { opacity: 0; transform: translateY(12px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* 閉じるボタン（YouTube側の右上アイコンと重ならないよう枠の外側に配置） */
.ytmp-close {
	display: none;
	position: absolute;
	top: -12px;
	right: -12px;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #fff;
	color: #333;
	font-size: 18px;
	line-height: 28px;
	text-align: center;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
	z-index: 1;
}

.ytmp-slot.is-floating .ytmp-close {
	display: block;
}

@media (max-width: 600px) {
	.ytmp-slot.is-floating .ytmp-box {
		bottom: calc(var(--ytmp-bottom-sp) + env(safe-area-inset-bottom, 0px));
		width: var(--ytmp-width-sp);
	}
}
