/* Site header — Figma 1:403 / dropdown 1:429 */

.hs-header {
	position: relative;
	z-index: 50;
	background: #fff;
}

.hs-header__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	min-height: 89px;
	padding: 24px;
	box-sizing: border-box;
}

.hs-header__logo {
	display: block;
	flex: 0 0 auto;
	line-height: 0;
}

.hs-header__logo-svg {
	width: 220px;
	height: auto;
}

.hs-header__list,
.hs-header__panel-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.hs-header__list {
	display: flex;
	align-items: center;
	gap: clamp(16px, 9.13vw - 77.5px, 54px); /* 16px at 1024 → 54px at 1440 */
}

/* Hover (Figma 1:156): hand-drawn underline, 9px tall, 8px below the text,
   stretched to the label width; colour cycles lemon → green → sky → lilac. */
.hs-header__item {
	--hs-nav-line: var(--wp--preset--color--lemon-700);
}
.hs-header__item:nth-child(4n + 2) { --hs-nav-line: var(--wp--preset--color--green-500); }
.hs-header__item:nth-child(4n + 3) { --hs-nav-line: var(--wp--preset--color--sky-500); }
.hs-header__item:nth-child(4n + 4) { --hs-nav-line: var(--wp--preset--color--lilac-500); }

.hs-header__item a {
	position: relative;
	display: inline-block;
	padding-block: 0 8px; /* Figma: text at the top of the item, 8px gap to the underline */
	font-size: 14px;
	font-weight: 500;
	line-height: 1.5;
	color: var(--hs-navy);
	text-decoration: none;
}

.hs-header__item a::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: calc(100% - 9px); /* text bottom (100% − 8px padding) + 8px gap − 9px line */
	height: 9px;
	background: var(--hs-nav-line);
	-webkit-mask: url(../../assets/svg/nav-underline.svg) 0 0 / 100% 100% no-repeat;
	mask: url(../../assets/svg/nav-underline.svg) 0 0 / 100% 100% no-repeat;
	clip-path: inset(0 100% 0 0);
	transition: clip-path 0.35s ease;
	pointer-events: none;
}

/* Desktop bar: no bottom padding, so the label centres on the logo and icons
   (the bar is align-items: center). The underline hangs below instead: its
   bottom stays 8px under the text, as in Figma, without taking up layout space. */
.hs-header__nav .hs-header__item > a {
	padding-block: 0;
}

.hs-header__nav .hs-header__item > a::after {
	top: calc(100% - 1px); /* text bottom + 8px gap − 9px line */
}

.hs-header__item a:hover::after,
.hs-header__item a:focus-visible::after,
.hs-header__item a[aria-current="page"]::after {
	clip-path: inset(0 0 0 0);
}

/* Panel list is right-aligned: draw from the right. */
.hs-header__panel .hs-header__item a::after {
	clip-path: inset(0 0 0 100%);
}
.hs-header__panel .hs-header__item a:hover::after,
.hs-header__panel .hs-header__item a:focus-visible::after,
.hs-header__panel .hs-header__item a[aria-current="page"]::after {
	clip-path: inset(0 0 0 0);
}

@media (prefers-reduced-motion: reduce) {
	.hs-header__item a::after {
		transition: none;
	}
}

/* ---------- Sub-menus (one level, e.g. Curriculum → its pages) ---------- */

/* A parent whose child page is open keeps its underline. */
.hs-header__item.is-current-parent > a::after {
	clip-path: inset(0 0 0 0);
}

.hs-header__sub {
	margin: 0;
	padding: 0;
	list-style: none;
}

.hs-header__sub[hidden] {
	display: none;
}

.hs-header__sub-item a {
	white-space: nowrap;
}

/* Desktop bar: link + chevron button; the panel matches the burger dropdown (Figma 1:429). */
.hs-header__nav .hs-header__item.has-children {
	position: relative;
	display: flex;
	align-items: flex-start;
	gap: 2px;
}

.hs-header__sub-toggle {
	display: grid;
	place-items: center;
	width: 24px;
	height: 21px; /* one 14px / 1.5 line, so the chevron sits on the label's centre */
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: none;
	color: var(--hs-navy);
	cursor: pointer;
}

.hs-header__sub-toggle:focus-visible {
	outline: 2px solid var(--wp--preset--color--sky-700);
	outline-offset: 2px;
}

.hs-header__sub-chevron {
	width: 10px;
	height: auto;
	transition: rotate 0.2s ease;
}

.hs-header__sub-toggle[aria-expanded="true"] .hs-header__sub-chevron {
	rotate: 180deg;
}

.hs-header__nav .hs-header__sub {
	position: absolute;
	top: calc(100% + 8px);
	left: -24px;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	min-width: 220px;
	padding: 16px 24px;
	border-radius: 16px;
	background: var(--wp--preset--color--sky-100);
	box-sizing: border-box;
}

.hs-header__nav .hs-header__sub[hidden] {
	display: none;
}

/* Hover bridge across the gap between the label and the panel. */
.hs-header__nav .hs-header__sub::before {
	content: "";
	position: absolute;
	inset: -8px 0 auto;
	height: 8px;
}

/* Burger panel (< 1024px): sub-pages listed under their parent, smaller. */
.hs-header__panel .hs-header__sub {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 4px;
	margin: 0 0 4px;
}

.hs-header__panel .hs-header__sub-item a {
	font-size: 13px;
	font-weight: 400;
}

/* Account icon + burger */
.hs-header__actions {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 8px;
}

.hs-header__account,
.hs-header__cart,
.hs-header__search-toggle {
	position: relative;
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--hs-navy);
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.hs-header__account:hover,
.hs-header__account[aria-current="page"],
.hs-header__cart:hover,
.hs-header__cart[aria-current="page"],
.hs-header__search-toggle:hover,
.hs-header__search-toggle[aria-expanded="true"] {
	background: var(--wp--preset--color--sky-100);
}

.hs-header__account:focus-visible,
.hs-header__cart:focus-visible,
.hs-header__search-toggle:focus-visible,
.hs-header__search-submit:focus-visible {
	outline: 2px solid var(--wp--preset--color--sky-700);
	outline-offset: 2px;
}

.hs-header__icon {
	width: 32px;
	height: 32px;
}

/* Cart item count on the cart icon. */
.hs-header__cart-count {
	position: absolute;
	top: 2px;
	right: 0;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 9px;
	background: var(--hs-navy);
	color: var(--wp--preset--color--base);
	font-size: 11px;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
}

.hs-header__cart-count[hidden] {
	display: none;
}

/* Search dropdown — same sky-100 panel as the burger (Figma 1:429). */
.hs-header__search {
	position: relative;
}

.hs-header__search-panel {
	position: absolute;
	top: calc(100% + 4px);
	right: -8px;
	display: flex;
	align-items: center;
	gap: 8px;
	width: min(360px, calc(100vw - 32px));
	padding: 12px 12px 12px 20px;
	border-radius: 16px;
	background: var(--wp--preset--color--sky-100);
	box-sizing: border-box;
}

.hs-header__search-panel[hidden] {
	display: none;
}

.hs-header__search-input {
	flex: 1 1 auto;
	min-width: 0;
	padding: 8px 0;
	border: 0;
	border-bottom: 1px solid rgba(14, 42, 92, 0.3);
	background: transparent;
	font: inherit;
	font-size: 16px;
	color: var(--hs-navy);
}

.hs-header__search-input:focus {
	outline: none;
	border-bottom-color: var(--hs-navy);
}

.hs-header__search-input::placeholder {
	color: rgba(14, 42, 92, 0.6);
}

.hs-header__search-submit {
	display: grid;
	flex: 0 0 auto;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--hs-navy);
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.hs-header__search-submit:hover {
	background: #fff;
}

.hs-header__search-submit-icon {
	width: 26px;
	height: 26px;
}

/* Burger */
.hs-header__more {
	position: relative;
	flex: 0 0 auto;
}

.hs-header__toggle {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--hs-navy);
	cursor: pointer;
}

.hs-header__burger {
	position: relative;
	display: block;
	width: 31px;
	height: 25px;
}

.hs-header__burger span {
	position: absolute;
	left: 0;
	width: 100%;
	height: 3px;
	border-radius: 3px;
	background: currentColor;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.hs-header__burger span:nth-child(1) { top: 0; }
.hs-header__burger span:nth-child(2) { top: 11px; }
.hs-header__burger span:nth-child(3) { top: 22px; }

/* Figma open state: only the middle bar remains. */
.hs-header__more.is-open .hs-header__burger span:nth-child(1) { opacity: 0; transform: translateY(11px); }
.hs-header__more.is-open .hs-header__burger span:nth-child(3) { opacity: 0; transform: translateY(-11px); }

.hs-header__panel {
	position: absolute;
	top: calc(100% + 4px);
	right: -8px;
	min-width: 140px;
	padding: 16px 24px;
	border-radius: 16px;
	background: var(--wp--preset--color--sky-100);
	box-sizing: border-box;
}

.hs-header__panel[hidden] {
	display: none;
}

.hs-header__panel-list {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 8px;
	text-align: right;
}

.hs-header__item--primary {
	display: none;
}

@media (max-width: 1023px) {
	.hs-header__nav {
		display: none;
	}

	.hs-header__item--primary {
		display: list-item;
	}

	.hs-header__item--primary + .hs-header__item:not(.hs-header__item--primary) {
		padding-top: 12px;
		margin-top: 4px;
		border-top: 1px solid rgba(14, 42, 92, 0.15);
	}
}

@media (max-width: 768px) {
	.hs-header__bar {
		min-height: 72px;
		padding: 16px 0;
	}

	.hs-header__logo-svg {
		width: 170px;
	}
}

/* Mobile / tablet (< 1024px, burger holds the whole menu): full-screen panel under the
   header bar, scrolls on its own; the burger turns into an X. --hs-menu-top is set by view.js. */
@media (max-width: 1023px) {
	.hs-header__panel {
		position: fixed;
		top: var(--hs-menu-top, 72px);
		right: 0;
		bottom: 0;
		left: 0;
		z-index: 60;
		min-width: 0;
		padding: 24px 24px calc(48px + env(safe-area-inset-bottom));
		border-radius: 0;
		overflow-y: auto;
		overscroll-behavior: contain;
		-webkit-overflow-scrolling: touch;
	}

	.hs-header__panel-list {
		align-items: stretch;
		gap: 4px;
		max-width: 640px;
		margin-inline: auto;
		text-align: left;
	}

	.hs-header__panel .hs-header__item a {
		padding-block: 8px 12px;
		font-size: 20px;
	}

	/* Left-aligned now: draw the underline from the left. */
	.hs-header__panel .hs-header__item a::after {
		top: calc(100% - 11px);
		clip-path: inset(0 100% 0 0);
	}

	.hs-header__panel .hs-header__sub {
		align-items: flex-start;
		gap: 0;
		margin: -4px 0 8px;
		padding-left: 16px;
		border-left: 2px solid rgba(14, 42, 92, 0.15);
	}

	.hs-header__panel .hs-header__sub-item a {
		padding-block: 6px 10px;
		font-size: 16px;
	}

	.hs-header__item--primary + .hs-header__item:not(.hs-header__item--primary) {
		padding-top: 16px;
		margin-top: 12px;
	}

	/* Burger → X */
	.hs-header__more.is-open .hs-header__burger span:nth-child(1) { opacity: 1; transform: translateY(11px) rotate(45deg); }
	.hs-header__more.is-open .hs-header__burger span:nth-child(2) { opacity: 0; }
	.hs-header__more.is-open .hs-header__burger span:nth-child(3) { opacity: 1; transform: translateY(-11px) rotate(-45deg); }

	/* Page behind the open menu doesn't scroll. */
	html.hs-menu-open,
	html.hs-menu-open body {
		overflow: hidden;
	}
}

@media (max-width: 1023px) and (prefers-reduced-motion: reduce) {
	.hs-header__burger span {
		transition: none;
	}
}

/* Narrow screens: anchor the search panel to the icon group's right edge so it stays on screen. */
@media (max-width: 600px) {
	.hs-header__actions {
		position: relative;
	}

	.hs-header__search {
		position: static;
	}

	.hs-header__search-panel {
		right: 0;
	}
}
