/* ==========================================================================
   KAUSTYA GROUP NAVIGATION
   A second navigation row under the site header, plus its mobile accordion.
   Loaded after redesign.css, so it inherits the theme's tokens and never
   overrides the primary menu.
   ========================================================================== */

:root {
	--gnav-h: 46px;
	--gnav-bp: 1200px;
}

/* --------------------------------------------------------------------------
   The bar
   -------------------------------------------------------------------------- */

.gnav {
	position: relative;
	z-index: 48;
	background: var(--color-primary);
	background-image: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-dark, var(--color-primary)) 100%);
	border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.has-group-nav-sticky .gnav {
	position: sticky;
	top: var(--header-h, 72px);
	z-index: 47;
}

.gnav__inner {
	display: flex;
	align-items: stretch;
	min-height: var(--gnav-h);
}

.gnav__list {
	display: flex;
	align-items: stretch;
	flex-wrap: wrap;
	row-gap: 0;
	column-gap: 0;
	margin: 0;
	padding: 0;
	list-style: none;
	width: 100%;
}

.gnav__item {
	position: static; /* the panel spans the bar, not the item */
	display: flex;
	align-items: stretch;
}

.gnav__link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 0 14px;
	min-height: var(--gnav-h);
	font-family: var(--font-body);
	font-size: .85rem;
	font-weight: 600;
	line-height: 1.2;
	color: rgba(255, 255, 255, .93);
	text-decoration: none;
	white-space: nowrap;
	border-right: 1px solid rgba(255, 255, 255, .13);
	transition: background-color .18s ease, color .18s ease;
}

.gnav__list > .gnav__item:first-child .gnav__link {
	border-left: 1px solid rgba(255, 255, 255, .13);
}

.gnav__link:hover,
.gnav__link:focus-visible {
	background: rgba(0, 0, 0, .18);
	color: #fff;
}

.gnav__item.is-current > .gnav__link,
.gnav__item.is-open > .gnav__link {
	background: rgba(0, 0, 0, .24);
	color: #fff;
}

.gnav__chev {
	flex: none;
	transition: transform .22s ease;
}

.gnav__item.is-open .gnav__chev { transform: rotate(180deg); }

/* The toggle button only exists for keyboard and touch users; pointer users
   get the panel on hover. It sits on top of the chevron. */
.gnav__toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 34px;
	background: transparent;
	border: 0;
	color: #fff;
	cursor: pointer;
}

/* --------------------------------------------------------------------------
   The mega panel
   -------------------------------------------------------------------------- */

.gmega {
	position: absolute;
	left: 0;
	right: 0;
	top: 100%;
	background: var(--card, #fff);
	border-top: 3px solid var(--color-primary);
	border-bottom: 1px solid var(--line, rgba(15, 23, 42, .1));
	box-shadow: var(--shadow-lg, 0 20px 48px rgba(15, 23, 42, .12));
	padding: 30px 0 22px;
	max-height: min(80vh, 720px);
	overflow-y: auto;
	overscroll-behavior: contain;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-8px);
	transition: opacity .2s ease, transform .2s ease, visibility .2s;
	z-index: 46;
}

.gnav__item--mega:hover > .gmega,
.gnav__item--mega:focus-within > .gmega,
.gnav__item.is-open > .gmega {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

/* Tall panels (Projects, Consulting) scroll inside the panel; the fade makes
   that obvious rather than looking like the list simply stops. */
.gmega.is-scrollable::after {
	content: "";
	position: sticky;
	bottom: -22px;
	display: block;
	height: 26px;
	margin: -26px 0 0;
	background: linear-gradient(to top, var(--card, #fff), rgba(255, 255, 255, 0));
	pointer-events: none;
}

[data-theme="dark"] .gmega.is-scrollable::after {
	background: linear-gradient(to top, var(--card, #101a2c), rgba(16, 26, 44, 0));
}

.gmega__cols {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 26px 40px;
	align-items: start;
}

.gmega__cols--1 { grid-template-columns: minmax(0, 1fr); }
.gmega__cols--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.gmega__col { min-width: 0; }

.gmega__head {
	margin: 0 0 12px;
	font-family: var(--font-display);
	font-size: .82rem;
	font-weight: 700;
	line-height: 1.35;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--ink, #0b1f3a);
}

.gmega__head a {
	color: inherit;
	text-decoration: none;
	border-bottom: 2px solid var(--color-primary);
	padding-bottom: 3px;
	transition: color .16s ease;
}

.gmega__head a:hover { color: var(--color-primary); }

.gmega__links {
	margin: 0;
	padding: 0;
	list-style: none;
	columns: 1;
}

.gmega__links li { margin: 0; }

.gmega__links a {
	display: block;
	padding: 6px 10px 6px 0;
	font-size: .855rem;
	font-weight: 500;
	line-height: 1.4;
	color: var(--ink-2, #475569);
	text-decoration: none;
	border-radius: 6px;
	transition: color .14s ease, background-color .14s ease, padding-left .14s ease;
}

.gmega__links a:hover,
.gmega__links a:focus-visible {
	color: var(--color-primary);
	background: var(--bg-alt, rgba(15, 23, 42, .04));
	padding-left: 9px;
}

.gmega__links a[aria-current="page"] {
	color: var(--color-primary);
	font-weight: 700;
}

.gmega__foot {
	margin-top: 24px;
	padding-top: 16px;
	border-top: 1px solid var(--line-soft, rgba(15, 23, 42, .07));
}

.gmega__all {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: .85rem;
	font-weight: 700;
	color: var(--color-primary);
	text-decoration: none;
}

.gmega__all svg { transition: transform .2s ease; }
.gmega__all:hover svg { transform: translateX(4px); }

/* --------------------------------------------------------------------------
   Desktop density — a 24-item column would otherwise run off the panel
   -------------------------------------------------------------------------- */

@media (min-width: 1201px) {
	.gmega__cols--3 .gmega__col:has(.gmega__links li:nth-child(19)) .gmega__links { columns: 2; column-gap: 26px; }
}

/* Six-column menus (Projects, Consulting) wrap to two rows of three. */
@media (min-width: 1201px) {
	.gmega__cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/*
 * Eight labels plus their chevrons need roughly 1320px once the display
 * webfont has loaded, which is more than the 1240px content container gives
 * them — the bar was wrapping onto a second row on a 1440px screen. From
 * 1440px up, the bar and its panel share a wider container instead. Below
 * that the labels tighten, which is enough down to the 1200px handover.
 */
@media (min-width: 1440px) {
	.gnav__inner,
	.gmega > .container { max-width: 1400px; }
	.gnav__link { padding: 0 16px; font-size: .875rem; }
}

@media (min-width: 1320px) and (max-width: 1439px) {
	.gnav__link { padding: 0 12px; font-size: .82rem; letter-spacing: -.005em; }
	.gmega__cols { gap: 22px 30px; }
}

/* The tightest desktop band, just above the handover to the burger. */
@media (min-width: 1201px) and (max-width: 1319px) {
	.gnav__link { padding: 0 9px; font-size: .795rem; letter-spacing: -.01em; }
	.gnav__chev { width: 11px; height: 11px; }
	.gmega__cols { gap: 20px 26px; }
}

/* --------------------------------------------------------------------------
   Tablet and below — the bar is replaced by the drawer section
   -------------------------------------------------------------------------- */

@media (max-width: 1200px) {
	.gnav { display: none; }
}

/* --------------------------------------------------------------------------
   Mobile drawer accordion
   -------------------------------------------------------------------------- */

.gnav-m {
	margin-top: 22px;
	padding-top: 18px;
	border-top: 1px solid var(--line, rgba(15, 23, 42, .1));
}

.gnav-m__title {
	margin: 0 0 4px;
	font-size: var(--text-xs, .75rem);
	font-weight: 700;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--color-primary);
}

.gnav-m__list,
.gnav-m__links {
	margin: 0;
	padding: 0;
	list-style: none;
}

.gnav-m__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	border-bottom: 1px solid var(--line-soft, rgba(15, 23, 42, .07));
}

.gnav-m__link {
	flex: 1;
	display: block;
	padding: 14px 2px;
	font-family: var(--font-display);
	font-size: var(--text-md, 1rem);
	font-weight: 700;
	color: var(--ink, #0b1f3a);
	text-decoration: none;
}

/* Matches the chevron the theme's own mobile menu draws, so the two
   sections of the drawer read as one list rather than two widgets. */
.gnav-m__toggle {
	flex: none;
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	background: transparent;
	border: 0;
	border-radius: var(--radius-xs, 10px);
	color: var(--muted, #64748b);
	cursor: pointer;
	transition: transform .22s ease, color .16s ease, background-color .16s ease;
}

.gnav-m__toggle[aria-expanded="true"] {
	transform: rotate(180deg);
	color: var(--color-primary);
	background: var(--bg-alt, rgba(15, 23, 42, .04));
}

.gnav-m__panel { padding: 6px 0 12px 10px; }

.gnav-m__group + .gnav-m__group { margin-top: 2px; }

.gnav-m__sub {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	width: 100%;
	padding: 11px 8px 11px 0;
	background: transparent;
	border: 0;
	border-bottom: 1px solid var(--line-soft, rgba(15, 23, 42, .07));
	font-family: var(--font-body);
	font-size: .82rem;
	font-weight: 700;
	line-height: 1.35;
	letter-spacing: .04em;
	text-transform: uppercase;
	text-align: left;
	color: var(--ink-2, #475569);
	cursor: pointer;
}

.gnav-m__sub svg { flex: none; transition: transform .22s ease; }
.gnav-m__sub[aria-expanded="true"] { color: var(--color-primary); }
.gnav-m__sub[aria-expanded="true"] svg { transform: rotate(180deg); }

.gnav-m__links { padding: 4px 0 10px 12px; }

.gnav-m__links a {
	display: block;
	padding: 9px 0;
	font-size: var(--text-sm, .9rem);
	line-height: 1.4;
	color: var(--muted, #64748b);
	text-decoration: none;
}

.gnav-m__links a:hover,
.gnav-m__links a:focus-visible { color: var(--color-primary); }

.gnav-m__overview {
	font-weight: 700;
	color: var(--color-primary) !important;
}

/* --------------------------------------------------------------------------
   Front page: the header overlays the hero, so the bar must not inherit
   the transparent treatment.
   -------------------------------------------------------------------------- */

body:not(.has-solid-header) .gnav {
	position: relative;
	z-index: 60;
}

/* --------------------------------------------------------------------------
   Dark mode
   -------------------------------------------------------------------------- */

[data-theme="dark"] .gmega {
	background: var(--card, #101a2c);
	border-bottom-color: var(--line, rgba(255, 255, 255, .1));
}

[data-theme="dark"] .gmega__head { color: #fff; }
[data-theme="dark"] .gmega__links a { color: rgba(255, 255, 255, .72); }
[data-theme="dark"] .gmega__links a:hover { background: rgba(255, 255, 255, .06); color: #fff; }

/* --------------------------------------------------------------------------
   Motion and print
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.gmega,
	.gnav__chev,
	.gnav-m__toggle,
	.gnav-m__sub svg,
	.gmega__all svg,
	.gmega__links a { transition: none; }
}

@media print {
	.gnav,
	.gnav-m { display: none !important; }
}

/* ==========================================================================
   FRONT PAGE — the header floats over the hero, so the group bar has to
   float with it rather than pushing the hero down the page.
   ========================================================================== */

body:not(.has-solid-header) .gnav {
	position: absolute;
	top: var(--header-h, 76px);
	left: 0;
	right: 0;
	z-index: 59;
	background: rgba(6, 20, 40, .40);
	background-image: none;
	backdrop-filter: saturate(160%) blur(12px);
	-webkit-backdrop-filter: saturate(160%) blur(12px);
	border-top: 1px solid rgba(255, 255, 255, .14);
	border-bottom: 1px solid rgba(255, 255, 255, .14);
}

body.has-top-bar:not(.has-solid-header) .gnav {
	top: calc(var(--topbar-h, 38px) + var(--header-h, 76px));
}

/* Give the hero back the space the bar sits on. */
@media (min-width: 1201px) {
	body.has-group-nav:not(.has-solid-header) .hero__inner {
		padding-top: calc(var(--header-h, 76px) + var(--gnav-h) + 44px);
	}
}

/* The panel still needs a solid surface even over a photographic hero. */
body:not(.has-solid-header) .gmega {
	background: var(--card, #fff);
	backdrop-filter: none;
	-webkit-backdrop-filter: none;
}

/* ==========================================================================
   TOUCH — without hover, the chevron button opens the panel and the label
   itself stays a normal link.
   ========================================================================== */

@media (min-width: 1201px) and (hover: none) {
	.gnav__link { padding-right: 6px; border-right: 0; }
	.gnav__chev { display: none; }

	.gnav__toggle {
		display: inline-flex;
		min-height: var(--gnav-h);
		border-right: 1px solid rgba(255, 255, 255, .13);
	}

	.gnav__item--mega:hover > .gmega { opacity: 0; visibility: hidden; }
	.gnav__item.is-open > .gmega { opacity: 1; visibility: visible; transform: translateY(0); }
}
