/*
 * Advanced Mega Menu — frontend styles.
 * All classes are prefixed `amm-menu` (BEM: block__element--modifier).
 * Visual values are driven by CSS custom properties set inline per mega
 * menu / row / column by Frontend\Renderer, so global overrides can be
 * made simply by redefining the custom properties on `.amm-menu__mega`.
 */

.amm-menu__item {
	position: relative;
}

/*
 * Parent-item arrow / accordion control.
 *
 * Injected by Frontend\FrontendModule right after a parent item's <a>, for
 * every item that has a native submenu or a mega menu panel — never
 * wrapping or altering the link itself. It is a real <button>, so it never
 * follows the parent URL; JS (mobile-nav.js) toggles `is-submenu-open` on
 * the <li> and flips `aria-expanded` here.
 */
.amm-submenu-toggle {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 1.4em;
	height: 1.4em;
	margin: 0;
	margin-inline-start: 0.15em;
	padding: 0;
	background: transparent;
	border: 0;
	color: inherit;
	font: inherit;
	line-height: 0;
	cursor: pointer;
	vertical-align: middle;
	-webkit-appearance: none;
	appearance: none;
}

.amm-submenu-toggle__icon {
	display: block;
	width: 0.45em;
	height: 0.45em;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	/* Closed: chevron points down. */
	transform: translateY(-0.12em) rotate(45deg);
	transition: transform 150ms ease;
}

/* Open: chevron rotates to point up. */
.amm-submenu-toggle[aria-expanded="true"] .amm-submenu-toggle__icon {
	transform: translateY(0.06em) rotate(-135deg);
}

.amm-submenu-toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
	border-radius: 3px;
}

/* Reduced-motion: keep the state change, drop the spin. */
@media (prefers-reduced-motion: reduce) {
	.amm-submenu-toggle__icon {
		transition: none;
	}
}

/*
 * Native (non-mega) submenu — desktop fly-out.
 *
 * Kept to single-class specificity and standard properties so a theme can
 * override it easily. A mega-menu item manages its own panel, so it is
 * excluded here. Reveal on hover, on keyboard focus within the item, or
 * when the arrow has toggled `is-submenu-open`.
 */
.amm-menu__item--has-children:not(.amm-menu__item--has-mega) {
	position: relative;
}

.amm-menu__item--has-children:not(.amm-menu__item--has-mega) > .sub-menu {
	position: absolute;
	top: 100%;
	inset-inline-start: 0;
	z-index: 100;
	min-width: 12rem;
	margin: 0;
	padding: 0.5rem 0;
	list-style: none;
	background: var(--amm-mega-background, #fff);
	border: var(--amm-mega-border, 1px solid rgba(0, 0, 0, 0.1));
	border-radius: var(--amm-mega-border-radius, 4px);
	box-shadow: var(--amm-mega-shadow, 0 8px 24px rgba(0, 0, 0, 0.12));
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(4px);
	transition: opacity 150ms ease, transform 150ms ease, visibility 0s linear 150ms;
}

.amm-menu__item--has-children:not(.amm-menu__item--has-mega):hover > .sub-menu,
.amm-menu__item--has-children:not(.amm-menu__item--has-mega):focus-within > .sub-menu,
.amm-menu__item--has-children:not(.amm-menu__item--has-mega).is-submenu-open > .sub-menu {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translateY(0);
	transition-delay: 0s;
}

/* Second level and deeper open to the side rather than stacking. */
.amm-menu__item--has-children .amm-menu__item--has-children:not(.amm-menu__item--has-mega) > .sub-menu {
	top: -0.5rem;
	inset-inline-start: 100%;
}

.amm-menu__item--has-children > .sub-menu li {
	list-style: none;
}

.amm-menu__item--has-children > .sub-menu a {
	display: block;
	padding: 0.4em 1.25em;
	text-decoration: none;
	color: inherit;
	white-space: nowrap;
}

/* A mega-menu item never also renders a native submenu list. */
.amm-menu__item--has-mega > .sub-menu {
	display: none;
}

/* Desktop: the arrow may also pin a mega menu open (keyboard / touch). */
.amm-menu__item--has-mega.is-submenu-open > .amm-menu__mega {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translateY(0);
	transition-delay: 0s;
}

.amm-menu__item-icon svg,
.amm-menu__tab-icon svg {
	width: 1em;
	height: 1em;
	display: inline-block;
	vertical-align: -0.125em;
}

.amm-menu__item-icon {
	margin-inline-end: 0.4em;
	display: inline-flex;
}

.amm-menu__item-description {
	display: block;
	font-size: 0.8em;
	opacity: 0.75;
	margin-top: 0.15em;
}

.amm-menu__item-badge,
.amm-menu__tab-badge {
	display: inline-block;
	margin-inline-start: 0.4em;
	padding: 0.1em 0.5em;
	font-size: 0.7em;
	line-height: 1.6;
	border-radius: 999px;
	background: #0073aa;
	color: #fff;
	vertical-align: middle;
}

/* Mega menu panel */

.amm-menu__mega {
	--amm-mega-anim-duration: 200ms;

	position: absolute;
	top: 100%;
	left: 0;
	z-index: 100;
	width: var(--amm-mega-width, max-content);
	max-width: var(--amm-mega-max-width, calc(100vw - 2rem));
	min-width: 20rem;
	background: var(--amm-mega-background, #fff);
	border: var(--amm-mega-border, 1px solid rgba(0, 0, 0, 0.1));
	border-radius: var(--amm-mega-border-radius, 4px);
	box-shadow: var(--amm-mega-shadow, 0 8px 24px rgba(0, 0, 0, 0.12));
	padding: var(--amm-mega-padding, 1.5rem);

	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(4px);
	transition: opacity var(--amm-mega-anim-duration) ease, transform var(--amm-mega-anim-duration) ease, visibility 0s linear var(--amm-mega-anim-duration);
}

.amm-menu__item.is-open > .amm-menu__mega {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translateY(0);
	transition-delay: 0s;
}

.amm-menu__mega[data-animation="none"] {
	transition: none;
}

/* Tabbed layout */

.amm-menu__mega--tabbed {
	display: flex;
	gap: 1.5rem;
}

.amm-menu__mega--tabbed[data-orientation="horizontal"],
.amm-menu__tablist[aria-orientation="horizontal"] {
	flex-direction: column;
}

.amm-menu__mega--tabbed .amm-menu__tablist[aria-orientation="vertical"] {
	flex-direction: column;
	flex: 0 0 220px;
	border-inline-end: 1px solid rgba(0, 0, 0, 0.08);
	padding-inline-end: 1rem;
}

.amm-menu__tablist[aria-orientation="horizontal"] {
	display: flex;
	flex-direction: row;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	margin-bottom: 1rem;
}

.amm-menu__tab {
	display: flex;
	align-items: center;
	gap: 0.5em;
	width: 100%;
	padding: 0.65em 1em;
	background: transparent;
	border: 0;
	border-radius: 4px;
	text-align: left;
	font: inherit;
	cursor: pointer;
	color: inherit;
}

.amm-menu__tablist[aria-orientation="horizontal"] .amm-menu__tab {
	width: auto;
}

.amm-menu__tab:hover {
	background: rgba(0, 0, 0, 0.04);
}

.amm-menu__tab.is-active {
	background: var(--amm-tab-active-background, rgba(0, 115, 170, 0.08));
	color: var(--amm-tab-active-text, #0073aa);
	font-weight: 600;
}

.amm-menu__tab:focus-visible {
	outline: 2px solid #0073aa;
	outline-offset: 2px;
}

.amm-menu__panels {
	flex: 1 1 auto;
	min-width: 0;
}

.amm-menu__panel[hidden] {
	display: none;
}

.amm-menu__panel:focus-visible {
	outline: 2px solid #0073aa;
	outline-offset: 2px;
}

.amm-menu__panel-description {
	margin: 0 0 1rem;
	opacity: 0.8;
}

/* Row / column / component grid */

/*
 * Columns are sized by percentage width (e.g. two columns at 50% each,
 * set by the admin so they sum to 100%). Flexbox `gap` is *added on top*
 * of item widths, not subtracted from them — so combining `gap` directly
 * with percentage widths that sum to 100% overflows the row and wraps the
 * last column onto its own line. The standard fix (used by every
 * percentage-based CSS grid system) is a negative margin on the row
 * matched by padding on each column, with `box-sizing: border-box` so
 * that padding is absorbed into the column's own percentage width rather
 * than added to it. A column's user-configurable padding/background/
 * border is applied to `.amm-menu__column-inner` instead of this element,
 * so it can never collide with the gutter padding here.
 */
.amm-menu__row {
	display: flex;
	flex-wrap: wrap;
	margin-left: calc(var(--amm-column-gap, 1.5rem) / -2);
	margin-right: calc(var(--amm-column-gap, 1.5rem) / -2);
}

.amm-menu__row + .amm-menu__row {
	margin-top: var(--amm-row-gap, 1.5rem);
}

.amm-menu__column {
	flex: 0 0 auto;
	width: var(--amm-column-width, 100%);
	min-width: 0;
	box-sizing: border-box;
	padding-left: calc(var(--amm-column-gap, 1.5rem) / 2);
	padding-right: calc(var(--amm-column-gap, 1.5rem) / 2);
}

.amm-menu__column-inner {
	width: 100%;
	height: 100%;
	box-sizing: border-box;
}

.amm-menu__component {
	display: block;
	margin-bottom: 0.75rem;
}

.amm-menu__component:last-child {
	margin-bottom: 0;
}

.amm-menu__component--menu-item {
	display: flex;
	align-items: flex-start;
	text-decoration: none;
	color: inherit;
	padding: 0.35em 0;
}

.amm-menu__component--heading {
	display: flex;
	align-items: center;
}

.amm-menu__component--text {
	display: flex;
	align-items: flex-start;
}

.amm-menu__component-icon {
	display: inline-flex;
	align-items: center;
	flex-shrink: 0;
	margin-inline-end: 0.5em;
}

.amm-menu__component-icon svg,
.amm-menu__component-icon img {
	width: 1.2em;
	height: 1.2em;
	object-fit: contain;
}

.amm-menu__component-text,
.amm-menu__component-text-content {
	display: block;
	min-width: 0;
}

.amm-menu__component-title {
	display: block;
	font-weight: 500;
}

.amm-menu__component-description {
	display: block;
	font-size: 0.85em;
	opacity: 0.7;
}

.amm-menu__component-image img {
	max-width: 100%;
	height: auto;
	display: inline-block;
}

.amm-menu__button {
	display: inline-block;
	padding: 0.6em 1.4em;
	border-radius: 4px;
	text-decoration: none;
	font-weight: 600;
	border: 1px solid transparent;
}

.amm-menu__button--primary {
	background: #0073aa;
	color: #fff;
}

.amm-menu__button--secondary {
	background: #f0f0f1;
	color: #1d2327;
}

.amm-menu__button--outline {
	background: transparent;
	border-color: currentColor;
}

.amm-menu__button--link {
	background: transparent;
	padding: 0;
	text-decoration: underline;
}

.amm-menu__component--divider hr {
	margin: 0;
	border: 0;
}

.amm-menu__component--dynamic-posts,
.amm-menu__component--dynamic-terms {
	list-style: none;
	margin: 0;
	padding: 0;
}

.amm-menu__dynamic-item {
	margin-bottom: 0.5em;
}

.amm-menu__dynamic-item a {
	text-decoration: none;
	color: inherit;
	display: flex;
	align-items: center;
	gap: 0.5em;
}

.amm-menu__dynamic-thumbnail {
	width: 2.5em;
	height: 2.5em;
	object-fit: cover;
	border-radius: 3px;
}

.amm-menu__component--product .amm-menu__product-link,
.amm-menu__component--product-category .amm-menu__product-category-link {
	display: block;
	text-decoration: none;
	color: inherit;
}

.amm-menu__product-title,
.amm-menu__product-category-title {
	display: block;
	font-weight: 500;
	margin-top: 0.35em;
}

.amm-menu__product-price {
	display: block;
	opacity: 0.8;
}

/* [CASE_STUDY] card — the whole <a> is the hit area, so nothing inside it
   carries its own link styling. */
.amm-case-study {
	display: block;
	text-decoration: none;
	color: inherit;
}

.amm-case-study__media {
	display: block;
	overflow: hidden;
	border-radius: 6px;
	line-height: 0;
}

.amm-case-study__image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 16 / 9;
	object-fit: cover;
	transition: transform 0.3s ease;
}

.amm-case-study:hover .amm-case-study__image,
.amm-case-study:focus-visible .amm-case-study__image {
	transform: scale(1.04);
}

.amm-case-study__body {
	display: block;
	margin-top: 0.6em;
}

.amm-case-study__title {
	display: block;
	font-weight: 600;
	line-height: 1.3;
}

.amm-case-study__excerpt {
	display: block;
	margin-top: 0.3em;
	font-size: 0.875em;
	line-height: 1.5;
	opacity: 0.8;
}

@media (prefers-reduced-motion: reduce) {
	.amm-case-study__image {
		transition: none;
	}

	.amm-case-study:hover .amm-case-study__image,
	.amm-case-study:focus-visible .amm-case-study__image {
		transform: none;
	}
}
