/**
 * YS Shorts Widget — Stylesheet
 *
 * @package YS_Shorts_Widget
 * @version 1.1.7
 */

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
.ys-shorts-shell *,
.ys-shorts-shell *::before,
.ys-shorts-shell *::after {
	box-sizing: border-box;
}

/* ── Shell ────────────────────────────────────────────────────────────────── */
.ys-shorts-shell {
	position: relative;
	display: flex;
	align-items: center;
	gap: 14px;
	width: 100%;
	max-width: 100%;
	overflow: hidden;   /* FIX #3: cegah keluar batas section */
	padding-bottom: 2px;
}

/* ── Track ────────────────────────────────────────────────────────────────── */
.ys-shorts-track {
	display: flex;
	gap: var(--ys-gap, 24px);
	overflow-x: auto;
	overflow-y: visible;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-ms-overflow-style: none;
	padding: 6px 4px 16px;
	flex: 1;
	min-width: 0;       /* FIX #3: penting di flex child */
	width: 100%;
}

.ys-shorts-track::-webkit-scrollbar { display: none; }

/* ── Short Card ───────────────────────────────────────────────────────────── */
.ys-short-card {
	position: relative;
	flex: 0 0 var(--ys-card-width, calc((100% - 72px) / 4));
	min-width: 200px;
	border-radius: 20px;
	overflow: hidden;
	cursor: pointer;
	background: #1a1a2e;
	transition: transform 0.28s ease, box-shadow 0.28s ease;
	-webkit-tap-highlight-color: transparent;
	outline-offset: 3px;
}

.ys-short-card:focus-visible { outline: 3px solid #3b82f6; }

.ys-short-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 28px 60px rgba(2,10,20,.18) !important;
}

/* ── Media ────────────────────────────────────────────────────────────────── */
.ys-short-media {
	position: relative;
	width: 100%;
	aspect-ratio: 9/16;
	overflow: hidden;
}

.ys-short-media img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.4s ease;
}

.ys-short-card:hover .ys-short-media img { transform: scale(1.04); }

/* ── Overlay ──────────────────────────────────────────────────────────────── */
.ys-short-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,.35);
	/* Mode default: play button di tengah */
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.25s ease;
}

.ys-short-card:hover .ys-short-overlay { background: rgba(0,0,0,.22); }

/* FIX #2: Mode posisi kustom — play button ikuti --play-top */
.ys-short-overlay.is-custom {
	align-items: flex-start;
	justify-content: center;
	padding-top: var(--play-top, 30%);
}

/* ── Play Button ──────────────────────────────────────────────────────────── */
.ys-play-btn {
	--play-bg:           rgba(255,255,255,.15);
	--play-border-color: rgba(255,255,255,.85);
	--play-icon-color:   #ffffff;

	display: flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	border-radius: 50%;
	border-style: solid;
	border-width: 2px;
	border-color: var(--play-border-color);
	background: var(--play-bg);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	transition: transform 0.25s ease, filter 0.25s ease;
	flex-shrink: 0;
}

.ys-play-btn svg {
	width: 40%;
	height: 40%;
	flex-shrink: 0;
	margin-left: 3px;
	fill: var(--play-icon-color);
	color: var(--play-icon-color);
}

.ys-short-card:hover .ys-play-btn {
	transform: scale(1.12);
	filter: brightness(1.18);
}

/* ── Tombol Panah ─────────────────────────────────────────────────────────── */
.ys-shorts-arrow {
	flex: 0 0 auto;
	flex-shrink: 0;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	border: 1px solid rgba(15,23,42,.10);
	background: rgba(255,255,255,.92);
	box-shadow: 0 18px 55px rgba(2,10,20,.12);
	color: #0f172a;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .25s ease, box-shadow .25s ease, opacity .25s ease;
	padding: 0;
	z-index: 2;
}

.ys-shorts-arrow svg { width: 10px; height: 18px; }

.ys-shorts-arrow:hover {
	transform: translateY(-2px);
	box-shadow: 0 24px 70px rgba(2,10,20,.16);
}

.ys-shorts-arrow:focus-visible { outline: 3px solid #3b82f6; outline-offset: 2px; }

.ys-shorts-arrow.is-hidden { opacity: 0; pointer-events: none; }

/* ── Fade gradient kanan ──────────────────────────────────────────────────── */
.ys-shorts-shell.has-fade::after {
	content: "";
	position: absolute;
	right: 60px;
	top: 0; bottom: 0;
	width: 80px;
	pointer-events: none;
	background: linear-gradient(90deg,
		rgba(245,249,255,0),
		var(--ys-fade-color, rgba(245,249,255,.95))
	);
	border-radius: 0 20px 20px 0;
	z-index: 1;
}

/* ── Modal Video ──────────────────────────────────────────────────────────── */
.ys-video-modal {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(2,10,20,.60);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	z-index: 99999;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.ys-video-modal.is-open {
	display: flex;
	animation: ysModalFadeIn 0.22s ease forwards;
}

@keyframes ysModalFadeIn {
	from { opacity: 0; }
	to   { opacity: 1; }
}

.ys-video-modal-inner {
	position: relative;
	width: 100%;
	max-width: 420px;
	transition: max-width 0.2s ease;
	animation: ysModalSlideUp 0.28s cubic-bezier(.22,1,.36,1) forwards;
}

@keyframes ysModalSlideUp {
	from { transform: translateY(24px); opacity: 0; }
	to   { transform: translateY(0);    opacity: 1; }
}

/* FIX #1 modal size per rasio */
.ys-video-modal-inner.is-landscape { max-width: min(860px, 92vw); }
.ys-video-modal-inner.is-portrait  { max-width: min(420px, 92vw); }

/* Tombol tutup */
.ys-modal-close {
	position: absolute;
	top: -52px;
	right: 0;
	width: 40px; height: 40px;
	border-radius: 50%;
	border: 1px solid rgba(255,255,255,.25);
	background: rgba(255,255,255,.12);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background .2s ease, transform .2s ease;
	padding: 0;
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
}

.ys-modal-close:hover { background: rgba(255,255,255,.22); transform: rotate(90deg); }
.ys-modal-close:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.ys-modal-close svg { width: 14px; height: 14px; }

/* Iframe wrapper — aspect-ratio diset langsung via JS */
.ys-iframe-wrap {
	position: relative;
	width: 100%;
	aspect-ratio: 9/16;   /* fallback — JS override per video */
	border-radius: 16px;
	overflow: hidden;
	background: #000;
	box-shadow: 0 40px 100px rgba(0,0,0,.55);
	max-height: 88vh;
}

.ys-iframe-wrap iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: none;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
	.ys-shorts-shell.has-fade::after { right: 50px; width: 60px; }
}

@media (max-width: 640px) {
	/* FIX #3: cegah widget overlap ke section bawah */
	.ys-shorts-shell {
		gap: 8px;
		width: 100%;
		max-width: 100%;
		overflow: hidden;
	}

	.ys-shorts-track {
		min-width: 0;
		width: 100%;
		padding-bottom: 16px;
	}

	.ys-shorts-arrow { width: 36px; height: 36px; }

	.ys-shorts-shell.has-fade::after { right: 40px; width: 40px; }

	/* Modal di mobile — semua rasio pakai 90vw */
	.ys-video-modal-inner,
	.ys-video-modal-inner.is-landscape,
	.ys-video-modal-inner.is-portrait {
		max-width: 90vw;
	}

	.ys-iframe-wrap { max-height: 80vh; }
}

/* ── Editor Elementor ─────────────────────────────────────────────────────── */
.elementor-editor-active .ys-short-card { pointer-events: none; }
