/**
 * Mega-menú de categorías Cashmascota — se abre al PULSAR (sin hover).
 * Marca: magenta #CF2A70, amarillo #F9E512.
 */

.cm-megamenu {
	--cm-magenta: #cf2a70;
	--cm-magenta-soft: rgba(207, 42, 112, 0.08);
	--cm-texto: #2b2b2b;
	--cm-gris: #5b555a;
	--cm-borde: #ececec;
	font-family: inherit;
	position: relative;
}

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

/* ---------- Lista principal ---------- */
.cm-megamenu__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.1rem;
}

.cm-megamenu__item {
	position: relative;
	display: flex;
	align-items: center;
}

.cm-megamenu__top {
	display: inline-flex;
	align-items: center;
	padding: 0.55rem 0.55rem 0.55rem 0.85rem;
	font-weight: 600;
	font-size: 0.98rem;
	line-height: 1;
	color: var(--cm-texto);
	text-decoration: none;
	border-radius: 999px 0 0 999px;
	white-space: nowrap;
	transition: color 0.15s ease, background-color 0.15s ease;
}

.cm-megamenu__item:not(.has-children) .cm-megamenu__top {
	border-radius: 999px;
	padding-right: 0.85rem;
}

/* Botón flecha (abre/cierra) */
.cm-megamenu__toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	padding: 0 0.5rem 0 0.2rem;
	background: transparent;
	border: 0;
	color: var(--cm-texto);
	cursor: pointer;
	border-radius: 0 999px 999px 0;
	transition: color 0.15s ease, background-color 0.15s ease;
}

.cm-megamenu__item.is-open .cm-megamenu__top,
.cm-megamenu__item.is-open .cm-megamenu__toggle {
	color: var(--cm-magenta);
	background: var(--cm-magenta-soft);
}

.cm-caret {
	transition: transform 0.18s ease;
}

.cm-megamenu__item.is-open .cm-caret {
	transform: rotate(180deg);
}

/* ---------- Panel desplegable ---------- */
.cm-megamenu__panel {
	display: none;
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	min-width: 260px;
	max-width: min(760px, 92vw);
	background: #fff;
	border: 1px solid var(--cm-borde);
	border-top: 3px solid var(--cm-magenta);
	border-radius: 10px;
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.13);
	padding: 1rem 1.15rem;
	z-index: 200;
}

.cm-megamenu__item.is-open .cm-megamenu__panel {
	display: block;
}

.cm-megamenu__cols {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 0.3rem 1.6rem;
}

.cm-megamenu__familia {
	display: block;
	font-weight: 700;
	font-size: 0.92rem;
	color: var(--cm-texto);
	text-decoration: none;
	padding: 0.3rem 0;
	border-bottom: 1px solid var(--cm-borde);
	margin-bottom: 0.3rem;
}

.cm-megamenu__familia:hover {
	color: var(--cm-magenta);
}

.cm-megamenu__subs {
	list-style: none;
	margin: 0 0 0.7rem;
	padding: 0;
}

.cm-megamenu__subs a {
	display: block;
	font-size: 0.88rem;
	color: var(--cm-gris);
	text-decoration: none;
	padding: 0.22rem 0;
}

.cm-megamenu__subs a:hover {
	color: var(--cm-magenta);
}

/* ---------- Botón "Categorías" (solo móvil) ---------- */
.cm-megamenu__bar {
	display: none;
	align-items: center;
	gap: 0.55rem;
	background: var(--cm-magenta);
	color: #fff;
	border: 0;
	border-radius: 999px;
	padding: 0.6rem 1.1rem;
	font-weight: 700;
	font-size: 0.98rem;
	cursor: pointer;
}

.cm-megamenu__burger,
.cm-megamenu__burger::before,
.cm-megamenu__burger::after {
	display: block;
	width: 18px;
	height: 2px;
	background: #fff;
	border-radius: 2px;
}

.cm-megamenu__burger {
	position: relative;
}

.cm-megamenu__burger::before,
.cm-megamenu__burger::after {
	content: "";
	position: absolute;
	left: 0;
}

.cm-megamenu__burger::before { top: -6px; }
.cm-megamenu__burger::after  { top: 6px; }

/* ----------------------------------------------------------------------
 * Móvil / tablet (<= 900px): acordeón a pantalla completa.
 * -------------------------------------------------------------------- */
@media (max-width: 900px) {
	.cm-megamenu__bar {
		display: inline-flex;
	}

	.cm-megamenu__list {
		display: none;
		flex-direction: column;
		align-items: stretch;
		gap: 0;
		position: absolute;
		top: calc(100% + 8px);
		left: 0;
		min-width: 260px;
		width: max-content;
		max-width: 92vw;
		background: #fff;
		border: 1px solid var(--cm-borde);
		border-radius: 12px;
		box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
		padding: 0.4rem;
		max-height: 76vh;
		overflow-y: auto;
		z-index: 300;
	}

	.cm-megamenu.is-open .cm-megamenu__list {
		display: flex;
	}

	.cm-megamenu__item {
		flex-wrap: wrap;
		border-bottom: 1px solid var(--cm-borde);
	}

	.cm-megamenu__item:last-child {
		border-bottom: 0;
	}

	.cm-megamenu__top {
		flex: 1;
		border-radius: 0;
		padding: 0.9rem 0.7rem;
	}

	.cm-megamenu__item:not(.has-children) .cm-megamenu__top {
		border-radius: 0;
	}

	.cm-megamenu__toggle {
		width: 48px;
		height: 48px;
		border-radius: 0;
		padding: 0;
	}

	.cm-megamenu__panel {
		display: none;
		position: static;
		flex-basis: 100%;
		min-width: 0;
		max-width: none;
		border: 0;
		border-top: 0;
		border-radius: 0;
		box-shadow: none;
		padding: 0 0 0.7rem 0.95rem;
	}

	.cm-megamenu__item.is-open .cm-megamenu__panel {
		display: block;
	}

	.cm-megamenu__cols {
		grid-template-columns: 1fr;
		gap: 0.1rem;
	}
}
