/*
 * Tribeca Video Gallery: estilos de frontend.
 * Versionado automático por TVG_Assets (TVG_VERSION + filemtime).
 */

/* ---------- Tokens (se sobreescriben por galería desde el atributo style) ---------- */

.tvg {
	--tvg-accent: #2563eb;
	--tvg-radius: 12px;
	--tvg-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
	--tvg-bg: transparent;
	--tvg-fg: #111827;
	--tvg-muted: #6b7280;
	--tvg-card-bg: #ffffff;
	--tvg-border: rgba(0, 0, 0, 0.08);
	--tvg-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--tvg-font-scale: 1;
	--tvg-gap: 20px;
	--tvg-maxw: 1200px;
	--tvg-ratio: 16 / 9;
	--tvg-cols-d: repeat(auto-fill, minmax(240px, 1fr));
	--tvg-cols-t: repeat(auto-fill, minmax(240px, 1fr));
	--tvg-cols-m: repeat(1, minmax(0, 1fr));
	--tvg-masonry-d: 3;
	--tvg-masonry-t: 2;
	--tvg-masonry-m: 1;
	--tvg-title-lines: 2;

	box-sizing: border-box;
	max-width: var(--tvg-maxw);
	margin: 0 auto;
	padding: 0;
	color: var(--tvg-fg);
	background: var(--tvg-bg);
	font-family: var(--tvg-font);
	font-size: calc(1rem * var(--tvg-font-scale));
	line-height: 1.5;
}

.tvg[data-theme="dark"] {
	--tvg-fg: #f3f4f6;
	--tvg-muted: #9ca3af;
	--tvg-card-bg: #161922;
	--tvg-border: rgba(255, 255, 255, 0.08);
}

@media (prefers-color-scheme: dark) {
	.tvg:not([data-theme]) {
		--tvg-fg: #f3f4f6;
		--tvg-muted: #9ca3af;
		--tvg-card-bg: #161922;
		--tvg-border: rgba(255, 255, 255, 0.08);
	}
}

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

/*
 * Tipografía aislada: los temas fijan fuentes en p, h1-h6 y botones con
 * especificidad alta (p. ej. Courier en los nombres). La fuente de la galería
 * es la que elige el usuario en Tema → Tipografía, siempre.
 */
.tvg,
.tvg * {
	font-family: var(--tvg-font) !important;
}

.tvg [hidden] {
	display: none !important;
}

/* Las consultas de contenedor usan el ancho de la galería, no el del viewport. */
.tvg {
	container-type: inline-size;
}

/*
 * Blindaje frente al CSS del tema. Los temas suelen dar estilos globales a
 * h1-h6, p, a, button, img, ul, li y article (color, tipografía, márgenes,
 * mayúsculas, sombras). Estas reglas los devuelven a un estado neutro dentro
 * de la galería; los componentes de abajo los ajustan con sus propias clases.
 */
.tvg :is(h1, h2, h3, h4, h5, h6, p, ul, ol, li, figure, figcaption, dl, dt, dd) {
	margin: 0;
	padding: 0;
	color: inherit;
	font: inherit;
	line-height: inherit;
	letter-spacing: normal;
	text-transform: none;
	text-decoration: none;
	list-style: none;
	box-shadow: none;
	background: none;
	border: 0;
}

.tvg :is(a, button) {
	color: inherit;
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
	text-decoration: none;
	line-height: inherit;
	box-shadow: none;
	min-height: 0;
	padding: 0;
}

.tvg img {
	max-width: 100%;
	height: auto;
	border: 0;
	box-shadow: none;
	margin: 0;
}

.tvg :is(article, header) {
	margin: 0;
	padding: 0;
	background: none;
	border: 0;
	box-shadow: none;
	color: inherit;
}

/* Los componentes restablecen de forma explícita lo que necesitan. */
.tvg .tvg-card {
	margin: 0;
	padding: 0;
}

.tvg .tvg-card__title {
	color: var(--tvg-fg);
	font-weight: 600;
}

.tvg .tvg-title {
	color: var(--tvg-fg);
	font-weight: 700;
}

.tvg .tvg-profile__name {
	color: var(--tvg-fg);
}

.tvg .tvg-card__thumb,
.tvg .tvg-carousel__btn,
.tvg .tvg-more__btn,
.tvg .tvg-lightbox__btn,
.tvg .tvg-stage__facade {
	height: auto;
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
}

/* ---------- Cabecera ---------- */

.tvg .tvg-title {
	margin: 0 0 16px;
	font-size: 1.5em;
	font-weight: 700;
	line-height: 1.25;
}

.tvg .tvg-profile {
	margin-bottom: 20px;
}

.tvg .tvg-profile__banner {
	display: block;
	width: 100%;
	height: auto;
	margin-bottom: 16px;
	border-radius: var(--tvg-radius);
}

/* La cabecera va en fila (avatar | texto | botón) aunque la columna sea estrecha. */
.tvg .tvg-profile__row {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: 16px;
}

.tvg .tvg-profile__avatar {
	flex: 0 0 auto;
	width: 64px;
	height: 64px;
	border-radius: 50%;
	object-fit: cover;
}

.tvg .tvg-profile__text {
	flex: 1 1 0;
	min-width: 0;
}

.tvg .tvg-profile__btn {
	flex: 0 0 auto;
	margin-left: auto;
	white-space: nowrap;
}

/* Solo en columnas muy estrechas, el botón pasa debajo del texto. */
@container (max-width: 380px) {
	.tvg .tvg-profile__row {
		flex-wrap: wrap;
	}

	.tvg .tvg-profile__btn {
		margin-left: 0;
	}
}

.tvg .tvg-profile__name {
	margin: 0;
	font-size: 1.125em;
	font-weight: 600;
}

.tvg .tvg-profile__desc {
	margin: 4px 0 0;
	color: var(--tvg-muted);
}

.tvg .tvg-profile__btn {
	display: inline-block;
	padding: 10px 20px;
	border-radius: 999px;
	background: var(--tvg-accent);
	color: #fff;
	text-decoration: none;
	font-weight: 600;
}

/* ---------- Tarjetas ---------- */

.tvg .tvg-card {
	position: relative;
	min-width: 0;
	background: var(--tvg-card-bg);
	border: 1px solid var(--tvg-border);
	border-radius: var(--tvg-radius);
	box-shadow: var(--tvg-shadow);
	overflow: hidden;
}

.tvg .tvg-card__thumb {
	display: block;
	position: relative;
	width: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: #000;
	color: inherit;
	font: inherit;
	text-align: left;
	text-decoration: none;
	cursor: pointer;
	aspect-ratio: var(--tvg-ratio);
	overflow: hidden;
}

.tvg .tvg-card[data-orientation="vertical"] .tvg-card__thumb {
	aspect-ratio: 9 / 16;
}

.tvg .tvg-card[data-orientation="square"] .tvg-card__thumb {
	aspect-ratio: 1 / 1;
}

.tvg .tvg-card__thumb:focus-visible {
	outline: 3px solid var(--tvg-accent);
	outline-offset: -3px;
}

.tvg .tvg-card__media {
	position: absolute;
	inset: 0;
	display: block;
}

.tvg .tvg-card__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.4s ease;
}

.tvg .tvg-card__thumb:hover .tvg-card__media img {
	transform: scale(1.03);
}

.tvg .tvg-card__noposter {
	position: absolute;
	inset: 0;
	background:
		radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.07), transparent 60%),
		linear-gradient(135deg, #1f2937, #111827);
}

/* Video sin fuente utilizable (adjunto borrado): mensaje, no rectangulo negro. */
.tvg .tvg-stage__error {
	display: grid;
	place-items: center;
	min-height: 120px;
	padding: 24px;
	color: #e5e7eb;
	text-align: center;
}

.tvg .tvg-card__play {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 56px;
	height: 56px;
	transform: translate(-50%, -50%);
	border-radius: 50%;
	background: var(--tvg-accent);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
	transition: transform 0.2s ease;
}

.tvg .tvg-card__play::after {
	content: "";
	position: absolute;
	left: 22px;
	top: 18px;
	border-left: 16px solid #fff;
	border-top: 10px solid transparent;
	border-bottom: 10px solid transparent;
}

/* Ajuste "Mostrar icono de play" desactivado: se ocultan los iconos en tarjetas, facade y lightbox. */
.tvg.tvg--no-play .tvg-card__play,
.tvg.tvg--no-play .tvg-stage__facade::before,
.tvg.tvg--no-play .tvg-stage__facade::after {
	display: none;
}

.tvg .tvg-card__thumb:hover .tvg-card__play {
	transform: translate(-50%, -50%) scale(1.08);
}

.tvg .tvg-card__duration {
	position: absolute;
	right: 8px;
	bottom: 8px;
	padding: 2px 6px;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.75);
	color: #fff;
	font-size: 0.75rem;
	font-variant-numeric: tabular-nums;
}

.tvg .tvg-card__badge {
	position: absolute;
	left: 8px;
	top: 8px;
	padding: 3px 8px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	font-size: 0.7rem;
	font-weight: 600;
}

.tvg .tvg-card__badge--youtube {
	background: #ff0000;
}

.tvg .tvg-card__badge--vimeo {
	background: #1ab7ea;
}

.tvg .tvg-card__body {
	padding: 12px 14px 14px;
}

.tvg .tvg-card__title {
	display: -webkit-box;
	-webkit-line-clamp: var(--tvg-title-lines);
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin: 0 0 6px;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.35;
}

.tvg .tvg-card__meta,
.tvg .tvg-card__desc {
	margin: 0;
	color: var(--tvg-muted);
	font-size: 0.85rem;
}

.tvg .tvg-card__desc {
	margin-top: 6px;
}

.tvg .tvg-card__player {
	position: relative;
	background: #000;
}

.tvg .tvg-card__player > iframe,
.tvg .tvg-card__player > video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* Estilo "Plain": sin fondo ni sombra. */
.tvg.tvg--card-plain .tvg-card {
	background: transparent;
	border-color: transparent;
	box-shadow: none;
}

/* Estilo "Minimal": sin contenedor, título discreto debajo. */
.tvg.tvg--card-minimal .tvg-card {
	background: transparent;
	border: 0;
	box-shadow: none;
}

.tvg.tvg--card-minimal .tvg-card__body {
	padding: 8px 0 0;
}

.tvg.tvg--card-minimal .tvg-card__title {
	font-size: 0.95rem;
}

/* ---------- Layouts ---------- */

.tvg .tvg-items--grid {
	display: grid;
	gap: var(--tvg-gap);
	grid-template-columns: var(--tvg-cols-d);
}

.tvg .tvg-items--masonry {
	columns: var(--tvg-masonry-d);
	column-gap: var(--tvg-gap);
}

.tvg .tvg-items--masonry > .tvg-card {
	break-inside: avoid;
	margin: 0 0 var(--tvg-gap);
}

.tvg .tvg-items--list {
	display: grid;
	gap: var(--tvg-gap);
}

.tvg .tvg-items--list > .tvg-card {
	display: grid;
	grid-template-columns: minmax(160px, 260px) 1fr;
	align-items: start;
}

.tvg .tvg-items--list > .tvg-card .tvg-card__body {
	align-self: center;
}

/* Carrusel y tiras horizontales: scroll-snap. */
.tvg .tvg-carousel {
	position: relative;
}

.tvg .tvg-items--carousel,
.tvg .tvg-items--strip {
	display: grid;
	grid-auto-flow: column;
	gap: var(--tvg-gap);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	padding-bottom: 8px;
}

.tvg .tvg-items--carousel {
	grid-auto-columns: 260px;
}

.tvg .tvg-items--strip {
	grid-auto-columns: 180px;
}

.tvg .tvg-items--carousel > .tvg-card,
.tvg .tvg-items--strip > .tvg-card {
	scroll-snap-align: start;
}

.tvg .tvg-carousel__btn {
	position: absolute;
	top: 40%;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	transform: translateY(-50%);
	border: 0;
	border-radius: 50%;
	background: var(--tvg-card-bg);
	color: var(--tvg-fg);
	box-shadow: var(--tvg-shadow);
	font-family: inherit;
	font-size: 24px;
	line-height: 1;
	text-align: center;
	cursor: pointer;
}

.tvg .tvg-carousel__btn--prev {
	left: -12px;
}

.tvg .tvg-carousel__btn--next {
	right: -12px;
}

/* Player + galería / playlist. */
.tvg .tvg-player {
	display: grid;
	gap: var(--tvg-gap);
	grid-template-columns: 1fr;
}

.tvg .tvg-stage {
	position: relative;
	aspect-ratio: var(--tvg-ratio);
	overflow: hidden;
	border-radius: var(--tvg-radius);
	background: #000;
}

.tvg .tvg-stage > iframe,
.tvg .tvg-stage > video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.tvg .tvg-stage__facade {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: #000;
	cursor: pointer;
}

.tvg .tvg-stage__facade img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.tvg .tvg-stage__facade::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 72px;
	height: 72px;
	transform: translate(-50%, -50%);
	border-radius: 50%;
	background: var(--tvg-accent);
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.tvg .tvg-stage__facade::before {
	content: "";
	position: absolute;
	left: calc(50% - 6px);
	top: 50%;
	z-index: 1;
	transform: translateY(-50%);
	border-left: 22px solid #fff;
	border-top: 14px solid transparent;
	border-bottom: 14px solid transparent;
}

.tvg .tvg-items--playlist {
	display: grid;
	align-content: start;
	gap: 12px;
	max-height: 70vh;
	overflow-y: auto;
}

.tvg .tvg-items--playlist > .tvg-card {
	display: grid;
	grid-template-columns: 140px 1fr;
	align-items: start;
	box-shadow: none;
}

.tvg .tvg-items--playlist > .tvg-card .tvg-card__body {
	padding: 8px 10px;
}

.tvg .tvg-items--playlist > .tvg-card .tvg-card__title {
	font-size: 0.9rem;
	-webkit-line-clamp: 2;
}

.tvg .tvg-card.is-active {
	outline: 2px solid var(--tvg-accent);
	outline-offset: -2px;
}

.tvg.tvg--player-playlist .tvg-player {
	grid-template-columns: minmax(0, 1fr) 320px;
}

.tvg.tvg--pos-left .tvg-player {
	grid-template-columns: 320px minmax(0, 1fr);
}

.tvg.tvg--pos-left .tvg-stage {
	order: 2;
}

/* ---------- Paginación ---------- */

.tvg .tvg-more {
	display: flex;
	justify-content: center;
	margin-top: 24px;
}

.tvg .tvg-more__btn {
	padding: 10px 22px;
	border: 1px solid var(--tvg-accent);
	border-radius: 999px;
	background: transparent;
	color: var(--tvg-accent);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.tvg .tvg-more__btn:hover,
.tvg .tvg-more__btn:focus-visible {
	background: var(--tvg-accent);
	color: #fff;
}

.tvg-notice {
	padding: 12px 16px;
	border-radius: var(--tvg-radius);
	background: #fef3c7;
	color: #78350f;
}

/* ---------- Lightbox (dialog nativo) ---------- */

/*
 * Centrado con transform en el viewport. El ancho se limita también por altura
 * (85vh) para que un video vertical quepa sin salirse de la pantalla.
 * --tvg-num lo fija el JS con la proporción ancho/alto del video que se abre.
 */
.tvg dialog.tvg-lightbox {
	position: fixed;
	inset: 50% auto auto 50%;
	margin: 0;
	transform: translate(-50%, -50%);
	width: min(96vw, 1200px, calc(85vh * var(--tvg-num, 1.7778)));
	height: auto;
	max-width: 96vw;
	max-height: 100vh;
	overflow: visible;
	padding: 0;
	border: 0;
	background: transparent;
	color: #fff;
}

.tvg .tvg-lightbox::backdrop {
	background: rgba(0, 0, 0, 0.85);
}

.tvg .tvg-lightbox__stage {
	position: relative;
	width: 100%;
	aspect-ratio: var(--tvg-num, 1.7778);
	background: #000;
	border-radius: var(--tvg-radius);
	overflow: hidden;
}

.tvg .tvg-lightbox__stage > iframe,
.tvg .tvg-lightbox__stage > video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.tvg .tvg-lightbox__btn {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	font-family: inherit;
	font-size: 26px;
	line-height: 1;
	text-align: center;
	box-shadow: none;
	cursor: pointer;
}

.tvg .tvg-lightbox__btn:hover,
.tvg .tvg-lightbox__btn:focus-visible {
	background: rgba(0, 0, 0, 0.85);
}

.tvg .tvg-lightbox__close {
	top: -52px;
	right: 0;
}

.tvg .tvg-lightbox__prev {
	top: 50%;
	left: -56px;
	transform: translateY(-50%);
}

.tvg .tvg-lightbox__next {
	top: 50%;
	right: -56px;
	transform: translateY(-50%);
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
	.tvg .tvg-items--grid {
		grid-template-columns: var(--tvg-cols-t);
	}

	.tvg .tvg-items--masonry {
		columns: var(--tvg-masonry-t);
	}
}

@media (max-width: 767px) {
	.tvg .tvg-items--grid {
		grid-template-columns: var(--tvg-cols-m);
	}

	.tvg .tvg-items--masonry {
		columns: var(--tvg-masonry-m);
	}

	.tvg .tvg-items--list > .tvg-card {
		grid-template-columns: 1fr;
	}

	.tvg.tvg--player-playlist .tvg-player,
	.tvg.tvg--pos-left .tvg-player {
		grid-template-columns: 1fr;
	}

	.tvg.tvg--pos-left .tvg-stage {
		order: 0;
	}

	.tvg .tvg-items--playlist {
		max-height: none;
	}

	.tvg .tvg-carousel__btn--prev {
		left: 4px;
	}

	.tvg .tvg-carousel__btn--next {
		right: 4px;
	}

	.tvg .tvg-lightbox__prev {
		left: 4px;
	}

	.tvg .tvg-lightbox__next {
		right: 4px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tvg .tvg-items--carousel,
	.tvg .tvg-items--strip,
	.tvg .tvg-items--playlist {
		scroll-behavior: auto;
	}

	.tvg .tvg-card__media img,
	.tvg .tvg-card__play {
		transition: none;
	}
}
