/*
Theme Name: Creciendo Juntos
Theme URI: https://creciendojuntos.org
Author: Creciendo Juntos
Description: Tema de bloques (Gutenberg) para Creciendo Juntos. Colores y tipografías de la marca, hero con la flor animada, bloques animados y pie con redes sociales. Listo para un sitio bilingüe español / inglés.
Version: 1.5.0
Requires at least: 6.6
Tested up to: 6.8
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: creciendo-juntos
Tags: block-theme, full-site-editing, nonprofit, bilingual
*/

/* ---------- Base ---------- */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
img { height: auto; }
:where(.wp-site-blocks) > * { margin-block-start: 0; }

/* ---------- Encabezado ---------- */
.cj-header {
	position: sticky;
	top: 0;
	z-index: 50;
	background: color-mix(in srgb, var(--wp--preset--color--crema) 92%, transparent);
	backdrop-filter: saturate(1.2) blur(8px);
	border-bottom: 1px solid var(--wp--preset--color--arena);
}
.admin-bar .cj-header { top: 32px; }
@media (max-width: 782px) { .admin-bar .cj-header { top: 0; position: relative; } }
.cj-header .wp-block-site-logo img { max-height: 56px; width: auto; }
.cj-header .wp-block-navigation .wp-block-navigation-item__content { padding: .35rem .2rem; }
.cj-header .wp-block-navigation__submenu-container {
	border: 1px solid var(--wp--preset--color--arena) !important;
	border-radius: 14px;
	padding: .5rem !important;
	box-shadow: var(--wp--preset--shadow--suave);
	min-width: 220px !important;
}
.cj-header .wp-block-navigation__submenu-container .wp-block-navigation-item__content { padding: .45rem .7rem; border-radius: 8px; }
.cj-header .wp-block-navigation__submenu-container .wp-block-navigation-item__content:hover { background: var(--wp--preset--color--arena); }
.cj-header .wp-block-navigation a { text-decoration: none; }
.cj-header .wp-block-navigation a:hover { color: var(--wp--preset--color--rojo); }
.cj-header .cj-boton-donar .wp-block-button__link { padding: .55rem 1.2rem; }

/* ---------- Hero con la flor ---------- */
.cj-hero { overflow: hidden; }
.cj-hero .cj-logo-animado { display: flex; justify-content: center; }
/* La flor usa todo el ancho disponible (hasta 1200px), con o sin el div envoltorio */
.cj-hero > .cj-logo-animado,
.cj-hero > svg { max-width: min(1200px, 100%) !important; width: 100%; margin-left: auto !important; margin-right: auto !important; }
.cj-hero .cj-logo-animado svg,
.cj-hero > svg { display: block; width: 100%; height: auto; overflow: visible; }

.cj-hero .tierra {
	fill: none; stroke: var(--wp--preset--color--terracota); stroke-width: 4; stroke-linecap: round; opacity: .55;
	stroke-dasharray: 1; stroke-dashoffset: 1; animation: cj-tierra .8s ease-out forwards;
}
@keyframes cj-tierra { to { stroke-dashoffset: 0; } }

.cj-hero .trazo {
	fill: none; stroke: var(--wp--preset--color--verde); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round;
	stroke-dasharray: 0 1 0 0;
	animation: cj-rama var(--t, 3s) cubic-bezier(.4,.1,.4,1) var(--d, .7s) both, cj-apagar .8s ease 4.22s forwards;
}
@keyframes cj-rama { 0% { stroke-dasharray: 0 1 0 0; stroke-width: 0; } 6% { stroke-width: 3.2; } 100% { stroke-dasharray: .5 0 .5 0; stroke-width: 3.2; } }
@keyframes cj-apagar { to { stroke-width: 0; } }

.cj-hero .relleno { opacity: 0; animation: cj-llenar 1.2s ease 4.22s forwards; }
@keyframes cj-llenar { to { opacity: 1; } }

.cj-hero .flor { transform-box: fill-box; transform-origin: 50% 100%; animation: cj-mecerse 6s ease-in-out 5.62s infinite; }
@keyframes cj-mecerse { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(1.5deg); } }

.cj-hero .letra {
	opacity: 0; transform: translateY(24px); transform-box: fill-box;
	animation: cj-subir .6s cubic-bezier(.2,.8,.2,1) forwards;
	animation-delay: calc(3.62s + var(--i, 0) * 70ms);
}
@keyframes cj-subir { to { opacity: 1; transform: none; } }

.cj-hero .cj-hero-texto { opacity: 0; animation: cj-aparecer .9s ease 4.6s forwards; }
@keyframes cj-aparecer { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* En el editor se ve todo quieto y completo */
.editor-styles-wrapper .cj-hero .trazo { display: none; }
.editor-styles-wrapper .cj-hero .tierra,
.editor-styles-wrapper .cj-hero .relleno,
.editor-styles-wrapper .cj-hero .flor,
.editor-styles-wrapper .cj-hero .letra,
.editor-styles-wrapper .cj-hero .cj-hero-texto { animation: none; stroke-dashoffset: 0; opacity: 1; transform: none; }
.editor-styles-wrapper .cj-hero .tierra { opacity: .55; }

/* ---------- Tres bloques animados ---------- */
.cj-tarjetas { align-items: stretch !important; }
.cj-tarjetas > .wp-block-column { display: flex; }
.cj-tarjeta {
	position: relative;
	width: 100%;
	height: 100%;
	border-radius: 22px;
	transition: transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s ease;
}
.cj-tarjeta:hover { transform: translateY(-6px); box-shadow: 0 4px 10px rgba(42,33,27,.08), 0 24px 44px rgba(42,33,27,.12); }
.cj-tarjeta .cj-icono {
	width: 64px; height: 64px; border-radius: 50%;
	display: grid; place-items: center;
	transition: transform .4s cubic-bezier(.2,.8,.2,1);
}
.cj-tarjeta .cj-icono svg { width: 32px; height: 32px; }
/* Si el ícono es una imagen (dibujo propio), se muestra sola, sin círculo */
.cj-tarjeta .cj-icono:has(> img) { width: auto; height: auto; background: none !important; border-radius: 0; place-items: start; }
.cj-tarjeta .cj-icono img { width: 120px; height: 120px; object-fit: contain; display: block; }
.cj-tarjeta:hover .cj-icono { transform: scale(1.08) rotate(-6deg); }
.cj-tarjeta .cj-enlace a { text-decoration: none; font-weight: 700; }
.cj-tarjeta .cj-enlace a::after { content: "→"; display: inline-block; margin-left: .35em; transition: transform .25s ease; }
.cj-tarjeta:hover .cj-enlace a::after { transform: translateX(4px); }
/* Toda la tarjeta es clicable usando el enlace "Conoce más" */
.cj-tarjeta .cj-enlace a::before { content: ""; position: absolute; inset: 0; border-radius: 22px; }
.cj-tarjeta .cj-enlace a:focus-visible::before { outline: 2px solid var(--wp--preset--color--rojo); outline-offset: 4px; }
.cj-tarjeta .cj-franja { height: 6px; border-radius: 6px; width: 48px; }

/* Aparición al hacer scroll (solo si hay JavaScript y el usuario acepta animaciones) */
@media (prefers-reduced-motion: no-preference) {
	.cj-js .cj-reveal { opacity: 0; transform: translateY(28px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.8,.2,1); }
	.cj-js .cj-reveal.is-visible { opacity: 1; transform: none; }
	.cj-js .cj-tarjetas > .cj-reveal:nth-child(2) { transition-delay: .12s; }
	.cj-js .cj-tarjetas > .cj-reveal:nth-child(3) { transition-delay: .24s; }
}

/* ---------- Noticias / entradas ---------- */
.cj-noticia { border-radius: 18px; overflow: hidden; height: 100%; }
.cj-noticia .wp-block-post-featured-image img { aspect-ratio: 3/2; object-fit: cover; width: 100%; }

/* ---------- Equipo ---------- */
.cj-persona .wp-block-image img { border-radius: 50%; aspect-ratio: 1; object-fit: cover; }

/* ---------- Pie de página ---------- */
.cj-footer a { color: inherit; }
.cj-footer a:hover { color: var(--wp--preset--color--arena); }
.cj-footer .wp-block-social-links .wp-social-link { background: var(--wp--preset--color--crema) !important; color: var(--wp--preset--color--verde-oscuro) !important; }
.cj-footer .wp-block-social-links .wp-social-link:hover { background: var(--wp--preset--color--terracota) !important; color: #fff !important; transform: translateY(-2px); }
.cj-footer .wp-block-social-links .wp-social-link a { color: inherit !important; }
.cj-footer .cj-lista-pie { list-style: none; padding-left: 0; line-height: 1.9; }
.cj-footer .cj-pie-legal { border-top: 1px solid rgba(251,247,240,.2); }

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
	.cj-hero .trazo { display: none; }
	.cj-hero .tierra, .cj-hero .relleno, .cj-hero .flor, .cj-hero .letra, .cj-hero .cj-hero-texto { animation: none; stroke-dashoffset: 0; opacity: 1; transform: none; }
	.cj-hero .tierra { opacity: .55; }
	.cj-tarjeta, .cj-tarjeta .cj-icono { transition: none; }
}
.cj-tarjeta .cj-enlace { margin-top: auto; }

/* Flor del hero: su alto es un porcentaje de la pantalla.
   Para cambiarlo, pon en CSS adicional:  :root { --cj-flor-alto: 50svh; }  */
:where(:root) { --cj-flor-alto: 66vh; }
@supports (height: 1svh) { :where(:root) { --cj-flor-alto: 66svh; } }
svg.logo-hero { display: block !important; width: min(100%, calc(var(--cj-flor-alto) * 1200 / 870)) !important; max-width: none !important; height: auto !important; margin: 0 auto !important; }
.wp-site-blocks *:not(.wp-block-column):has(> svg.logo-hero),
.wp-site-blocks *:not(.wp-block-column):has(> * > svg.logo-hero) { max-width: none !important; width: 100% !important; }
section.hero:has(svg.logo-hero) { min-height: 0 !important; padding: 0 !important; }
.repetir { display: none !important; }

/* ---------- Hero: flor a la izquierda, frases a la derecha ---------- */
.cj-hero .cj-hero-fila { display: flex !important; align-items: center !important; gap: var(--wp--preset--spacing--50); }
@media (min-width: 782px) {
	.cj-hero .wp-block-columns.cj-hero-fila { flex-wrap: nowrap !important; }
	.cj-hero .cj-hero-fila > .cj-hero-col-flor { flex: 0 0 58% !important; max-width: 58%; min-width: 0; }
	.cj-hero .cj-hero-fila > .cj-frases { flex: 1 1 0 !important; min-width: 0; }
}
@media (max-width: 781px) {
	.cj-hero .wp-block-columns.cj-hero-fila { flex-direction: column !important; flex-wrap: wrap !important; }
	.cj-hero .cj-hero-fila > .wp-block-column { flex: 1 1 auto !important; width: 100%; max-width: 100%; }
}
.cj-hero .cj-frases { display: flex; flex-direction: column; gap: .35em; }
.cj-hero .cj-frases > * { margin: 0 !important; }
.cj-hero .cj-frase {
	font-family: var(--wp--preset--font-family--titulos);
	color: var(--wp--preset--color--terracota);
	font-weight: 400;
	font-size: clamp(1.6rem, 2.5vw, 2.4rem);
	line-height: 1.15;
	letter-spacing: -0.01em;
	opacity: 0;
	transform: translateY(14px);
	animation: cj-aparecer .8s cubic-bezier(.2,.8,.2,1) forwards;
}
.cj-hero .cj-frase:nth-child(1) { animation-delay: 4.4s; }
.cj-hero .cj-frase:nth-child(2) { animation-delay: 5.0s; }
.cj-hero .cj-frase:nth-child(3) { animation-delay: 5.6s; }
.cj-hero .cj-frase:nth-child(4) { animation-delay: 6.2s; }
.cj-hero .cj-frase:nth-child(5) { animation-delay: 6.8s; }
.cj-hero .cj-hero-texto { animation-delay: 7.2s; }
@media (max-width: 781px) {
	.cj-hero .cj-frases { text-align: center; }
	.cj-hero .cj-frase { font-size: 1.6rem; }
}
.editor-styles-wrapper .cj-hero .cj-frase { animation: none; opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
	.cj-hero .cj-frase { animation: none; opacity: 1; transform: none; }
}
