/*
 * Shared header navigation.
 *
 * One panel treatment is defined once and used by every menu in the header:
 * the standard dropdowns (About, More, the language switcher) and the
 * Courses mega panel differ only in how wide they are and how many columns
 * they lay their rows out in. The row and its hover state are the same objects
 * in both, which is what keeps the two kinds looking related.
 *
 * The panels carry no icons or chips: a row is a label, an optional level code
 * and an optional description, so the reading order is the type scale.
 */

/*
 * bootstrap_purged.css dropped .fixed-top but kept .navbar{position:relative},
 * and it loads after style.css, so the header only stayed pinned where a later
 * rule put it back — above 767px. Below that it fell into the flow of the
 * absolutely positioned .header and covered the first heading of every article
 * page. !important is needed to beat the purged framework rule at every width.
 */
.header .navbar.fixed-top {
	position: fixed !important;
	top: 0;
	right: 0;
	left: 0;
	z-index: 1030;
}

.joi-nav {
	--joi-nav-ink: #505050;
	--joi-nav-ink-strong: #1d2939;
	--joi-nav-ink-soft: #6b7280;
	/* The two pinks the home page already uses: #f31065 is its accent (link
	   hover, carousel dots) and #e6718d its primary button. The navigation was
	   built on a purple that appears nowhere else on the site. */
	--joi-nav-accent: #f31065;
	--joi-nav-accent-2: #e6718d;
	--joi-nav-accent-ink: #b00a49;
	--joi-nav-accent-glow: rgba(243, 16, 101, 0.55);
	--joi-nav-deep: #1e4e79;
	--joi-nav-line: rgba(16, 24, 40, 0.08);
	--joi-nav-hover: #f4f6fb;
	--joi-nav-radius: 16px;
	--joi-nav-ease: cubic-bezier(0.22, 1, 0.36, 1);

	display: flex;
	flex-direction: column;
	align-items: stretch;
	list-style: none;
	margin: 0;
	padding: 0;
}

.joi-nav__item {
	position: relative;
	list-style: none;
}

/* ---------------------------------------------------------------- top level */

.joi-nav__link {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.35rem;
	width: 100%;
	margin: 0;
	padding: 0.55rem 0.85rem;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: var(--joi-nav-ink);
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.5;
	text-align: left;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: color 0.2s var(--joi-nav-ease), background-color 0.2s var(--joi-nav-ease);
}

.joi-nav__link:hover,
.joi-nav__link:focus-visible,
.joi-nav__item--menu.is-open > .joi-nav__link {
	color: var(--joi-nav-ink-strong);
	text-decoration: none;
}

.joi-nav__link:focus-visible {
	outline: 2px solid var(--joi-nav-accent);
	outline-offset: 2px;
}

/* Opening a menu by pointer should not leave the ring behind. */
.joi-nav__toggle:focus:not(:focus-visible) {
	outline: none;
	box-shadow: none;
}

.joi-nav__caret {
	width: 14px;
	height: 14px;
	flex: none;
	opacity: 0.55;
	transition: transform 0.25s var(--joi-nav-ease), opacity 0.2s linear;
}

.joi-nav__item--menu.is-open > .joi-nav__link .joi-nav__caret {
	transform: rotate(180deg);
	opacity: 1;
}

/* ------------------------------------------------------------- panel chrome */

.joi-nav__panel {
	background: #fff;
	color: var(--joi-nav-ink);
}

.joi-nav__panel-inner {
	display: block;
}

.joi-nav__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.joi-nav__row-item {
	list-style: none;
}

/* ------------------------------------------------------------------- a row */

.joi-nav__row {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.7rem;
	padding: 0.55rem 0.65rem;
	border-radius: 12px;
	color: var(--joi-nav-ink-strong);
	text-decoration: none;
	transition: background-color 0.18s var(--joi-nav-ease), color 0.18s var(--joi-nav-ease);
}

.joi-nav__row:hover,
.joi-nav__row:focus-visible {
	background: var(--joi-nav-hover);
	color: var(--joi-nav-deep);
	text-decoration: none;
}

.joi-nav__row-text {
	display: flex;
	min-width: 0;
	flex-direction: column;
	gap: 1px;
}

.joi-nav__row-label {
	font-size: 14px;
	font-weight: 600;
	line-height: 1.35;
}

.joi-nav__row-desc {
	color: var(--joi-nav-ink-soft);
	font-size: 12px;
	font-weight: 400;
	line-height: 1.4;
}

.joi-nav__row:hover .joi-nav__row-desc {
	color: #4b5563;
}

/* The CEFR/JLPT code trails its label at description weight, so the ladders
   still read as levels without a chip around each one. */
.joi-nav__row-level {
	color: var(--joi-nav-ink-soft);
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.02em;
	white-space: nowrap;
}

.joi-nav__row:hover .joi-nav__row-level {
	color: #4b5563;
}

/* The language switcher is the one panel with images in its rows. */
.joi-nav__flag {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
}

.joi-nav__flag img {
	width: 22px;
	height: auto;
	border-radius: 3px;
}

.joi-nav__tick {
	width: 16px;
	height: 16px;
	flex: none;
	margin-left: auto;
	color: #16a34a;
	opacity: 0;
}

.joi-nav__row.is-current .joi-nav__tick {
	opacity: 1;
}

/* -------------------------------------------------------- mega panel layout */

.joi-nav__grid {
	display: grid;
	gap: 1.5rem;
}

.joi-nav__col-title {
	display: flex;
	/* Bottom-aligned over a fixed height so a heading that wraps does not push
	   its own column's rows out of line with the neighbouring columns. */
	align-items: flex-end;
	min-height: 2.6em;
	margin: 0 0 0.45rem;
	padding: 0 0.65rem 0.5rem;
	border-bottom: 1px solid var(--joi-nav-line);
	/* A shade lighter than the rows it introduces, so the column reads as
	   heading-then-links without a size jump doing the work. */
	color: var(--joi-nav-ink-soft);
	font-size: 12.5px;
	font-weight: 600;
	line-height: 1.35;
}

.joi-nav__feature {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	overflow: hidden;
	padding: 1.25rem;
	border-radius: 14px;
	/* The highlight is a lighter tint of the same pink rather than a second hue,
	   so the card reads as one colour with depth instead of a two-colour ramp. */
	background:
		radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0) 62%),
		linear-gradient(150deg, var(--joi-nav-accent) 0%, var(--joi-nav-accent-2) 100%);
	color: #fff;
}

.joi-nav__feature-eyebrow {
	display: block;
	margin-bottom: 0.55rem;
	color: rgba(255, 255, 255, 0.85);
	font-size: 12px;
	font-weight: 600;
}

.joi-nav__feature-title {
	margin: 0 0 0.4rem;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.3;
}

.joi-nav__feature-text {
	margin: 0 0 1.1rem;
	color: rgba(255, 255, 255, 0.78);
	font-size: 12.5px;
	line-height: 1.55;
}

.joi-nav__feature-cta {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	margin-top: auto;
	padding: 0.55rem 1rem;
	border-radius: 999px;
	background: #fff;
	color: var(--joi-nav-accent-ink);
	font-size: 13px;
	font-weight: 700;
	text-decoration: none;
	transition: transform 0.2s var(--joi-nav-ease), box-shadow 0.2s var(--joi-nav-ease);
}

.joi-nav__feature-cta:hover,
.joi-nav__feature-cta:focus-visible {
	color: var(--joi-nav-accent-ink);
	text-decoration: none;
	box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.65);
}

.joi-nav__panel-footer {
	margin-top: 1rem;
	padding-top: 0.85rem;
	border-top: 1px solid var(--joi-nav-line);
}

.joi-nav__panel-footer-link {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0 0.65rem;
	color: var(--joi-nav-deep);
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
}

.joi-nav__panel-footer-link:hover {
	color: var(--joi-nav-accent);
	text-decoration: underline;
}

/* ================================================================== desktop */

@media (min-width: 992px) {
	.joi-nav {
		flex-direction: row;
		align-items: center;
	}

	.joi-nav__link::after {
		content: "";
		position: absolute;
		right: 0.85rem;
		bottom: 0.2rem;
		left: 0.85rem;
		height: 2px;
		border-radius: 2px;
		background: linear-gradient(90deg, var(--joi-nav-accent) 0%, var(--joi-nav-accent-2) 100%);
		transform: scaleX(0);
		transition: transform 0.28s var(--joi-nav-ease);
	}

	.joi-nav__link:hover::after,
	.joi-nav__item--menu.is-open > .joi-nav__link::after {
		transform: scaleX(1);
	}

	.joi-nav__item--lang .joi-nav__link::after {
		content: none;
	}

	.joi-nav__panel {
		position: absolute;
		top: 100%;
		left: 0;
		z-index: 1040;
		min-width: 360px;
		margin-top: 10px;
		padding: 0.5rem;
		border: 1px solid var(--joi-nav-line);
		border-radius: var(--joi-nav-radius);
		box-shadow:
			0 1px 2px rgba(16, 24, 40, 0.04),
			0 12px 28px -10px rgba(16, 24, 40, 0.2),
			0 36px 64px -28px rgba(16, 24, 40, 0.28);
		opacity: 0;
		visibility: hidden;
		transform: translateY(8px);
		transition:
			opacity 0.2s var(--joi-nav-ease),
			transform 0.24s var(--joi-nav-ease),
			visibility 0s linear 0.24s;
	}

	/* Keeps the pointer inside the menu while it crosses the gap to the panel. */
	.joi-nav__panel::before {
		content: "";
		position: absolute;
		top: -12px;
		right: 0;
		left: 0;
		height: 12px;
	}

	.joi-nav__item--menu.is-open > .joi-nav__panel {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
		transition-delay: 0s;
	}

	.joi-nav__panel--end {
		right: 0;
		left: auto;
		min-width: 210px;
	}

	/* The mega panel spans the navbar rather than its own <li>, so it is
	   positioned against .navbar (which is fixed, and therefore the containing
	   block) instead of the item. */
	.joi-nav__item--mega {
		position: static;
	}

	.joi-nav__panel--mega {
		right: 0;
		left: 0;
		max-width: 1160px;
		margin: 10px auto 0;
		padding: 1.4rem 1.5rem 1.25rem;
	}

	.joi-nav__panel--mega .joi-nav__panel-inner {
		display: grid;
		grid-template-columns: minmax(0, 1fr) 264px;
		gap: 1.75rem;
	}

	/* The two level ladders take exactly the width their labels need, so a long
	   one ("Low Intermediate Grammar") stays on one line and whatever is left
	   goes to the descriptions in the last column. */
	.joi-nav__panel--mega .joi-nav__grid {
		grid-template-columns: auto auto minmax(0, 1fr);
	}

	/* Rows fade up in sequence as the panel opens. */
	.joi-nav__panel--mega .joi-nav__row-item,
	.joi-nav__panel--mega .joi-nav__col-title,
	.joi-nav__panel--mega .joi-nav__feature {
		opacity: 0;
		transform: translateY(6px);
	}

	.joi-nav__item--mega.is-open .joi-nav__row-item,
	.joi-nav__item--mega.is-open .joi-nav__col-title,
	.joi-nav__item--mega.is-open .joi-nav__feature {
		animation: joi-nav-rise 0.34s var(--joi-nav-ease) forwards;
	}

	.joi-nav__item--mega.is-open .joi-nav__col:nth-child(1) .joi-nav__row-item { animation-delay: 0.04s; }
	.joi-nav__item--mega.is-open .joi-nav__col:nth-child(2) .joi-nav__row-item { animation-delay: 0.08s; }
	.joi-nav__item--mega.is-open .joi-nav__col:nth-child(3) .joi-nav__row-item { animation-delay: 0.12s; }
	.joi-nav__item--mega.is-open .joi-nav__feature { animation-delay: 0.14s; }
}

@keyframes joi-nav-rise {
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@media (prefers-reduced-motion: reduce) {
	.joi-nav *,
	.joi-nav__panel {
		animation: none !important;
		transition-duration: 0.01ms !important;
	}

	.joi-nav__panel--mega .joi-nav__row-item,
	.joi-nav__panel--mega .joi-nav__col-title,
	.joi-nav__panel--mega .joi-nav__feature {
		opacity: 1;
		transform: none;
	}
}

/* =================================================================== mobile */

.joi-header-end {
	display: flex;
	align-items: center;
	flex: none;
}

.header .mobile_view {
	align-items: center;
	flex-wrap: nowrap;
	width: auto;
	margin: 0;
}

@media (max-width: 991.98px) {
	/*
	 * .mobile_view held the burger and was only shown below 768px, while the
	 * navbar collapses below 992px (navbar-expand-lg), so the nav was
	 * unreachable in between. It now shares a right-hand cluster with the
	 * login buttons so space-between cannot park it in the centre.
	 */
	.header .joi-header-end {
		margin-left: auto;
	}

	.header .mobile_view {
		display: flex;
		gap: 0.45rem;
	}

	#navbar .navbar-collapse {
		position: fixed;
		top: 90px;
		right: 0;
		left: 0;
		max-height: calc(100vh - 90px);
		padding: 0.75rem 1rem 2rem;
		border-top: 1px solid var(--joi-nav-line, rgba(16, 24, 40, 0.08));
		background: #fff;
		box-shadow: 0 28px 48px -28px rgba(16, 24, 40, 0.45);
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}

	.joi-nav__item + .joi-nav__item {
		border-top: 1px solid var(--joi-nav-line);
	}

	.joi-nav__link {
		padding: 0.85rem 0.5rem;
		font-size: 15px;
	}

	.joi-nav__item--menu > .joi-nav__link {
		justify-content: space-between;
	}

	.joi-nav__caret {
		margin-left: auto;
	}

	/* Panels become inline accordions; the chrome is dropped so the drawer
	   reads as one surface rather than cards inside a card. */
	.joi-nav__panel {
		display: none;
		padding: 0 0 0.75rem;
	}

	.joi-nav__item--menu.is-open > .joi-nav__panel {
		display: block;
	}

	.joi-nav__grid {
		gap: 1.1rem;
	}

	.joi-nav__col-title {
		padding-left: 0.5rem;
	}

	.joi-nav__row {
		padding: 0.55rem 0.5rem;
	}

	.joi-nav__feature {
		margin-top: 1.1rem;
	}
}

@media (max-width: 767.98px) {
	.header .joi-header-end {
		padding-right: 16px;
	}
}
