/*
 * Mega menu of the header's "Danh mục sản phẩm" item (markup: inc/mega-menu.php).
 * Layout follows the header-mega-menu.html reference; colours are the theme's own tokens.
 * Below 600px the Navigation block's overlay is used instead and the mega menu is not shown.
 */

.mnn-mega {
	display: none;
}

@media (min-width: 600px) {
	/* A filter on the item would turn it into the containing block of the panel and blur its text. */
	.mnn-header__menu .wp-block-navigation-item.mnn-nav-categories.has-mnn-mega {
		filter: none;
		box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
		cursor: pointer;
	}

	/* The plain dropdown gives way to the mega menu. */
	.mnn-header__menu .wp-block-navigation-item.mnn-nav-categories.has-mnn-mega > .wp-block-navigation__submenu-container {
		display: none;
	}

	.mnn-header__menu .mnn-nav-categories.has-mnn-mega > .wp-block-navigation__submenu-icon {
		transition: transform 0.2s ease;
	}

	.mnn-header__menu .mnn-nav-categories.has-mnn-mega.is-mega-open > .wp-block-navigation__submenu-icon {
		transform: rotate(180deg);
	}

	/* Bridge between the button and the panel, so the pointer can cross the gap. */
	.mnn-header__menu .mnn-nav-categories.has-mnn-mega::after {
		content: "";
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		height: 12px;
	}

	.mnn-mega {
		position: absolute;
		top: calc(100% + 10px);
		left: var(--mnn-mega-left, 0);
		z-index: 30;
		display: grid;
		grid-template-columns: 300px minmax(0, 1fr);
		/* Fallback until mega-menu.js measures the header row; kept inside the viewport even with a scrollbar. */
		width: var(--mnn-mega-width, min(1184px, calc(100vw - 96px)));
		box-sizing: border-box;
		border-radius: 14px;
		background-color: var(--wp--preset--color--white);
		box-shadow: 0 24px 60px rgba(16, 24, 40, 0.22);
		color: var(--wp--preset--color--contrast);
		font-size: 15px;
		font-weight: 400;
		line-height: 1.5;
		text-align: left;
		white-space: normal;
		cursor: default;
		opacity: 0;
		visibility: hidden;
		transform: translateY(6px);
		/* Hidden only once the fade-out has ended; shown at once, so focus can move in immediately. */
		transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
		overflow: hidden;
	}

	/* Without JavaScript the panel opens on hover and keyboard focus. */
	.mnn-nav-categories.has-mnn-mega.is-mega-open > .mnn-mega,
	.mnn-nav-categories.has-mnn-mega:not(.is-mega-js):hover > .mnn-mega,
	.mnn-nav-categories.has-mnn-mega:not(.is-mega-js):focus-within > .mnn-mega {
		opacity: 1;
		visibility: visible;
		transform: none;
		transition-delay: 0s;
	}

	.mnn-mega ul {
		margin: 0;
		padding: 0;
		list-style: none;
	}

	.mnn-mega li {
		margin: 0;
	}

	.mnn-mega p {
		margin: 0;
	}

	/* ---------- First level ---------- */

	.mnn-mega .mnn-mega__l1 {
		padding: 12px 0;
		border-right: 1px solid var(--wp--preset--color--border);
		background-color: #fbfbfc;
	}

	.mnn-mega .mnn-mega__l1-item {
		position: relative;
		display: flex;
		align-items: center;
		gap: 14px;
		min-height: 54px;
		padding: 10px 20px;
		box-sizing: border-box;
		color: var(--wp--preset--color--contrast);
		font-size: 15px;
		font-weight: 500;
		line-height: 1.35;
		text-decoration: none;
		transition: background-color 0.15s ease, color 0.15s ease;
	}

	.mnn-mega__l1-item::after {
		content: "";
		flex: none;
		width: 16px;
		height: 16px;
		margin-left: auto;
		background-color: #c0c5cd;
		-webkit-mask: var(--mnn-mega-chevron) center / 100% 100% no-repeat;
		mask: var(--mnn-mega-chevron) center / 100% 100% no-repeat;
	}

	.mnn-mega__ico {
		position: relative;
		flex: none;
		width: 36px;
		height: 36px;
		border-radius: 9px;
		background-color: #fff0f2;
		transition: background-color 0.15s ease;
	}

	.mnn-mega__ico::after,
	.mnn-mega__thumb--icon::after {
		content: "";
		position: absolute;
		inset: 0;
		background-color: var(--wp--preset--color--maroon);
		-webkit-mask: var(--mnn-icon) center / 18px 18px no-repeat;
		mask: var(--mnn-icon) center / 18px 18px no-repeat;
		transition: background-color 0.15s ease;
	}

	.mnn-mega .mnn-mega__l1-item.is-active {
		background-color: var(--wp--preset--color--white);
		color: var(--wp--preset--color--maroon);
		font-weight: 600;
	}

	.mnn-mega__l1-item.is-active::before {
		content: "";
		position: absolute;
		top: 10px;
		bottom: 10px;
		left: 0;
		width: 3px;
		border-radius: 0 3px 3px 0;
		background-color: var(--wp--preset--color--maroon);
	}

	.mnn-mega__l1-item.is-active::after {
		background-color: var(--wp--preset--color--maroon);
	}

	.mnn-mega__l1-item.is-active .mnn-mega__ico {
		background-color: var(--wp--preset--color--maroon);
	}

	.mnn-mega__l1-item.is-active .mnn-mega__ico::after {
		background-color: var(--wp--preset--color--white);
	}

	.mnn-mega .mnn-mega__l1-item:focus-visible,
	.mnn-mega .mnn-mega__link:focus-visible,
	.mnn-mega .mnn-mega__brand:focus-visible,
	.mnn-mega .mnn-mega__more:focus-visible,
	.mnn-mega .mnn-mega__all:focus-visible,
	.mnn-mega .mnn-mega__promo-button:focus-visible {
		outline: 2px solid var(--wp--preset--color--maroon);
		outline-offset: -2px;
	}

	.mnn-mega .mnn-mega__all {
		display: flex;
		align-items: center;
		gap: 8px;
		margin: 10px 20px 0;
		padding: 14px 0 6px;
		border-top: 1px dashed var(--wp--preset--color--border);
		color: var(--wp--preset--color--maroon);
		font-size: 14px;
		font-weight: 600;
		text-decoration: none;
	}

	.mnn-mega__all::after,
	.mnn-mega__more::after {
		content: "→";
	}

	.mnn-mega .mnn-mega__all:hover,
	.mnn-mega .mnn-mega__more:hover {
		text-decoration: underline;
	}

	/* ---------- Second level ---------- */

	.mnn-mega__panel {
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		gap: 32px;
		min-height: 100%;
		padding: 28px 32px 32px;
		box-sizing: border-box;
	}

	.mnn-mega__panel[hidden] {
		display: none;
	}

	/* The promo box only takes its column when the item has one. */
	.mnn-mega__panel.has-promo {
		grid-template-columns: minmax(0, 1fr) 230px;
	}

	.mnn-mega__head {
		display: flex;
		align-items: baseline;
		justify-content: space-between;
		gap: 12px;
		margin-bottom: 18px;
		padding-bottom: 16px;
		border-bottom: 1px solid var(--wp--preset--color--border);
	}

	.mnn-mega .mnn-mega__title {
		color: var(--wp--preset--color--contrast);
		font-size: 18px;
		font-weight: 700;
		line-height: 1.3;
	}

	.mnn-mega .mnn-mega__more {
		position: relative;
		display: inline-flex;
		gap: 4px;
		padding: 6px 0;
		color: var(--wp--preset--color--maroon);
		font-size: 14px;
		font-weight: 600;
		text-decoration: none;
		white-space: nowrap;
	}

	.mnn-mega .mnn-mega__grid {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 8px 16px;
	}

	.mnn-mega .mnn-mega__link {
		display: flex;
		align-items: center;
		gap: 14px;
		min-height: 72px;
		padding: 12px 14px;
		box-sizing: border-box;
		border-radius: 10px;
		color: var(--wp--preset--color--contrast);
		text-decoration: none;
		transition: background-color 0.15s ease;
	}

	.mnn-mega .mnn-mega__link:hover {
		background-color: #fff0f2;
	}

	.mnn-mega__thumb {
		position: relative;
		flex: none;
		width: 52px;
		height: 52px;
		border-radius: 10px;
		background-color: #f2f3f5;
		overflow: hidden;
	}

	.mnn-mega__thumb img {
		display: block;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}

	.mnn-mega__thumb--icon::after {
		background-color: #98a2b3;
		-webkit-mask-size: 22px 22px;
		mask-size: 22px 22px;
	}

	.mnn-mega__link-text {
		min-width: 0;
	}

	.mnn-mega__link-name {
		display: block;
		font-size: 15px;
		font-weight: 600;
		line-height: 1.3;
	}

	.mnn-mega__link:hover .mnn-mega__link-name {
		color: var(--wp--preset--color--maroon);
	}

	.mnn-mega__link-desc {
		display: block;
		margin-top: 2px;
		color: var(--wp--preset--color--muted);
		font-size: 13px;
		line-height: 1.4;
	}

	.mnn-mega .mnn-mega__empty {
		color: var(--wp--preset--color--muted);
		font-size: 14px;
	}

	.mnn-mega__brands {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 10px;
		margin-top: 24px;
		padding-top: 20px;
		border-top: 1px solid var(--wp--preset--color--border);
		color: var(--wp--preset--color--muted);
		font-size: 13px;
	}

	.mnn-mega .mnn-mega__brand {
		display: inline-flex;
		align-items: center;
		height: 36px;
		padding: 0 16px;
		border: 1px solid var(--wp--preset--color--border);
		border-radius: 99px;
		color: #3d434b;
		font-size: 13px;
		font-weight: 700;
		text-decoration: none;
		transition: border-color 0.15s ease, color 0.15s ease;
	}

	.mnn-mega .mnn-mega__brand:hover {
		border-color: var(--wp--preset--color--maroon);
		color: var(--wp--preset--color--maroon);
	}

	/* ---------- Promo box ---------- */

	.mnn-mega__promo {
		position: relative;
		display: flex;
		flex-direction: column;
		padding: 24px;
		border-radius: 14px;
		background: linear-gradient(160deg, var(--wp--preset--color--maroon), var(--wp--preset--color--maroon-deep));
		color: var(--wp--preset--color--white);
		overflow: hidden;
	}

	.mnn-mega__promo::after {
		content: "";
		position: absolute;
		right: -50px;
		bottom: -50px;
		width: 170px;
		height: 170px;
		box-sizing: border-box;
		border: 30px solid rgba(212, 175, 90, 0.14);
		border-radius: 50%;
	}

	.mnn-mega .mnn-mega__promo-label {
		color: var(--wp--preset--color--gold-light);
		font-size: 11px;
		font-weight: 700;
		letter-spacing: 0.08em;
		text-transform: uppercase;
	}

	.mnn-mega .mnn-mega__promo-title {
		margin-top: 8px;
		font-size: 19px;
		font-weight: 700;
		line-height: 1.25;
	}

	.mnn-mega .mnn-mega__promo-text {
		margin-top: 6px;
		margin-bottom: 18px;
		color: rgba(255, 255, 255, 0.78);
		font-size: 13px;
	}

	.mnn-mega .mnn-mega__promo-button {
		position: relative;
		z-index: 1;
		align-self: flex-start;
		margin-top: auto;
		padding: 12px 18px;
		border-radius: 9px;
		background-color: var(--wp--preset--color--gold);
		color: var(--wp--preset--color--maroon-deep);
		font-size: 14px;
		font-weight: 700;
		text-decoration: none;
	}

	.mnn-mega .mnn-mega__promo-button:hover {
		background-color: var(--wp--preset--color--gold-light);
	}
}

/* Narrow desktop and tablet: narrower first column, no promo box. */
@media (min-width: 600px) and (max-width: 1099px) {
	.mnn-mega {
		grid-template-columns: 260px minmax(0, 1fr);
	}

	.mnn-mega__panel.has-promo {
		grid-template-columns: minmax(0, 1fr);
	}

	.mnn-mega__promo {
		display: none;
	}

	.mnn-mega__panel {
		padding: 24px;
	}
}

@media (min-width: 600px) and (max-width: 859px) {
	.mnn-mega {
		grid-template-columns: 230px minmax(0, 1fr);
	}

	.mnn-mega .mnn-mega__grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.mnn-mega .mnn-mega__l1-item {
		padding-inline: 14px;
	}
}

/* ---------- Backdrop (added by mega-menu.js; sits under the header, above the page) ---------- */

.mnn-mega-backdrop {
	position: fixed;
	inset: 0;
	z-index: 15;
	background-color: rgba(16, 24, 40, 0.45);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s;
}

.mnn-mega-backdrop.is-on {
	opacity: 1;
	visibility: visible;
}

.mnn-mega-toggle {
	display: none;
}

/* ---------- Small screens: the Navigation block's overlay, child categories fold away ---------- */

@media (max-width: 599px) {
	.mnn-mega-backdrop {
		display: none;
	}

	/* The list and its rows span the overlay, so every row is a 44px touch target with the button at its end. */
	.mnn-header__menu .is-menu-open .mnn-nav-categories.is-mnn-accordion,
	.mnn-header__menu .is-menu-open .mnn-nav-categories.is-mnn-accordion > .wp-block-navigation__submenu-container {
		align-self: stretch;
		box-sizing: border-box;
	}

	.mnn-header__menu .is-menu-open .mnn-nav-categories.is-mnn-accordion > .wp-block-navigation__submenu-container > .wp-block-navigation-item {
		position: relative;
		align-self: stretch;
	}

	.mnn-header__menu .is-menu-open .mnn-nav-categories.is-mnn-accordion > .wp-block-navigation__submenu-container > .wp-block-navigation-item > .wp-block-navigation-item__content {
		display: flex;
		align-items: center;
		min-height: 44px;
		padding-block: 6px;
		box-sizing: border-box;
	}

	.mnn-header__menu .is-menu-open .mnn-nav-categories.is-mnn-accordion > .wp-block-navigation__submenu-container > .has-child > .wp-block-navigation-item__content {
		padding-right: 52px;
	}

	.mnn-header__menu .is-menu-open .mnn-mega-toggle {
		position: absolute;
		top: 0;
		right: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 44px;
		height: 44px;
		padding: 0;
		border: 0;
		border-radius: 10px;
		background-color: rgba(255, 255, 255, 0.1);
		color: inherit;
		cursor: pointer;
	}

	.mnn-header__menu .is-menu-open .mnn-mega-toggle::before {
		content: "";
		width: 10px;
		height: 10px;
		margin-top: -4px;
		border-right: 2px solid currentColor;
		border-bottom: 2px solid currentColor;
		transform: rotate(45deg);
		transition: transform 0.2s ease;
	}

	.mnn-header__menu .is-menu-open .mnn-mega-toggle[aria-expanded="true"]::before {
		margin-top: 4px;
		transform: rotate(-135deg);
	}

	.mnn-header__menu .is-menu-open .mnn-mega-toggle:focus-visible {
		outline: 2px solid var(--wp--preset--color--gold-light);
		outline-offset: 2px;
	}

	/* Selector kept this long on purpose: it has to win over the overlay's own "always open" rule. */
	.mnn-header .mnn-header__menu.wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .mnn-nav-categories.is-mnn-accordion > .wp-block-navigation__submenu-container > .has-child:not(.is-mnn-open) > .wp-block-navigation__submenu-container {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mnn-mega,
	.mnn-mega-backdrop,
	.mnn-header__menu .mnn-nav-categories.has-mnn-mega > .wp-block-navigation__submenu-icon {
		transition: none;
	}
}
