/*
 * The Nudeln menu (inc/mega-menu.php), wide screens only: this file is linked
 * with media="(min-width: 68.75rem)", the nav's own breakpoint. Below it
 * global.css keeps panel and button hidden and the drawer is unchanged.
 *
 * The panel is display: none while closed, so its lazy photos are not fetched
 * with every page; site.js asks for them as the pointer reaches the menu.
 * Designed and built by BatuWeb.de.
 */

.has-mega {
	align-items: center;
	display: flex;
	gap: var(--wp--preset--spacing--xxs);
}

/* site.js marks the item ready; without it "Nudeln" is a plain link. */
.has-mega.is-ready > .mega-toggle {
	align-items: center;
	background: none;
	border: 0;
	border-radius: var(--an-radius-s);
	color: inherit;
	display: inline-flex;
	height: 1.5rem;
	justify-content: center;
	min-height: 0;
	padding: 0;
	width: 1.5rem;
}

.mega-toggle svg {
	height: 1rem;
	stroke: currentColor;
	transition: rotate var(--an-duration-fast) var(--an-easing);
	width: 1rem;
}

.has-mega.is-open > .mega-toggle svg {
	rotate: 180deg;
}

.has-mega > .mega-toggle:hover {
	background-color: var(--wp--preset--color--surface);
	color: inherit;
}

.site-nav__list .has-mega.is-open > a {
	border-block-end-color: var(--wp--preset--color--primary);
}

/* Under the whole header, edge to edge; the sticky header is its frame. */
.has-mega.is-open > .mega {
	animation: an-mega-in var(--an-duration-fast) var(--an-easing) both;
	background-color: var(--wp--preset--color--base);
	border-block-start: var(--an-border-width) solid var(--wp--preset--color--line);
	box-shadow: var(--an-shadow-m);
	display: block;
	inset-block-start: 100%;
	inset-inline: 0;
	position: absolute;
}

@keyframes an-mega-in {
	from {
		opacity: 0;
		translate: 0 -0.5rem;
	}
}

.mega__inner {
	align-items: start;
	display: grid;
	gap: var(--wp--preset--spacing--l);
	grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
	margin-inline: auto;
	max-width: var(--wp--style--global--wide-size);
	padding: var(--wp--preset--spacing--l) var(--wp--preset--spacing--gutter);
}

.mega__intro {
	min-inline-size: 0;
	overflow-wrap: break-word;
	padding-block-start: var(--wp--preset--spacing--xs);
}

.mega__eyebrow {
	margin-block-end: var(--wp--preset--spacing--s);
}

.mega__title {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--xl);
	hyphens: manual;
	font-style: italic;
	line-height: var(--an-leading-tight);
	margin-block-end: var(--wp--preset--spacing--m);
}

/* The menu's link rules (border, size, padding) are not wanted here. */
.site-nav__list .mega a {
	border: 0;
	font-size: var(--wp--preset--font-size--s);
	padding: 0;
}

.site-nav__list .mega__all {
	align-items: center;
	display: inline-flex;
	gap: var(--wp--preset--spacing--xs);
	text-decoration: underline;
	text-underline-offset: 0.25em;
}

.site-nav__list .mega__all:hover {
	color: var(--wp--preset--color--primary);
}

.mega__all .icon {
	height: 1rem;
	transition: translate var(--an-duration-fast) var(--an-easing);
	width: 1rem;
}

.mega__all:hover .icon {
	translate: 0.25rem 0;
}

.mega__grid {
	display: grid;
	gap: var(--wp--preset--spacing--m);
	/* Five categories stay one row from 1100px; more wrap. */
	grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
	list-style: none;
	margin: 0;
	padding: 0;
}

.site-nav__list .mega__tile {
	display: grid;
	gap: var(--wp--preset--spacing--xxs);
	text-decoration: none;
}

.mega__media {
	aspect-ratio: 4 / 3;
	background-color: var(--wp--preset--color--paper);
	border: var(--an-border-width) solid var(--wp--preset--color--line);
	border-radius: var(--an-radius-m);
	display: block;
	margin-block-end: var(--wp--preset--spacing--xs);
	overflow: hidden;
}

.mega__image {
	height: 100%;
	object-fit: cover;
	transition: scale 0.5s var(--an-easing);
	width: 100%;
}

/* A category without a photo shows the logo, as a product does. */
.mega__image--logo {
	object-fit: contain;
	padding: var(--wp--preset--spacing--m);
}

.mega__tile:hover .mega__image {
	scale: 1.05;
}

.mega__name {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--l);
	line-height: var(--an-leading-tight);
	overflow-wrap: break-word;
}

.mega__tile:hover .mega__name {
	color: var(--wp--preset--color--primary);
}

.mega__count {
	color: var(--wp--preset--color--secondary);
	font-size: var(--wp--preset--font-size--xs);
	letter-spacing: var(--an-tracking-wide);
	text-transform: uppercase;
}

/*
 * Second row: popular sorts, a small photo beside the name, no price (a price
 * here would need its per-kilo price and shipping note). Across the whole
 * panel, so a long name such as Lasagneblätter fits at 1100px.
 */
.mega__popular {
	align-items: center;
	border-block-start: var(--an-border-width) solid var(--wp--preset--color--line);
	display: flex;
	gap: var(--wp--preset--spacing--l);
	grid-column: 1 / -1;
	padding-block-start: var(--wp--preset--spacing--m);
}

.mega__label {
	flex: none;
	margin: 0;
}

.mega__products {
	display: grid;
	flex: 1;
	gap: var(--wp--preset--spacing--m);
	grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
	list-style: none;
	margin: 0;
	min-inline-size: 0;
	padding: 0;
}

.site-nav__list .mega__product {
	align-items: center;
	display: flex;
	gap: var(--wp--preset--spacing--s);
	text-decoration: none;
}

.mega__thumb {
	border-radius: var(--an-radius-s);
	flex: none;
	height: 3rem;
	object-fit: cover;
	width: 3rem;
}

.mega__product-name {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--m);
	line-height: var(--an-leading-tight);
	min-inline-size: 0;
	overflow-wrap: break-word;
}

.mega__product:hover .mega__product-name {
	color: var(--wp--preset--color--primary);
}

@media (prefers-reduced-motion: reduce) {
	.has-mega.is-open > .mega {
		animation: none;
	}

	.mega__image,
	.mega__all .icon {
		transition: none;
	}
}
