/**
 * MiRed How It Works — diagrama "¿Cómo funciona MiRed?".
 * Todo namespaced bajo .mired-cf para no contaminar el resto del sitio.
 */

.mired-cf {
	--cf-card: 219.833px;
	--cf-arrow: 56px;
	--cf-card-bg: #f4f4f4;
	--cf-conn-bg: #dddddd;
	--cf-arrow-bg: #00AEF0;
	--cf-card-radius: 19px;
	--cf-icon-size: 64px;
	/* Aire mínimo arriba/abajo cuando el widget queda fijo (sticky). */
	--cf-sticky-gap: 100px;

	box-sizing: border-box;
	width: 100%;
	background: #fff;
	border-radius: 30px;
}

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

/* ── Tarjeta de paso ─────────────────────────────────────────────────────── */
.mired-cf__card {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	height: 100%;
	padding: 14px;
	background: var(--cf-card-bg);
	border-radius: 0;
	text-align: center;
}

/* ── Tarjeta destacada (highlight): fondo sólido, texto blanco, sin ícono ─ */
.mired-cf__card--highlight {
	/* background-color se aplica inline desde PHP con el color de acento. */
	justify-content: center;
}

.mired-cf__card--highlight .mired-cf__title {
	color: var(--step-title-color, #ffffff);
}

.mired-cf__card--highlight .mired-cf__text,
.mired-cf__card--highlight .mired-cf__text p,
.mired-cf__card--highlight .mired-cf__text strong,
.mired-cf__card--highlight .mired-cf__text b {
	color: var(--step-text-color, #ffffff);
}

.mired-cf__card--highlight.mired-cf__card--light-bg {
	border: 1px solid #e2e8f0;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.mired-cf__card--highlight.mired-cf__card--light-bg .mired-cf__title {
	color: var(--step-title-color, #161616);
}

.mired-cf__card--highlight.mired-cf__card--light-bg .mired-cf__text,
.mired-cf__card--highlight.mired-cf__card--light-bg .mired-cf__text p,
.mired-cf__card--highlight.mired-cf__card--light-bg .mired-cf__text strong,
.mired-cf__card--highlight.mired-cf__card--light-bg .mired-cf__text b {
	color: var(--step-text-color, #161616);
}

.mired-cf__card--highlight .mired-cf__text {
	font-size: clamp(14px, 1.15vw, 18px);
	line-height: 1.55;
}

.mired-cf__body {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	min-width: 0;
}

.mired-cf__title {
	margin: 0;
	font-weight: 800;
	font-size: 18px;
	line-height: 1.2;
	color: var(--step-title-color, #161616);
}

.mired-cf__text {
	margin: 0;
	/* Escala con la resolución entre 18 → 16 → 14, sin bajar nunca de 14px. */
	font-size: clamp(14px, 1.15vw, 18px);
	line-height: 1.45;
	color: var(--step-text-color, #161616);
}

.mired-cf__text p,
.mired-cf__text strong,
.mired-cf__text b {
	font-weight: inherit;
	color: var(--step-text-color, inherit);
}

.mired-cf__text strong,
.mired-cf__text b {
	font-weight: 700;
}

/* ── Íconos ──────────────────────────────────────────────────────────────── */
.mired-cf__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: var(--cf-icon-size);
	height: var(--cf-icon-size);
	border-radius: 16px;
	overflow: hidden;
}

.mired-cf__icon:not(.mired-cf__icon--logo):not(.mired-cf__icon--custom) {
	background: var(--accent, #1dafb2);
}

.mired-cf__icon--logo {
	background: transparent;
	width: calc(var(--cf-icon-size) + 8px);
	height: calc(var(--cf-icon-size) + 8px);
	border-radius: 0;
}

.mired-cf__icon--custom {
	background: transparent;
	width: auto;
	height: var(--cf-icon-size);
	border-radius: 0;
	overflow: visible;
}

.mired-cf__icon--custom .mired-cf__img {
	height: var(--cf-icon-size);
	width: auto;
	max-width: none;
	max-height: none;
	object-fit: contain;
}

.mired-cf__glyph {
	width: 60%;
	height: 60%;
}

.mired-cf__glyph--pos {
	width: 42%;
	height: 70%;
}

.mired-cf__logo-svg {
	width: 100%;
	height: 100%;
}

.mired-cf__img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 12px;
}

/* ── Flecha conectora ────────────────────────────────────────────────────── */
.mired-cf__arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 7px;
	background: var(--cf-arrow-bg);
}

.mired-cf__arrow-svg {
	width: 19px;
	height: 19px;
	display: block;
}

.mired-cf__arrow--right .mired-cf__arrow-svg { transform: rotate(0deg); }
.mired-cf__arrow--down  .mired-cf__arrow-svg { transform: rotate(90deg); }
.mired-cf__arrow--left  .mired-cf__arrow-svg { transform: rotate(180deg); }
.mired-cf__arrow--up    .mired-cf__arrow-svg { transform: rotate(270deg); }

/* ── Layout escritorio (snake grid) ──────────────────────────────────────── */
.mired-cf__desktop {
	display: none;
	width: 100%;
}

.mired-cf__grid {
	display: grid;
	width: 100%;
	margin: 0;
	gap: 0;
}

.mired-cf__cell {
	width: 100%;
	/* Alto mínimo responsivo; la celda crece con el contenido para que el
	   texto nunca se corte. Las filas del grid se auto-ajustan y mantienen
	   alineadas las tarjetas de cada fila. */
	min-height: clamp(170px, 15vw, 230px);
	overflow: hidden;
}

.mired-cf__conn {
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--cf-conn-bg);
}

/* ── Layout móvil (stack) ────────────────────────────────────────────────── */
.mired-cf__mobile {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	width: 100%;
	max-width: 100%;
	margin: 0;
	background: var(--cf-conn-bg);
	border-radius: var(--cf-card-radius);
	overflow: hidden;
}

.mired-cf__mrow {
	width: 100%;
}

.mired-cf__card--mobile {
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	height: auto;
	min-height: 0;
	padding: 24px 22px;
	text-align: center;
}

.mired-cf__card--mobile .mired-cf__body {
	flex: 0 1 auto;
	align-items: center;
	gap: 6px;
	text-align: center;
}

.mired-cf__card--mobile .mired-cf__title {
	font-size: 17px;
}

.mired-cf__card--mobile .mired-cf__text {
	font-size: 14.5px;
	line-height: 1.5;
}

.mired-cf__mconn {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 44px;
	background: var(--cf-conn-bg);
}

/* ── Overlay (highlight sobre paso anterior) ─────────────────────────────── */

/* Escritorio: la celda overlay comparte la misma posición de grid;
   CSS Grid las apila automáticamente. */
.mired-cf__cell--overlay {
	z-index: 1;
}

/* Móvil: wrapper relativo que contiene la tarjeta base y la overlay absoluta. */
.mired-cf__mrow-group {
	position: relative;
	width: 100%;
}

.mired-cf__mrow--overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1;
}

/* ── Conmutador responsive ───────────────────────────────────────────────── */
/* La cuadrícula de escritorio sólo aparece a partir de 1200px; por debajo se usa
   el layout apilado para evitar que las tarjetas/íconos se compriman y corten. */
@media (min-width: 1200px) {
	.mired-cf__desktop { display: block; }
	.mired-cf__mobile  { display: none; }
}

/* Desde 1301px hacia abajo los íconos se encogen gradualmente para que el
   widget no crezca de más y la sección siga visible (sin taparse con el navbar). */
@media (max-width: 1300px) {
	.mired-cf {
		--cf-icon-size: clamp(40px, 3.7vw, 56px);
		/* Más aire arriba en estas resoluciones para que, al quedar fijo,
		   el plugin no se pegue al navbar. */
		--cf-sticky-gap: 150px;
	}
}

/* ── Pista de scroll (runway) ── creada por JS ───────────────────────────── */
.mired-cf-runway {
	position: relative;
	width: 100%;
	overflow: visible;
}

/* Cuando JS arma la animación, el widget se vuelve sticky. */
.mired-cf.is-armed {
	position: sticky;
	z-index: 2;
	margin-left: auto;
	margin-right: auto;
	/* top se calcula en JS para centrar verticalmente. */
}

/* ── Animación de aparición on-scroll (armada por JS) ────────────────────── */
.mired-cf.is-armed .mired-cf__item {
	opacity: 0;
	transform: scale(0.8);
	will-change: opacity, transform;
	transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
}

/* Transición más lenta y suave para revelar el paso destacado (tarjeta azul) */
.mired-cf.is-armed .mired-cf__item:has(.mired-cf__card--highlight) {
	transition: opacity 1.2s ease-in-out, transform 1.2s ease-in-out;
}

.mired-cf.is-armed .mired-cf__item.is-visible {
	opacity: 1;
	transform: scale(1);
}

@media (prefers-reduced-motion: reduce) {
	.mired-cf.is-armed .mired-cf__item {
		opacity: 1;
		transform: none;
		transition: none;
	}
}
