/* Akmal Pure — glass sticky header.
   Sizes come from Customizer via CSS vars (see inc/customizer.php).
   Fallbacks below keep it sane if a var is ever missing. */

:root {
	--ak-header-h: 76px;
	--ak-header-h-sm: 62px;
	--ak-logo-h: 46px;
	--ak-logo-h-stuck: 38px;
	--ak-logo-h-mobile: 36px;
	--ak-glass: rgba(255, 255, 255, .82);
	--ak-glass-solid: rgba(255, 255, 255, .95);
}

.ak-header {
	position: sticky;
	top: 0;
	/* Must stay under #wpadminbar (z-index 99999) or the blur eats it. */
	z-index: 999;
	background: var(--ak-glass);
	-webkit-backdrop-filter: saturate(180%) blur(16px);
	backdrop-filter: saturate(180%) blur(16px);
	border-block-end: 1px solid rgba(0, 0, 0, .06);
	transition: background .3s ease, box-shadow .3s ease, block-size .3s ease;
}

/* Scrolled state (JS adds .is-stuck) */
.ak-header.is-stuck {
	background: var(--ak-glass-solid);
	-webkit-backdrop-filter: saturate(180%) blur(20px);
	backdrop-filter: saturate(180%) blur(20px);
	box-shadow: 0 8px 30px rgba(0, 0, 0, .08);
}

/* Sit below the WP admin bar — `top`, not a logical property: the admin bar is
   always physically at the top regardless of text direction. */
.admin-bar .ak-header { top: 32px; }
@media screen and (max-width: 782px) {
	/* WP's admin bar is not fixed below 600px, so no offset is needed there. */
	.admin-bar .ak-header { top: 46px; }
}
@media screen and (max-width: 600px) {
	.admin-bar .ak-header { top: 0; }
}

.ak-header__inner {
	display: flex;
	align-items: center;
	gap: 20px;
	min-block-size: var(--ak-header-h);
	transition: min-block-size .3s ease;
}
.ak-header.is-stuck .ak-header__inner { min-block-size: var(--ak-header-h-sm); }

/* Brand */
.ak-header__brand { display: flex; align-items: center; flex-shrink: 0; }
.ak-header__brand img {
	block-size: var(--ak-logo-h);
	max-block-size: none;
	inline-size: auto;
	max-inline-size: 260px;
	object-fit: contain;
	transition: block-size .3s ease;
	display: block;
}
.ak-header.is-stuck .ak-header__brand img { block-size: var(--ak-logo-h-stuck); }
.ak-header__title { font-weight: 800; font-size: 1.25rem; color: var(--ak-text); }

/* Nav */
.ak-nav { margin-inline: auto; }
.ak-nav ul { list-style: none; display: flex; align-items: center; gap: 6px; margin: 0; padding: 0; }
.ak-nav li { position: relative; }
.ak-nav a {
	display: block;
	padding: 10px 14px;
	color: var(--ak-text);
	font-weight: 600;
	font-size: .95rem;
	border-radius: 8px;
	transition: .2s;
}
.ak-nav a:hover,
.ak-nav .current-menu-item > a {
	color: var(--ak-primary);
	background: rgba(153, 0, 0, .06);
}

/* Dropdown */
.ak-nav ul ul {
	position: absolute;
	inset-block-start: calc(100% + 8px);
	inset-inline-start: 0;
	display: block;
	min-inline-size: 210px;
	background: rgba(255, 255, 255, .96);
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	border: 1px solid rgba(0, 0, 0, .06);
	border-radius: 14px;
	padding: 8px;
	box-shadow: 0 16px 40px rgba(0, 0, 0, .1);
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: .22s ease;
}
.ak-nav li:hover > ul,
.ak-nav li:focus-within > ul { opacity: 1; visibility: visible; transform: none; }

/* Actions */
.ak-header__actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Cart */
.ak-cart {
	position: relative;
	display: grid;
	place-items: center;
	inline-size: 42px;
	block-size: 42px;
	border-radius: 12px;
	color: var(--ak-text);
	background: rgba(0, 0, 0, .04);
	transition: .2s;
}
.ak-cart:hover { background: rgba(153, 0, 0, .08); color: var(--ak-primary); }
.ak-cart svg { inline-size: 20px; block-size: 20px; }
.ak-cart__count {
	position: absolute;
	inset-block-start: -4px;
	inset-inline-end: -4px;
	min-inline-size: 19px;
	block-size: 19px;
	padding-inline: 5px;
	display: grid;
	place-items: center;
	background: var(--ak-primary);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	border-radius: 999px;
	border: 2px solid #fff;
	direction: ltr;
}

/* User chip */
.ak-user { position: relative; }
.ak-user__btn {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 5px 10px 5px 5px;
	background: rgba(0, 0, 0, .04);
	border: 1px solid transparent;
	border-radius: 999px;
	cursor: pointer;
	font: inherit;
	color: var(--ak-text);
	transition: .2s;
}
.ak-user__btn:hover { background: rgba(153, 0, 0, .07); border-color: rgba(153, 0, 0, .15); }

.ak-user__avatar {
	inline-size: 36px;
	block-size: 36px;
	border-radius: 50%;
	overflow: hidden;
	flex-shrink: 0;
	display: block;
}
.ak-user__avatar img { inline-size: 100%; block-size: 100%; object-fit: cover; display: block; border-radius: 50%; }

.ak-user__text { display: flex; flex-direction: column; line-height: 1.2; text-align: start; }
.ak-user__hi { font-size: .7rem; color: var(--ak-muted); }
.ak-user__name { font-size: .88rem; font-weight: 700; max-inline-size: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ak-user__caret { inline-size: 16px; block-size: 16px; color: var(--ak-muted); transition: transform .25s; }
.ak-user.is-open .ak-user__caret { transform: rotate(180deg); }

.ak-user__menu {
	position: absolute;
	inset-block-start: calc(100% + 10px);
	inset-inline-end: 0;
	min-inline-size: 210px;
	background: rgba(255, 255, 255, .97);
	-webkit-backdrop-filter: blur(14px);
	backdrop-filter: blur(14px);
	border: 1px solid rgba(0, 0, 0, .07);
	border-radius: 14px;
	padding: 8px;
	box-shadow: 0 18px 44px rgba(0, 0, 0, .12);
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: .22s ease;
	z-index: 20;
}
.ak-user.is-open .ak-user__menu { opacity: 1; visibility: visible; transform: none; }

.ak-user__link {
	display: block;
	padding: 10px 12px;
	border-radius: 9px;
	color: var(--ak-text);
	font-size: .92rem;
	font-weight: 600;
	transition: .18s;
}
.ak-user__link:hover { background: rgba(153, 0, 0, .07); color: var(--ak-primary); }
.ak-user__link--danger { color: #b91c1c; border-block-start: 1px solid var(--ak-border); margin-block-start: 6px; padding-block-start: 12px; border-radius: 0 0 9px 9px; }
.ak-user__link--danger:hover { background: rgba(185, 28, 28, .08); color: #b91c1c; }

/* Ghost button */
.ak-btn--ghost { background: transparent; color: var(--ak-text); border-color: var(--ak-border); }
.ak-btn--ghost:hover { background: rgba(0, 0, 0, .04); color: var(--ak-primary); }

/* Header CTA — force white text; some plugins/themes bleed a dark colour in
   and the label disappears against the red fill. */
.ak-header__cta,
.ak-header__cta:hover,
.ak-header__cta:focus,
.ak-header__cta:visited { color: #fff !important; }
.ak-header__cta { box-shadow: 0 4px 14px color-mix(in srgb, var(--ak-primary) 30%, transparent); }

/* Burger */
.ak-burger {
	display: none;
	background: rgba(0, 0, 0, .04);
	border: 0;
	inline-size: 42px;
	block-size: 42px;
	border-radius: 12px;
	cursor: pointer;
	place-items: center;
}
.ak-burger__bar,
.ak-burger__bar::before,
.ak-burger__bar::after {
	content: "";
	display: block;
	inline-size: 20px;
	block-size: 2px;
	background: var(--ak-text);
	border-radius: 2px;
	transition: .25s;
}
.ak-burger__bar::before { transform: translateY(-6px); }
.ak-burger__bar::after { transform: translateY(4px); }
.ak-burger[aria-expanded="true"] .ak-burger__bar { background: transparent; }
.ak-burger[aria-expanded="true"] .ak-burger__bar::before { transform: rotate(45deg); }
.ak-burger[aria-expanded="true"] .ak-burger__bar::after { transform: rotate(-45deg); }

/* Mobile */
@media (max-width: 1024px) {
	.ak-burger { display: grid; }
	.ak-header__cta { display: none; }

	/* IMPORTANT: the header uses backdrop-filter, which makes it a containing
	   block for position:fixed descendants. A fixed nav would therefore anchor
	   to the HEADER, not the viewport — that's why the menu dropped below the
	   page. Anchor it to the header with `absolute` instead. */
	.ak-nav {
		position: absolute;
		top: 100%;
		inset-inline: 0;
		background: #fff;
		border-block-end: 1px solid var(--ak-border);
		box-shadow: 0 18px 40px rgba(16, 24, 40, .14);
		padding: 16px 20px 22px;
		max-block-size: calc(100vh - var(--ak-header-h) - 40px);
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		transform: translateY(-10px);
		opacity: 0;
		visibility: hidden;
		transition: opacity .22s ease, transform .22s ease, visibility .22s;
		margin: 0;
		z-index: 20;
	}
	.ak-nav.is-open { opacity: 1; visibility: visible; transform: none; }

	/* The header must not clip the open menu. */
	.ak-header { overflow: visible; }
	.ak-header__inner { position: relative; }

	.ak-nav ul { flex-direction: column; align-items: stretch; gap: 2px; }
	.ak-nav a { padding: 14px 16px; font-size: 1rem; }
	.ak-nav ul ul {
		position: static;
		opacity: 1;
		visibility: inherit;
		transform: none;
		box-shadow: none;
		border: 0;
		background: transparent;
		padding: 0;
		padding-inline-start: 16px;
		min-inline-size: 0;
	}
	/* Sub-menus must follow the drawer. A hard `visibility: visible` — here, or
	   from the desktop :hover/:focus-within rule, which sticks on touch
	   screens — overrides the hidden it would inherit from the closed drawer.
	   That left Recorded / Live Courses invisible (opacity 0) but tappable over
	   every page on mobile: a tap on the registration form's Last Name field
	   or Register button opened /recorded-courses/ instead. */
	.ak-nav li:hover > ul,
	.ak-nav li:focus-within > ul { visibility: inherit; }
	.ak-user__text { display: none; }
	.ak-user__btn { padding: 4px; }
	.ak-header__brand img,
	.ak-header.is-stuck .ak-header__brand img { block-size: var(--ak-logo-h-mobile); }
}

@media (max-width: 480px) {
	.ak-user__caret { display: none; }
}

/* Logo sits closer to the page edge on desktop.
 *
 * .ak-container centres a 1200px box, so on a 1440px screen the logo started
 * 140px in. This pulls the brand back out of that gutter towards a ~32px page
 * margin. clamp() keeps it at 0 once the viewport is no wider than the
 * container (nothing to claw back) and stops it running off very wide screens.
 * margin-inline-start, so RTL flips with the layout. */
@media (min-width: 1100px) {
	.ak-header__brand {
		margin-inline-start: clamp(-140px, calc(16px - (100vw - var(--ak-container)) / 2), 0px);
	}
}
