/**
 * WTMJ Shorts Carousel styles.
 */

.wtmj-shorts-carousel {
	--wtmj-radius: 12px;
	--wtmj-bg: #0a0a0a;
	--wtmj-accent: #ff2d55;
	--wtmj-fg: #fff;
	--wtmj-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
	position: relative;
}

.wtmj-shorts-swiper {
	padding: 8px 0 40px;
}

.wtmj-shorts-slide {
	width: auto;
	height: auto;
	box-sizing: border-box;
}

/* 9:16 card */
.wtmj-shorts-card {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 9 / 16;
	border: 0;
	padding: 0;
	margin: 0;
	background: var(--wtmj-bg);
	border-radius: var(--wtmj-radius);
	overflow: hidden;
	cursor: pointer;
	box-shadow: var(--wtmj-shadow);
	transition: transform 180ms ease, box-shadow 180ms ease;
	color: var(--wtmj-fg);
}

.wtmj-shorts-card:hover,
.wtmj-shorts-card:focus-visible {
	transform: translateY(-2px);
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
	outline: none;
}

.wtmj-shorts-card:focus-visible {
	box-shadow: 0 0 0 3px var(--wtmj-accent), var(--wtmj-shadow);
}

.wtmj-shorts-thumb {
	position: absolute;
	inset: 0;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	transform: scale(1.02);
	transition: transform 300ms ease;
}

.wtmj-shorts-card:hover .wtmj-shorts-thumb {
	transform: scale(1.06);
}

.wtmj-shorts-play {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 64px;
	height: 64px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	transition: background 180ms ease, transform 180ms ease;
	pointer-events: none;
}

.wtmj-shorts-card:hover .wtmj-shorts-play {
	background: var(--wtmj-accent);
	transform: translate(-50%, -50%) scale(1.05);
}

.wtmj-shorts-title {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 72px 14px 18px;
	color: #fff;
	font-size: 14px;
	line-height: 1.3;
	font-weight: 600;
	text-align: left;
	background: linear-gradient(
		to top,
		rgba(0, 0, 0, 0.92) 0%,
		rgba(0, 0, 0, 0.78) 30%,
		rgba(0, 0, 0, 0.45) 65%,
		rgba(0, 0, 0, 0) 100%
	);
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
	display: -webkit-box;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
	word-wrap: break-word;
}

/* Swiper nav */
.wtmj-shorts-nav {
	color: var(--wtmj-fg);
	background: rgba(0, 0, 0, 0.5);
	border: 0;
	border-radius: 50%;
	width: 40px;
	height: 40px;
	margin-top: -20px;
}
.wtmj-shorts-nav::after {
	font-size: 18px;
}
@media (max-width: 639px) {
	.wtmj-shorts-nav { display: none; }
}

.wtmj-shorts-pagination .swiper-pagination-bullet-active {
	background: var(--wtmj-accent);
}

/* Modal */
.wtmj-shorts-modal {
	border: 0;
	padding: 0;
	background: transparent;
	max-width: 100vw;
	max-height: 100vh;        /* fallback for very old browsers */
	max-height: 100dvh;       /* dynamic viewport — accounts for mobile browser chrome */
}
.wtmj-shorts-modal::backdrop {
	background: rgba(0, 0, 0, 0.86);
}
.wtmj-shorts-modal[open] {
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Frame holds the player + all overlaid controls so they scale together. */
.wtmj-shorts-modal-frame {
	position: relative;
	background: #000;
	box-shadow: var(--wtmj-shadow);
	border-radius: 8px;
	overflow: hidden;
}
.wtmj-shorts-modal-frame[data-aspect="9:16"] {
	width: min(100vw, calc(100vh * 9 / 16));
	aspect-ratio: 9 / 16;
}
.wtmj-shorts-modal-frame[data-aspect="16:9"] {
	width: min(100vw, calc(100vh * 16 / 9));
	aspect-ratio: 16 / 9;
}

/* Gradient strips at top + bottom so overlaid controls always read against the video. */
.wtmj-shorts-modal-frame::before,
.wtmj-shorts-modal-frame::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	height: 120px;
	pointer-events: none;
	z-index: 1;
}
.wtmj-shorts-modal-frame::before {
	top: 0;
	background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}
.wtmj-shorts-modal-frame::after {
	bottom: 0;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}

/* iframe container (sibling of controls so swapping the iframe doesn't disturb them). */
.wtmj-shorts-modal-player {
	position: absolute;
	inset: 0;
	background: #000;
}
.wtmj-shorts-modal-player iframe {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

/* Decorative mobile-only top/bottom bar backgrounds. Hidden by default. */
.wtmj-shorts-modal-bar {
	display: none;
	position: absolute;
	left: 0;
	right: 0;
	height: 64px;
	background: #000;
	z-index: 2;
}
.wtmj-shorts-modal-bar--top    { top: 0; }
.wtmj-shorts-modal-bar--bottom { bottom: 0; }

/* Counter chip — desktop only (top-left). */
.wtmj-shorts-modal-counter {
	position: absolute;
	top: 14px;
	left: 14px;
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.02em;
	padding: 6px 12px;
	background: rgba(0, 0, 0, 0.55);
	border-radius: 999px;
	pointer-events: none;
	z-index: 3;
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
}
.wtmj-shorts-modal-counter:empty { display: none; }

/* Close button — desktop top-right circle; mobile rule overrides below. */
.wtmj-shorts-modal-close {
	position: absolute;
	top: 14px;
	right: 14px;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 0;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	z-index: 4;
	display: flex;
	align-items: center;
	justify-content: center;
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	transition: background 160ms ease;
}
.wtmj-shorts-modal-close:hover,
.wtmj-shorts-modal-close:focus-visible {
	background: rgba(0, 0, 0, 0.78);
	outline: none;
}

/* Button label spans — hidden on desktop, shown in the mobile bars. */
.wtmj-shorts-modal-btn-label {
	display: none;
}

/* Prev / Next — desktop default: side arrows centered on the frame. */
.wtmj-shorts-modal-prev,
.wtmj-shorts-modal-next {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 52px;
	height: 52px;
	border-radius: 50%;
	border: 0;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	cursor: pointer;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	transition: background 160ms ease, opacity 160ms ease, transform 160ms ease;
}
.wtmj-shorts-modal-prev { left: 14px; }
.wtmj-shorts-modal-next { right: 14px; }

.wtmj-shorts-modal-prev:hover,
.wtmj-shorts-modal-next:hover,
.wtmj-shorts-modal-prev:focus-visible,
.wtmj-shorts-modal-next:focus-visible {
	background: rgba(0, 0, 0, 0.78);
	outline: none;
	transform: translateY(-50%) scale(1.05);
}
.wtmj-shorts-modal-prev:disabled,
.wtmj-shorts-modal-next:disabled {
	opacity: 0.25;
	cursor: default;
	pointer-events: none;
}

/* ===== Mobile layout (≤ 767px) =====
   Full-viewport modal with solid black bars above + below the video.
   Prev = full-width top bar (icon + "PREVIOUS"), with the X tucked at the top-right.
   Next = full-width bottom bar (icon + "NEXT"). */
@media (max-width: 767px) {
	/* Frame fills the *current* viewport (dvh, not vh) so it shrinks/grows
	   with mobile browser chrome instead of slipping behind it. */
	.wtmj-shorts-modal-frame,
	.wtmj-shorts-modal-frame[data-aspect="9:16"],
	.wtmj-shorts-modal-frame[data-aspect="16:9"] {
		width: 100vw;
		height: 100vh;        /* fallback */
		height: 100dvh;
		max-width: 100vw;
		max-height: 100vh;    /* fallback */
		max-height: 100dvh;
		aspect-ratio: auto;
		border-radius: 0;
	}

	/* Show the solid bar backgrounds. Each bar visually extends to the screen
	   edge to cover the safe-area inset (notch / home indicator zone) in black. */
	.wtmj-shorts-modal-bar { display: block; }
	.wtmj-shorts-modal-bar--top {
		height: calc(64px + env(safe-area-inset-top, 0px));
	}
	.wtmj-shorts-modal-bar--bottom {
		height: calc(64px + env(safe-area-inset-bottom, 0px));
	}

	/* Hide the desktop gradient strips — solid bars take over. */
	.wtmj-shorts-modal-frame::before,
	.wtmj-shorts-modal-frame::after { display: none; }

	/* Player sits between the bars (offset by safe-area too). */
	.wtmj-shorts-modal-player {
		top: calc(64px + env(safe-area-inset-top, 0px));
		bottom: calc(64px + env(safe-area-inset-bottom, 0px));
		left: 0;
		right: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		overflow: hidden;
	}
	.wtmj-shorts-modal-player iframe {
		aspect-ratio: 9 / 16;
		height: 100%;
		width: auto;
		max-width: 100%;
		max-height: 100%;
	}

	/* Counter has no room here — desktop only. */
	.wtmj-shorts-modal-counter { display: none; }

	/* Prev = top bar (full width minus the close button), offset for the safe area. */
	.wtmj-shorts-modal-prev {
		position: absolute;
		top: env(safe-area-inset-top, 0px);
		left: 0;
		right: 64px;
		bottom: auto;
		width: auto;
		height: 64px;
		margin: 0;
		padding: 0 16px;
		border-radius: 0;
		background: transparent;
		backdrop-filter: none;
		-webkit-backdrop-filter: none;
		transform: none;
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 10px;
		color: #fff;
		font-weight: 700;
		font-size: 15px;
		letter-spacing: 0.08em;
		text-transform: uppercase;
		z-index: 3;
	}

	/* Next = full-width bottom bar, lifted off the home indicator. */
	.wtmj-shorts-modal-next {
		position: absolute;
		top: auto;
		bottom: env(safe-area-inset-bottom, 0px);
		left: 0;
		right: 0;
		width: auto;
		height: 64px;
		margin: 0;
		padding: 0 16px;
		border-radius: 0;
		background: transparent;
		backdrop-filter: none;
		-webkit-backdrop-filter: none;
		transform: none;
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 10px;
		color: #fff;
		font-weight: 700;
		font-size: 15px;
		letter-spacing: 0.08em;
		text-transform: uppercase;
		z-index: 3;
	}

	/* Reset hover/focus transform from the desktop rule (mobile buttons aren't translated). */
	.wtmj-shorts-modal-prev:hover,
	.wtmj-shorts-modal-next:hover,
	.wtmj-shorts-modal-prev:focus-visible,
	.wtmj-shorts-modal-next:focus-visible {
		transform: none;
		background: rgba(255, 255, 255, 0.08);
	}

	/* Rotate chevrons so the same SVGs point up / down. */
	.wtmj-shorts-modal-prev svg,
	.wtmj-shorts-modal-next svg {
		transform: rotate(90deg);
		width: 26px;
		height: 26px;
	}

	/* Show the text labels. */
	.wtmj-shorts-modal-btn-label {
		display: inline-block;
	}

	/* Close — top-right inside the top bar, offset for the safe area. */
	.wtmj-shorts-modal-close {
		top: env(safe-area-inset-top, 0px);
		right: 0;
		width: 64px;
		height: 64px;
		border-radius: 0;
		background: transparent;
		backdrop-filter: none;
		-webkit-backdrop-filter: none;
		font-size: 24px;
		font-weight: 700;
		z-index: 4;
	}
	.wtmj-shorts-modal-close:hover,
	.wtmj-shorts-modal-close:focus-visible {
		background: rgba(255, 255, 255, 0.08);
	}
}
