/**
 * Youtube Video Search — front-end styles.
 *
 * Self-contained: no Bootstrap or external CDN dependency. Uses CSS
 * custom properties for easy theming, CSS Grid for a responsive card
 * layout, and aspect-ratio for a fluid video player — no JS width
 * calculations needed.
 */

.ytps-container {
	--ytps-accent: #cc0000;
	--ytps-accent-hover: #a30000;
	--ytps-bg: #ffffff;
	--ytps-surface: #f8f9fa;
	--ytps-border: #e2e4e7;
	--ytps-text: #1a1a1a;
	--ytps-text-muted: #65676b;
	--ytps-radius: 12px;
	--ytps-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.06);
	--ytps-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);

	width: 100%;
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--ytps-text);
}

@media (prefers-color-scheme: dark) {
	.ytps-container {
		--ytps-bg: #18191a;
		--ytps-surface: #242526;
		--ytps-border: #3a3b3c;
		--ytps-text: #e4e6eb;
		--ytps-text-muted: #b0b3b8;
		--ytps-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
		--ytps-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.5);
	}
}

.ytps-container *,
.ytps-container *::before,
.ytps-container *::after {
	box-sizing: border-box;
}

/* Search form */

.ytps-heading {
	margin: 0 0 12px;
	font-size: 1.3em;
	font-weight: 700;
	color: var(--ytps-text);
}

.ytps-search-form {
	display: flex;
	align-items: stretch;
	max-width: 560px;
	margin: 0 0 20px;
	background: var(--ytps-bg);
	border: 1px solid var(--ytps-border);
	border-radius: 999px;
	box-shadow: var(--ytps-shadow);
	overflow: hidden;
	transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.ytps-search-form:focus-within {
	border-color: var(--ytps-accent);
	box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.12);
}

.ytps-search-icon {
	flex: 0 0 auto;
	width: 20px;
	margin: auto 0 auto 16px;
	background: url('../images/searchicon.png') center / contain no-repeat;
	opacity: 0.55;
}

.ytps-search-form .ytps-query {
	flex: 1 1 auto;
	min-width: 0;
	height: 46px;
	padding: 0 12px;
	border: 0;
	background: transparent;
	color: var(--ytps-text);
	font-size: 15px;
	outline: none;
}

.ytps-search-submit {
	flex: 0 0 auto;
	height: 46px;
	padding: 0 20px;
	border: 0;
	background: var(--ytps-accent);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.ytps-search-submit:hover,
.ytps-search-submit:focus-visible {
	background: var(--ytps-accent-hover);
}

/* Video player */

.ytps-player {
	position: relative;
	width: 100%;
	margin: 0 0 20px;
}

.ytps-player.ytps-has-video {
	aspect-ratio: 16 / 9;
	border-radius: var(--ytps-radius);
	overflow: hidden;
	box-shadow: var(--ytps-shadow);
	background: #000;
}

.ytps-player iframe {
	width: 100%;
	height: 100%;
	display: block;
	border: 0;
}

/* Loading indicator */

.ytps-loading-indicator {
	display: none;
	align-items: center;
	gap: 6px;
	padding: 16px 4px;
}

.ytps-container.is-loading .ytps-loading-indicator {
	display: flex;
}

.ytps-loading-indicator span {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--ytps-accent);
	animation: ytps-bounce 1s infinite ease-in-out both;
}

.ytps-loading-indicator span:nth-child(2) { animation-delay: 0.15s; }
.ytps-loading-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ytps-bounce {
	0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
	40% { transform: scale(1); opacity: 1; }
}

/* Results grid */

.ytps-results-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 20px;
}

.ytps-card {
	display: flex;
	flex-direction: column;
	background: var(--ytps-bg);
	border: 1px solid var(--ytps-border);
	border-radius: var(--ytps-radius);
	overflow: hidden;
	cursor: pointer;
	box-shadow: var(--ytps-shadow);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	/* .ytps-card is a real <a> element (crawlable + works without JS),
	   so reset default anchor styling to match the card design. */
	color: inherit;
	text-decoration: none;
}

.ytps-card:visited {
	color: inherit;
}

.ytps-card:hover,
.ytps-card:focus-visible {
	transform: translateY(-3px);
	box-shadow: var(--ytps-shadow-hover);
	outline: none;
}

.ytps-card-thumb {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	background: var(--ytps-surface);
	overflow: hidden;
}

.ytps-card-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.ytps-play-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0);
	transition: background-color 0.15s ease;
}

.ytps-play-overlay::after {
	content: "";
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 11px 0 11px 18px;
	border-color: transparent transparent transparent #ffffff;
	opacity: 0;
	filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
	transition: opacity 0.15s ease, transform 0.15s ease;
	transform: scale(0.8);
}

.ytps-card:hover .ytps-play-overlay,
.ytps-card:focus-visible .ytps-play-overlay {
	background: rgba(0, 0, 0, 0.25);
}

.ytps-card:hover .ytps-play-overlay::after,
.ytps-card:focus-visible .ytps-play-overlay::after {
	opacity: 1;
	transform: scale(1);
}

.ytps-badge {
	position: absolute;
	top: 8px;
	left: 8px;
	padding: 3px 9px;
	border-radius: 999px;
	background: var(--ytps-accent);
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.02em;
}

.ytps-card-body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 12px 14px 14px;
}

.ytps-card-title {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--ytps-text);
}

.ytps-card-channel {
	font-size: 12.5px;
	font-weight: 500;
	color: var(--ytps-text-muted);
}

.ytps-card-desc {
	margin: 2px 0 0;
	font-size: 12.5px;
	color: var(--ytps-text-muted);
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.ytps-card-stats {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 6px;
	font-size: 12px;
	color: var(--ytps-text-muted);
}

.ytps-stat::before {
	margin-right: 4px;
}

.ytps-stat-views::before { content: "👁"; }
.ytps-stat-comments::before { content: "💬"; }

.star {
	width: 46px;
	height: 10px;
	display: inline-block;
	background: url('../images/dark.png') 0 0 no-repeat;
	background-size: 46px 10px;
	border-radius: 5px;
	overflow: hidden;
}

.star-rating {
	height: 100%;
	display: block;
	background: url('../images/gold.png') 0 0 no-repeat;
	background-size: 46px 10px;
}

/* State messages */

.ytps-no-results,
.ytps-error {
	grid-column: 1 / -1;
	padding: 14px 18px;
	border-radius: var(--ytps-radius);
	background: var(--ytps-surface);
	border: 1px solid var(--ytps-border);
	color: var(--ytps-text-muted);
	font-size: 14px;
}

.ytps-error {
	background: #fef2f2;
	border-color: #f3c8c8;
	color: #7a1f1f;
}

@media (prefers-color-scheme: dark) {
	.ytps-error {
		background: #3a1f1f;
		border-color: #5c2b2b;
		color: #f3b8b8;
	}
}

/* jQuery UI autocomplete list */

.ui-autocomplete {
	background: var(--ytps-bg, #fff);
	border: 1px solid var(--ytps-border, #e2e4e7);
	border-radius: 0 0 14px 14px;
	max-height: 280px;
	overflow-y: auto;
	z-index: 9999;
	list-style: none;
	margin: 4px 0 0;
	padding: 6px;
	box-shadow: var(--ytps-shadow, 0 4px 16px rgba(0, 0, 0, 0.12));
}

.ui-autocomplete .ui-menu-item {
	padding: 8px 12px;
	border-radius: 8px;
	cursor: pointer;
	font-size: 14px;
}

.ui-autocomplete .ui-state-active,
.ui-autocomplete .ui-menu-item:hover {
	background: var(--ytps-surface, #f8f9fa);
}

/* Mobile responsiveness */

@media (max-width: 480px) {
	.ytps-search-form {
		max-width: 100%;
		border-radius: 24px;
	}

	.ytps-search-icon {
		margin-left: 12px;
	}

	.ytps-search-submit {
		padding: 0 14px;
		font-size: 13px;
	}

	.ytps-results-grid {
		grid-template-columns: 1fr;
		gap: 14px;
	}

	.ytps-card-title {
		font-size: 14px;
	}
}

@media (min-width: 481px) and (max-width: 768px) {
	.ytps-results-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}
