/* =============================================================================
   MEGA-MENUS — four panels (Products, Industries, Technical Center, About Us)
   Spec: section 4 interactions. Panels open on hover and dissolve over 300ms.
   Keyboard: focus-within keeps panel open; Escape closes (mega-menu.js).
   Figma uses LINEAR for wide Products/Industries panels and EASE_OUT for
   narrow Technical Center/About Us panels.
   ============================================================================= */

/* ── Shared token ─────────────────────────────────────────────────────────── */

:root {
	--mega-cat-color: #8B8D8E;   /* grey-500 — category heading + icon tint */
	--mega-link-color: #333333;  /* ink — link items */
	--mega-bg: #fff;
}

/* Keep the real WordPress menu links above the transparent hover bridge
   without positioning .main-nav itself. The narrow panels calculate their
   offsets from .header-primary__inner, so changing that containing block
   pushes Technical Center and About Us beyond the viewport. */
.main-nav__link {
	/* An item with no URL is rendered without an href - it opens its menu
	   rather than going anywhere - and an <a> without href shows the text
	   caret instead of the pointer. */
	cursor: pointer;
	position: relative;
	z-index: 1001;
	pointer-events: auto;
}

/* ── Base panel ───────────────────────────────────────────────────────────── */

.mega-menu {
	--mega-panel-gap: 16px;
	--mega-bridge-height: 0px;
	box-sizing: border-box;
	position: absolute;
	z-index: 1000;
	background: var(--mega-bg);
	border: 1px solid var(--fig-neutral-100);
	border-radius: var(--r-sm);
	box-shadow: 0 24px 40px rgba(0, 0, 0, .12);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition:
		opacity var(--dur-base) ease-out,
		visibility 0s var(--dur-base);
}

.site-header.mega-menu-active {
	z-index: 220;
}

/* Transparent hover bridge between the trigger and the panel. */
.mega-menu::before {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: calc(-1 * var(--mega-bridge-height));
	height: var(--mega-bridge-height);
}

/* Open state — toggled by JS (aria-expanded) and CSS :hover fallback */
.mega-menu[aria-hidden="false"],
.mega-menu.is-open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transition:
		opacity var(--dur-base) ease-out,
		visibility 0s 0s;
}

@media (prefers-reduced-motion: reduce) {
	.mega-menu {
		transition: none !important;
	}
}

/* ── Wide panels (Products, Industries) ─────────────────────────────────── */
/*
   Positioned relative to .header-primary__inner (position:relative set there).
   Span the full inner bar width; left:0 right:0 matches the 1408px Figma panels.
*/

.mega-menu--wide {
	top: calc(100% + var(--mega-panel-gap));
	left: 0;
	right: 0;
	box-shadow: none;
	transition:
		opacity var(--dur-base) linear,
		visibility 0s var(--dur-base);
}

.mega-menu--wide[aria-hidden="false"],
.mega-menu--wide.is-open {
	transition:
		opacity var(--dur-base) linear,
		visibility 0s 0s;
}
/* ── Narrow panels (Technical Center, About Us) ─────────────────────────── */
/*
   Positioned against .header-primary__inner. JavaScript aligns the panel
   right edge to the owning trigger while keeping it below the full bar.
   Width matches Figma: 188px.
*/

.mega-menu--narrow {
	top: calc(100% + var(--mega-panel-gap));
	left: var(--mega-trigger-left, 0px);
	width: 188px;
}

/* ── CSS hover fallback (enhances the JS layer) ─────────────────────────── */
/*
   Works even when JS is unavailable. JS additionally manages aria-expanded,
   focus-within persistence, and Escape. Do not rely on hover alone for
   keyboard access — that is what :focus-within handles here.
*/

@media (hover: hover) and (pointer: fine) {
	.has-mega-menu:hover > .mega-menu,
	.has-mega-menu:focus-within > .mega-menu {
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
		transition:
			opacity var(--dur-base) ease-out,
			visibility 0s 0s;
	}
}

/* Wide panels are not children of <li>; the :hover trigger is wired by JS
   which adds .is-open. The :focus-within rule below targets the nav item. */
@media (hover: hover) and (pointer: fine) {
	.main-nav__item.has-mega-wide:hover ~ .mega-menu--wide,
	.main-nav__item.has-mega-wide:focus-within ~ .mega-menu--wide {
		/* Cannot directly reach sibling panels via CSS — JS required.
		   This rule is a no-op; left here to document the intent. */
	}
}

/* ============================================================================
   PRODUCTS panel (164:8574)
   6 columns × 129px, gap 114px. Padding: 49px top / 57px bottom / 32px inline.
   ============================================================================ */

.mega-menu--products {
	min-height: 331px;
	padding: 49px 32px 57px;
}

.mega-products__grid {
	display: grid;
	/* Was a fixed repeat(6, 129px): now driven by admin-editable menu items
	   (any number of columns), so auto-fill at the same 129px column width
	   and 114px gap — 6 fit per row at the design content width, matching
	   the original density; extra columns wrap to a second row instead of
	   forcing exactly 6. */
	grid-template-columns: repeat(6, 129px);
	justify-content: space-between;
}

.mega-products__column {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

/* Figma: column 5 stacks at 24px; column 6 stacks at 16px. */
.mega-products__column[data-visual-column="6"] { gap: 16px; }

@media (min-width: 768px) and (max-width: 1120px) {
	.mega-products__grid {
		grid-template-columns: repeat(6, minmax(0, 1fr));
		column-gap: 24px;
	}
}

/* ============================================================================
   INDUSTRIES panel (164:8752)
   Left: 2 image cards 259px wide, gap 22px.
   Right: 3 link columns in a 659px area at offset 717px from left.
   Padding: 49px top / 44px bottom / 16px left.
   ============================================================================ */

.mega-menu--industries {
	min-height: 459px;
	padding: 49px 16px 44px;
}

.mega-industries__body {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	width: 100%;
}

.mega-industries__cards {
	display: flex;
	flex-shrink: 0;
	gap: 22px;
	width: 539px; /* 2 × 258.61 + 22 gap ≈ 539px */
}

.mega-industries__links {
	display: grid;
	grid-template-columns: 166px 156px 156px;
	column-gap: 65px;
	flex-shrink: 0;
}

/* The same tablet pass the Products grid already got. Both halves here are
   flex-shrink: 0 at 539 + 608 + 32 padding = 1179, inside a panel that is 719
   wide at this breakpoint, so the content ran 460px past the panel edge.

   A closed panel is only visibility:hidden, so it stays in layout - which made
   that overflow extend the document and put a horizontal scrollbar on every
   page of the site at tablet width, with no menu even open.

   3 columns to 2 and a 32px gutter is the collapse order in _tokens-layout.css,
   not a new decision. */
@media (min-width: 768px) and (max-width: 1120px) {
	.mega-industries__body { gap: 32px; }

	.mega-industries__cards {
		width: auto;
		min-width: 0;
		flex-shrink: 1;
	}

	.mega-industries__links {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: 32px;
		min-width: 0;
		flex-shrink: 1;
	}
}

/* ── In-menu image card ─────────────────────────────────────────────────── */

.mega-card {
	width: 259px;
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	text-decoration: none;
	color: var(--mega-link-color);
}

.mega-card__img-wrap {
	position: relative;
	width: 259px;
	height: 250px; /* approximate from screenshot — needs visual review */
	overflow: hidden;
	background: #f0f0f0; /* placeholder until real image loads */
	flex-shrink: 0;
}

.mega-card__img-wrap img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.mega-card__body {
	padding-top: 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.mega-card__title-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.mega-card__title {
	font: var(--fw-bold) 1.25rem/1.5rem var(--font-heading); /* 20/24 — .t-h6 */
	color: var(--mega-link-color);
	margin: 0;
}

.mega-card__desc {
	font: var(--fw-regular) 0.9010162354rem/1.0812194347rem var(--font-body); /* .t-body-sm */
	color: var(--mega-link-color);
	margin: 0;
}

.mega-card__cta {
	font: var(--fw-bold) 0.625rem/0.75rem var(--font-heading); /* .t-caption-sm */
	letter-spacing: var(--ls-wide);
	text-transform: uppercase;
	color: var(--mega-link-color);
	text-decoration: underline;
}

@media (hover: hover) and (pointer: fine) {
	.mega-card:hover .mega-card__cta {
		color: var(--fig-siegel-red);   /* #d41927 — brand accent on hover */
	}
}

.mega-card:focus-visible {
	outline: 2px solid var(--mega-link-color);
	outline-offset: 2px;
	border-radius: var(--r-xs);
}

/* ============================================================================
   TECHNICAL CENTER panel (182:17862)
   Narrow: 188px wide. 16px side padding. 16px top padding.
   Heading: t-caption-sm. Items: t-body. Gap heading→list: 16px. Item gap: 12px.
   ============================================================================ */

/* Exact 164:8752 card geometry and typography. Kept together so legacy
   declarations above remain readable while these final values win. */
.mega-card { width: 258.614px; }
.mega-card__img-wrap {
	width: 258.614px;
	height: 265.825px;
	border-radius: 2px;
	background: #e5e7eb;
}
.mega-card__img-wrap img { border-radius: inherit; }
.mega-card__body { gap: 12px; padding-top: 12px; }
.mega-card__title-row { align-items: flex-start; }
.mega-card__title { font: var(--fw-bold) 1rem/1.2625rem var(--font-body); }
.mega-card__desc {
	width: 225px;
	font: var(--fw-regular) 0.800875rem/0.9610625rem var(--font-body);
	color: var(--fig-neutral-700);
}
.mega-card__cta {
	font: var(--fw-bold) 0.6328125rem/0.759375rem var(--font-body);
	letter-spacing: 0;
}

.mega-menu--compact {
	padding: 16px 16px 24px;
}

.main-nav .mega-menu--compact .mega-col__link {
	padding-left: 0;
	font: var(--fw-regular) 0.875rem/1.25rem var(--font-body);
	letter-spacing: var(--ls-tight);
	color: #3c3d3d;
}

.main-nav .mega-menu--compact .mega-col__label {
	color: var(--mega-cat-color);
}

/* ============================================================================
   ABOUT US panel (182:17978)
   Narrow: 188px wide. Same padding structure as Technical Center.
   ============================================================================ */

/* ============================================================================
   SHARED COLUMN ANATOMY
   Used by all four panels' link column groups.
   ============================================================================ */

.mega-col {
	display: flex;
	flex-direction: column;
}

.mega-col + .mega-col {
	/* Within Products grid — gap handled by column-gap on the grid.
	   Within narrow panels — single column, no siblings. */
}

/* Category heading: icon + caption label */
.mega-col__heading {
	display: flex;
	align-items: center;
	gap: 8px;               /* icon 24px + 8px gap + text = x:32 from Figma */
	margin-bottom: 16px;    /* heading to first list item: 40-24=16px from Figma */
	width: fit-content;
	color: var(--mega-cat-color);
	text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
	.mega-col__heading:hover .mega-col__label { text-decoration: underline; }
}

.mega-col__heading:focus-visible {
	outline: 2px solid var(--mega-link-color);
	outline-offset: 3px;
	border-radius: 1px;
}

.mega-col__icon {
	display: block;
	flex-shrink: 0;
	width: 20px;
	height: 20px;
	margin: 2px;
	color: var(--mega-cat-color);
}

.mega-col__icon--image,
.mega-col__icon--svg { object-fit: contain; }

.mega-col__icon--fa {
	font-size: 20px;
	line-height: 1;
	text-align: center;
}

.mega-col__label {
	color: var(--mega-cat-color);
	/* .t-caption-sm applied in HTML */
}

/* Multi-group columns (e.g., Self Levelling + Timber Coatings in one col) */
.mega-col__group + .mega-col__group {
	margin-top: 24px; /* gap between stacked groups within one visual column */
}

/* Link list */
.mega-col__links {
	list-style: none;
	padding: 0;
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;              /* items: y-pitch 32 - height 20 = 12px gap */
}

.main-nav .mega-col__link,
.main-nav .mega-dropdown__link {
	color: var(--mega-link-color);
}

.mega-col__link {
	display: flex;
	align-items: center;
	gap: 8px;
	padding-left: 28px;     /* text starts at x:28 within 149px link frame */
	font: var(--fw-regular) 0.875rem/1.25rem var(--font-body);
	letter-spacing: var(--ls-tight);
	color: var(--mega-link-color);
	text-decoration: none;
	white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
	.mega-col__link:hover {
		text-decoration: underline;
	}
}

.mega-col__link:focus-visible {
	outline: 2px solid var(--mega-link-color);
	outline-offset: 2px;
	border-radius: 1px;
}

/* .mega-badge removed — replaced by .badge-new (badge.css, task 2.4c) */

/* ── Hide on mobile — desktop-only chrome ─────────────────────────────── */

@media (max-width: 767px) {
	.mega-menu {
		display: none;
	}
}

/* Simple dropdowns (admin-selected per top-level menu item). */
.mega-menu--dropdown {
	top: calc(100% + var(--mega-panel-gap));
	left: var(--mega-trigger-left, 0px);
	min-width: 220px;
	max-width: min(320px, calc(100% - 24px));
	padding: 8px;
	border: 1px solid var(--fig-neutral-100);
	border-radius: var(--r-sm);
	box-shadow: 0 14px 34px rgba(0, 0, 0, .14);
	transition: opacity var(--dur-base) ease-out, visibility 0s var(--dur-base);
}

.mega-menu--dropdown[aria-hidden="false"],
.mega-menu--dropdown.is-open {
	transition: opacity var(--dur-base) ease-out, visibility 0s 0s;
}

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

.mega-dropdown__link {
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	min-height: 40px; padding: 8px 12px; border-radius: var(--r-xs);
	font: var(--fw-regular) 1rem/1.25rem var(--font-body);
	color: var(--mega-link-color); text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
	.mega-dropdown__link:hover { background: var(--fig-neutral-50); color: var(--fig-red-600); }
}

.mega-dropdown__link:focus-visible { outline: 2px solid var(--btn-stroke-focused); outline-offset: -2px; }
