/* ==========================================================================
   互動作品嵌入（/portfolio/<slug>/）
   標記：<figure class="work-embed" data-src data-title> … 見 assets/js/works.js
   ========================================================================== */
.work-embed {
	--we-radius: var(--radius, 18px);
	--we-ease: var(--ease, cubic-bezier(.2, .7, .2, 1));
	display: block;
	margin: 0;
}

/* 文章內容欄只有 860px，互動作品需要更寬的畫面：置中放大到 1120px（窄螢幕自動回到欄寬） */
.prose .work-embed {
	width: min(1120px, calc(100vw - 2 * var(--gutter, 16px)));
	margin: 2.4em 0 2.4em 50%;
	transform: translateX(-50%);
}

/* ---- 畫面區 ---- */
.work-embed__stage {
	position: relative;
	isolation: isolate;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	border-radius: var(--we-radius);
	border: 1px solid var(--line, rgba(12, 13, 16, .12));
	background: var(--dark, #07080c);
	box-shadow: var(--shadow, 0 12px 32px -12px rgba(12, 13, 16, .18));
}
/* 手機：未開始時維持 16:10 的封面，開始後拉高成直式，作品的手機版面才排得開 */
@media (max-width: 720px) {
	.work-embed.is-live .work-embed__stage {
		aspect-ratio: auto;
		height: min(80vh, 760px);
		height: clamp(540px, 80svh, 760px);
	}
	.work-embed__cta { padding-bottom: 14px; }
	.work-embed__tag { left: 10px; top: 10px; }
}

.work-embed__poster {
	position: absolute;
	inset: 0;
	z-index: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border-radius: 0;
	object-fit: cover;
	object-position: top center;
	transition: transform .9s var(--we-ease), opacity .4s;
}
.work-embed:not(.is-live) .work-embed__stage { cursor: pointer; }
.work-embed:not(.is-live) .work-embed__stage:hover .work-embed__poster { transform: scale(1.025); }
.work-embed:not(.is-live) .work-embed__stage::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	pointer-events: none;
	background: linear-gradient(180deg, rgba(7, 8, 12, .1) 0%, rgba(7, 8, 12, .28) 45%, rgba(7, 8, 12, .7) 100%);
}

.work-embed__tag {
	position: absolute;
	left: 16px;
	top: 16px;
	z-index: 2;
	padding: 5px 12px;
	border-radius: 999px;
	background: var(--yellow, #f2b630);
	color: var(--ink, #0c0d10);
	font-size: 13px;
	font-weight: 700;
	line-height: 1.5;
	letter-spacing: .06em;
}

.work-embed__cta {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	padding: 0 16px clamp(24px, 6%, 56px);
	pointer-events: none;
}
.work-embed__cta .btn { pointer-events: auto; }

/* 沒有 JS 時不顯示按鈕，只留「新分頁開啟」 */
.work-embed__start { display: none; }
.js .work-embed__start { display: inline-flex; }
.work-embed__start::before {
	content: "";
	width: 0;
	height: 0;
	border-left: 11px solid currentColor;
	border-top: 7px solid transparent;
	border-bottom: 7px solid transparent;
	margin-right: -2px;
}

/* ---- 載入中與已載入 ---- */
.work-embed__frame {
	position: absolute;
	inset: 0;
	z-index: 1;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border: 0;
	border-radius: 0;
	background: #fff;
	opacity: 1;
	transition: opacity .35s;
}
.work-embed.is-live .work-embed__cta,
.work-embed.is-live .work-embed__tag { display: none; }
.work-embed.is-live.is-loading .work-embed__frame { opacity: 0; }
.work-embed.is-live:not(.is-loading) .work-embed__poster { visibility: hidden; }
.work-embed.is-live.is-loading .work-embed__stage::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	z-index: 3;
	width: 38px;
	height: 38px;
	margin: -19px 0 0 -19px;
	border-radius: 50%;
	border: 3px solid rgba(255, 255, 255, .28);
	border-top-color: #fff;
	animation: we-spin .8s linear infinite;
}
@keyframes we-spin { to { transform: rotate(360deg); } }

/* ---- 工具列 ---- */
.work-embed__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px 16px;
	margin-top: 14px;
}
.work-embed__title {
	flex: 1 1 220px;
	min-width: 0;
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.5;
	color: var(--ink, #0c0d10);
}
.work-embed__title small {
	display: block;
	font-size: 13px;
	font-weight: 400;
	color: var(--muted, #6a6e78);
}
.work-embed__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.work-embed__actions .btn { text-decoration: none; }
.prose .work-embed__actions a.btn { text-decoration: none; color: var(--b-fg); }

/* ---- 全螢幕 ---- */
.work-embed__exit { display: none; position: absolute; right: 14px; top: 14px; z-index: 4; }
.work-embed.is-fs .work-embed__exit { display: inline-flex; }
.work-embed.is-fs .work-embed__stage {
	width: 100%;
	height: 100%;
	aspect-ratio: auto;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

.work-embed figcaption {
	margin-top: 10px;
	font-size: 14px;
	line-height: 1.7;
	color: var(--muted, #6a6e78);
	text-align: left;
}

@media (prefers-reduced-motion: reduce) {
	.work-embed__poster, .work-embed__frame { transition: none; }
	.work-embed.is-live.is-loading .work-embed__stage::after { animation-duration: 2.4s; }
}
