/* Header — logo giữa + cluster menu + search panel (U16.08 header) */

#site-header {
	background-color: var(--hah-surface);
	border-bottom: 1px solid var(--hah-border);
	padding: 0.4rem 0;
	transition: transform 0.22s ease;
	will-change: transform;
	z-index: 1030;
}

#site-header.is-scroll-hidden {
	transform: translateY(-100%);
	pointer-events: none;
}

#site-header.is-scroll-hidden:focus-within,
#site-header.is-scroll-pinned {
	transform: none;
	pointer-events: auto;
}

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

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

.hah-header-inner {
	position: relative;
}

/* —— Desktop: nav trái | lupa giữa | actions phải —— */
.hah-header-desktop {
	display: none;
	grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
	align-items: center;
	column-gap: 0.75rem;
	min-height: 3rem;
}

.hah-header-nav-left {
	justify-self: start;
	min-width: 0;
}

.hah-header-nav-left .hah-header-nav-list {
	flex-wrap: wrap;
}

.hah-header-brand-search {
	justify-self: center;
	position: relative;
	flex: 0 0 auto;
	z-index: 2;
}

.hah-header-actions-right {
	justify-self: end;
	min-width: 0;
}

.hah-header-nav-list {
	display: flex;
	align-items: center;
	gap: 0.15rem 0.85rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.hah-header-nav-link {
	color: var(--hah-ink, #212529);
	text-decoration: none;
	font-weight: 500;
	font-size: 0.95rem;
	white-space: nowrap;
}

.hah-header-nav-link:hover,
.hah-header-nav-item.is-active .hah-header-nav-link {
	color: var(--hah-brand);
}

.hah-header-actions {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
	justify-content: flex-end;
}

.hah-header-actions .hah-header-action-link,
.hah-header-actions .hah-header-user-link,
.hah-header-actions .hah-header-user-logout {
	font-weight: 500;
}

.hah-header-actions.is-mobile {
	flex-direction: column;
	align-items: stretch;
	gap: 0.65rem;
	justify-content: flex-start;
	margin-top: 0.25rem;
	padding-top: 0.25rem;
}

.hah-header-actions.is-mobile .hah-header-user {
	flex-direction: column;
	align-items: flex-start;
}

.hah-header-user-link {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
}

.hah-header-brand-trigger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0.2rem;
	border: 1px solid transparent;
	border-radius: 999px;
	background: transparent;
	cursor: pointer;
	color: var(--hah-ink, #212529);
}

.hah-header-brand-trigger:hover,
.hah-header-brand-trigger[aria-expanded="true"] {
	border-color: var(--hah-border);
	background: color-mix(in srgb, var(--hah-brand) 6%, transparent);
}

/* Rung nhẹ — gợi ý click tìm kiếm (tắt khi đã mở / reduced-motion) */
@keyframes hah-lupa-nudge {
	0%,
	100% {
		transform: rotate(0deg);
	}
	12% {
		transform: rotate(-7deg);
	}
	24% {
		transform: rotate(6deg);
	}
	36% {
		transform: rotate(-5deg);
	}
	48% {
		transform: rotate(4deg);
	}
	60% {
		transform: rotate(-2deg);
	}
	72% {
		transform: rotate(0deg);
	}
}

.hah-header-brand-trigger:not([aria-expanded="true"]) .hah-header-lupa-mark {
	animation: hah-lupa-nudge 2.4s ease-in-out infinite;
	transform-origin: 42% 50%;
}

.hah-header-brand-trigger[aria-expanded="true"] .hah-header-lupa-mark,
.hah-header-brand-trigger.is-lupa-settled .hah-header-lupa-mark {
	animation: none;
}

@media (prefers-reduced-motion: reduce) {
	.hah-header-brand-trigger:not([aria-expanded="true"]) .hah-header-lupa-mark {
		animation: none;
	}
}

/* Logo nằm giữa kính lúp — nét dày hơn */
.hah-header-lupa-mark {
	display: inline-flex;
	align-items: center;
	position: relative;
	padding-right: 0.6rem;
}

.hah-header-lupa-ring {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.85rem;
	height: 2.85rem;
	border: 3.5px solid var(--hah-brand, #d83030);
	border-radius: 50%;
	box-sizing: border-box;
	background: #fff;
	overflow: hidden;
}

.hah-header-lupa-ring .hah-brand-logo {
	width: 1.55rem;
	height: 1.55rem;
	max-width: 1.55rem;
	max-height: 1.55rem;
	object-fit: contain;
	display: block;
}

.hah-header-lupa-handle {
	position: absolute;
	right: 0;
	bottom: 0.1rem;
	width: 0.78rem;
	height: 3.5px;
	background: var(--hah-brand, #d83030);
	border-radius: 2px;
	transform: rotate(45deg);
	transform-origin: center;
}

.hah-header-mobile .hah-header-lupa-ring {
	width: 2.55rem;
	height: 2.55rem;
}

.hah-header-mobile .hah-header-lupa-ring .hah-brand-logo {
	width: 1.35rem;
	height: 1.35rem;
	max-width: 1.35rem;
	max-height: 1.35rem;
}

/* Dropdown Hợp âm → Thế tay */
.hah-header-nav-item {
	position: relative;
}

.hah-header-subnav {
	display: none;
	position: absolute;
	left: 0;
	top: 100%;
	min-width: 12rem;
	margin: 0.25rem 0 0;
	padding: 0.35rem;
	list-style: none;
	background: var(--hah-surface, #fff);
	border: 1px solid var(--hah-border);
	border-radius: 10px;
	box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.1);
	z-index: 1050;
}

.hah-header-nav-item.has-children:hover > .hah-header-subnav,
.hah-header-nav-item.has-children:focus-within > .hah-header-subnav {
	display: block;
}

.hah-header-subnav-link {
	display: block;
	padding: 0.45rem 0.65rem;
	color: var(--hah-ink, #212529);
	text-decoration: none;
	font-size: 0.9rem;
	border-radius: 6px;
	white-space: nowrap;
}

.hah-header-subnav-link:hover,
.hah-header-subnav-item.is-active .hah-header-subnav-link {
	background: #f1f3f5;
	color: var(--hah-brand);
}

.hah-header-mobile-panel .hah-header-subnav {
	position: static;
	display: block;
	box-shadow: none;
	border: none;
	padding: 0 0 0 0.85rem;
	margin: 0;
}

.hah-header-search-heading {
	padding: 0.35rem 0.7rem 0.15rem;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: #6c757d;
}

.hah-header-search-panel {
	position: absolute;
	left: 50%;
	top: calc(100% + 0.4rem);
	transform: translateX(-50%);
	width: min(28rem, 92vw);
	background: var(--hah-surface, #fff);
	border: 1px solid var(--hah-border);
	border-radius: 12px;
	box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.12);
	padding: 0.65rem;
	z-index: 1040;
}

.hah-header-search-panel[hidden] {
	display: none !important;
}

.hah-header-search-form {
	position: relative;
	width: 100%;
}

.hah-header-search-input {
	width: 100%;
	height: 2.75rem;
	padding: 0 2.5rem 0 0.85rem;
	border: 1px solid #ccc;
	border-radius: 10px;
	font-size: 1rem;
	box-sizing: border-box;
	background: #fff;
	color: var(--hah-ink, #212529);
}

.hah-header-search-input:focus {
	outline: none;
	border-color: var(--hah-brand);
	box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--hah-brand) 25%, transparent);
}

.hah-header-search-spinner {
	position: absolute;
	right: 0.75rem;
	top: 1.35rem;
	transform: translateY(-50%);
	width: 1.15rem;
	height: 1.15rem;
	border: 2px solid #adb5bd;
	border-top-color: var(--hah-brand);
	border-radius: 50%;
	animation: hah-header-spin 1s linear infinite;
}

.hah-header-search-spinner[hidden] {
	display: none !important;
}

@keyframes hah-header-spin {
	to {
		transform: translateY(-50%) rotate(360deg);
	}
}

.hah-header-search-results {
	margin-top: 0.4rem;
	max-height: min(60vh, 28rem);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	display: none;
}

.hah-header-search-results.is-open {
	display: block;
}

.hah-header-search-results .autocomplete-result a {
	display: block;
	padding: 0.65rem 0.7rem;
	color: #212529;
	text-decoration: none;
	border-radius: 6px;
}

.hah-header-search-results .autocomplete-result a:hover {
	background-color: #f1f3f5;
}

.hah-header-search-results .ac-title-text {
	font-weight: 600;
	display: block;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.hah-header-search-results .ac-description,
.hah-header-search-results .ac-lyric {
	font-size: 0.8125rem;
	color: #6c757d;
	display: block;
	margin-top: 0.2rem;
}

.hah-header-search-results .ac-harmony {
	font-size: 0.8125rem;
	color: var(--hah-brand);
	font-weight: 500;
	margin-top: 0.3rem;
	font-family: ui-monospace, monospace;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.hah-header-search-results .ac-description i,
.hah-header-search-results .ac-harmony i {
	margin-right: 0.3rem;
}

.hah-header-search-results .no-results,
.hah-header-search-results .hah-search-status {
	padding: 0.85rem;
	color: #6c757d;
	text-align: center;
	font-size: 0.875rem;
}

.hah-header-user {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.hah-header-avatar {
	border-radius: 50%;
	width: 32px;
	height: 32px;
}

/* —— Mobile bar —— */
.hah-header-mobile {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	min-height: 2.75rem;
}

.hah-header-mobile .hah-header-brand-trigger .hah-brand-logo {
	/* legacy rule removed — logo size via .hah-header-lupa-ring */
}

.hah-header-icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	margin: 0;
	padding: 0;
	border: none;
	background: transparent;
	cursor: pointer;
	color: #343a40;
}

.hah-header-icon-bars {
	display: block;
	width: 1.25rem;
	height: 2px;
	background: currentColor;
	border-radius: 1px;
	box-shadow: 0 0.4rem 0 currentColor, 0 0.8rem 0 currentColor;
	margin-bottom: 0.8rem;
}

.hah-header-icon-dots {
	display: block;
	width: 1.15rem;
	height: 1.15rem;
	background:
		radial-gradient(circle closest-side, currentColor 92%, transparent 100%) 0 0 / 33.33% 33.33%,
		radial-gradient(circle closest-side, currentColor 92%, transparent 100%) 50% 0 / 33.33% 33.33%,
		radial-gradient(circle closest-side, currentColor 92%, transparent 100%) 100% 0 / 33.33% 33.33%,
		radial-gradient(circle closest-side, currentColor 92%, transparent 100%) 0 50% / 33.33% 33.33%,
		radial-gradient(circle closest-side, currentColor 92%, transparent 100%) 50% 50% / 33.33% 33.33%,
		radial-gradient(circle closest-side, currentColor 92%, transparent 100%) 100% 50% / 33.33% 33.33%,
		radial-gradient(circle closest-side, currentColor 92%, transparent 100%) 0 100% / 33.33% 33.33%,
		radial-gradient(circle closest-side, currentColor 92%, transparent 100%) 50% 100% / 33.33% 33.33%,
		radial-gradient(circle closest-side, currentColor 92%, transparent 100%) 100% 100% / 33.33% 33.33%;
	background-repeat: no-repeat;
}

.hah-header-mobile-panel {
	padding: 0.75rem 0 0.25rem;
	border-top: 1px solid var(--hah-border);
	margin-top: 0.5rem;
}

.hah-header-mobile-panel[hidden] {
	display: none !important;
}

.hah-header-mobile-panel .hah-header-nav-list {
	flex-direction: column;
	align-items: stretch;
	gap: 0;
}

.hah-header-mobile-panel .hah-header-nav-link {
	display: block;
	padding: 0.55rem 0;
}

/* Mobile search overlay */
.hah-mobile-search-overlay {
	position: fixed;
	inset: 0;
	background: rgba(255, 255, 255, 0.92);
	backdrop-filter: blur(5px);
	z-index: 1040;
	padding: 1rem;
	display: flex;
	align-items: flex-start;
	justify-content: center;
}

.hah-mobile-search-overlay[hidden] {
	display: none !important;
}

.hah-mobile-search-box {
	position: relative;
	width: 100%;
	max-width: 36rem;
	margin-top: 10vh;
}

.hah-mobile-search-close {
	position: absolute;
	top: -2.5rem;
	right: 0;
	font-size: 2rem;
	line-height: 1;
	color: #333;
	background: none;
	border: none;
	cursor: pointer;
}

.screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}

@media (min-width: 992px) {
	.hah-header-desktop {
		display: grid;
	}

	.hah-header-mobile,
	.hah-header-mobile-panel {
		display: none !important;
	}
}
