/**
 * YouTube Enhancer — Frontend Styles
 *
 * Poster overlay, play button, pause overlay, end screen, and
 * responsive layout for enhanced YouTube embeds. Loaded only on
 * pages with YouTube blocks.
 *
 * @package Z2WAdminSuite
 * @since   1.29.0
 */

/* ----------------------------------------------------------------
   Poster Overlay Container
   ---------------------------------------------------------------- */
.z2w-yt-poster {
	position: relative;
	width: 100%;
	padding-bottom: 56.25%; /* 16:9 aspect ratio */
	background: #000;
	cursor: pointer;
	overflow: hidden;
	border-radius: 4px;
}

.z2w-yt-poster img.z2w-yt-poster-img {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* ----------------------------------------------------------------
   Play Button
   ---------------------------------------------------------------- */
.z2w-yt-play-btn {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: 2;
	background: transparent;
	border: none;
	border-radius: 14px;
	padding: 0;
	width: 68px;
	height: 48px;
	box-sizing: content-box;
	cursor: pointer;
	transition: opacity 0.2s ease;
	opacity: 1;
}

.z2w-yt-play-btn:hover,
.z2w-yt-play-btn:focus {
	opacity: 1;
}

.z2w-yt-play-btn:focus {
	outline: 2px solid #fff;
	outline-offset: 4px;
}

.z2w-yt-play-btn svg {
	display: block;
	width: 100%;
	height: 100%;
}

/* ----------------------------------------------------------------
   Subscribe CTA Bar — bottom of poster
   ---------------------------------------------------------------- */
.z2w-yt-subscribe-bar {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 3;
	background: rgba(0, 0, 0, 0.7);
	padding: 8px 14px;
	text-align: right;
	opacity: 0.6;
	transition: opacity 0.3s ease;
	border-radius: 0 0 4px 4px;
}

.z2w-yt-poster:hover .z2w-yt-subscribe-bar {
	opacity: 1;
}

.z2w-yt-subscribe-bar a {
	color: #fff;
	font-size: 15px;
	font-weight: 500;
	line-height: 1.4;
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	display: inline-block;
	max-width: 100%;
	vertical-align: bottom;
}

.z2w-yt-subscribe-bar a:hover,
.z2w-yt-subscribe-bar a:focus {
	text-decoration: underline;
	color: #fff;
}

/* ----------------------------------------------------------------
   Playing State — iframe replaces poster
   ---------------------------------------------------------------- */
.z2w-yt-poster.z2w-yt-playing {
	cursor: default;
}

/* ----------------------------------------------------------------
   Neutralize WP core responsive-embed aspect-ratio spacing.
   Core uses a ::before with padding-top to reserve space for the
   absolutely-positioned iframe. Our poster div has its own
   padding-bottom for the 16:9 ratio, so the core ::before creates
   unwanted whitespace. Disable it in both poster AND playing states
   — the poster div handles aspect ratio in all states since the
   iframe is placed inside it, not directly in the wrapper.
   ---------------------------------------------------------------- */
.wp-block-embed .wp-block-embed__wrapper:has(.z2w-yt-poster)::before {
	display: none;
}

.wp-block-embed .wp-block-embed__wrapper:has(.z2w-yt-poster) {
	position: relative;
	padding-top: 0;
	padding-bottom: 0;
}

/* ----------------------------------------------------------------
   Pause Overlay — suppresses YouTube's native suggestion overlay
   ---------------------------------------------------------------- */
.z2w-yt-pause-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: transparent;
	z-index: 10;
	display: flex;
	justify-content: center;
	align-items: center;
	pointer-events: none;
	animation: z2w-yt-fade-in 0.15s ease;
}

.z2w-yt-pause-play-btn {
	background: transparent;
	border: none;
	padding: 0;
	cursor: pointer;
	opacity: 1;
	pointer-events: auto;
	transition: opacity 0.2s ease;
}

.z2w-yt-pause-play-btn:hover {
	opacity: 1;
}

.z2w-yt-pause-play-btn svg {
	display: block;
	width: 68px;
	height: 48px;
}

/* ----------------------------------------------------------------
   Related Videos End Screen — 2x2 Grid Overlay
   ---------------------------------------------------------------- */
.z2w-yt-related-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.92);
	z-index: 10;
	display: flex;
	flex-direction: column;
	padding: 12px 16px;
	box-sizing: border-box;
	animation: z2w-yt-fade-in 0.3s ease;
}

@keyframes z2w-yt-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

.z2w-yt-related-header {
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	text-align: center;
	padding-bottom: 8px;
	flex-shrink: 0;
}

.z2w-yt-related-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	grid-template-rows: 1fr 1fr;
	gap: 8px;
	flex: 1;
	min-height: 0;
}

.z2w-yt-related-item {
	position: relative;
	overflow: hidden;
	border-radius: 6px;
	text-decoration: none;
	display: block;
	background: #1a1a1a;
}

.z2w-yt-related-thumb {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.2s ease;
}

.z2w-yt-related-item:hover .z2w-yt-related-thumb {
	transform: scale(1.05);
}

.z2w-yt-related-label {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
	color: #fff;
	font-size: 15px;
	font-weight: 500;
	line-height: 1.3;
	padding: 24px 10px 8px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.z2w-yt-related-empty {
	background: transparent;
}

.z2w-yt-related-footer {
	text-align: center;
	padding-top: 10px;
	flex-shrink: 0;
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.z2w-yt-end-subscribe {
	display: inline-block;
	background: #cc0000;
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	padding: 8px 20px;
	border-radius: 4px;
	text-decoration: none;
	transition: filter 0.2s ease, transform 0.15s ease;
	white-space: nowrap;
}

.z2w-yt-end-subscribe:hover,
.z2w-yt-end-subscribe:focus {
	filter: brightness(1.15);
	color: #fff;
	text-decoration: none;
	transform: scale(1.03);
}

.z2w-yt-related-replay {
	background: transparent;
	border: 1px solid rgba(255, 255, 255, 0.4);
	color: #fff;
	padding: 7px 18px;
	border-radius: 4px;
	cursor: pointer;
	font-size: 13px;
	transition: background 0.2s, border-color 0.2s;
}

.z2w-yt-related-replay:hover {
	background: rgba(255, 255, 255, 0.15);
	border-color: rgba(255, 255, 255, 0.7);
}

/* ----------------------------------------------------------------
   Subscribe-Only Bottom Bar — shown when no related videos available
   Sits at the bottom of the video so YouTube's own end screen
   remains visible above.
   ---------------------------------------------------------------- */
.z2w-yt-end-subscribe-bar {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 10;
	background: rgba(0, 0, 0, 0.88);
	padding: 10px 16px;
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
	animation: z2w-yt-fade-in 0.3s ease;
	border-radius: 0 0 4px 4px;
}

/* ----------------------------------------------------------------
   Responsive — Mobile adjustments
   ---------------------------------------------------------------- */
@media (max-width: 600px) {
	.z2w-yt-play-btn {
		width: 54px;
		height: 38px;
		border-radius: 10px;
	}

	.z2w-yt-subscribe-bar {
		opacity: 0.7;
		font-size: 11px;
		padding: 5px 8px;
	}

	.z2w-yt-subscribe-bar a {
		font-size: 11px;
	}

	.z2w-yt-end-subscribe {
		font-size: 12px;
		padding: 6px 14px;
	}

	.z2w-yt-related-overlay {
		padding: 8px 10px;
	}

	.z2w-yt-related-header {
		font-size: 12px;
		padding-bottom: 6px;
	}

	.z2w-yt-related-grid {
		gap: 6px;
	}

	.z2w-yt-related-label {
		font-size: 12px;
		padding: 16px 6px 5px;
	}

	.z2w-yt-related-replay {
		font-size: 11px;
		padding: 4px 14px;
	}

	.z2w-yt-pause-play-btn svg {
		width: 54px;
		height: 38px;
	}

	.z2w-yt-end-subscribe-bar {
		padding: 8px 10px;
		gap: 8px;
	}
}
