/*
 * Separes Store header (0.3.0): main row (logo, search, cart, account) and a
 * sticky menu row. Sizes follow the store's former header: 96px main row and
 * 180px logo on desktop, 41px row and 116px logo on mobile, a 45px grey search
 * field, and a 60px menu row that sticks to the top with a soft shadow.
 * The mega menu and the drawer are styled in mega-menu.css.
 */
:root {
	--sps-header-main-h: 96px;
	--sps-header-main-h-mobile: 41px;
	--sps-header-logo-w: 180px;
	--sps-header-logo-w-mobile: 116px;
	--sps-header-text: #333333;
	--sps-search-bg: #F2F2F2;
	--sps-bottom-h: 0px;
}

/* Hide Hello/Elementor's header only when this theme header is active. */
body.sps-has-header #site-header,
body.sps-has-header .site-header:not(.sps-header),
body.sps-has-header .elementor-location-header {
	display: none !important;
}

.sps-header,
.sps-header * {
	box-sizing: border-box;
}

.sps-header {
	position: relative;
	z-index: 1000;
	width: 100%;
	background: var(--sps-color-surface, #FFFFFF);
	color: var(--sps-header-text);
	direction: rtl;
	font-family: var(--sps-store-font);
}

.sps-header a { text-decoration: none; color: inherit; }

.sps-header__inner {
	position: relative;
	width: 100%;
	max-width: var(--sps-container-width);
	margin-inline: auto;
	padding-inline: 15px;
}

/* ---------- Main row ---------- */
.sps-header__main .sps-header__inner {
	display: flex;
	align-items: center;
	gap: 20px;
	height: var(--sps-header-main-h);
}

.sps-header__burger { display: none; }

.sps-logo {
	display: inline-flex;
	align-items: center;
	flex: none;
	width: var(--sps-header-logo-w);
	max-width: 100%;
}
.sps-logo img,
.sps-logo__img {
	display: block;
	width: 100%;
	height: auto;
	max-height: calc(var(--sps-header-main-h) - 10px);
	object-fit: contain;
}
.sps-logo__text {
	font-size: 22px;
	font-weight: 800;
	color: var(--sps-color-primary);
	white-space: nowrap;
}

.sps-header__search {
	flex: 1 1 auto;
	display: flex;
	justify-content: center;
	min-width: 0;
}

.sps-search {
	position: relative;
	display: flex;
	align-items: center;
	width: 100%;
	max-width: 600px;
	height: 45px;
	margin: 0;
	border: 2px solid #FFFFFF;
	border-radius: 5px;
	background: var(--sps-search-bg);
}
.sps-search__input,
.sps-search__input[type="search"] {
	flex: 1 1 auto;
	min-width: 0;
	height: 100%;
	margin: 0;
	padding: 0 15px;
	border: 0;
	border-radius: 5px;
	outline: 0;
	background: transparent;
	box-shadow: none;
	font-family: var(--sps-store-font);
	font-size: 14px;
	color: var(--sps-header-text);
}
.sps-search__input::placeholder { color: #777777; }
.sps-search__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.sps-search__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 45px;
	height: 100%;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--sps-header-text);
	cursor: pointer;
}
.sps-search__btn svg { width: 20px; height: 20px; }
.sps-search__btn:hover,
.sps-search__btn:focus-visible { background: transparent; color: var(--sps-color-secondary); }

/* Live search results. */
.sps-search__results {
	position: absolute;
	inset-inline: 0;
	top: calc(100% + 8px);
	z-index: 1100;
	max-height: min(70vh, 480px);
	overflow-y: auto;
	padding: 6px;
	border-radius: 12px;
	background: #FFFFFF;
	box-shadow: 0 20px 40px -12px rgba(66, 21, 54, 0.28), 0 0 0 1px rgba(99, 32, 79, 0.08);
}
.sps-search__results[hidden] { display: none; }
.sps-search__item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px;
	border-radius: 10px;
	color: var(--sps-header-text);
}
.sps-search__item:hover,
.sps-search__item.is-active { background: #F5EAE3; }
.sps-search__item img {
	flex: none;
	width: 48px;
	height: 48px;
	border-radius: 8px;
	object-fit: cover;
	background: #F5EAE3;
}
.sps-search__name { flex: 1 1 auto; font-size: 14px; line-height: 1.6; }
.sps-search__price { flex: none; font-size: 13px; font-weight: 700; color: var(--sps-color-secondary); white-space: nowrap; }
.sps-search__price del { color: #81777D; font-weight: 400; margin-inline-end: 4px; }
.sps-search__more,
.sps-search__empty {
	display: block;
	padding: 10px;
	text-align: center;
	font-size: 13px;
	font-weight: 700;
	color: var(--sps-color-secondary);
}
.sps-search__empty { font-weight: 400; color: #81777D; }

/* Cart and account. */
.sps-header__actions {
	display: flex;
	align-items: center;
	gap: 6px;
	flex: none;
}
.sps-header__divider {
	display: block;
	width: 1px;
	height: 18px;
	margin-inline: 8px;
	background: rgba(0, 0, 0, 0.105);
}
.sps-icon-btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--sps-header-text);
	cursor: pointer;
	transition: color 0.2s;
}
.sps-icon-btn svg { width: 24px; height: 24px; }
.sps-icon-btn:hover,
.sps-icon-btn:focus-visible { color: var(--sps-color-secondary); }
.sps-cart-count {
	position: absolute;
	top: 2px;
	inset-inline-end: 0;
	min-width: 17px;
	height: 17px;
	padding-inline: 4px;
	border-radius: 50%;
	background: var(--sps-color-secondary);
	color: #FFFFFF;
	font-size: 9px;
	font-weight: 700;
	line-height: 17px;
	text-align: center;
}
.sps-cart-count:empty { display: none; }

/* ---------- Menu row ---------- */
.sps-header__nav {
	background: #FFF9F5;
	/* The open panel's page dimmer is wider than the screen; never scroll sideways. */
	overflow-x: clip;
}
.sps-header__nav .sps-header__inner { position: relative; }
.sps-header__nav.is-stuck {
	position: fixed;
	top: 0;
	inset-inline: 0;
	z-index: 1001;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 10px 24px -14px rgba(66, 21, 54, 0.35);
	animation: sps-nav-in 0.3s ease;
}
body.admin-bar .sps-header__nav.is-stuck { top: 32px; }
@keyframes sps-nav-in { from { transform: translateY(-100%); } to { transform: none; } }

/* ---------- Tablet and mobile (the menu moves into the drawer) ---------- */
@media (max-width: 1024px) {
	.sps-header__nav { display: none; }
	.sps-header__search,
	.sps-header__divider,
	.sps-account-link { display: none; }

	.sps-header__main .sps-header__inner {
		display: grid;
		grid-template-columns: 1fr auto 1fr;
		gap: 10px;
		height: auto;
		min-height: var(--sps-header-main-h-mobile);
		padding-block: 8px;
	}
	.sps-header__burger { display: flex; justify-self: start; }
	.sps-logo { width: var(--sps-header-logo-w-mobile); justify-self: center; }
	.sps-logo img,
	.sps-logo__img { max-height: 60px; }
	.sps-header__actions { justify-self: end; }
}

@media (prefers-reduced-motion: reduce) {
	.sps-header__nav.is-stuck { animation: none; }
}
