/* =========================================================
   STUDY MRCOG HEADER
========================================================= */

:root {
	--header-height: 72px;
	--header-max-width: 1200px;
	--header-text: var(--sm-text);
	--header-blue: var(--sm-blue);
	--header-pink: var(--sm-pink);
}


/* =========================================================
   HEADER
========================================================= */

.site-header {
	position: sticky;
	top: 0;
	z-index: 9999;

	width: 100%;
	height: var(--header-height);

	background: #ffffff;
	border: 0;

	transition:
		background-color 0.25s ease,
		box-shadow 0.25s ease,
		backdrop-filter 0.25s ease;
}

/* Homepage only: let the hero sit behind the header. */
.site-header-home {
	margin-bottom: calc(var(--header-height) * -1);
	background: transparent;
	box-shadow: none;
}

/* White sticky state after scrolling. */
.site-header.is-scrolled {
	background: rgba(255, 255, 255, 0.96);
	-webkit-backdrop-filter: blur(14px);
	backdrop-filter: blur(14px);
	box-shadow: 0 5px 24px rgba(26, 32, 70, 0.08);
}


/* =========================================================
   WORDPRESS ADMIN BAR
========================================================= */

.admin-bar .site-header {
	top: 32px;
}


/* =========================================================
   HEADER CONTAINER
========================================================= */

.header-container {
	width: min(calc(100% - 40px), var(--header-max-width));
	height: 100%;
	margin-inline: auto;

	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 28px;
}


/* =========================================================
   LOGO
========================================================= */

.site-branding {
	display: flex;
	align-items: center;
	flex-shrink: 0;
}

.site-branding .custom-logo-link {
	display: flex;
	align-items: center;
	margin: 0;
	padding: 0;
	line-height: 0;
}

.site-branding .custom-logo {
	display: block;
	width: auto;
	height: 52px;
	max-width: 175px;
	object-fit: contain;
	transition: height 0.25s ease, transform 0.25s ease;
}

.site-header.is-scrolled .custom-logo {
	height: 46px;
}

.site-name {
	color: var(--header-blue);
	font-size: 22px;
	font-weight: 700;
	text-decoration: none;
}


/* =========================================================
   PRIMARY NAVIGATION
========================================================= */

.primary-navigation {
	margin-left: auto;
}

.primary-menu {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.primary-menu li {
	position: relative;
	margin: 0;
	padding: 0;
	list-style: none;
}

.primary-menu > li > a {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 10px 14px;

	color: var(--header-text);
	font-size: 14px;
	font-weight: 500;
	line-height: 1;
	letter-spacing: 0.1px;
	text-transform: uppercase;
	text-decoration: none;
	border-radius: 30px;

	transition: color 0.2s ease, background-color 0.2s ease;
}

.primary-menu > li > a:hover {
	background: rgba(255, 255, 255, 0.8);
	color: #111111;
}

.primary-menu > .current-menu-item > a,
.primary-menu > .current-menu-parent > a,
.primary-menu > .current-menu-ancestor > a {
	background: rgba(255, 255, 255, 0.92);
	color: #111111;
}

/* On the white sticky state, keep links dark and the active item subtle. */
.site-header.is-scrolled .primary-menu > li > a {
	color: #111111;
}

.site-header.is-scrolled .primary-menu > li > a:hover,
.site-header.is-scrolled .primary-menu > .current-menu-item > a,
.site-header.is-scrolled .primary-menu > .current-menu-parent > a,
.site-header.is-scrolled .primary-menu > .current-menu-ancestor > a {
	background: #f6f7fb;
	color: #111111;
}


/* =========================================================
   DROPDOWN ARROW
========================================================= */

.primary-menu > .menu-item-has-children > a::after {
	content: "";
	width: 6px;
	height: 6px;
	margin-left: 8px;
	margin-top: -3px;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(45deg);
	transition: transform 0.2s ease, margin-top 0.2s ease;
}

.primary-menu > .menu-item-has-children:hover > a::after,
.primary-menu > .menu-item-has-children:focus-within > a::after {
	transform: rotate(225deg);
	margin-top: 3px;
}


/* =========================================================
   DROPDOWN
========================================================= */

.primary-menu .sub-menu {
	position: absolute;
	top: calc(100% + 10px);
	left: 0;
	min-width: 230px;
	margin: 0;
	padding: 9px;

	background: #ffffff;
	border: 1px solid rgba(0, 0, 0, 0.04);
	border-radius: 14px;
	box-shadow: 0 15px 45px rgba(0, 0, 0, 0.11);
	list-style: none;

	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	pointer-events: none;

	transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.primary-menu li:hover > .sub-menu,
.primary-menu li:focus-within > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	pointer-events: auto;
}

.primary-menu .sub-menu a {
	display: block;
	padding: 11px 14px;
	color: #151515;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.4;
	text-decoration: none;
	border-radius: 8px;
	white-space: nowrap;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.primary-menu .sub-menu a:hover,
.primary-menu .sub-menu a:focus {
	background: #f8f4f7;
	color: var(--header-pink);
}

.primary-menu .sub-menu .sub-menu {
	top: 0;
	left: calc(100% + 8px);
}


/* =========================================================
   LMS LOGIN BUTTON
========================================================= */

.primary-menu > li.lms-login > a {
	min-width: 116px;
	padding: 10px 17px;
	background: linear-gradient(105deg, #299bea 0%, #e9589a 100%);
	color: #101010;
	border: 1px solid #111111;
	border-radius: 30px;
	transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.primary-menu > li.lms-login > a:hover {
	background: linear-gradient(105deg, #248ed9 0%, #dc4f8d 100%);
	color: #ffffff;
	transform: translateY(-1px);
}

.site-header.is-scrolled .primary-menu > li.lms-login > a {
	color: #101010;
}

.site-header.is-scrolled .primary-menu > li.lms-login > a:hover {
	color: #ffffff;
}


/* =========================================================
   MOBILE BUTTON
========================================================= */

.mobile-menu-toggle {
	display: none;
	width: 44px;
	height: 44px;
	padding: 8px;
	margin: 0;
	background: transparent;
	border: 0;
	border-radius: 8px;
	cursor: pointer;
}

.mobile-menu-toggle span {
	display: block;
	width: 24px;
	height: 2px;
	margin: 5px auto;
	background: #111111;
	border-radius: 20px;
	transition: background-color 0.2s ease, transform 0.25s ease, opacity 0.25s ease;
}

.mobile-menu-toggle.is-active span:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
}

.mobile-menu-toggle.is-active span:nth-child(2) {
	opacity: 0;
}

.mobile-menu-toggle.is-active span:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
}


/* =========================================================
   TABLET / MOBILE
========================================================= */

@media (max-width: 1024px) {
	:root {
		--header-height: 68px;
	}

	.header-container {
		width: calc(100% - 32px);
	}

	.site-branding .custom-logo,
	.site-header.is-scrolled .custom-logo {
		height: 46px;
		max-width: 155px;
	}

	.mobile-menu-toggle {
		display: block;
		margin-left: auto;
	}

	.primary-navigation {
		position: absolute;
		top: 100%;
		left: 0;
		width: 100%;
		max-height: calc(100vh - var(--header-height));
		margin: 0;
		padding: 18px 20px 25px;
		background: rgba(255, 255, 255, 0.98);
		-webkit-backdrop-filter: blur(14px);
		backdrop-filter: blur(14px);
		box-shadow: 0 15px 30px rgba(0, 0, 0, 0.08);
		overflow-x: hidden;
		overflow-y: auto;
		opacity: 0;
		visibility: hidden;
		transform: translateY(-10px);
		pointer-events: none;
		transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
	}

	.primary-navigation.is-open {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
		pointer-events: auto;
	}

	.primary-menu {
		width: 100%;
		flex-direction: column;
		align-items: stretch;
		gap: 3px;
	}

	.primary-menu > li {
		width: 100%;
	}

	.primary-menu > li > a,
	.site-header.is-scrolled .primary-menu > li > a {
		width: 100%;
		min-height: 46px;
		justify-content: space-between;
		padding: 12px 14px;
		color: #111111;
		border-radius: 10px;
	}

	.primary-menu > li > a:hover,
	.primary-menu > .current-menu-item > a,
	.primary-menu > .current-menu-parent > a,
	.primary-menu > .current-menu-ancestor > a {
		background: #f8f4f7;
		color: #111111;
	}

	.primary-menu .sub-menu {
		position: static;
		display: none;
		width: 100%;
		min-width: 0;
		margin: 2px 0 8px;
		padding: 4px 0 4px 14px;
		background: transparent;
		border: 0;
		border-radius: 0;
		box-shadow: none;
		opacity: 1;
		visibility: visible;
		transform: none;
		pointer-events: auto;
		transition: none;
	}

	.primary-menu li.submenu-open > .sub-menu {
		display: block;
	}

	.primary-menu .sub-menu a {
		padding: 11px 14px;
		color: #151515;
		white-space: normal;
	}

	.primary-menu .sub-menu .sub-menu {
		position: static;
		margin-left: 10px;
	}

	.primary-menu > li.lms-login > a,
	.site-header.is-scrolled .primary-menu > li.lms-login > a {
		margin-top: 8px;
		justify-content: center;
		text-align: center;
		color: #101010;
	}

	.primary-menu > li.lms-login > a:hover,
	.site-header.is-scrolled .primary-menu > li.lms-login > a:hover {
		color: #ffffff;
	}
}


/* =========================================================
   WORDPRESS ADMIN BAR MOBILE
========================================================= */

@media (max-width: 782px) {
	.admin-bar .site-header {
		top: 46px;
	}
}


/* =========================================================
   SMALL MOBILE
========================================================= */

@media (max-width: 600px) {
	:root {
		--header-height: 64px;
	}

	.header-container {
		width: calc(100% - 28px);
	}

	.site-branding .custom-logo,
	.site-header.is-scrolled .custom-logo {
		height: 44px;
		max-width: 145px;
	}

	.mobile-menu-toggle {
		width: 40px;
		height: 44px;
		padding: 8px;
	}

	.mobile-menu-toggle span {
		width: 23px;
	}
}


/* =========================================================
   ACCESSIBILITY / KEYBOARD FOCUS
========================================================= */

.site-branding a:focus-visible,
.primary-menu a:focus-visible,
.mobile-menu-toggle:focus-visible {
	outline: 3px solid #1f4fbf;
	outline-offset: 3px;
}


/* =========================================================
   HEADER TYPOGRAPHY NORMALIZATION
========================================================= */

.site-name {
	color: var(--sm-blue);
	font-family: var(--sm-font-family);
	font-size: 1.25rem;
	font-weight: var(--sm-weight-bold);
}

.primary-menu > li > a,
.primary-menu .sub-menu a {
	font-family: var(--sm-font-family);
	font-size: var(--sm-font-small);
	font-weight: var(--sm-weight-semibold);
}

.primary-menu > li > a {
	color: var(--sm-text);
}

.primary-menu > li > a:hover,
.primary-menu > .current-menu-item > a,
.primary-menu > .current-menu-parent > a,
.primary-menu > .current-menu-ancestor > a {
	color: var(--sm-blue-dark);
}

.primary-menu .sub-menu a {
	color: var(--sm-text);
}

.primary-menu .sub-menu a:hover,
.primary-menu .sub-menu a:focus {
	color: var(--sm-pink-dark);
}


/* =========================================================
   HEADER LMS LOGIN + MOBILE SUBMENU STATE
========================================================= */

.header-lms-login {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 42px;
	padding: 10px 18px;
	margin-left: 16px;
	border-radius: 999px;
	background: linear-gradient(105deg, var(--sm-pink, #eb568f) 0%, var(--sm-blue, #2a1e7c) 100%);
	color: #ffffff;
	font-family: var(--sm-font-family);
	font-size: var(--sm-font-small);
	font-weight: var(--sm-weight-semibold);
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	transition: transform .2s ease, box-shadow .2s ease;
}

.header-lms-login:hover,
.header-lms-login:focus-visible {
	color: #ffffff;
	transform: translateY(-1px);
	box-shadow: 0 8px 18px rgba(42, 30, 124, .16);
}

.header-lms-login:focus-visible {
	outline: 3px solid #1f4fbf;
	outline-offset: 3px;
}

@media (max-width: 1024px) {
	.header-lms-login {
		display: flex;
		width: 100%;
		min-height: 46px;
		margin: 10px 0 0;
	}

	.primary-menu .menu-item-has-children > a::after {
		transition: transform .2s ease;
	}

	.primary-menu .menu-item-has-children.submenu-open > a::after {
		transform: rotate(225deg);
	}
}


/* =========================================================
   DESKTOP NAV + LMS LOGIN
   Keep LMS Login on the same row as the primary menu.
========================================================= */

@media (min-width: 1025px) {
	.primary-navigation {
		display: flex;
		align-items: center;
		justify-content: flex-end;
		gap: 16px;
		margin-left: auto;
		white-space: nowrap;
	}

	.primary-navigation .primary-menu {
		flex: 0 1 auto;
	}

	.header-lms-login {
		flex: 0 0 auto;
		width: auto;
		min-width: 118px;
		min-height: 42px;
		margin: 0;
		padding: 10px 18px;
	}
}

/* =========================================================
   MOBILE NAVIGATION POLISH
========================================================= */

@media (max-width: 1024px) {
	.primary-navigation {
		display: block;
	}

	.primary-menu > .menu-item-has-children > a::after {
		width: 8px;
		height: 8px;
		margin-left: 12px;
		margin-top: -4px;
		border-right-width: 2px;
		border-bottom-width: 2px;
		transform: rotate(45deg) !important;
		transition: transform .2s ease, margin-top .2s ease;
	}

	.primary-menu > .menu-item-has-children.submenu-open > a::after {
		margin-top: 4px;
		transform: rotate(225deg) !important;
	}

	.header-lms-login {
		width: 100%;
		margin: 14px 0 0;
		background: linear-gradient(100deg, #eb568f 0%, #2a1e7c 100%);
		color: #ffffff;
	}
}


/* =========================================================
   DESKTOP SUBMENU HOVER BRIDGE
   Keep parent links clickable while opening dropdowns on hover.
   Mobile behavior is unchanged.
========================================================= */
@media (min-width: 1025px) {
	.primary-menu .menu-item-has-children {
		position: relative;
	}

	/*
	 * The desktop dropdown sits 10px below its parent. This invisible
	 * bridge keeps :hover active while the pointer crosses that gap.
	 */
	.primary-menu > .menu-item-has-children::after {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		top: 100%;
		height: 12px;
		background: transparent;
	}

	.primary-menu > .menu-item-has-children:hover > .sub-menu,
	.primary-menu > .menu-item-has-children:focus-within > .sub-menu {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
		pointer-events: auto;
	}

	/* Nested desktop submenus also open on hover/focus. */
	.primary-menu .sub-menu .menu-item-has-children:hover > .sub-menu,
	.primary-menu .sub-menu .menu-item-has-children:focus-within > .sub-menu {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
		pointer-events: auto;
	}
}
