/* EArk Header & Aliyun-style Mega Menu
   Clean, deduplicated stylesheet for desktop & mobile navigation
*/

:root {
	--eark-primary: #0066ff;
	--eark-primary-dark: #0044cc;
	--eark-text: #1a1a2e;
	--eark-muted: #64748b;
	--eark-border: #e2e8f0;
	--eark-bg: #ffffff;
	--eark-sidebar-bg: #f4f7fb;
	--eark-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
	--eark-radius: 6px;
	--eark-header-height: 64px;
}

.eark-header {
	background: var(--eark-bg);
	border-bottom: 1px solid var(--eark-border);
	position: sticky;
	top: 0;
	z-index: 1400;
	height: var(--eark-header-height);
	overflow: visible;
	will-change: transform;
	transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, background 0.22s ease;
}

.eark-header.is-scrolled {
	box-shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
}

.eark-header-inner {
	max-width: 1400px;
	margin: 0 auto;
	padding: 0 1.5rem;
	height: 100%;
	display: flex;
	align-items: center;
	gap: 1.5rem;
	overflow: visible;
}

.eark-logo {
	flex-shrink: 0;
	font-weight: 700;
	font-size: 1.25rem;
	display: flex;
	align-items: center;
}

.eark-logo a,
.eark-logo .custom-logo-link,
.eark-site-title {
	color: var(--eark-text);
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	line-height: 1;
}

/* Scale 2x Retina logo (e.g. 269x80) cleanly to 1x display height (40px -> ~135x40) */
.eark-logo img,
.eark-logo .custom-logo {
	height: 40px;
	max-height: 40px;
	width: auto;
	max-width: 180px;
	object-fit: contain;
	display: block;
}

.eark-nav {
	flex: 1;
	min-width: 0;
}

.eark-menu {
	display: flex;
	list-style: none;
	margin: 0;
	padding: 0;
	gap: 0.25rem;
	align-items: center;
	height: var(--eark-header-height);
}

.eark-top-item {
	position: static;
	height: 100%;
	display: flex;
	align-items: center;
}

.eark-top-item > a {
	display: flex;
	align-items: center;
	padding: 0 1rem;
	height: 100%;
	color: var(--eark-text);
	text-decoration: none;
	font-weight: 500;
	font-size: 0.95rem;
	white-space: nowrap;
	transition: color 0.15s ease;
}

.eark-top-item > a:hover,
.eark-top-item:hover > a,
.eark-top-item.is-active > a {
	color: var(--eark-primary);
}

/* Menu Icons (strictly 16x16 inline SVG on icon element only, inherits --eark-primary) */
.eark-menu-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	min-width: 16px;
	max-width: 16px;
	max-height: 16px;
	margin-right: 0.5rem;
	flex: 0 0 16px;
	color: var(--eark-primary, #1677ff);
}

.eark-menu-icon svg {
	width: 16px;
	height: 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.9;
	stroke-linecap: square;
	stroke-linejoin: miter;
	display: block;
}

li[class*="icon-"] {
	background-image: none !important;
}

/* Mega Menu Wrapper (Edge-to-Edge Split Layout) */
.eark-mega-wrap {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	width: 100%;
	margin: 0;
	background: #ffffff;
	box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
	border-top: 1px solid var(--eark-border);
	border-bottom: 1px solid var(--eark-border);
	z-index: 1100;
}

.eark-top-item:hover > .eark-mega-wrap,
.eark-top-item:focus-within > .eark-mega-wrap,
.eark-top-item.is-active > .eark-mega-wrap {
	display: block;
}

.eark-mega-inner {
	display: flex;
	width: 100%;
	max-width: none;
	margin: 0;
	min-height: 320px;
	padding: 0;
}

/* Left Sidebar: #f4f7fb stretches to left viewport edge, text aligns with 1400px header container */
.eark-mega-sidebar {
	width: calc(max(0px, (100vw - 1400px) / 2) + 1.5rem + 240px);
	padding: 1rem 0 1rem calc(max(0px, (100vw - 1400px) / 2) + 1.5rem);
	background: var(--eark-sidebar-bg);
	border-right: 1px solid var(--eark-border);
	box-sizing: border-box;
	flex-shrink: 0;
}

.eark-mega-cats {
	list-style: none;
	margin: 0;
	padding: 0;
}

.eark-mega-cat > a {
	position: relative;
	display: flex;
	align-items: center;
	margin: 2px 0;
	padding: 0.7rem 1rem;
	color: var(--eark-text);
	text-decoration: none;
	font-weight: 500;
	font-size: 0.9rem;
	border-radius: 8px 0 0 8px;
	transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.eark-mega-cat > a:hover,
.eark-mega-cat.is-active > a {
	background: #ffffff;
	color: var(--eark-primary);
	box-shadow: -4px 4px 12px rgba(15, 23, 42, 0.06);
	margin-right: -1px;
	z-index: 1;
}

/* Right Content Panel: #ffffff stretches to right viewport edge, content aligns with 1400px container */
.eark-mega-content {
	flex: 1;
	background: #ffffff;
	padding: 1.5rem calc(max(0px, (100vw - 1400px) / 2) + 1.5rem) 1.5rem 2rem;
	max-height: 480px;
	overflow-y: auto;
}

.eark-mega-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
	gap: 1.25rem 2rem;
}

.eark-mega-items-hidden {
	display: none !important;
}

.eark-mega-grid .eark-mega-item {
	list-style: none;
	margin: 0;
	padding: 0;
}

.eark-mega-grid .eark-mega-item a {
	display: flex;
	align-items: center;
	padding: 0.45rem 0.6rem;
	margin-left: -0.6rem;
	color: var(--eark-text);
	text-decoration: none;
	font-size: 0.875rem;
	line-height: 1.45;
	border-radius: 4px;
	transition: background 0.15s ease, color 0.15s ease;
}

.eark-mega-grid .eark-mega-item a:hover {
	background: #f4f8ff;
	color: var(--eark-primary);
}

/* Header Search & Live Search Panel */
.eark-header-search {
	position: relative;
	flex: 0 0 220px;
	transition: flex-basis 0.25s ease;
}

.eark-search-shell {
	position: relative;
	box-sizing: border-box;
	transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, background 0.2s ease;
}

.eark-search-shell *,
.eark-search-shell *::before,
.eark-search-shell *::after {
	box-sizing: border-box;
}

.eark-header.is-searching .eark-search-shell {
	position: absolute;
	right: 0;
	top: -10px;
	width: min(680px, calc(100vw - 32px));
	background: linear-gradient(135deg, #ffffff 0%, #f6f9ff 100%);
	box-shadow: 0 0 0 5px rgba(22, 119, 255, 0.1), 0 20px 50px rgba(15, 23, 42, 0.16);
	border: 1px solid #cfe0ff;
	z-index: 1500;
	padding: 12px;
}

.eark-search-form {
	display: flex;
	align-items: center;
	background: #f1f5f9;
	border: 1px solid transparent;
	overflow: hidden;
	transition: border-color 0.2s ease, background 0.2s ease;
}

.eark-search-form:focus-within,
.eark-header.is-searching .eark-search-form {
	border-color: var(--eark-primary, #1677ff);
	background: #ffffff;
}

.eark-search-input {
	border: 0;
	background: transparent;
	padding: 0.55rem 0.75rem;
	width: 100%;
	outline: none;
	font-size: 14px;
	color: var(--eark-text);
	-webkit-appearance: none;
	appearance: none;
}

/* Hide browser native clear/cancel button so it doesn't duplicate .eark-search-close */
.eark-search-input::-webkit-search-decoration,
.eark-search-input::-webkit-search-cancel-button,
.eark-search-input::-webkit-search-results-button,
.eark-search-input::-webkit-search-results-decoration {
	-webkit-appearance: none;
	appearance: none;
	display: none;
}

.eark-search-input::-ms-clear,
.eark-search-input::-ms-reveal {
	display: none;
	width: 0;
	height: 0;
}

.eark-search-input::placeholder {
	color: #94a3b8;
}

.eark-search-btn {
	background: none;
	border: 0;
	padding: 0.45rem 0.65rem;
	cursor: pointer;
	color: var(--eark-muted);
	display: flex;
	align-items: center;
}

.eark-search-btn:hover {
	color: var(--eark-primary);
}

.eark-search-close {
	display: none;
	border: 0;
	background: none;
	font-size: 20px;
	line-height: 1;
	padding: 0 8px;
	cursor: pointer;
	color: #64748b;
}

.eark-header.is-searching .eark-search-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.eark-search-panel {
	display: none;
	margin-top: 0;
	max-height: 70vh;
	overflow-y: auto;
	background: #ffffff;
	border-top: 1px solid #eef2f7;
}

.eark-header.is-searching .eark-search-panel {
	display: block;
}

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

.eark-search-section {
	padding: 10px 4px;
}

.eark-search-section h4 {
	margin: 0 8px 8px;
	font-size: 13px;
	color: #1a1a2e;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.eark-search-clear {
	border: 0;
	background: none;
	color: #64748b;
	cursor: pointer;
	font-size: 12px;
}

.eark-search-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 8px 4px;
}

.eark-search-chips button {
	border: 1px solid #e2e8f0;
	background: #fff;
	padding: 6px 10px;
	cursor: pointer;
	font-size: 13px;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.eark-search-chips button:hover {
	border-color: var(--eark-primary, #1677ff);
	color: var(--eark-primary, #1677ff);
}

.eark-search-item {
	display: flex;
	gap: 12px;
	align-items: center;
	padding: 10px 8px;
	text-decoration: none;
	color: inherit;
	transition: background 0.15s ease;
}

.eark-search-item:hover {
	background: #f4f8ff;
}

.eark-search-thumb,
.eark-search-item img {
	width: 52px;
	height: 40px;
	object-fit: cover;
	background: #f1f5f9;
	flex-shrink: 0;
}

.eark-search-copy {
	min-width: 0;
	flex: 1;
}

.eark-search-copy strong {
	display: block;
	font-size: 14px;
	color: #1a1a2e;
}

.eark-search-copy span {
	display: block;
	font-size: 12px;
	color: #64748b;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.eark-search-price {
	color: #ff6a00;
	font-weight: 700;
	font-size: 14px;
	flex-shrink: 0;
}

.eark-search-muted {
	color: #94a3b8;
	font-size: 13px;
	padding: 0 8px;
}

.eark-search-empty {
	padding: 16px;
	color: #64748b;
	font-size: 14px;
}

/* Loader hidden by default; only shown when actively searching */
.eark-search-loader {
	display: none;
	gap: 6px;
	justify-content: center;
	padding: 18px;
}

.eark-search-loader.is-loading {
	display: flex;
}

.eark-search-loader[hidden] {
	display: none !important;
}

.eark-search-loader span {
	width: 8px;
	height: 8px;
	background: #0066ff;
	animation: eark-bounce 0.8s infinite ease-in-out;
}

.eark-search-loader span:nth-child(2) { animation-delay: 0.12s; }
.eark-search-loader span:nth-child(3) { animation-delay: 0.24s; }

@keyframes eark-bounce {
	0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
	40% { transform: translateY(-6px); opacity: 1; }
}

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
}

/* Header Action Buttons */
.eark-header-actions {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-left: auto;
	flex-shrink: 0;
}

.eark-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.5rem 1rem;
	border-radius: var(--eark-radius);
	text-decoration: none;
	font-weight: 600;
	font-size: 0.9rem;
	transition: all 0.15s ease;
}

.eark-btn-outline {
	border: 1px solid var(--eark-border);
	color: var(--eark-text);
	background: transparent;
}

.eark-btn-outline:hover {
	border-color: var(--eark-primary);
	color: var(--eark-primary);
}

.eark-btn-primary {
	background: var(--eark-primary);
	color: #fff;
	border: 1px solid var(--eark-primary);
}

.eark-btn-primary:hover {
	background: var(--eark-primary-dark);
}

/* Base Mobile Elements (Hidden on Desktop by default) */
.eark-mobile-toggle {
	display: none;
	background: none;
	border: 0;
	cursor: pointer;
	padding: 0.5rem;
	width: 40px;
	height: 40px;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 5px;
	flex-shrink: 0;
}

.eark-mobile-toggle span {
	display: block;
	width: 22px;
	height: 2px;
	background: var(--eark-text);
	transition: transform 0.2s ease, opacity 0.2s ease;
}

.eark-mobile-toggle[aria-expanded="true"] span:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
}

.eark-mobile-toggle[aria-expanded="true"] span:nth-child(2) {
	opacity: 0;
}

.eark-mobile-toggle[aria-expanded="true"] span:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
}

.eark-drawer {
	display: none;
}

/* Mobile & Tablet Navigation (<= 1024px) */
@media (max-width: 1024px) {
	.eark-header-inner {
		gap: 0.75rem;
		padding: 0 1rem;
	}

	.eark-logo img,
	.eark-logo .custom-logo {
		height: 34px;
		max-height: 34px;
		max-width: 148px;
	}

	.eark-nav,
	.eark-header-actions {
		display: none !important;
	}

	.eark-mobile-toggle {
		display: flex;
		margin-left: auto;
	}

	.eark-header-search {
		flex: 1 1 auto;
		max-width: 320px;
		margin-left: auto;
	}

	.eark-header.is-searching .eark-search-shell {
		position: fixed;
		left: 0;
		right: 0;
		top: var(--eark-header-height);
		width: 100%;
		padding: 0;
		background: #ffffff;
		box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
		border: none;
		border-bottom: 1px solid var(--eark-border);
		border-radius: 0;
		z-index: 1500;
	}
	
	/* On mobile, edge-to-edge divider with 16px inner padding aligned to header */
	.eark-header.is-searching .eark-search-form {
		border-radius: 0;
		border: none;
		border-bottom: 1px solid #eef2f7;
		padding: 4px 16px;
	}

	.eark-header.is-searching .eark-search-input {
		padding-left: 0;
	}

	.eark-header.is-searching .eark-search-close {
		padding-right: 0;
	}

	.eark-drawer[hidden] {
		display: none !important;
	}

	.eark-header.is-searching .eark-search-panel {
		max-height: calc(100vh - var(--eark-header-height) - 52px);
		margin-top: 0;
		padding: 0 16px 24px;
		border-top: 0;
	}

	.eark-header.is-searching .eark-search-section {
		padding: 12px 0;
	}

	.eark-header.is-searching .eark-search-section h4,
	.eark-header.is-searching .eark-search-chips,
	.eark-header.is-searching .eark-search-item,
	.eark-header.is-searching .eark-search-muted {
		margin-left: 0;
		margin-right: 0;
		padding-left: 0;
		padding-right: 0;
	}

	.eark-drawer {
		display: flex;
		flex-direction: column;
		position: fixed;
		top: var(--eark-header-height);
		left: 0;
		right: 0;
		bottom: 0;
		background: #ffffff;
		z-index: 2000;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		border-top: 1px solid var(--eark-border);
	}

	body.eark-nav-open {
		overflow: hidden;
	}

	.eark-drawer-list {
		padding: 4px 0;
	}

	.eark-drawer-row,
	.eark-drawer-subrow {
		width: 100%;
		display: flex;
		align-items: center;
		gap: 8px;
		background: none;
		border: 0;
		border-bottom: 1px solid #eef0f4;
		padding: 16px 20px;
		font-size: 16px;
		font-weight: 500;
		color: #1a1a2e;
		text-align: left;
		cursor: pointer;
	}

	.eark-drawer-subrow {
		padding-left: 36px;
		font-size: 15px;
		color: #334155;
	}

	.eark-drawer-label {
		flex: 1;
	}

	.eark-drawer-row.has-children::after,
	.eark-drawer-subrow.has-children::after {
		content: "";
		width: 8px;
		height: 8px;
		border-right: 2px solid #94a3b8;
		border-bottom: 2px solid #94a3b8;
		transform: rotate(45deg);
		transition: transform 0.18s ease;
		flex-shrink: 0;
		margin-left: auto;
	}

	.eark-drawer-item.is-open > .eark-drawer-row {
		color: var(--eark-primary);
		background: #f8fbff;
	}

	.eark-drawer-item.is-open > .eark-drawer-row::after,
	.eark-drawer-group.is-open > .eark-drawer-subrow::after {
		transform: rotate(-135deg);
		border-color: var(--eark-primary);
	}

	.eark-drawer-sub,
	.eark-drawer-leaves {
		display: none;
		background: #f8fafc;
	}

	.eark-drawer-item.is-open > .eark-drawer-sub,
	.eark-drawer-group.is-open > .eark-drawer-leaves {
		display: block;
	}

	.eark-drawer-leaves a {
		display: flex;
		align-items: center;
		padding: 12px 20px 12px 52px;
		color: #334155;
		text-decoration: none;
		font-size: 14px;
		border-bottom: 1px solid #eef0f4;
	}

	.eark-drawer-leaves a:hover {
		color: var(--eark-primary);
		background: #f1f6ff;
	}

	.eark-drawer-actions {
		display: flex;
		gap: 12px;
		padding: 20px;
		margin-top: auto;
		border-top: 1px solid #eef0f4;
		background: #ffffff;
	}

	.eark-drawer-actions .eark-btn {
		flex: 1;
		justify-content: center;
	}
}

/* WordPress Admin Bar offset (Desktop, Tablet & Mobile) */
@media (max-width: 782px) {
	body.admin-bar .eark-header {
		top: 46px;
	}
	body.admin-bar .eark-drawer {
		top: calc(var(--eark-header-height) + 46px);
	}
	body.admin-bar .eark-header.is-searching .eark-search-shell {
		top: calc(var(--eark-header-height) + 46px);
	}
	body.admin-bar .eark-header.is-searching .eark-search-panel {
		max-height: calc(100vh - var(--eark-header-height) - 46px - 50px);
	}
}

@media (min-width: 783px) {
	body.admin-bar .eark-header {
		top: 32px;
	}
}

@media (min-width: 783px) and (max-width: 1024px) {
	body.admin-bar .eark-drawer {
		top: calc(var(--eark-header-height) + 32px);
	}
	body.admin-bar .eark-header.is-searching .eark-search-shell {
		top: calc(var(--eark-header-height) + 32px);
	}
	body.admin-bar .eark-header.is-searching .eark-search-panel {
		max-height: calc(100vh - var(--eark-header-height) - 32px - 50px);
	}
}



/* Intelligent Sticky Header Hide State (accounts for WP Admin Bar when logged in) */
.eark-header.is-hidden-up {
	transform: translateY(-100%);
}

@media (max-width: 782px) {
	body.admin-bar .eark-header.is-hidden-up {
		transform: translateY(calc(-100% - 46px));
	}
}

@media (min-width: 783px) {
	body.admin-bar .eark-header.is-hidden-up {
		transform: translateY(calc(-100% - 32px));
	}
}
