/**
 * Crochetts — Modulo Proyectos
 *
 * Imagen corporativa: verde #416843 + crema + Poppins + radio 14-16.
 * Cards, filtro, single y galeria siguen la misma linea que el shortcode
 * de productos para que la web se sienta coherente.
 */

:root {
	--cpg-proy-accent:        #416843;
	--cpg-proy-accent-dark:   #355837;
	--cpg-proy-accent-soft:   rgba( 65, 104, 67, .12 );
	--cpg-proy-bg:            #faf7f1;
	--cpg-proy-bg-soft:       #f3ebdd;
	--cpg-proy-border:        #e9e0cf;
	--cpg-proy-chip-border:   #e0d4bd;
	--cpg-proy-text:          #5a4a32;
	--cpg-proy-title:         #3a2f20;
	--cpg-proy-radius:        14px;
	--cpg-proy-card-radius:   16px;
}

/* ===================================================================== *
 *  Tipografia global del modulo
 * ===================================================================== */
.cpg-proyectos,
.cpg-proyectos *,
.cpg-proyecto-single,
.cpg-proyecto-single * {
	font-family: 'Poppins', sans-serif;
}

/* ===================================================================== *
 *  BARRA DE FILTROS (lista)
 * ===================================================================== */
.cpg-proyectos-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	margin: 0 0 28px;
	background: var( --cpg-proy-bg );
	border: 1px solid var( --cpg-proy-border );
	border-radius: var( --cpg-proy-radius );
}

.cpg-proyectos-filters-label {
	margin: 0 6px 0 0;
	font-size: .7rem;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var( --cpg-proy-text );
}

.cpg-proyectos-filter {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border: 1px solid var( --cpg-proy-chip-border );
	border-radius: 999px;
	background: #fff;
	color: var( --cpg-proy-text );
	font-size: .82rem;
	font-weight: 500;
	text-decoration: none;
	cursor: pointer;
	transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.cpg-proyectos-filter:hover {
	border-color: var( --cpg-proy-accent );
	color: var( --cpg-proy-accent );
}

.cpg-proyectos-filter.is-active {
	background: var( --cpg-proy-accent );
	border-color: var( --cpg-proy-accent );
	color: #fff;
}

.cpg-proyectos-filter-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: 999px;
	background: rgba( 255, 255, 255, .22 );
	font-size: .68rem;
	font-weight: 700;
	line-height: 1;
}

.cpg-proyectos-filter:not( .is-active ) .cpg-proyectos-filter-count {
	background: var( --cpg-proy-accent-soft );
	color: var( --cpg-proy-accent );
}

.cpg-proyectos-filter-clear {
	margin-left: auto;
	border: 1px solid var( --cpg-proy-chip-border );
	background: #fff;
	color: var( --cpg-proy-text );
	padding: 8px 14px;
	border-radius: 999px;
	font-size: .78rem;
	cursor: pointer;
	transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.cpg-proyectos-filter-clear:hover {
	background: var( --cpg-proy-bg-soft );
	color: var( --cpg-proy-accent );
	border-color: var( --cpg-proy-accent );
}

/* ===================================================================== *
 *  GRID DE CARDS
 * ===================================================================== */
.cpg-proyectos-grid {
	display: grid;
	gap: 24px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.cpg-proyectos-cols-2 { grid-template-columns: repeat( 2, minmax( 0, 1fr ) ); }
.cpg-proyectos-cols-3 { grid-template-columns: repeat( 3, minmax( 0, 1fr ) ); }
.cpg-proyectos-cols-4 { grid-template-columns: repeat( 4, minmax( 0, 1fr ) ); }

@media ( max-width: 960px ) {
	.cpg-proyectos-cols-3,
	.cpg-proyectos-cols-4 { grid-template-columns: repeat( 2, minmax( 0, 1fr ) ); }
}
@media ( max-width: 560px ) {
	.cpg-proyectos-cols-2,
	.cpg-proyectos-cols-3,
	.cpg-proyectos-cols-4 { grid-template-columns: 1fr; }
}

/* ===================================================================== *
 *  CARD
 * ===================================================================== */
.cpg-proyecto-card {
	position: relative;
	display: flex;
	flex-direction: column;
	background: #fff;
	border: 1px solid var( --cpg-proy-border );
	border-radius: var( --cpg-proy-card-radius );
	overflow: hidden;
	margin: 0;
	padding: 0;
	transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
	text-align: center;
}

.cpg-proyecto-card:hover {
	border-color: rgba( 65, 104, 67, .45 );
	box-shadow: 0 14px 30px rgba( 58, 44, 24, .15 );
	transform: translateY( -4px );
}

.cpg-proyecto-card-media {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 4 / 5;
	overflow: hidden;
	background: var( --cpg-proy-bg );
	text-decoration: none;
}

.cpg-proyecto-card-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .5s ease;
}

.cpg-proyecto-card:hover .cpg-proyecto-card-img {
	transform: scale( 1.05 );
}

/* Badge: numero de fotos de la galeria */
.cpg-proyecto-card-badge {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 4px 9px;
	border-radius: 999px;
	background: var( --cpg-proy-accent );
	color: #fff;
	font-size: .68rem;
	font-weight: 700;
	letter-spacing: .02em;
	line-height: 1.2;
	box-shadow: 0 2px 6px rgba( 0, 0, 0, .15 );
}

.cpg-proyecto-card-badge::before {
	content: "";
	width: 12px;
	height: 12px;
	background-image: url( "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'><path d='M4 7a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7zm2 0v10h12V7H6zm0 0L8 9l2.5 2.5L15 7l5 5v5H6V7z'/></svg>" );
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
}

/* Chip de tipo en la parte baja de la imagen */
.cpg-proyecto-card-type {
	position: absolute;
	left: 12px;
	bottom: 12px;
	z-index: 2;
	display: inline-block;
	padding: 4px 10px;
	border-radius: 999px;
	background: rgba( 255, 255, 255, .92 );
	color: var( --cpg-proy-accent );
	font-size: .66rem;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	box-shadow: 0 2px 6px rgba( 0, 0, 0, .12 );
}

/* Cuerpo del card */
.cpg-proyecto-card-body {
	padding: 16px 18px 20px;
}

.cpg-proyecto-card-title {
	margin: 0 0 6px;
	font-size: 1.05rem;
	font-weight: 700;
	color: var( --cpg-proy-title );
	line-height: 1.3;
}

.cpg-proyecto-card-title a {
	color: inherit;
	text-decoration: none;
}

.cpg-proyecto-card:hover .cpg-proyecto-card-title a {
	color: var( --cpg-proy-accent );
}

.cpg-proyecto-card-excerpt {
	margin: 0 0 14px;
	font-size: .82rem;
	color: var( --cpg-proy-text );
	line-height: 1.45;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.cpg-proyecto-card-more {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 8px 16px;
	border-radius: 999px;
	background: transparent;
	border: 1px solid var( --cpg-proy-accent );
	color: var( --cpg-proy-accent );
	font-size: .78rem;
	font-weight: 700;
	text-decoration: none;
	transition: background .15s ease, color .15s ease;
}

.cpg-proyecto-card-more:hover {
	background: var( --cpg-proy-accent );
	color: #fff;
}

/* Estado vacio */
.cpg-proyectos-empty {
	padding: 18px 22px;
	max-width: 620px;
	margin: 20px auto;
	text-align: center;
	background: var( --cpg-proy-bg );
	border: 1px solid var( --cpg-proy-border );
	border-radius: var( --cpg-proy-radius );
	color: var( --cpg-proy-text );
}

/* ===================================================================== *
 *  SINGLE — ficha del proyecto
 * ===================================================================== */
.cpg-proyecto-single {
	margin: 24px 0 60px;
}

/* El H1 del theme (entry-title) y el titulo del archive ya los pintamos
 * nosotros en el hero. Los ocultamos solo dentro del single del CPT
 * para no duplicar el encabezado ni penalizar SEO. */
body.single-proyecto h1.entry-title {
	display: none !important;
}

/* Hero: imagen destacada + overlay con titulo y tipo */
.cpg-proyecto-hero {
	position: relative;
	overflow: hidden;
	border-radius: var( --cpg-proy-card-radius );
	background: var( --cpg-proy-bg );
	margin: 0 0 32px;
}

.cpg-proyecto-hero-img {
	display: block;
	width: 100%;
	height: clamp( 320px, 50vw, 560px );
	object-fit: cover;
}

.cpg-proyecto-hero-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-end;
	padding: 28px 32px;
	background: linear-gradient(
		to top,
		rgba( 0, 0, 0, .55 ) 0%,
		rgba( 0, 0, 0, .15 ) 50%,
		rgba( 0, 0, 0, 0 ) 100%
	);
	color: #fff;
}

.cpg-proyecto-hero-overlay-inner {
	max-width: 760px;
}

.cpg-proyecto-hero-type {
	display: inline-block;
	margin: 0 0 10px;
	padding: 5px 12px;
	border-radius: 999px;
	background: var( --cpg-proy-accent );
	color: #fff;
	font-size: .68rem;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
}

.cpg-proyecto-hero-title {
	margin: 0;
	font-size: clamp( 1.6rem, 4vw, 2.6rem );
	font-weight: 700;
	line-height: 1.15;
	color: #fff;
	text-shadow: 0 2px 12px rgba( 0, 0, 0, .35 );
}

/* Layout principal de la ficha: contenido + sidebar */
.cpg-proyecto-layout {
	display: grid;
	grid-template-columns: minmax( 0, 1fr ) 320px;
	gap: 40px;
	align-items: start;
}

@media ( max-width: 900px ) {
	.cpg-proyecto-layout { grid-template-columns: 1fr; gap: 28px; }
}

/* Contenido principal */
.cpg-proyecto-content {
	font-size: 1rem;
	line-height: 1.7;
	color: var( --cpg-proy-text );
}

.cpg-proyecto-content > h1,
.cpg-proyecto-content > h2,
.cpg-proyecto-content > h3,
.cpg-proyecto-content > h4 {
	color: var( --cpg-proy-title );
	font-weight: 700;
	line-height: 1.25;
	margin-top: 1.4em;
	margin-bottom: .6em;
}

.cpg-proyecto-content > h2 { font-size: 1.6rem; }
.cpg-proyecto-content > h3 { font-size: 1.3rem; }

.cpg-proyecto-content p { margin: 0 0 1em; }
.cpg-proyecto-content a { color: var( --cpg-proy-accent ); }
.cpg-proyecto-content img { max-width: 100%; height: auto; border-radius: 10px; }

/* Galeria (grid 4 cols, click para abrir lightbox) */
.cpg-proyecto-galeria {
	margin: 0 0 36px;
}

.cpg-proyecto-galeria-titulo {
	margin: 0 0 14px;
	font-size: 1.1rem;
	font-weight: 700;
	color: var( --cpg-proy-title );
	letter-spacing: .02em;
}

.cpg-proyecto-galeria-grid {
	display: grid;
	grid-template-columns: repeat( 4, minmax( 0, 1fr ) );
	gap: 10px;
	margin: 0;
	padding: 0;
	list-style: none;
}

@media ( max-width: 900px ) {
	.cpg-proyecto-galeria-grid { grid-template-columns: repeat( 3, minmax( 0, 1fr ) ); }
}
@media ( max-width: 600px ) {
	.cpg-proyecto-galeria-grid { grid-template-columns: repeat( 2, minmax( 0, 1fr ) ); }
}

.cpg-proyecto-galeria-item {
	position: relative;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border-radius: 10px;
	cursor: zoom-in;
	background: var( --cpg-proy-bg );
	aspect-ratio: 1 / 1;
}

.cpg-proyecto-galeria-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .4s ease, opacity .15s ease;
}

.cpg-proyecto-galeria-item:hover img {
	transform: scale( 1.05 );
	opacity: .92;
}

/* Sidebar */
.cpg-proyecto-sidebar {
	position: sticky;
	top: 24px;
	display: flex;
	flex-direction: column;
	gap: 18px;
}

@media ( max-width: 900px ) {
	.cpg-proyecto-sidebar { position: static; }
}

.cpg-proyecto-aside-card {
	padding: 18px 20px;
	background: var( --cpg-proy-bg );
	border: 1px solid var( --cpg-proy-border );
	border-radius: var( --cpg-proy-radius );
}

.cpg-proyecto-aside-card h4 {
	margin: 0 0 10px;
	font-size: .7rem;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var( --cpg-proy-text );
}

.cpg-proyecto-aside-card p {
	margin: 0 0 .6em;
	font-size: .92rem;
	color: var( --cpg-proy-title );
	line-height: 1.45;
}

.cpg-proyecto-aside-card .cpg-proyecto-aside-meta {
	display: flex;
	justify-content: space-between;
	padding: 6px 0;
	border-bottom: 1px dashed var( --cpg-proy-border );
	font-size: .85rem;
}

.cpg-proyecto-aside-card .cpg-proyecto-aside-meta:last-child {
	border-bottom: 0;
}

.cpg-proyecto-aside-card strong {
	font-weight: 600;
	color: var( --cpg-proy-title );
}

/* Navegacion prev/next entre proyectos */
.cpg-proyecto-nav {
	display: flex;
	gap: 16px;
	margin: 36px 0 0;
}

.cpg-proyecto-nav a {
	flex: 1 1 0;
	display: flex;
	flex-direction: column;
	padding: 16px 18px;
	background: #fff;
	border: 1px solid var( --cpg-proy-border );
	border-radius: var( --cpg-proy-radius );
	text-decoration: none;
	color: var( --cpg-proy-text );
	transition: border-color .15s ease, background .15s ease;
}

.cpg-proyecto-nav a:hover {
	border-color: var( --cpg-proy-accent );
	background: var( --cpg-proy-bg );
}

.cpg-proyecto-nav .cpg-proyecto-nav-dir {
	font-size: .68rem;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var( --cpg-proy-accent );
}

.cpg-proyecto-nav .cpg-proyecto-nav-tit {
	margin: 4px 0 0;
	font-size: .95rem;
	font-weight: 600;
	color: var( --cpg-proy-title );
}

.cpg-proyecto-nav .cpg-proyecto-nav-next {
	text-align: right;
}

/* ===================================================================== *
 *  Lightbox
 * ===================================================================== */
.cpg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 32px;
	background: rgba( 0, 0, 0, .88 );
	cursor: zoom-out;
}

.cpg-lightbox.is-open {
	display: flex;
}

.cpg-lightbox-img {
	max-width: 92vw;
	max-height: 88vh;
	object-fit: contain;
	border-radius: 10px;
	box-shadow: 0 30px 80px rgba( 0, 0, 0, .6 );
}

.cpg-lightbox-close,
.cpg-lightbox-prev,
.cpg-lightbox-next {
	position: absolute;
	z-index: 1;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background: rgba( 255, 255, 255, .92 );
	color: var( --cpg-proy-accent );
	font-size: 1.4rem;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .15s ease;
}

.cpg-lightbox-close:hover,
.cpg-lightbox-prev:hover,
.cpg-lightbox-next:hover {
	background: #fff;
}

.cpg-lightbox-close { top: 24px; right: 24px; }
.cpg-lightbox-prev  { left: 24px;  top: 50%; transform: translateY( -50% ); }
.cpg-lightbox-next  { right: 24px; top: 50%; transform: translateY( -50% ); }

.cpg-lightbox-counter {
	position: absolute;
	left: 50%;
	bottom: 24px;
	transform: translateX( -50% );
	padding: 6px 12px;
	border-radius: 999px;
	background: rgba( 255, 255, 255, .15 );
	color: #fff;
	font-size: .78rem;
	letter-spacing: .04em;
}

body.cpg-lightbox-open {
	overflow: hidden;
}
