/* Desktop mega menu (includes/mega.php): Parts, New plant and Used plant open a white panel under
   the header, the width of the page content, with the page dimmed behind it. Pictures sit on a light
   tile, labels are sentence case, counts are small and grey, links are text, not buttons. */

.smp-mega { display: none; }

@media (min-width: 922px) {
	/* The theme's own drop-downs for these three items step aside */
	body.smp-mega-on #ast-desktop-header .smp-mega-li > .sub-menu,
	body.smp-mega-on #ast-desktop-header .smp-mega-li > .astra-full-megamenu-wrapper { display: none !important; }

	/* The panel hangs from the header bar, so everything between them stays unpositioned */
	body.smp-mega-on #ast-desktop-header .ast-primary-header-bar { position: relative; }
	body.smp-mega-on #ast-desktop-header .ast-primary-header-bar .ast-builder-grid-row,
	body.smp-mega-on #ast-desktop-header .ast-primary-header-bar .site-header-section,
	body.smp-mega-on #ast-desktop-header .ast-primary-header-bar .ast-builder-layout-element,
	body.smp-mega-on #ast-desktop-header .ast-builder-menu-1,
	body.smp-mega-on #ast-desktop-header .ast-builder-menu-1 .main-navigation,
	body.smp-mega-on #ast-desktop-header .ast-builder-menu-1 .main-header-bar-navigation,
	body.smp-mega-on #ast-desktop-header .ast-builder-menu-1 .main-header-menu,
	body.smp-mega-on #ast-desktop-header .ast-builder-menu-1 .main-header-menu > .smp-mega-li { position: static !important; }

	body.smp-mega-on #ast-desktop-header .smp-mega {
		display: block; position: absolute; z-index: 1001; top: 100%; left: 50%;
		width: min(1180px, calc(100vw - 64px)); box-sizing: border-box; padding: 28px 32px 24px;
		background: #fff; border: 1px solid #e3e7ee; border-top-color: #eef1f5; border-radius: 0 0 16px 16px;
		box-shadow: 0 24px 48px rgba(0, 25, 48, 0.16), 0 2px 6px rgba(0, 25, 48, 0.06);
		color: #1a1a1a; font-size: 15px; font-weight: 400; line-height: 1.4; text-align: left; white-space: normal; cursor: default; user-select: none; -webkit-user-select: none;
		visibility: hidden; opacity: 0; transform: translate(-50%, 6px);
		transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0.16s;
	}
	/* A strip above the panel keeps the pointer "inside" on its way down from the menu word */
	body.smp-mega-on #ast-desktop-header .smp-mega::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 28px; }
	body.smp-mega-on #ast-desktop-header .smp-mega-li.smp-open > .smp-mega,
	html:not(.smp-mega-js) body.smp-mega-on #ast-desktop-header .smp-mega-li:hover > .smp-mega,
	html:not(.smp-mega-js) body.smp-mega-on #ast-desktop-header .smp-mega-li:focus-within > .smp-mega {
		visibility: visible; opacity: 1; transform: translate(-50%, 0); transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s;
	}
	/* The open item's word gets a small amber bar, so you can see which panel this is */
	body.smp-mega-on #ast-desktop-header .smp-mega-li > .menu-link { position: relative; }
	body.smp-mega-on #ast-desktop-header .smp-mega-li.smp-open > .menu-link::after {
		content: ""; position: absolute; left: 20px; right: 20px; bottom: 6px; height: 3px; border-radius: 2px; background: #f9b101;
	}
	body.smp-mega-on #ast-desktop-header .main-header-menu > .smp-mega-li:first-child.smp-open > .menu-link::after { left: 0; }

	/* The page dims behind an open panel; the header stays above it */
	body.smp-mega-on.smp-mega-open #masthead { position: relative; z-index: 1000; }
	body.smp-mega-on.smp-mega-open::after {
		content: ""; position: fixed; inset: 0; z-index: 999; background: rgba(0, 25, 48, 0.28); pointer-events: none;
		animation: smp-mega-dim 0.16s ease;
	}
	@keyframes smp-mega-dim { from { opacity: 0; } to { opacity: 1; } }

	/* Shared pieces */
	#ast-desktop-header .smp-mega *, #ast-desktop-header .smp-mega *::before, #ast-desktop-header .smp-mega *::after { box-sizing: border-box; }
	#ast-desktop-header .smp-mega ul { margin: 0; padding: 0; list-style: none; }
	#ast-desktop-header .smp-mega li { margin: 0; padding: 0; border: 0; }
	#ast-desktop-header .smp-mega p { margin: 0; }
	#ast-desktop-header .smp-mega a { color: #003768; text-decoration: none; }
	#ast-desktop-header .smp-mega a:hover { color: #003768; text-decoration: underline; text-underline-offset: 3px; }
	#ast-desktop-header .smp-mega a { cursor: pointer; }
	#ast-desktop-header .smp-mega input, #ast-desktop-header .smp-mega select { user-select: text; -webkit-user-select: text; cursor: auto; }
	#ast-desktop-header .smp-mega select { cursor: pointer; }
	#ast-desktop-header .smp-mega a:focus-visible { outline: 2px solid #003768; outline-offset: 2px; border-radius: 6px; }
	#ast-desktop-header .smp-mega .smp-mega-label {
		margin: 0 0 10px; padding: 0 0 9px; border-bottom: 1px solid #e6e9ee;
		color: #545d68; font-size: 13px; font-weight: 600; line-height: 1.3; letter-spacing: 0; text-transform: none;
	}
	#ast-desktop-header .smp-mega .smp-mega-count { color: #6b7480; font-size: 13px; font-weight: 400; }
	#ast-desktop-header .smp-mega-img {
		display: flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 56px; height: 56px;
		overflow: hidden; border-radius: 10px; background: #f4f6f9;
	}
	#ast-desktop-header .smp-mega-img img { display: block; width: 100%; height: 100%; object-fit: cover; mix-blend-mode: multiply; }
	#ast-desktop-header .smp-mega-img--none { background: #f4f6f9; }
	#ast-desktop-header .smp-mega .smp-mega-all {
		display: inline-flex; align-items: center; gap: 6px; color: #003768; font-size: 15px; font-weight: 600;
	}
	#ast-desktop-header .smp-mega .smp-mega-all svg { width: 16px; height: 16px; transition: transform 0.15s ease; }
	#ast-desktop-header .smp-mega .smp-mega-all:hover svg { transform: translateX(3px); }
	#ast-desktop-header .smp-mega .smp-mega-help { color: #545d68; font-size: 13px; line-height: 1.45; }
	#ast-desktop-header .smp-mega .smp-mega-help a { font-weight: 600; white-space: nowrap; }
	#ast-desktop-header .smp-mega .smp-mega-links { display: grid; gap: 2px; }
	#ast-desktop-header .smp-mega .smp-mega-links a { display: block; margin: 0 -8px; padding: 6px 8px; border-radius: 6px; font-size: 14px; font-weight: 500; }
	#ast-desktop-header .smp-mega .smp-mega-links a:hover { background: #e9edf2; text-decoration: none; }

	#ast-desktop-header .smp-mega-grid { display: grid; gap: 28px; }
	#ast-desktop-header .smp-mega-side { display: flex; flex-direction: column; gap: 16px; padding: 18px; border-radius: 12px; background: #f4f6f9; }
	#ast-desktop-header .smp-mega-foot { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 16px; border-top: 1px solid #e6e9ee; }

	/* Parts: six picture tiles, then the finder card on the right */
	#ast-desktop-header .smp-mega-grid--parts { grid-template-columns: minmax(0, 1fr) 300px; }
	#ast-desktop-header .smp-mega-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
	#ast-desktop-header .smp-mega-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 4px 16px; } /* every tile the same height */
	#ast-desktop-header .smp-mega-tile { position: relative; display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 12px; transition: background 0.15s ease; }
	#ast-desktop-header .smp-mega-tile:hover { background: #f4f6f9; }
	#ast-desktop-header .smp-mega-tile:hover .smp-mega-img { background: #e9edf2; }
	#ast-desktop-header .smp-mega-tile-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
	#ast-desktop-header .smp-mega .smp-mega-tile-title { color: #003768; font-size: 15px; font-weight: 600; line-height: 1.3; }
	#ast-desktop-header .smp-mega .smp-mega-tile-title .smp-mega-count { margin-left: 4px; }
	/* One-range tiles: the whole tile is the link */
	#ast-desktop-header .smp-mega .smp-mega-stretch::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }
	#ast-desktop-header .smp-mega .smp-mega-stretch:hover { text-decoration: none; }
	#ast-desktop-header .smp-mega-tile-links { display: flex; flex-wrap: wrap; gap: 2px 10px; }
	#ast-desktop-header .smp-mega .smp-mega-tile-links a { position: relative; z-index: 1; color: #545d68; font-size: 13px; font-weight: 500; }
	#ast-desktop-header .smp-mega .smp-mega-tile-links a:hover { color: #003768; }
	#ast-desktop-header .smp-mega-popular { margin: 0 10px; }
	#ast-desktop-header .smp-mega .smp-mega-popular .smp-mega-label { margin-bottom: 6px; padding-bottom: 7px; }
	#ast-desktop-header .smp-mega .smp-mega-popular-links { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 16px; }
	#ast-desktop-header .smp-mega .smp-mega-popular-links a { overflow: hidden; padding: 4px 0; color: #1a1a1a; font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }
	#ast-desktop-header .smp-mega .smp-mega-popular-links a:hover { color: #003768; }
	#ast-desktop-header .smp-mega-foot .smp-mega-more { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; font-size: 13px; }
	#ast-desktop-header .smp-mega-more span { color: #6b7480; }
	#ast-desktop-header .smp-mega .smp-mega-more a { color: #545d68; font-weight: 500; }

	/* The machine finder, stacked for the card */
	#ast-desktop-header .smp-mega .smp-finder--mega { margin: 0; padding: 0; border: 0; background: none; max-width: none; }
	#ast-desktop-header .smp-mega .smp-finder--mega .smp-finder-head { margin-bottom: 8px; }
	#ast-desktop-header .smp-mega .smp-finder--mega .smp-finder-title { font-size: 14px; }
	#ast-desktop-header .smp-mega .smp-finder--mega .smp-finder-all { display: none; } /* All machines is in the links below */
	#ast-desktop-header .smp-mega .smp-finder--mega .smp-finder-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 6px; }
	#ast-desktop-header .smp-mega .smp-finder--mega select { height: 40px; min-height: 40px; padding-top: 0; padding-bottom: 0; font-size: 14px; background-color: #fff; }
	#ast-desktop-header .smp-mega .smp-finder--mega button { width: 40px; height: 40px; min-height: 40px; padding: 0; }
	#ast-desktop-header .smp-mega .smp-finder--mega .smp-finder-btn-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
	#ast-desktop-header .smp-mega .smp-finder--mega .smp-finder-btn-icon { display: block; margin: 0 auto; }
	#ast-desktop-header .smp-mega-search .smp-mega-label { margin: 0 0 8px; padding: 0; border: 0; color: #003768; font-size: 14px; font-weight: 700; }
	#ast-desktop-header .smp-mega-search-row { display: flex; height: 40px; overflow: hidden; border: 1px solid #c9d0d9; border-radius: 8px; background: #fff; }
	#ast-desktop-header .smp-mega-search-row:focus-within { border-color: #003768; box-shadow: 0 0 0 3px rgba(249, 177, 1, 0.6); }
	#ast-desktop-header .smp-mega .smp-mega-search-row input[type="search"] {
		flex: 1 1 auto; min-width: 0; height: 38px; margin: 0; padding: 0 12px; border: 0 !important; border-radius: 0; background: none;
		box-shadow: none !important; outline: 0; color: #1a1a1a; font-size: 14px;
	}
	#ast-desktop-header .smp-mega .smp-mega-search-row button {
		display: flex; align-items: center; justify-content: center; flex: 0 0 40px; width: 40px; height: 38px; margin: 0; padding: 0;
		border: 0; border-radius: 0; background: none; color: #003768; cursor: pointer;
	}
	#ast-desktop-header .smp-mega .smp-mega-search-row button:hover { background: #e9edf2; }

	/* New plant: machine types with pictures, makes as a list, the featured machine on the right */
	#ast-desktop-header .smp-mega-grid--new { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 300px; }
	#ast-desktop-header .smp-mega-grid--new > .smp-mega-foot { grid-column: 1 / -1; }
	#ast-desktop-header .smp-mega-rows { display: grid; gap: 2px; }
	#ast-desktop-header .smp-mega-col--types .smp-mega-rows { gap: 4px; }
	#ast-desktop-header .smp-mega .smp-mega-row { display: flex; align-items: center; gap: 12px; min-height: 56px; margin: 0 -8px; padding: 6px 8px; border-radius: 10px; color: #1a1a1a; font-size: 15px; } /* one row height in every column */
	#ast-desktop-header .smp-mega-col--makes .smp-mega-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
	#ast-desktop-header .smp-mega .smp-mega-row:hover { background: #f4f6f9; color: #003768; text-decoration: none; }
	#ast-desktop-header .smp-mega .smp-mega-row .smp-mega-img { width: 44px; height: 44px; border-radius: 8px; }
	#ast-desktop-header .smp-mega .smp-mega-row:hover .smp-mega-img { background: #e9edf2; }
	#ast-desktop-header .smp-mega-row-label { flex: 1 1 auto; min-width: 0; }
	#ast-desktop-header .smp-mega .smp-mega-rows--plain .smp-mega-row { min-height: 44px; padding: 8px; }
	#ast-desktop-header .smp-mega .smp-mega-rows--plain li:first-child .smp-mega-row { color: #003768; font-weight: 600; }

	/* Machine cards (featured, used stock) */
	#ast-desktop-header .smp-mega .smp-mega-card { display: flex; flex-direction: column; height: 100%; overflow: hidden; border: 1px solid #e3e7ee; border-radius: 12px; background: #fff; color: #1a1a1a; }
	#ast-desktop-header .smp-mega .smp-mega-card:hover { border-color: #c9d0d9; box-shadow: 0 8px 20px rgba(0, 25, 48, 0.1); text-decoration: none; }
	#ast-desktop-header .smp-mega .smp-mega-card-img { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 0; background: #f4f6f9; }
	#ast-desktop-header .smp-mega .smp-mega-card-img img { mix-blend-mode: normal; transition: transform 0.25s ease; }
	#ast-desktop-header .smp-mega .smp-mega-card:hover .smp-mega-card-img img { transform: scale(1.03); }
	#ast-desktop-header .smp-mega-card-body { display: flex; flex: 1 1 auto; flex-direction: column; gap: 3px; padding: 12px 14px 14px; }
	#ast-desktop-header .smp-mega-card-eyebrow { align-self: flex-start; margin-bottom: 4px; padding: 2px 8px; border-radius: 999px; background: #fff4d6; color: #7a5600; font-size: 12px; font-weight: 600; }
	#ast-desktop-header .smp-mega-card-title { display: -webkit-box; overflow: hidden; min-height: 2.6em; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: #003768; font-size: 15px; font-weight: 600; line-height: 1.3; } /* two lines kept for every title */
	#ast-desktop-header .smp-mega-card-meta { min-height: 1.4em; color: #6b7480; font-size: 13px; line-height: 1.4; }
	#ast-desktop-header .smp-mega-card-price { margin-top: auto; padding-top: 6px; color: #1a1a1a; font-size: 14px; font-weight: 600; } /* prices on one line across the cards */
	#ast-desktop-header .smp-mega-card-price .woocommerce-Price-amount { font-weight: 700; }
	#ast-desktop-header .smp-mega-grid--new .smp-mega-side { padding: 14px; }
	#ast-desktop-header .smp-mega-grid--new .smp-mega-card-img { aspect-ratio: 16 / 10; }

	/* Used plant: the list, then the latest machines in stock */
	#ast-desktop-header .smp-mega-grid--used { grid-template-columns: 260px minmax(0, 1fr); }
	#ast-desktop-header .smp-mega-stock { display: flex; flex-direction: column; min-width: 0; }
	#ast-desktop-header .smp-mega-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 16px; margin-bottom: 14px !important; }
	#ast-desktop-header .smp-mega-cards > li { display: flex; min-width: 0; }
	#ast-desktop-header .smp-mega-cards > li > .smp-mega-card { flex: 1 1 auto; }
}

/* Small laptops: a little less room, two tiles a row would still fit but three read better */
@media (min-width: 922px) and (max-width: 1199px) {
	body.smp-mega-on #ast-desktop-header .smp-mega { padding: 22px 22px 20px; }
	#ast-desktop-header .smp-mega-grid--parts { grid-template-columns: minmax(0, 1fr) 260px; }
	#ast-desktop-header .smp-mega-tile { gap: 10px; }
	#ast-desktop-header .smp-mega-tile .smp-mega-img { width: 44px; height: 44px; border-radius: 8px; }
	#ast-desktop-header .smp-mega-grid--new { grid-template-columns: minmax(0, 1fr) minmax(0, 0.7fr) 250px; }
	#ast-desktop-header .smp-mega-col--types .smp-mega-rows { grid-template-columns: minmax(0, 1fr); }
	#ast-desktop-header .smp-mega-grid--used { grid-template-columns: 220px minmax(0, 1fr); }
}
