/* =============================================================================
   TRAMA PROJECTS – Hoja de estilos principal
   Compatible con cualquier tema de WordPress; hereda colores del tema.
   ============================================================================= */

/* ── Variables (se sobreescriben con las del tema si existen) ── */
.trama-projects-wrapper {
	--tp-primary:      var(--wp--preset--color--primary, #0d6efd);
	--tp-secondary:    var(--wp--preset--color--secondary, #343a40);
	--tp-text:         var(--wp--preset--color--foreground, #1e1e1e);
	--tp-bg:           var(--wp--preset--color--background, #ffffff);
	--tp-border:       rgba(0, 0, 0, 0.1);
	--tp-radius:       8px;
	--tp-radius-sm:    4px;
	--tp-shadow:       0 2px 12px rgba(0, 0, 0, 0.07);
	--tp-shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.14);
	--tp-ease:         0.28s cubic-bezier(0.4, 0, 0.2, 1);
	--tp-gap:          24px;

	position: relative;
	font-family: inherit;
}

/* ─────────────────────────────────────────────
   FILTROS DE CATEGORÍA
───────────────────────────────────────────── */
.trama-category-filter {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 36px;
	padding: 0;
	list-style: none;
}

.trama-filter-btn {
	display: inline-flex;
	align-items: center;
	padding: 8px 20px;
	border: 2px solid var(--tp-primary);
	background: transparent;
	color: var(--tp-primary);
	border-radius: 999px;
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	cursor: pointer;
	transition: background var(--tp-ease), color var(--tp-ease), transform var(--tp-ease);
	font-family: inherit;
	line-height: 1.4;
	white-space: nowrap;
}

.trama-filter-btn:hover {
	background: var(--tp-primary);
	color: #fff;
	transform: translateY(-1px);
}

.trama-filter-btn.active {
	background: var(--tp-primary);
	color: #fff;
	pointer-events: none;
}

/* ─────────────────────────────────────────────
   ZONA DE CONTENIDO (grid + overlay)
───────────────────────────────────────────── */
.trama-grid-area {
	position: relative;
}

/* ─────────────────────────────────────────────
   GRID DE TARJETAS
───────────────────────────────────────────── */
.trama-projects-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: var(--tp-gap);
	min-height: 220px;
}

/* ─────────────────────────────────────────────
   TARJETA INDIVIDUAL
───────────────────────────────────────────── */
.trama-project-card {
	background: var(--tp-bg);
	border: 1px solid var(--tp-border);
	border-radius: var(--tp-radius);
	overflow: hidden;
	box-shadow: var(--tp-shadow);
	cursor: pointer;
	transition: transform var(--tp-ease), box-shadow var(--tp-ease);
	display: flex;
	flex-direction: column;
}

.trama-project-card:hover,
.trama-project-card:focus-visible {
	transform: translateY(-4px);
	box-shadow: var(--tp-shadow-hover);
	outline: none;
}

/* Imagen de la tarjeta */
.trama-card-image-wrapper {
	position: relative;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	background: #eee;
	flex-shrink: 0;
}

.trama-card-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform var(--tp-ease);
}

.trama-project-card:hover .trama-card-image,
.trama-project-card:focus-visible .trama-card-image {
	transform: scale(1.04);
}

.trama-card-image-placeholder {
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
}

/* Overlay de hover */
.trama-card-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background var(--tp-ease);
}

.trama-card-view-label {
	background: var(--tp-primary);
	color: #fff;
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	padding: 8px 22px;
	border-radius: 999px;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity var(--tp-ease), transform var(--tp-ease);
}

.trama-project-card:hover .trama-card-overlay,
.trama-project-card:focus-visible .trama-card-overlay {
	background: rgba(0, 0, 0, 0.38);
}

.trama-project-card:hover .trama-card-view-label,
.trama-project-card:focus-visible .trama-card-view-label {
	opacity: 1;
	transform: translateY(0);
}

/* Contenido de texto de la tarjeta */
.trama-card-content {
	padding: 20px;
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.trama-card-categories {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.trama-card-category {
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--tp-primary);
}

.trama-card-title {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.3;
	color: var(--tp-text);
}

.trama-card-client {
	margin: 0;
	font-size: 0.85rem;
	color: var(--tp-secondary);
}

.trama-card-client .trama-label {
	font-weight: 600;
	margin-right: 4px;
}

/* Sin resultados */
.trama-no-results {
	grid-column: 1 / -1;
	text-align: center;
	padding: 60px 20px;
	font-size: 1rem;
	opacity: 0.6;
}

/* ─────────────────────────────────────────────
   PAGINACIÓN
───────────────────────────────────────────── */
.trama-pagination-wrapper {
	margin-top: 48px;
	display: flex;
	justify-content: center;
}

.trama-pagination {
	/* nav element */
}

.trama-pagination-inner {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	justify-content: center;
}

.trama-page-btn {
	min-width: 40px;
	height: 40px;
	padding: 0 10px;
	border: 1px solid var(--tp-border);
	background: var(--tp-bg);
	color: var(--tp-text);
	border-radius: var(--tp-radius-sm);
	font-size: 0.875rem;
	font-weight: 500;
	cursor: pointer;
	transition: background var(--tp-ease), color var(--tp-ease), border-color var(--tp-ease);
	font-family: inherit;
}

.trama-page-btn:hover:not(.trama-page-active) {
	background: var(--tp-primary);
	color: #fff;
	border-color: var(--tp-primary);
}

.trama-page-btn.trama-page-active {
	background: var(--tp-primary);
	color: #fff;
	border-color: var(--tp-primary);
	cursor: default;
}

.trama-page-dots {
	padding: 0 4px;
	opacity: 0.45;
	font-size: 0.875rem;
}

/* ─────────────────────────────────────────────
   OVERLAY DE CARGA
───────────────────────────────────────────── */
.trama-loading-overlay {
	display: none;
	position: absolute;
	inset: 0;
	background: rgba(255, 255, 255, 0.65);
	z-index: 10;
	align-items: center;
	justify-content: center;
	border-radius: var(--tp-radius);
	backdrop-filter: blur(2px);
}

.trama-loading-overlay.is-visible {
	display: flex;
}

.trama-spinner {
	width: 44px;
	height: 44px;
	border: 3px solid rgba(0, 0, 0, 0.1);
	border-top-color: var(--tp-primary);
	border-radius: 50%;
	animation: trama-spin 0.75s linear infinite;
}

@keyframes trama-spin {
	to { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────
   MODAL
───────────────────────────────────────────── */
.trama-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.72);
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0.3s ease;
	backdrop-filter: blur(3px);
}

.trama-modal-overlay.is-open {
	opacity: 1;
	visibility: visible;
}

.trama-modal-container {
	background: var(--tp-bg, #fff);
	border-radius: 12px;
	width: 100%;
	max-width: 860px;
	max-height: 92vh;
	overflow-y: auto;
	overflow-x: hidden;
	position: relative;
	box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
	transform: translateY(24px) scale(0.97);
	opacity: 0;
	transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
	scroll-behavior: smooth;
}

.trama-modal-overlay.is-open .trama-modal-container {
	transform: translateY(0) scale(1);
	opacity: 1;
}

/* Scrollbar del modal */
.trama-modal-container::-webkit-scrollbar       { width: 6px; }
.trama-modal-container::-webkit-scrollbar-track  { background: transparent; }
.trama-modal-container::-webkit-scrollbar-thumb  { background: rgba(0,0,0,0.2); border-radius: 3px; }

/* Barra superior sticky con el botón de cierre */
.trama-modal-topbar {
	position: sticky;
	top: 0;
	z-index: 20;
	display: flex;
	justify-content: flex-end;
	padding: 10px 12px 0;
	pointer-events: none;
}

.trama-modal-close {
	pointer-events: auto;
	width: 36px;
	height: 36px;
	border: none;
	background: rgba(0, 0, 0, 0.3);
	color: #fff;
	border-radius: 50%;
	font-size: 1.2rem;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background var(--tp-ease);
	backdrop-filter: blur(4px);
}

.trama-modal-close:hover {
	background: rgba(0, 0, 0, 0.55);
}

.trama-modal-body {
	/* El padding lo da cada sección interna */
}

/* Hero */
.trama-modal-hero {
	width: 100%;
	aspect-ratio: 16 / 7;
	overflow: hidden;
	border-radius: 12px 12px 0 0;
	margin-top: -46px; /* solapar con la topbar */
}

.trama-modal-hero-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* Área de título */
.trama-modal-title-area {
	padding: 28px 36px 20px;
	border-bottom: 1px solid var(--tp-border);
}

.trama-modal-categories {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 12px;
}

.trama-badge {
	display: inline-block;
	padding: 4px 14px;
	background: var(--tp-primary);
	color: #fff;
	border-radius: 999px;
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.trama-modal-project-title {
	font-size: 1.75rem;
	font-weight: 800;
	line-height: 1.2;
	margin: 0 0 8px;
	color: var(--tp-text);
}

.trama-modal-client {
	margin: 0;
	font-size: 0.9rem;
	color: var(--tp-secondary);
}

/* Contenido principal del modal */
.trama-modal-main-content {
	padding: 28px 36px;
}

.trama-modal-section {
	margin-bottom: 36px;
}

.trama-modal-section:last-child {
	margin-bottom: 0;
}

.trama-modal-section-title {
	font-size: 1.05rem;
	font-weight: 700;
	margin: 0 0 16px;
	color: var(--tp-text);
}

/* Detalle del proyecto */
.trama-modal-detalle {
	font-size: 0.975rem;
	line-height: 1.7;
	color: var(--tp-text);
}

.trama-modal-detalle p { margin: 0 0 1em; }
.trama-modal-detalle p:last-child { margin-bottom: 0; }

/* Vídeos */
.trama-videos-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 20px;
}

.trama-video-embed {
	position: relative;
	aspect-ratio: 16 / 9;
	border-radius: var(--tp-radius);
	overflow: hidden;
	background: #000;
}

.trama-video-embed iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* Galería */
.trama-modal-gallery-desc {
	margin-bottom: 16px;
	font-size: 0.95rem;
	line-height: 1.6;
}

.trama-gallery-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 10px;
}

.trama-gallery-item {
	display: block;
	border-radius: var(--tp-radius-sm);
	overflow: hidden;
	aspect-ratio: 1;
	transition: opacity var(--tp-ease), transform var(--tp-ease);
}

.trama-gallery-item:hover {
	opacity: 0.82;
	transform: scale(1.03);
}

.trama-gallery-thumb {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* Más info */
.trama-modal-mas-info {
	font-size: 0.95rem;
	line-height: 1.65;
	padding-top: 24px;
	border-top: 1px solid var(--tp-border);
}

/* Pie del modal */
.trama-modal-footer {
	padding: 20px 36px 28px;
	border-top: 1px solid var(--tp-border);
	display: flex;
	justify-content: flex-end;
}

.trama-btn-ver-proyecto {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 28px;
	background: var(--tp-primary);
	color: #fff !important;
	text-decoration: none !important;
	border-radius: 999px;
	font-weight: 700;
	font-size: 0.875rem;
	letter-spacing: 0.04em;
	transition: background var(--tp-ease), transform var(--tp-ease);
}

.trama-btn-ver-proyecto:hover {
	background: var(--tp-secondary);
	transform: translateX(3px);
}

/* Bloquear scroll del body cuando el modal está abierto */
body.trama-modal-open {
	overflow: hidden;
}

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */

/* Tablet */
@media (max-width: 1024px) {
	.trama-projects-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* Móvil */
@media (max-width: 640px) {
	.trama-projects-grid {
		grid-template-columns: 1fr;
		gap: 16px;
	}

	.trama-category-filter {
		margin-bottom: 24px;
	}

	.trama-filter-btn {
		padding: 6px 14px;
		font-size: 0.72rem;
	}

	.trama-modal-hero {
		aspect-ratio: 16 / 9;
		margin-top: -46px;
	}

	.trama-modal-title-area,
	.trama-modal-main-content,
	.trama-modal-footer {
		padding-left: 20px;
		padding-right: 20px;
	}

	.trama-modal-project-title {
		font-size: 1.3rem;
	}

	.trama-gallery-grid {
		grid-template-columns: repeat(2, 1fr);
	}

	.trama-modal-footer {
		justify-content: center;
	}

	.trama-btn-ver-proyecto {
		width: 100%;
		justify-content: center;
	}
}
