/**
 * 카드뉴스 숏폼 플레이어 — YouTube Shorts / Instagram Reels 스타일.
 *
 * PHP(짧은.php)가 그려 놓은 마크업 위에서 동작한다.
 *  - 자동 재생은 음소거 상태로만(브라우저 정책). 소리 버튼으로 해제한다.
 *  - 상단 진행 막대는 슬라이드 수 기준으로 움직이며, 실제 영상 길이에서
 *    한 장 길이를 계산한다(장당 초 설정과 어긋나지 않게).
 *  - 세로 화면에 꽉 차게, 가로 화면에서는 중앙 정렬로 제한한다.
 */

.scnm-reels {
	--scnm-reels-max: min(420px, 100%);
	margin: 0 auto 18px;
	width: 100%;
	display: flex;
	justify-content: center;
	background: #000;
}

.scnm-reels-stage {
	position: relative;
	width: 100%;
	max-width: var(--scnm-reels-max);
	aspect-ratio: 9 / 16;
	max-height: 82vh;
	background: #000;
	border-radius: 14px;
	overflow: hidden;
	/* 세로 화면 Notch/홈바 영역을 침범하지 않게 */
	padding-bottom: env(safe-area-inset-bottom, 0px);
}

.scnm-reels-video {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	background: #000;
}

/* ── 컨트롤(오른쪽 세로) ──────────────────────────────────────────── */
.scnm-reels-chrome {
	position: absolute;
	right: 8px;
	bottom: 44px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	z-index: 2;
}

.scnm-reels-btn {
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.45);
	color: #fff;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	transition: background 0.15s ease;
}

.scnm-reels-btn:hover,
.scnm-reels-btn:focus-visible {
	background: rgba(0, 0, 0, 0.72);
	outline: none;
}

/* 재생 상태에 따라 두 아이콘을 갈아 끼운다 */
.scnm-reels-icon-play::before { content: "\25B6"; }
.scnm-reels-icon-pause::before { content: "\275A\275A"; letter-spacing: 1px; }

.scnm-reels-stage.is-paused .scnm-reels-icon-play { display: block; }
.scnm-reels-stage.is-paused .scnm-reels-icon-pause { display: none; }
.scnm-reels-stage:not(.is-paused) .scnm-reels-icon-play { display: none; }
.scnm-reels-stage:not(.is-paused) .scnm-reels-icon-pause { display: block; }

.scnm-reels-icon-sound::before { content: "\1F50A"; }
.scnm-reels-icon-muted::before { content: "\1F507"; }

.scnm-reels-stage.is-muted .scnm-reels-icon-sound { display: none; }
.scnm-reels-stage.is-muted .scnm-reels-icon-muted { display: block; }
.scnm-reels-stage:not(.is-muted) .scnm-reels-icon-sound { display: block; }
.scnm-reels-stage:not(.is-muted) .scnm-reels-icon-muted { display: none; }

/* ── 상단 진행 막대 ────────────────────────────────────────────────── */
.scnm-reels-progress {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	display: flex;
	gap: 3px;
	padding: 8px 8px 0;
	z-index: 2;
}

.scnm-reels-bar {
	flex: 1 1 0;
	height: 3px;
	border-radius: 2px;
	background: rgba(255, 255, 255, 0.3);
	overflow: hidden;
}

/* 너비(0~100%)는 JS 가 timeupdate 때 인라인으로 채운다. */
.scnm-reels-bar::after {
	content: "";
	display: block;
	height: 100%;
	width: 0;
	border-radius: 2px;
	background: #fff;
	transition: width 0.12s linear;
}

/* 활성 막대는 바 전체를 그라데이션으로 채운다(인라인 스타일). */
.scnm-reels-bar.is-active {
	background: rgba(255, 255, 255, 0.3);
}

.scnm-reels-bar.is-active::after { display: none; }

/* ── 힌트/안내 ─────────────────────────────────────────────────────── */
.scnm-reels-hint {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 14px;
	text-align: center;
	font-size: 12px;
	color: rgba(255, 255, 255, 0.82);
	background: rgba(0, 0, 0, 0.4);
	padding: 4px 8px;
	border-radius: 20px;
	margin: 0 auto;
	width: fit-content;
	max-width: 90%;
	z-index: 2;
	transition: opacity 0.3s ease;
}

.scnm-reels-stage.is-engaged .scnm-reels-hint { opacity: 0; }

/* 자동 재생이 막힌 상태 — 안내를 남기고 손님 조작을 기다린다 */
.scnm-reels-stage.is-blocked .scnm-reels-hint::after {
	content: " · 화면을 눌러 재생";
	font-weight: 700;
}

/* 화면 전체를 눌러 재생/일시정지 (버튼 위 클릭은 무시) */
.scnm-reels-stage::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	cursor: pointer;
}

.scnm-reels-btn,
.scnm-reels-hint { z-index: 3; }

/* ── 다크모드(카드 배경이 밝은 테마 대비) ───────────────────────────── */
body.dark-mode .scnm-reels-stage {
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

/* ── 접근성: 동작 줄이기 설정 존중 ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
	.scnm-reels-bar::after { transition: none; }
	.scnm-reels-hint { transition: none; }
}

/* ── 좁은 화면 ─────────────────────────────────────────────────────── */
@media (max-width: 480px) {
	.scnm-reels-stage {
		max-width: 100%;
		max-height: 78vh;
		border-radius: 10px;
	}
	.scnm-reels-chrome { right: 6px; bottom: 40px; }
	.scnm-reels-btn { width: 38px; height: 38px; font-size: 17px; }
}