/* ==========================================================================
   Site navigation (tsg/nav)
   Header: row ≥ 1024px, menu panel below. Footer: grouped lists.
   ========================================================================== */

.tsg-nav {
	--tsg-nav-ink: var(--wp--preset--color--ink);
	display: flex;
	align-items: center;
	gap: 0.75rem;
	font-family: var(--wp--preset--font-family--body);
}

.tsg-nav *,
.tsg-nav *::before,
.tsg-nav *::after {
	box-sizing: border-box;
}

.tsg-nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tsg-nav .tsg-icon {
	width: 1.125rem;
	height: 1.125rem;
	flex-shrink: 0;
}

/* Shared link look -------------------------------------------------------- */

.tsg-nav__link {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	min-height: 44px;
	padding: 0.5rem 0.875rem;
	border: 0;
	border-radius: var(--wp--custom--radius--pill);
	background: none;
	color: var(--tsg-nav-ink);
	font: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	transition: background-color var(--wp--custom--motion--quick) ease, color var(--wp--custom--motion--quick) ease;
}

.tsg-nav__link:hover {
	background: var(--wp--preset--color--cloud);
	color: var(--tsg-nav-ink);
}

/* Current page: weight + blue underline (not colour alone). */
.tsg-nav__link[aria-current="page"],
.tsg-nav__item--panel.is-active > .tsg-nav__link {
	font-weight: 700;
	text-decoration: underline;
	text-decoration-color: var(--wp--preset--color--genius-blue);
	text-decoration-thickness: 2px;
	text-underline-offset: 0.45em;
}

.tsg-nav__disclosure .tsg-icon {
	transition: transform var(--wp--custom--motion--quick) var(--wp--custom--motion--ease);
}

.tsg-nav__disclosure[aria-expanded="true"] .tsg-icon {
	transform: rotate(180deg);
}

/* Services panel content -------------------------------------------------- */

.tsg-nav__thread {
	margin: 0 0 0.75rem;
	color: var(--wp--preset--color--slate);
	font-size: var(--wp--preset--font-size--caption);
	font-weight: 500;
}

/* THE LINK: one line, three nodes. Brand, Web and Growth sit on the same thread. */
.tsg-nav__groups {
	display: grid;
	gap: 1.5rem;
	position: relative;
}

.tsg-nav__group {
	position: relative;
}

.tsg-nav__group-title {
	margin: 0;
	font-family: var(--wp--preset--font-family--display);
	font-size: 1.25rem;
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.2;
}

.tsg-nav__group-desc {
	margin: 0.25rem 0 0.75rem;
	color: var(--wp--preset--color--slate);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.45;
}

.tsg-nav__sublink {
	display: inline-flex;
	align-items: center;
	min-height: 40px;
	color: var(--tsg-nav-ink);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	text-decoration: none;
}

.tsg-nav__sublink:hover,
.tsg-nav__sublink[aria-current="page"] {
	color: var(--wp--preset--color--genius-blue);
	text-decoration: underline;
	text-underline-offset: 0.3em;
}

.tsg-nav__mega-foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem 1.5rem;
	margin-top: 1.5rem;
	padding-top: 1rem;
	border-top: 1px solid var(--wp--preset--color--line);
	font-size: var(--wp--preset--font-size--small);
}

.tsg-nav__more {
	font-weight: 600;
	color: var(--wp--preset--color--genius-blue);
	text-underline-offset: 0.3em;
}

.tsg-nav__nudge {
	margin: 0;
	color: var(--wp--preset--color--slate);
}

.tsg-nav__nudge a {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	color: var(--tsg-nav-ink);
	font-weight: 600;
	text-underline-offset: 0.3em;
}

.tsg-nav__nudge a .tsg-icon {
	transition: transform var(--wp--custom--motion--quick) var(--wp--custom--motion--ease);
}

.tsg-nav__nudge a:hover .tsg-icon {
	transform: translateX(3px);
}

/* CTA ------------------------------------------------------------------- */

.tsg-nav .tsg-nav__cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0.625rem 1.25rem;
	font-size: 0.9375rem;
	white-space: nowrap;
	text-decoration: none;
}

/* Menu toggle ------------------------------------------------------------- */

.tsg-nav__toggle {
	display: none;
	align-items: center;
	gap: 0.5rem;
	min-width: 44px;
	min-height: 44px;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--white);
	color: var(--tsg-nav-ink);
	font: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	cursor: pointer;
}

.tsg-nav__toggle .tsg-icon path {
	transition: transform var(--wp--custom--motion--quick) var(--wp--custom--motion--ease), opacity var(--wp--custom--motion--quick) ease;
	transform-origin: 12px 12px;
}

.tsg-nav__toggle[aria-expanded="true"] .tsg-icon__top {
	transform: translateY(5px) rotate(45deg);
}

.tsg-nav__toggle[aria-expanded="true"] .tsg-icon__mid {
	opacity: 0;
}

.tsg-nav__toggle[aria-expanded="true"] .tsg-icon__bot {
	transform: translateY(-5px) rotate(-45deg);
}

/* ==========================================================================
   Below 1024px: menu panel
   ========================================================================== */

@media (max-width: 1023.98px) {

	.tsg-nav.is-enhanced .tsg-nav__toggle {
		display: inline-flex;
	}

	.tsg-nav__cta--bar {
		order: -1;
	}

	/* Small phones: the button moves into the panel so the logo keeps its minimum size. */
	@media (max-width: 479.98px) {
		.tsg-nav.is-enhanced .tsg-nav__cta--bar {
			display: none;
		}
		.tsg-nav__toggle-label {
			position: absolute;
			width: 1px;
			height: 1px;
			overflow: hidden;
			clip: rect(0 0 0 0);
			white-space: nowrap;
		}
	}

	@media (min-width: 480px) {
		.tsg-nav__item--cta {
			display: none;
		}
	}

	.tsg-nav.is-enhanced .tsg-nav__panel {
		position: fixed;
		inset: var(--tsg-header-offset, 64px) 0 0;
		z-index: 40;
		overflow-y: auto;
		overscroll-behavior: contain;
		padding: 0.5rem var(--wp--style--root--padding-right) 2.5rem var(--wp--style--root--padding-left);
		background: var(--wp--preset--color--white);
		visibility: hidden;
		opacity: 0;
		transform: translateY(-8px);
		transition:
			opacity var(--wp--custom--motion--quick) ease,
			transform var(--wp--custom--motion--standard) var(--wp--custom--motion--ease),
			visibility 0s linear var(--wp--custom--motion--standard);
	}

	.tsg-nav.is-enhanced.is-open .tsg-nav__panel {
		visibility: visible;
		opacity: 1;
		transform: none;
		transition:
			opacity var(--wp--custom--motion--quick) ease,
			transform var(--wp--custom--motion--standard) var(--wp--custom--motion--ease),
			visibility 0s;
	}

	/* Without JavaScript the list simply sits under the logo. */
	.wp-block-group:has(> .tsg-nav:not(.is-enhanced)) {
		flex-wrap: wrap;
		padding-bottom: 1rem;
	}

	.tsg-nav:not(.is-enhanced) {
		flex: 1 1 100%;
		flex-wrap: wrap;
	}

	.tsg-nav:not(.is-enhanced) .tsg-nav__panel {
		flex: 1 1 100%;
	}

	.tsg-nav__list {
		display: flex;
		flex-direction: column;
	}

	.tsg-nav__item {
		border-bottom: 1px solid var(--wp--preset--color--line);
	}

	.tsg-nav__item--cta {
		border-bottom: 0;
		padding-top: 1.5rem;
	}

	.tsg-nav__item--cta .tsg-nav__cta {
		width: 100%;
		min-height: 52px;
		font-size: 1rem;
	}

	.tsg-nav__list > .tsg-nav__item > .tsg-nav__link {
		justify-content: space-between;
		width: 100%;
		min-height: 60px;
		padding: 0.75rem 0;
		border-radius: 0;
		font-family: var(--wp--preset--font-family--display);
		font-size: 1.375rem;
		font-weight: 600;
		letter-spacing: -0.01em;
	}

	.tsg-nav__list > .tsg-nav__item > .tsg-nav__link:hover {
		background: none;
		color: var(--wp--preset--color--genius-blue);
	}

	.tsg-nav .tsg-nav__disclosure .tsg-icon {
		width: 1.5rem;
		height: 1.5rem;
	}

	.tsg-nav.is-enhanced .tsg-nav__item--panel:not(.is-expanded) .tsg-nav__mega {
		display: none;
	}

	.tsg-nav__mega {
		padding: 0.25rem 0 1.25rem;
	}

	/* The thread runs down the left edge on small screens. */
	.tsg-nav__groups {
		gap: 1.25rem;
		padding-left: 1.25rem;
		border-left: 2px solid var(--wp--preset--color--genius-blue);
	}

	.tsg-nav__group::before {
		content: "";
		position: absolute;
		top: 0.4em;
		left: calc(-1.25rem - 6px);
		width: 10px;
		height: 10px;
		border-radius: 50%;
		background: var(--wp--preset--color--genius-blue);
	}

	.tsg-nav__group-title {
		font-size: 1.0625rem;
	}

	.tsg-nav__group-desc {
		margin-bottom: 0.25rem;
	}

	.tsg-nav__mega-foot {
		flex-direction: column;
		align-items: flex-start;
		margin-top: 1.25rem;
	}
}

/* ==========================================================================
   1024px and up: row with Services panel
   ========================================================================== */

@media (min-width: 1024px) {

	.tsg-nav__panel {
		display: block;
	}

	.tsg-nav__list {
		display: flex;
		align-items: center;
		gap: 0.125rem;
	}

	.tsg-nav__item--cta {
		display: none;
	}

	/* Panel is positioned against the sticky header, so it spans the full width. */
	.tsg-nav__mega {
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		z-index: 40;
		border-top: 1px solid var(--wp--preset--color--line);
		border-bottom: 1px solid var(--wp--preset--color--line);
		background: var(--wp--preset--color--white);
		box-shadow: var(--wp--preset--shadow--lift);
		visibility: hidden;
		opacity: 0;
		transform: translateY(-6px);
		transition:
			opacity var(--wp--custom--motion--quick) ease,
			transform var(--wp--custom--motion--standard) var(--wp--custom--motion--ease),
			visibility 0s linear var(--wp--custom--motion--standard);
	}

	.tsg-nav.is-enhanced .tsg-nav__item--panel.is-expanded .tsg-nav__mega,
	.tsg-nav:not(.is-enhanced) .tsg-nav__item--panel:hover .tsg-nav__mega,
	.tsg-nav:not(.is-enhanced) .tsg-nav__item--panel:focus-within .tsg-nav__mega {
		visibility: visible;
		opacity: 1;
		transform: none;
		transition:
			opacity var(--wp--custom--motion--quick) ease,
			transform var(--wp--custom--motion--standard) var(--wp--custom--motion--ease),
			visibility 0s;
	}

	.tsg-nav__mega-inner {
		box-sizing: border-box;
		max-width: calc(var(--wp--style--global--wide-size) + var(--wp--style--root--padding-left) + var(--wp--style--root--padding-right));
		margin: 0 auto;
		padding: 2rem var(--wp--style--root--padding-right) 1.75rem var(--wp--style--root--padding-left);
	}

	.tsg-nav__groups {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 2.5rem;
		padding-top: 1.75rem;
	}

	/* The line… */
	.tsg-nav__groups::before {
		content: "";
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		height: 2px;
		background: var(--wp--preset--color--genius-blue);
	}

	/* …and a node where each pillar joins it. */
	.tsg-nav__group::before {
		content: "";
		position: absolute;
		top: calc(-1.75rem - 4px);
		left: 0;
		width: 10px;
		height: 10px;
		border-radius: 50%;
		background: var(--wp--preset--color--genius-blue);
	}

	.tsg-nav__groups[data-count="1"] {
		grid-template-columns: minmax(0, 1fr);
	}

	.tsg-nav__groups[data-count="2"] {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.tsg-nav__cta--bar {
		margin-left: 0.75rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tsg-nav *,
	.tsg-nav *::before {
		transition: none !important;
	}
}

/* ==========================================================================
   Footer variant
   ========================================================================== */

.tsg-fnav {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(136px, 40%), 1fr));
	gap: 2rem 1.5rem;
}

.tsg-fnav__title {
	margin: 0 0 0.75rem;
	color: var(--tsg-text-quiet, var(--wp--preset--color--slate));
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--caption);
	font-weight: 600;
	letter-spacing: 0;
}

.tsg-fnav__list {
	display: grid;
	gap: 0.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.tsg-fnav__link {
	display: inline-flex;
	align-items: center;
	min-height: 36px;
	color: inherit;
	font-size: var(--wp--preset--font-size--small);
	text-decoration: none;
}

.tsg-fnav__link:hover,
.tsg-fnav__link[aria-current="page"] {
	text-decoration: underline;
	text-underline-offset: 0.3em;
}
