/* ============================================================
   Youtube Feed — frontend styles
   ============================================================ */

.ytf,
.ytf * { box-sizing: border-box; }

.ytf {
	--ytf-radius-card: 12px;
	--ytf-radius-img: 8px;
	--ytf-gap: 20px;
	--ytf-cols-d: 3;
	--ytf-cols-m: 1;

	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--ytf-text);
	background: transparent;
	line-height: 1.4;
	width: 100%;
}

/* -----------------------------------------------------------
   Palettes
   ----------------------------------------------------------- */
.ytf[data-palette="youtube"] {
	--ytf-bg: transparent;
	--ytf-surface: #ffffff;
	--ytf-surface-2: #f9f9f9;
	--ytf-text: #0f0f0f;
	--ytf-text-muted: #606060;
	--ytf-accent: #FF0000;
	--ytf-accent-2: #FF0000;
	--ytf-border: #e5e5e5;
	--ytf-hover: rgba(0,0,0,.04);
	--ytf-shadow: 0 1px 2px rgba(0,0,0,.06);
}

.ytf[data-palette="fii"] {
	--ytf-bg: transparent;
	--ytf-surface: #ffffff;
	--ytf-surface-2: #f7faef;
	--ytf-text: #005e7f;
	--ytf-text-muted: #4a6470;
	--ytf-accent: #94bf23;
	--ytf-accent-2: #29afdc;
	--ytf-accent-3: #97c03b;
	--ytf-accent-light: #7bd8fc;
	--ytf-accent-magenta: #b094ff;
	--ytf-border: #ddd;
	--ytf-hover: rgba(148,191,35,.08);
	--ytf-shadow: 0 1px 2px rgba(0,94,127,.08);
}

/* -----------------------------------------------------------
   Shared: card, thumb, body, title, description, meta
   ----------------------------------------------------------- */
.ytf-card,
.ytf-list-row,
.ytf-side-item,
.ytf-yt-hero {
	display: block;
	text-decoration: none;
	color: inherit;
	background: var(--ytf-surface);
	border: 1px solid var(--ytf-border);
	border-radius: var(--ytf-radius-card);
	overflow: hidden;
	transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
	box-shadow: var(--ytf-shadow);
}
.ytf-card:hover,
.ytf-list-row:hover,
.ytf-side-item:hover,
.ytf-yt-hero:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 18px rgba(0,0,0,.10);
	background: var(--ytf-hover);
}

.ytf-body { padding: 12px 14px 14px; }

.ytf-thumb {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 16/9;
	background: #000;
	overflow: hidden;
	border-radius: var(--ytf-radius-img);
}
.ytf-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .25s ease;
}
.ytf-card:hover .ytf-thumb img,
.ytf-list-row:hover .ytf-thumb img,
.ytf-side-item:hover .ytf-thumb img { transform: scale(1.03); }

.ytf-thumb--placeholder {
	background: linear-gradient(135deg, #222, #555);
}

.ytf-duration {
	position: absolute;
	right: 8px;
	bottom: 8px;
	padding: 2px 6px;
	font-size: 12px;
	font-weight: 600;
	background: rgba(0,0,0,.78);
	color: #fff;
	border-radius: 4px;
	line-height: 1.3;
}
.ytf-duration--short {
	background: var(--ytf-accent);
	color: #fff;
}

.ytf-play {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	opacity: 0;
	transition: opacity .15s ease;
	pointer-events: none;
	text-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.ytf-card:hover .ytf-play,
.ytf-list-row:hover .ytf-play,
.ytf-side-item:hover .ytf-play,
.ytf-yt-hero:hover .ytf-play { opacity: .95; }

.ytf-title {
	margin: 0 0 6px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--ytf-text);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.ytf-title--lg { font-size: 20px; -webkit-line-clamp: 3; }
.ytf-title--sm { font-size: 13px; -webkit-line-clamp: 2; }

.ytf-desc {
	margin: 4px 0 8px;
	font-size: 13px;
	color: var(--ytf-text-muted);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.ytf-meta {
	display: inline-flex;
	gap: 8px;
	font-size: 12px;
	color: var(--ytf-text-muted);
	align-items: center;
	flex-wrap: wrap;
}
.ytf-meta > span + span::before {
	content: "•";
	margin-right: 8px;
	color: var(--ytf-text-muted);
}

.ytf-error,
.ytf-empty {
	padding: 16px;
	border: 1px dashed var(--ytf-border, #ccc);
	border-radius: 8px;
	color: var(--ytf-text-muted, #666);
	font-size: 14px;
	background: var(--ytf-surface-2, #f9f9f9);
}

/* -----------------------------------------------------------
   Layout: Grid
   ----------------------------------------------------------- */
.ytf-grid {
	display: grid;
	grid-template-columns: repeat(var(--ytf-cols-m), minmax(0, 1fr));
	gap: var(--ytf-gap);
}
@media (min-width: 768px) {
	.ytf-grid {
		grid-template-columns: repeat(var(--ytf-cols-d), minmax(0, 1fr));
	}
}

/* -----------------------------------------------------------
   Layout: List (image left, body right – single column)
   ----------------------------------------------------------- */
.ytf-list {
	display: flex;
	flex-direction: column;
	gap: var(--ytf-gap);
}
.ytf-list-row {
	display: grid;
	grid-template-columns: minmax(140px, 36%) 1fr;
	gap: 16px;
	padding: 12px;
	align-items: start;
}
.ytf-list-thumb { width: 100%; }
.ytf-list-body { padding: 4px 4px 4px 0; }
.ytf-list .ytf-title { font-size: 17px; -webkit-line-clamp: 2; }
.ytf-list .ytf-desc { -webkit-line-clamp: 3; }

@media (max-width: 600px) {
	.ytf-list-row {
		grid-template-columns: 120px 1fr;
		gap: 12px;
		padding: 8px;
	}
	.ytf-list .ytf-title { font-size: 14px; }
	.ytf-list .ytf-desc { -webkit-line-clamp: 2; font-size: 12px; }
}

/* -----------------------------------------------------------
   Layout: YouTube channel style
   ----------------------------------------------------------- */
.ytf-yt {
	display: flex;
	flex-direction: column;
	gap: var(--ytf-gap);
}
.ytf-yt-hero {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0;
}
@media (min-width: 900px) {
	.ytf-yt-hero {
		grid-template-columns: 60% 40%;
	}
	.ytf-yt-hero-body { padding: 24px; display: flex; flex-direction: column; justify-content: center; }
}
.ytf-yt-hero-thumb { width: 100%; }
.ytf-yt-hero-body { padding: 16px; }
.ytf-yt-hero .ytf-desc { -webkit-line-clamp: 4; font-size: 14px; }
.ytf-yt-rest {
	display: grid;
	grid-template-columns: repeat(var(--ytf-cols-m), minmax(0, 1fr));
	gap: var(--ytf-gap);
}
@media (min-width: 768px) {
	.ytf-yt-rest {
		grid-template-columns: repeat(var(--ytf-cols-d), minmax(0, 1fr));
	}
}

/* -----------------------------------------------------------
   Layout: Featured + sidebar
   ----------------------------------------------------------- */
.ytf-featured {
	display: flex;
	flex-direction: column;
	gap: var(--ytf-gap);
}
.ytf-featured-main { width: 100%; }
.ytf-featured-mobile-first { display: block; }
.ytf-player { display: none; }

@media (min-width: 900px) {
	/* Desktop: use position-based layout so the sidebar height tracks
	   the natural height of the main column (player + title + desc).
	   The sidebar is taken out of flow, so it cannot inflate the row,
	   and height:100% resolves against the relative container. */
	.ytf-featured {
		display: block;
		position: relative;
	}
	.ytf-featured-main {
		width: 70%;
		max-width: 70%;
	}
	.ytf-featured-mobile-first { display: none; }
	.ytf-player { display: block; }
}

.ytf-player-frame {
	position: relative;
	width: 100%;
	aspect-ratio: 16/9;
	background: #000;
	border-radius: var(--ytf-radius-img);
	overflow: hidden;
	margin-bottom: 12px;
}
.ytf-player-frame iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}
.ytf-player-title { margin-top: 8px; }
.ytf-player-desc { -webkit-line-clamp: 3; }

.ytf-featured-side {
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-height: none;
	overflow: visible;
}
@media (min-width: 900px) {
	.ytf-featured-side {
		position: absolute;
		top: 0;
		right: 0;
		width: 25%;
		height: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		padding-right: 6px;
		scrollbar-gutter: stable;
	}
	.ytf-featured-side::-webkit-scrollbar { width: 6px; }
	.ytf-featured-side::-webkit-scrollbar-track { background: transparent; }
	.ytf-featured-side::-webkit-scrollbar-thumb {
		background: var(--ytf-border);
		border-radius: 3px;
	}
	.ytf-featured-side::-webkit-scrollbar-thumb:hover {
		background: var(--ytf-text-muted);
	}
	/* Firefox */
	.ytf-featured-side {
		scrollbar-width: thin;
		scrollbar-color: var(--ytf-border) transparent;
	}
}

.ytf-side-item {
	display: grid;
	grid-template-columns: 110px 1fr;
	gap: 10px;
	padding: 8px;
	font-size: 13px;
	/* Critical for the desktop sidebar: prevent flexbox from shrinking
	   each card to fit inside the fixed-height scroll container. */
	flex: 0 0 auto;
}
.ytf-side-item.is-active {
	background: var(--ytf-hover);
	border-color: var(--ytf-accent);
}
.ytf-side-thumb { width: 100%; }
.ytf-side-body .ytf-desc { -webkit-line-clamp: 2; font-size: 12px; margin: 4px 0; }

@media (max-width: 600px) {
	.ytf-side-item {
		grid-template-columns: 100px 1fr;
		gap: 8px;
	}
}

/* -----------------------------------------------------------
   Layout: Carousel
   -----------------------------------------------------------
   Containment strategy:
   The carousel sits inside a chain of flex containers (Oxygen's
   .ct-div-block is display:flex). Flex children have min-width:auto
   by default, which lets them grow to fit their intrinsic content
   — for us that's 12 thumbnails at ~1280px each, ~15000px total.
   To stop that growth from breaking the surrounding layout we:
     1. Cap our outer wrapper at 100% of its parent
     2. Set min-width:0 along the chain so flex shrinking can occur
     3. Use `contain: inline-size` so layout effects don't escape
     4. Use overflow:hidden as a final guard
   ----------------------------------------------------------- */
.ytf--carousel {
	position: relative;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	overflow: hidden;
	box-sizing: border-box;
	contain: inline-size;
}

.ytf-carousel {
	position: relative;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

.ytf-carousel-track {
	display: flex;
	flex-wrap: nowrap;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
	gap: var(--ytf-gap);
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-ms-overflow-style: none;
	-webkit-overflow-scrolling: touch;
	padding: 0;
	overscroll-behavior-x: contain;
}
.ytf-carousel-track::-webkit-scrollbar { display: none; }
.ytf-carousel-track:focus { outline: none; }
.ytf-carousel-track:focus-visible { outline: 2px solid var(--ytf-accent); outline-offset: 2px; border-radius: 4px; }

.ytf-carousel-slide {
	/* Sized with both flex-basis AND width — redundancy guards against
	   Safari/Chrome differences in how each is honored for flex items. */
	flex: 0 0 calc((100% - (var(--ytf-cols-m) - 1) * var(--ytf-gap)) / var(--ytf-cols-m));
	width:    calc((100% - (var(--ytf-cols-m) - 1) * var(--ytf-gap)) / var(--ytf-cols-m));
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
	scroll-snap-align: start;
}
@media (min-width: 768px) {
	.ytf-carousel-slide {
		flex: 0 0 calc((100% - (var(--ytf-cols-d) - 1) * var(--ytf-gap)) / var(--ytf-cols-d));
		width:    calc((100% - (var(--ytf-cols-d) - 1) * var(--ytf-gap)) / var(--ytf-cols-d));
	}
}
/* Carousel slide hover: don't translate (interferes with scroll-snap math) */
.ytf-carousel-slide:hover { transform: none; }

.ytf-carousel-arrow {
	position: absolute;
	top: 28%;
	transform: translateY(-50%);
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: rgba(0,0,0,.7);
	color: #fff;
	border: 0;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	z-index: 3;
	box-shadow: 0 2px 8px rgba(0,0,0,.25);
	transition: opacity .2s ease, background .15s ease, visibility .2s ease;
}
.ytf-carousel-arrow:hover { background: rgba(0,0,0,.9); }
.ytf-carousel-arrow:focus-visible {
	outline: 2px solid var(--ytf-accent);
	outline-offset: 2px;
}
.ytf-carousel-arrow:disabled {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}
/* Arrows live INSIDE the wrapper so overflow:hidden can clip safely. */
.ytf-carousel-arrow--prev { left: 8px; }
.ytf-carousel-arrow--next { right: 8px; }

/* On touch / small screens, hide arrows entirely — swipe is the primary
   navigation and arrows just steal real estate and overlap thumbnails. */
@media (max-width: 767px) {
	.ytf-carousel-arrow { display: none; }
}

.ytf-carousel-dots {
	display: flex;
	justify-content: center;
	gap: 4px;
	margin-top: 14px;
	flex-wrap: wrap;
}
.ytf-carousel-dots:empty { display: none; }
.ytf-carousel-dot {
	/* Visual dot sits inside a larger transparent tap area for mobile. */
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: transparent;
	border: 0;
	cursor: pointer;
	padding: 0;
	position: relative;
	transition: background .15s ease;
}
.ytf-carousel-dot::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--ytf-border);
	transform: translate(-50%, -50%);
	transition: background .15s ease, width .15s ease, border-radius .15s ease;
}
.ytf-carousel-dot:hover::before { background: var(--ytf-text-muted); }
.ytf-carousel-dot.is-active::before {
	background: var(--ytf-accent);
	width: 22px;
	border-radius: 5px;
}

/* -----------------------------------------------------------
   Lightbox (used by frontend JS for non-featured layouts)
   ----------------------------------------------------------- */
.ytf-lightbox {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,.85);
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 99999;
	padding: 20px;
}
.ytf-lightbox.is-open { display: flex; }
.ytf-lightbox-inner {
	position: relative;
	width: 100%;
	max-width: 1100px;
	aspect-ratio: 16/9;
	background: #000;
	border-radius: 8px;
	overflow: hidden;
}
.ytf-lightbox-inner iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}
.ytf-lightbox-close {
	position: absolute;
	top: -42px;
	right: 0;
	width: 36px;
	height: 36px;
	background: rgba(255,255,255,.15);
	color: #fff;
	border: 0;
	border-radius: 50%;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}
.ytf-lightbox-close:hover { background: rgba(255,255,255,.3); }
