/* Subjects mega menu. Reuses --gh-* tokens from style.css. */

.gh-nav__item.gh-mega {
	position: static; /* panel is positioned relative to the header, not the li */
}

/* The toggle is a <button> styled to match .gh-nav links. */
.gh-mega-toggle {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 8px 0 12px;
	margin: 0;
	border: 0;
	background: none;
	cursor: pointer;
	font-family: 'avenir_next_worlddemi', 'Verdana';
	font-weight: normal;
	font-size: 14px;
	line-height: 20px;
	color: var(--gh-text-secondary);
	white-space: nowrap;
}

.gh-mega-toggle::after {
	content: "";
	width: 12px;
	height: 12px;
	background: url("../assets/images/chevron.svg") no-repeat center / contain;
	transition: transform 0.15s ease;
}

.gh-nav__item.gh-mega.is-open .gh-mega-toggle,
.gh-mega-toggle:hover {
	color: var(--gh-text-primary);
}

.gh-nav__item.gh-mega.is-open .gh-mega-toggle::after {
	transform: rotate(180deg);
}

/* Panel */
.gh-mega-panel {
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%) translateY(4px);
	z-index: 200;
	max-width: calc(100vw - 32px);
	background: var(--gh-white);
	border-radius: 16px;
	box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.gh-mega-panel[hidden] {
	display: none; /* keep semantics; .is-open below overrides for the open state */
}

.gh-nav__item.gh-mega.is-open .gh-mega-panel {
	opacity: 1;
	visibility: visible;
	transform: translateX(-50%) translateY(0);
}

.gh-mega-panel__inner {
	display: flex;
	align-items: stretch;
}

.gh-mega-col {
	display: flex;
	flex-direction: column;
	gap: 20px;
	padding: 24px 24px 32px;
	min-width: 264px;
}

.gh-mega-col + .gh-mega-col {
	border-left: 1px solid var(--gh-accent);
}

/* Divider between stacked groups in the same column. */
.gh-mega-group + .gh-mega-group {
	padding-top: 20px;
	border-top: 1px solid var(--gh-accent);
}

.gh-mega-group__heading {
	margin: 0 0 4px;
	padding: 8px;
	font-family: 'avenir_next_worldmedium', 'Verdana';
	font-weight: normal;
	font-size: 11px;
	line-height: 20px;
	text-transform: uppercase;
	color: var(--gh-text-secondary);
}

.gh-mega-group__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

/* These rows live inside `.gh-nav`, so the `.gh-nav a` rule in style.css
   (specificity 0,1,1) would otherwise win over a bare `.gh-mega-item__link`
   (0,1,0) and force gap:4px / padding:8px 0 12px / nowrap / secondary colour
   onto the anchor items. Scope every item rule under the panel / mobile-subjects
   container so it reliably overrides, and reset white-space so long names wrap. */
:is(.gh-mega-panel, .gh-mobile-subjects) .gh-mega-item__link {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px;
	border-radius: 8px;
	color: var(--gh-text-primary);
	font-family: 'avenir_next_worlddemi', 'Verdana';
	font-weight: normal;
	font-size: 14px;
	line-height: 20px;
	white-space: normal;
	transition: background-color 0.12s ease;
}

:is(.gh-mega-panel, .gh-mobile-subjects) .gh-mega-item__link:hover {
	background: #faf1fe;
}

:is(.gh-mega-panel, .gh-mobile-subjects) .gh-mega-item__icon {
	flex-shrink: 0;
	width: 20px;
	height: 20px;
	display: block;
	object-fit: contain;
}

/* Fixed-width name keeps columns aligned and matches Figma's 224px text block
   (long names wrap to a second line, as in the design). */
:is(.gh-mega-panel, .gh-mobile-subjects) .gh-mega-item__name {
	flex: 0 0 auto;
	width: 224px;
}

:is(.gh-mega-panel, .gh-mobile-subjects) .gh-mega-item__badge {
	flex-shrink: 0;
	padding: 0 4px;
	border-radius: 4px;
	background: var(--gh-surface-hover, #f5f5f5);
	color: var(--gh-text-secondary);
	font-family: 'avenir_next_worldmedium', 'Verdana';
	font-weight: normal;
	font-size: 11px;
	line-height: 20px;
	white-space: nowrap;
}

/* "Coming soon" rows are disabled: greyed, not clickable, name sits next to the
   badge instead of filling the fixed text column. */
:is(.gh-mega-panel, .gh-mobile-subjects) .gh-mega-item--disabled .gh-mega-item__link {
	cursor: default;
}

:is(.gh-mega-panel, .gh-mobile-subjects) .gh-mega-item--disabled .gh-mega-item__link:hover {
	background: none;
}

:is(.gh-mega-panel, .gh-mobile-subjects) .gh-mega-item--disabled .gh-mega-item__name {
	width: auto;
	white-space: nowrap;
	color: var(--gh-text-secondary);
}

/* Responsive. The natural desktop panel is ~1280px wide (4 cols × ~320px, the
   width forced by the fixed 224px item name). Two ranges:

   • 1024–1319px: keep the 4-column desktop layout but let it fit a narrower
     viewport — columns become equal-width/flexible and the item name relaxes
     to fill the remaining space so long names wrap instead of overflowing.
   • ≤1023px: fold the 4 columns into a 2×2 grid. Nav itself hides ≤768px. */
@media (min-width: 1024px) and (max-width: 1319px) {
	/* Stretch the panel toward the viewport edges (it would otherwise shrink to
	   ~820px of content and leave wide margins) so the columns have more room. */
	.gh-mega-panel {
		width: min(calc(100vw - 48px), 1100px);
	}
	.gh-mega-col {
		min-width: 0;
		flex: 1 1 auto;
		padding-left: 16px;
		padding-right: 16px;
	}
	.gh-mega-panel .gh-mega-item__name {
		width: auto;
		flex: 1 1 auto;
	}
	/* "Coming soon" rows default to nowrap (fine at full desktop width); in the
	   shrunk 4-column range let the name wrap so the badge can't overflow into
	   the next column. */
	.gh-mega-panel .gh-mega-item--disabled .gh-mega-item__name {
		white-space: normal;
	}
}

@media (max-width: 1023px) {
	.gh-mega-panel__inner {
		flex-wrap: wrap;
		max-width: 792px;
	}
	.gh-mega-col {
		min-width: 0;
		flex: 1 1 50%;
	}
	.gh-mega-col + .gh-mega-col:nth-child(odd) {
		border-left: 0;
	}
}
