/**
 * Mega menu: template-parts/header/mega-menu.php (Flowers 2084:514).
 * Full-width white panel under the header, rounded bottom corners, page dimmed
 * below. Columns: sub-groups 400, SHOP 240, divider, promo card (fills the rest).
 */

/* Category item: link + chevron button share one pill. */

.primary-nav__item--mega {
	display: flex;
	align-items: center;
	border-radius: var(--radius-pill);
	transition: background-color 0.15s ease;
}

.primary-nav__item--mega .primary-nav__link {
	padding-right: 0;
}

.primary-nav__item--mega .primary-nav__link:hover,
.primary-nav__item--mega .primary-nav__link[aria-current="page"] {
	background: none;
}

.primary-nav__item--mega:hover,
.primary-nav__item--mega.is-open,
.primary-nav__item--mega:has(.primary-nav__link[aria-current="page"]) {
	background: var(--color-white);
}

.primary-nav__toggle {
	display: flex;
	align-items: center;
	align-self: stretch;
	margin: 0;
	padding: 0 14px 0 8px;
	border: 0;
	border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
	background: none;
	color: var(--color-ink);
	cursor: pointer;
}

.primary-nav__toggle .primary-nav__chevron {
	transition: transform 0.15s ease;
}

.primary-nav__toggle[aria-expanded="true"] .primary-nav__chevron {
	transform: rotate(180deg);
}

/* Panel. Positioned against the sticky header. */

.mega {
	position: absolute;
	z-index: 2;
	top: 100%;
	right: 0;
	left: 0;
	border-radius: 0 0 var(--radius-xl) var(--radius-xl);
	background: var(--color-white);
	box-shadow: var(--shadow-panel);
}

.mega[hidden],
.mega-dim[hidden] {
	display: none;
}

.mega-dim {
	position: absolute;
	z-index: 1;
	top: 100%;
	right: 0;
	left: 0;
	height: 100vh;
	background: var(--color-dim);
}

.mega__inner {
	display: flex;
	align-items: flex-start;
	gap: var(--space-lg);
	box-sizing: content-box;
	max-width: var(--container-max);
	margin: 0 auto;
	padding: 40px var(--container-gutter) 48px;
}

.mega__eyebrow {
	margin: 0;
	color: var(--color-muted);
	font-size: var(--text-label-s);
	font-weight: var(--weight-semibold);
	letter-spacing: var(--tracking-label-s);
	line-height: var(--leading-label-s);
	text-transform: uppercase;
}

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

/* Sub-groups (product types). */

.mega__subs {
	display: flex;
	flex: none;
	flex-direction: column;
	gap: 8px;
	width: 400px;
}

.mega__sub-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.mega__sub {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 10px 16px 10px 10px;
	border-radius: 20px;
	color: var(--color-black);
	text-decoration: none;
}

.mega__sub-media {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 72px;
	height: 72px;
	overflow: hidden;
	border-radius: var(--radius-md);
	background: var(--color-cream);
	transition: background-color 0.15s ease;
}

.mega__sub-img {
	display: block;
	width: auto;
	max-width: 56px;
	height: auto;
	max-height: 52px;
	object-fit: contain;
}

.mega__sub-text {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.mega__sub-title {
	font-family: var(--font-display);
	font-size: var(--text-h4);
	font-weight: var(--weight-bold);
	letter-spacing: var(--tracking-h4);
	line-height: var(--leading-h4);
}

.mega__sub-desc {
	color: var(--color-muted);
	font-size: var(--text-body-s);
	line-height: var(--leading-body-s);
}

.mega__sub-arrow {
	flex: none;
	opacity: 0;
	transition: opacity 0.15s ease;
}

.mega__sub:hover,
.mega__sub:focus-visible {
	background: var(--color-cream);
}

.mega__sub:hover .mega__sub-media,
.mega__sub:focus-visible .mega__sub-media {
	background: var(--color-white);
}

.mega__sub:hover .mega__sub-arrow,
.mega__sub:focus-visible .mega__sub-arrow {
	opacity: 1;
}

.mega__all {
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	gap: 8px;
	padding: 12px 0 0 10px;
	color: var(--color-orange);
	font-size: var(--text-label-m);
	font-weight: var(--weight-semibold);
	line-height: var(--leading-label-m);
	text-decoration: none;
}

.mega__all:hover {
	color: var(--color-orange-dark);
}

/* SHOP column. */

.mega__shop {
	display: flex;
	flex: none;
	flex-direction: column;
	gap: 12px;
	width: 240px;
}

.mega__shop-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.mega__shop-link {
	color: var(--color-black);
	font-size: var(--text-body-m);
	line-height: var(--leading-body-m);
	text-decoration: none;
}

.mega__shop-link:hover {
	text-decoration: underline;
}

.mega__divider {
	flex: none;
	align-self: stretch;
	width: 1px;
	background: var(--color-line);
}

/* Promo card. */

.mega__promo {
	position: relative;
	display: flex;
	flex: 1;
	align-items: center;
	box-sizing: border-box;
	min-width: 0;
	height: 306px;
	overflow: hidden;
	padding: 48px 28px 48px 36px;
	border-radius: var(--radius-xl);
}

.mega__promo-bg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.mega__promo-copy {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 20px;
	max-width: 350px;
	color: var(--color-white);
}

.mega__promo-title {
	margin: 0;
	font-family: var(--font-display);
	font-size: 40px;
	font-weight: var(--weight-extrabold);
	letter-spacing: var(--tracking-display-l);
	line-height: 1;
	max-width: 333px;
	text-wrap: balance; /* two even lines, as in the frames */
}

.mega__promo-text {
	max-width: 350px; /* two lines for the Figma copy (Pens line 1 is about 344px) */
	margin: 0;
	font-size: var(--text-body-m);
	line-height: var(--leading-body-m);
}

/* Opening (desktop panel only; the stacked copy in the mobile menu is an
 * accordion): the panel slides down out of the header and fades in, the page
 * dims, then the sub-groups, "View all", the SHOP links and the promo card
 * follow one after the other. Moving from one category to the next
 * (navigation.js sets .is-switch) keeps the panel still and brings in the new
 * content only. Closing (.is-closing, then hidden): the panel slides back up.
 * Transform and opacity only. */
.mega:not(.mega--stacked):not([hidden]) {
	animation: mega-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.mega:not(.mega--stacked):not([hidden]).is-switch {
	animation: none;
}

.mega:not(.mega--stacked):not([hidden]).is-closing {
	animation: mega-out 0.2s ease both;
}

.mega-dim:not([hidden]) {
	animation: mega-fade-in 0.3s ease both;
}

.mega-dim.is-closing {
	animation: mega-fade-out 0.2s ease both;
}

.mega:not(.mega--stacked):not([hidden]) .mega__eyebrow,
.mega:not(.mega--stacked):not([hidden]) .mega__sub-list > li,
.mega:not(.mega--stacked):not([hidden]) .mega__all,
.mega:not(.mega--stacked):not([hidden]) .mega__shop-list > li {
	animation: mega-item-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.mega:not(.mega--stacked):not([hidden]) .mega__promo {
	animation: mega-promo-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.mega:not(.mega--stacked):not([hidden]) .mega__sub-list > li:nth-child(1) {
	animation-delay: 0.04s;
}

.mega:not(.mega--stacked):not([hidden]) .mega__sub-list > li:nth-child(2) {
	animation-delay: 0.08s;
}

.mega:not(.mega--stacked):not([hidden]) .mega__sub-list > li:nth-child(3) {
	animation-delay: 0.12s;
}

.mega:not(.mega--stacked):not([hidden]) .mega__sub-list > li:nth-child(n+4) {
	animation-delay: 0.16s;
}

.mega:not(.mega--stacked):not([hidden]) .mega__all {
	animation-delay: 0.2s;
}

.mega:not(.mega--stacked):not([hidden]) .mega__shop .mega__eyebrow {
	animation-delay: 0.06s;
}

.mega:not(.mega--stacked):not([hidden]) .mega__shop-list > li:nth-child(1) {
	animation-delay: 0.09s;
}

.mega:not(.mega--stacked):not([hidden]) .mega__shop-list > li:nth-child(2) {
	animation-delay: 0.12s;
}

.mega:not(.mega--stacked):not([hidden]) .mega__shop-list > li:nth-child(n+3) {
	animation-delay: 0.15s;
}

@keyframes mega-in {
	from {
		opacity: 0;
		transform: translateY(-12px);
	}
}

@keyframes mega-out {
	to {
		opacity: 0;
		transform: translateY(-10px);
	}
}

@keyframes mega-item-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
}

@keyframes mega-promo-in {
	from {
		opacity: 0;
		transform: translateY(12px) scale(0.98);
	}
}

@keyframes mega-fade-in {
	from {
		opacity: 0;
	}
}

@keyframes mega-fade-out {
	to {
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mega,
	.mega *,
	.mega-dim {
		animation: none !important;
	}

	.primary-nav__item--mega,
	.primary-nav__toggle .primary-nav__chevron,
	.mega__sub,
	.mega__sub-media,
	.mega__sub-arrow {
		transition: none;
	}
}
