/*!
 * Hero Air Conditioning — Desktop Navigation (hacd)
 * WAI-ARIA Disclosure Navigation Menu.
 *
 * MEGA PANEL STRATEGY
 * -------------------
 * Services / Systems / Brands render as full-width mega panels laid out in
 * CSS columns. A 24-brand list becomes ~5 rows instead of ~24, which is what
 * keeps the panel inside a 768px-tall laptop viewport.
 *
 * js/desktop-nav.js moves each mega panel out of the sticky <header> and
 * appends it to <body>, then pins it with position:fixed under the blue bar.
 * That is the only reliable way to escape a sticky ancestor's stacking
 * context and overflow clip across browsers.
 *
 * Every panel also carries a max-height + overflow-y guard, so if a list ever
 * outgrows the viewport anyway it scrolls instead of disappearing.
 */

/* =====================================================================
   TOKENS
   ===================================================================== */
:root {
	--hacd-blue:    #1065bd;
	--hacd-blue-lt: #2986ff;
	--hacd-red:     #e00b16;
	--hacd-ink:     #1a2332;
	--hacd-muted:   #5b6472;
	--hacd-tint:    #fff0f0;
	--hacd-line:    #eef1f5;
	--hacd-font:    'Open Sans', Arial, Helvetica, sans-serif;
	/* JS overwrites this per-open with the real distance to the viewport
	   bottom; the value here is a safe fallback for the first paint. */
	--hacd-panel-max-h: calc(100vh - 220px);
}

/* =====================================================================
   DESKTOP ONLY (>= 992px)
   ===================================================================== */
@media screen and (min-width: 992px) {

/* ── Bar ─────────────────────────────────────────────────────────── */
.topnavbar { background: var(--hacd-blue) !important; }

/* Each dropdown anchors its own standard panel */
.topnavbar .hacd-dd {
	position: relative;
	display: inline-block;
}

/* ── Toggle row (label + chevron button) ─────────────────────────── */
.topnavbar .hacd-toggle-row {
	display: flex;
	align-items: center;
	gap: 2px;
	padding-right: .55rem;
	transition: background .15s ease;
}
.topnavbar .hacd-dd:hover > .hacd-toggle-row,
.topnavbar .hacd-dd.hacd-open > .hacd-toggle-row {
	background: rgba(255, 255, 255, .09);
}

.topnavbar .hacd-toplink,
.topnavbar .hacd-toplabel-static {
	color: inherit;
	text-decoration: none;
}
.topnavbar .hacd-toplabel {
	white-space: nowrap;
	line-height: 1.4;
}

/* Chevron button — a real <button>, so keyboard and AT get a control */
.topnavbar .hacd-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 26px;
	height: 26px;
	margin: 0;
	padding: 0;
	background: none;
	border: 0;
	border-radius: 6px;
	color: inherit;
	cursor: pointer;
	line-height: 0;
}
.topnavbar .hacd-toggle:hover { background: rgba(255, 255, 255, .16); }
.topnavbar .hacd-chev { transition: transform .2s ease; }
.topnavbar .hacd-dd.hacd-open .hacd-toggle .hacd-chev { transform: rotate(180deg); }

/* Current section gets a red underline on the bar */
.topnavbar .hacd-dd.hacd-current-section > .hacd-toggle-row {
	box-shadow: inset 0 -3px 0 var(--hacd-red);
}

/* =====================================================================
   SHARED PANEL BASE (closed state)
   Applies to standard panels AND to mega panels both before and after
   the JS portal, so there is never a flash of unstyled panel.
   ===================================================================== */
.topnavbar .hacd-panel,
.hacd-mega-panel {
	box-sizing: border-box;
	background: #fff;
	border-top: 3px solid var(--hacd-red);
	border-radius: 0 0 10px 10px;
	box-shadow: 0 14px 40px rgba(8, 12, 20, .18);
	font-family: var(--hacd-font);
	/* CLOSED */
	opacity: 0;
	visibility: hidden;
	transform: translateY(-6px);
	pointer-events: none;
	transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
}

/* ── Standard panel (single column, anchored to its toggle) ──────── */
.topnavbar .hacd-standard-panel {
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 9999;
	min-width: 236px;
	padding: 6px 0;
	/* Guard: scroll rather than run off-screen */
	max-height: var(--hacd-panel-max-h);
	overflow-y: auto;
	overscroll-behavior: contain;
}
/* Last two dropdowns sit near the right edge — flip them */
.topnavbar .hacd-dd:nth-last-child(1) > .hacd-standard-panel,
.topnavbar .hacd-dd:nth-last-child(2) > .hacd-standard-panel,
.topnavbar .hacd-standard-panel.hacd-flip {
	left: auto;
	right: 0;
}

.topnavbar .hacd-dd.hacd-open > .hacd-standard-panel {
	opacity: 1;
	visibility: visible;
	transform: none;
	pointer-events: auto;
	transition: opacity .18s ease, transform .18s ease;
}

.topnavbar .hacd-list {
	list-style: none;
	margin: 0;
	padding: 0;
}
.topnavbar .hacd-item { margin: 0; }
.topnavbar .hacd-link {
	display: block;
	padding: 9px 18px;
	color: var(--hacd-ink);
	font-size: 13px;
	font-weight: 500;
	text-decoration: none;
	white-space: nowrap;
	transition: background .14s ease, color .14s ease, padding-left .14s ease;
}
.topnavbar .hacd-link:hover,
.topnavbar .hacd-link:focus-visible {
	background: var(--hacd-tint);
	color: var(--hacd-red);
	padding-left: 24px;
}
.topnavbar .hacd-link.hacd-current {
	color: var(--hacd-red);
	font-weight: 700;
	box-shadow: inset 3px 0 0 var(--hacd-red);
}

/* =====================================================================
   MEGA PANEL
   After the portal it is a direct child of <body>, so these rules are
   deliberately NOT scoped under .topnavbar.
   ===================================================================== */
.hacd-mega-panel {
	position: fixed !important;
	top: auto;              /* JS writes the exact px value */
	left: 0 !important;
	right: 0 !important;
	width: 100% !important;
	padding: 0;
	border-radius: 0 0 12px 12px;
	z-index: 99999;
	/* Guard: a very long list scrolls inside the panel instead of
	   extending past the bottom of the screen. */
	max-height: var(--hacd-panel-max-h);
	overflow-y: auto;
	overscroll-behavior: contain;
}

.hacd-mega-panel.hacd-open {
	opacity: 1;
	visibility: visible;
	transform: none;
	pointer-events: auto;
	transition: opacity .18s ease, transform .18s ease;
}

.hacd-mega-inner {
	box-sizing: border-box;
	max-width: 1356px;      /* matches .container-2 */
	margin: 0 auto;
	padding: 26px 40px 24px;
}

/* ── Column layout ───────────────────────────────────────────────
   CSS multi-column fills top-to-bottom then across, so an alphabetical
   list still reads alphabetically down each column. Column counts step
   down on narrower desktops. */
.hacd-mega-list {
	list-style: none;
	margin: 0;
	padding: 0;
	column-gap: 28px;
}
.hacd-mega-list.hacd-cols-1 { column-count: 1; }
.hacd-mega-list.hacd-cols-2 { column-count: 2; }
.hacd-mega-list.hacd-cols-3 { column-count: 3; }
.hacd-mega-list.hacd-cols-4 { column-count: 4; }
.hacd-mega-list.hacd-cols-5 { column-count: 5; }

.hacd-mega-item {
	margin: 0;
	break-inside: avoid;
	-webkit-column-break-inside: avoid;
	page-break-inside: avoid;
}

.hacd-mega-link {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 7px 10px 7px 8px;
	border-radius: 6px;
	color: var(--hacd-ink);
	font-family: var(--hacd-font);
	font-size: 13.5px;
	font-weight: 500;
	line-height: 1.35;
	text-decoration: none;
	transition: background .14s ease, color .14s ease;
}
.hacd-mega-link::before {
	content: "";
	flex: none;
	width: 5px;
	height: 5px;
	margin-top: 6px;
	border-radius: 50%;
	background: #b9c1cc;
	transition: background .14s ease;
}
.hacd-mega-link:hover,
.hacd-mega-link:focus-visible {
	background: var(--hacd-tint);
	color: var(--hacd-red);
}
.hacd-mega-link:hover::before,
.hacd-mega-link:focus-visible::before { background: var(--hacd-red); }
.hacd-mega-link.hacd-current {
	color: var(--hacd-red);
	font-weight: 700;
}
.hacd-mega-link.hacd-current::before { background: var(--hacd-red); }

/* Narrower desktops / laptops: fewer columns so labels stop wrapping */
@media screen and (max-width: 1280px) {
	.hacd-mega-inner { padding: 22px 28px 20px; }
	.hacd-mega-list.hacd-cols-5 { column-count: 4; }
}
@media screen and (max-width: 1120px) {
	.hacd-mega-list.hacd-cols-5,
	.hacd-mega-list.hacd-cols-4 { column-count: 3; }
}

/* ── Focus ring (keyboard only) ──────────────────────────────────── */
.topnavbar .hacd-toggle:focus-visible,
.topnavbar .hacd-toplink:focus-visible,
.topnavbar .hacd-link:focus-visible,
.hacd-mega-link:focus-visible {
	outline: 3px solid var(--hacd-blue-lt);
	outline-offset: 2px;
	border-radius: 4px;
}
.topnavbar .hacd-toggle:focus:not(:focus-visible) { outline: none; }

/* ── Mobile-only controls stay hidden on desktop ─────────────────── */
.hacm-burger,
.hacm-phone { display: none !important; }

/* ── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
	.topnavbar .hacd-panel,
	.topnavbar .hacd-chev,
	.hacd-mega-panel { transition-duration: .01ms !important; }
}

/* ── Forced colours ──────────────────────────────────────────────── */
@media (forced-colors: active) {
	.topnavbar .hacd-panel,
	.hacd-mega-panel { border: 1px solid CanvasText; background: Canvas; }
	.topnavbar .hacd-link,
	.hacd-mega-link { color: LinkText; }
	.topnavbar .hacd-link.hacd-current,
	.hacd-mega-link.hacd-current { color: Highlight; }
}

} /* end @media (min-width: 992px) */

/* =====================================================================
   MOBILE (<= 991px)
   The desktop bar collapses; any mega panel already portalled to <body>
   must not linger as a stray element.
   ===================================================================== */
@media screen and (max-width: 991px) {
	.hacd-mega-panel { display: none !important; }
	.topnavbar .hacd-panel { display: none !important; }
}
