/* Header cart dropdown + live search */

/* Immediate native-navigation feedback without covering existing content. */
html.cp-is-navigating { cursor: progress; }
html.cp-is-navigating::before {
	content: '';
	position: fixed;
	top: 0;
	inset-inline: 0;
	height: 3px;
	z-index: 10000;
	pointer-events: none;
	background: var(--cp-primary);
	animation: cp-navigation-pulse 0.85s ease-in-out infinite alternate;
}
@keyframes cp-navigation-pulse { from { opacity: 0.35; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
	html.cp-is-navigating::before { animation: none; }
}

.cp-header__actions {
	position: relative;
	z-index: 230;
}

/* ── Cart ── */
.cp-header-cart {
	position: relative;
}

.cp-header-cart__trigger {
	position: relative;
	text-decoration: none;
}

.cp-header-cart__count {
	position: absolute;
	top: -0.15rem;
	inset-inline-end: -0.1rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.15rem;
	height: 1.15rem;
	padding: 0 0.25rem;
	border-radius: var(--cp-btn-radius);
	background: var(--cp-primary);
	color: #fff;
	font-size: 0.68rem;
	font-weight: 800;
	line-height: 1;
}

.cp-header-cart__count.is-empty {
	display: none;
}

.cp-header-cart__dropzone {
	position: absolute;
	top: 100%;
	inset-inline-end: 0;
	z-index: 240;
	width: min(22rem, calc(100vw - 1.7rem));
	margin-top: 0;
	padding-top: 1rem;
	pointer-events: none;
}

.cp-header-cart__panel {
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition:
		opacity 180ms ease,
		transform 180ms ease,
		visibility 180ms ease;
	pointer-events: none;
}

.cp-header.is-cart-open .cp-header-cart__panel,
.cp-header-cart.is-open .cp-header-cart__panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	pointer-events: auto;
}

.cp-header.is-cart-open .cp-header-cart__dropzone,
.cp-header-cart.is-open .cp-header-cart__dropzone {
	pointer-events: auto;
}

.cp-header-cart__panel-inner {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--cp-border);
	border-radius: var(--cp-btn-radius);
	background: var(--cp-surface-elevated);
	box-shadow: var(--cp-shadow);
}

.cp-header-cart__content {
	min-height: 0;
	overflow-x: hidden;
	overflow-y: visible;
	overscroll-behavior: contain;
	touch-action: pan-y;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: color-mix(in srgb, var(--cp-primary) 55%, transparent) transparent;
}

.cp-header-cart__content::-webkit-scrollbar {
	width: 5px;
}

.cp-header-cart__content::-webkit-scrollbar-track {
	margin-block: 0.35rem;
	border-radius: var(--cp-radius-full);
	background: transparent;
}

.cp-header-cart__content::-webkit-scrollbar-thumb {
	border: 1px solid transparent;
	border-radius: var(--cp-radius-full);
	background: color-mix(in srgb, var(--cp-primary) 70%, var(--cp-border));
	background-clip: padding-box;
}

.cp-header-cart__content::-webkit-scrollbar-thumb:hover {
	background: var(--cp-primary);
}

.cp-header-cart__footer-wrap {
	min-height: 0;
}

.cp-header-cart__footer-wrap:empty {
	display: none;
}

.cp-header-cart__empty {
	padding: 1.35rem 1rem;
	color: var(--cp-text-muted);
	font-size: 0.9rem;
	text-align: center;
}

.cp-header-cart__list {
	margin: 0;
	padding: 0.65rem 0;
	list-style: none;
}

.cp-header-cart__item {
	display: grid;
	grid-template-columns: 4rem minmax(0, 1fr);
	gap: 0.75rem;
	align-items: start;
	padding: 0.65rem 1rem;
	direction: ltr;
}

.cp-header-cart__item + .cp-header-cart__item {
	border-top: 1px solid var(--cp-border);
}

.cp-header-cart__thumb {
	overflow: hidden;
	border: 1px solid var(--cp-border);
	border-radius: var(--cp-card-radius);
	background: var(--cp-surface);
	line-height: 0;
}

.cp-header-cart__thumb img {
	display: block;
	width: 4rem;
	height: 4rem;
	object-fit: cover;
}

.cp-header-cart__meta {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0.35rem;
	min-width: 0;
	direction: rtl;
	text-align: right;
}

.cp-header-cart__name {
	display: block;
	margin: 0 0 0.3rem;
	color: var(--cp-primary);
	font-size: 0.82rem;
	font-weight: 700;
	line-height: 1.45;
	text-decoration: none;
}

.cp-header-cart__name:hover {
	color: var(--cp-primary-hover);
}

.cp-header-cart__meta .caseplus-cart-item-details {
	margin-top: 0.45rem;
}

.cp-header-cart__meta .caseplus-cart-item-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
	justify-content: flex-start;
}

.cp-header-cart__meta .caseplus-cart-item-tag {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.15rem;
	max-width: 100%;
	padding: 0.2rem 0.55rem;
	border-radius: var(--cp-btn-radius);
	background: rgba(14, 165, 183, 0.1);
	color: var(--cp-text-muted);
	font-size: 0.68rem;
	line-height: 1.35;
}

.cp-header-cart__meta .caseplus-cart-item-tag__label {
	font-weight: 600;
}

.cp-header-cart__meta .caseplus-cart-item-tag__sep {
	opacity: 0.45;
}

.cp-header-cart__meta .caseplus-cart-item-tag__value {
	color: var(--cp-text);
	word-break: break-word;
}

.cp-header-cart__meta .caseplus-cart-item-tag__value a {
	color: var(--cp-primary);
	text-decoration: none;
}

.cp-header-cart__price {
	margin-top: 0.45rem;
	color: var(--cp-text);
	font-size: 0.82rem;
	font-weight: 700;
	direction: rtl;
}

.cp-header-cart__footer {
	padding: 0.85rem 1rem 1.5rem;
	border-top: 1px solid var(--cp-border);
	border-radius: 0 0 var(--cp-btn-radius) var(--cp-btn-radius);
	background: color-mix(in srgb, var(--cp-primary) 4%, var(--cp-surface-elevated));
}

.cp-header-cart__total {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.75rem;
	direction: rtl;
}

.cp-header-cart__total-label {
	color: var(--cp-text-muted);
	font-size: 0.88rem;
	font-weight: 600;
}

.cp-header-cart__total-value {
	color: var(--cp-text);
	font-size: 0.95rem;
	font-weight: 800;
	direction: rtl;
}

.cp-header-cart__checkout {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 44px;
	padding: 0.75rem 1rem;
	border: 1px solid var(--cp-primary);
	border-radius: var(--cp-btn-radius);
	background: var(--cp-primary);
	color: #fff !important;
	font-size: 0.9rem;
	font-weight: 700;
	text-align: center;
	text-decoration: none;
}

.cp-header-cart__checkout:hover {
	background: var(--cp-primary-hover);
	border-color: var(--cp-primary-hover);
	color: #fff !important;
}

/* ── Search ── */
@property --cp-search-angle {
	syntax: '<angle>';
	initial-value: 0deg;
	inherits: true;
}

.cp-header-search {
	position: relative;
	min-width: 0;
}

.cp-hero-search-toggle {
	display: none;
}

.cp-header.is-hero-search-visible [data-header-search] {
	display: none;
}

.cp-header.is-hero-search-visible .cp-hero-search-toggle {
	display: inline-grid;
}

.cp-header.is-hero-search-visible .cp-header__actions {
	margin-inline-start: auto;
}

.cp-header-search__frame:focus-within::before {
	background: var(--cp-primary);
}

.cp-header-search__frame {
	--cp-search-stroke: 2px;
	position: relative;
	box-sizing: border-box;
	height: var(--cp-logo-height);
	border: 0;
	border-radius: var(--cp-btn-radius);
	background: var(--cp-surface-elevated);
	animation: cp-search-sheen 3.2s linear infinite;
}

.cp-header-search__frame::before {
	content: "";
	position: absolute;
	z-index: 1;
	inset: 0;
	border-radius: inherit;
	padding: var(--cp-search-stroke);
	background: conic-gradient(
		from var(--cp-search-angle),
		var(--cp-primary) 0deg,
		var(--cp-primary) 248deg,
		color-mix(in srgb, var(--cp-primary) 72%, white) 268deg,
		color-mix(in srgb, var(--cp-primary) 72%, white) 308deg,
		var(--cp-primary) 328deg,
		var(--cp-primary) 360deg
	);
	pointer-events: none;
	-webkit-mask:
		linear-gradient(#fff 0 0) content-box,
		linear-gradient(#fff 0 0);
	-webkit-mask-composite: xor;
	mask:
		linear-gradient(#fff 0 0) content-box,
		linear-gradient(#fff 0 0);
	mask-composite: exclude;
}

@media (min-resolution: 1.2dppx) and (max-resolution: 1.35dppx) {
	.cp-header-search__frame {
		--cp-search-stroke: 2.4px;
	}
}

.cp-header-search__sheen {
	display: none;
}

.cp-header-search__form {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.25rem;
	height: 100%;
	min-height: 0;
	padding: 0 0.35rem 0 0.5rem;
	z-index: 0;
	border-radius: var(--cp-btn-radius);
	background: var(--cp-surface-elevated);
	direction: rtl;
}

.cp-header-search__submit {
	display: inline-grid;
	place-items: center;
	flex: 0 0 auto;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 0;
	border-radius: var(--cp-btn-radius);
	background: transparent;
	color: var(--cp-text-muted);
	cursor: pointer;
}

.cp-header-search__submit:hover {
	color: var(--cp-primary);
}

.cp-header-search__submit svg {
	width: 20px;
	height: 20px;
}

.cp-header-search__control {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
	height: 100%;
}

.cp-header-search__input {
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--cp-text);
	font-family: inherit;
	font-size: 0.875rem;
	line-height: 1.4;
	text-align: right;
	outline: none;
}

.cp-header-search__hint {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	overflow: hidden;
	color: var(--cp-text-muted);
	font-size: 0.875rem;
	line-height: 1.4;
	white-space: nowrap;
	pointer-events: none;
	transition: opacity 280ms ease;
}

.cp-header-search__hint::after {
	content: '';
	width: 1px;
	height: 1em;
	margin-inline-start: 2px;
	background: var(--cp-primary);
	opacity: 0;
	animation: cp-search-caret 1s steps(1) infinite;
}

.cp-header-search.is-filled .cp-header-search__hint,
.cp-header-search:focus-within .cp-header-search__hint {
	opacity: 0;
}

.cp-header-search__hint.is-fading {
	opacity: 0;
}

.cp-header-search__panel {
	position: absolute;
	top: calc(100% + 0.55rem);
	inset-inline-end: 0;
	z-index: 245;
	width: min(24rem, calc(100vw - 1.7rem));
}

.cp-header-search__panel[hidden] {
	display: none !important;
}

.cp-header-search__input::placeholder {
	color: var(--cp-text-muted);
}

.cp-header-search__input::-webkit-search-cancel-button,
.cp-header-search__input::-webkit-search-decoration,
.cp-header-search__input::-webkit-search-results-button {
	-webkit-appearance: none;
	appearance: none;
	display: none;
}

.cp-header-search__input::-ms-clear,
.cp-header-search__input::-ms-reveal {
	display: none;
	width: 0;
	height: 0;
}

.cp-header-search__close {
	display: inline-grid;
	place-items: center;
	flex-shrink: 0;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: var(--cp-btn-radius);
	background: transparent;
	color: var(--cp-text-muted);
	cursor: pointer;
}

.cp-header-search__close:hover {
	color: var(--cp-primary);
	background: rgba(14, 165, 183, 0.08);
}

.cp-header-search__close svg {
	width: 18px;
	height: 18px;
}

.cp-header-search__results {
	margin-top: 0.45rem;
	overflow: hidden;
	border: 1px solid var(--cp-border);
	border-radius: var(--cp-btn-radius);
	background: var(--cp-surface-elevated);
	box-shadow: var(--cp-shadow);
}

.cp-header-search__results[hidden] {
	display: none !important;
}

.cp-search-suggestions {
	position: absolute;
	inset: 100% 0 auto;
	z-index: 245;
	margin-block-start: .5rem;
	direction: rtl;
	text-align: start;
	color: var(--cp-text);
	font-family: var(--cp-font-body-fa);
	line-height: 1.7;
}
.cp-search-suggestions [role="status"]:not(:empty) {
	padding: .75rem 1rem;
	font-size: .875rem;
	font-weight: 500;
	color: var(--cp-text-muted);
}
.cp-search-suggestions .cp-search-suggestion {
	display: flex;
	align-items: center;
	gap: .75rem;
	min-height: 3rem;
	padding: .5rem 1rem;
	color: var(--cp-text);
	font: inherit;
	font-size: .875rem;
	font-weight: 500;
	text-decoration: none;
}
.cp-search-suggestion + .cp-search-suggestion {
	border-block-start: 1px solid var(--cp-border);
}
.cp-search-suggestion bdi { flex: 1; overflow-wrap: anywhere; }
.cp-search-suggestion .cp-icon { flex: none; color: var(--cp-text-muted); }
.cp-search-suggestions .cp-search-suggestion:hover,
.cp-search-suggestions .cp-search-suggestion:focus-visible {
	color: var(--cp-primary);
	background: var(--cp-surface);
}
.cp-search-suggestions .cp-header-search__view-all {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: .5rem;
	width: 100%;
	min-height: 3rem;
	margin: 0;
	padding: .5rem 1rem;
	appearance: none;
	border: 0;
	border-block-start: 1px solid var(--cp-border);
	border-radius: 0;
	background: var(--cp-surface);
	color: var(--cp-primary);
	box-shadow: none;
	font: inherit;
	font-size: .875rem;
	font-weight: 600;
	cursor: pointer;
}
.cp-search-suggestions .cp-header-search__view-all:hover { color: var(--cp-primary-hover); }
.cp-search-suggestions :is(a, button):focus-visible { outline: 2px solid var(--cp-primary); outline-offset: -2px; }
.cp-home-hero:has(.cp-search-suggestions:not([hidden])),
.cp-home-hero__content:has(.cp-search-suggestions:not([hidden])) { overflow: visible; }
.cp-home-hero__content:has(.cp-search-suggestions:not([hidden])) { z-index: 3; }

.cp-header-search__results-inner {
	max-height: min(22rem, 50vh);
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: var(--cp-primary) transparent;
}

.cp-header-search__results-inner::-webkit-scrollbar {
	width: 4px;
}

.cp-header-search__results-inner::-webkit-scrollbar-track {
	background: transparent;
}

.cp-header-search__results-inner::-webkit-scrollbar-thumb {
	border-radius: var(--cp-radius-full);
	background: var(--cp-primary);
}

.cp-header-search__status {
	padding: 1rem;
	color: var(--cp-text-muted);
	font-size: 0.88rem;
	text-align: center;
}

.cp-header-search__result {
	display: grid;
	grid-template-columns: 3.25rem minmax(0, 1fr);
	gap: 0.7rem;
	align-items: center;
	padding: 0.7rem 0.9rem;
	color: inherit;
	text-decoration: none;
	direction: ltr;
	transition: background-color var(--cp-transition);
}

.cp-header-search__result:hover {
	background: rgba(14, 165, 183, 0.08);
}

.cp-header-search__result + .cp-header-search__result {
	border-top: 1px solid var(--cp-border);
}

.cp-header-search__result-thumb {
	overflow: hidden;
	border: 1px solid var(--cp-border);
	border-radius: var(--cp-card-radius);
	background: var(--cp-surface);
	line-height: 0;
}

.cp-header-search__result-thumb img {
	display: block;
	width: 3.25rem;
	height: 3.25rem;
	object-fit: cover;
}

.cp-header-search__result-meta {
	min-width: 0;
	direction: rtl;
	text-align: right;
}

.cp-header-search__result-title {
	display: block;
	margin: 0 0 0.2rem;
	color: var(--cp-primary);
	font-size: 0.82rem;
	font-weight: 700;
	line-height: 1.4;
}

.cp-header-search__result-price {
	display: block;
	margin: 0;
	color: var(--cp-text);
	font-size: 0.8rem;
	font-weight: 700;
	direction: rtl;
}

.cp-header-search__view-all {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0.65rem 1rem;
	border-top: 1px solid var(--cp-border);
	background: color-mix(in srgb, var(--cp-primary) 5%, var(--cp-surface-elevated));
	color: var(--cp-primary);
	font-size: 0.88rem;
	font-weight: 700;
	text-align: center;
	text-decoration: none;
}

.cp-header-search__view-all:hover {
	background: rgba(14, 165, 183, 0.12);
	color: var(--cp-primary-hover);
}

.cp-header-search__view-all[hidden] {
	display: none !important;
}

@keyframes cp-search-sheen {
	to {
		--cp-search-angle: 360deg;
	}
}

@keyframes cp-search-caret {
	0%,
	45% {
		opacity: 1;
	}

	50%,
	100% {
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cp-header-search__frame,
	.cp-header-search__frame::before {
		animation: none;
	}

	.cp-header-search__frame::before {
		background: var(--cp-primary);
	}

	.cp-header-search__sheen {
		animation: none;
	}

	.cp-header-search__hint,
	.cp-header-search__hint::after {
		animation: none;
		transition: none;
	}

	.cp-header-search__hint::after {
		opacity: 0;
	}
}

/* Header open states */
.cp-header.is-cart-open,
.cp-header.is-search-open {
	border-bottom-color: transparent;
}

.cp-header.is-cart-open .cp-mega__panel,
.cp-header.is-search-open .cp-mega__panel {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

/* Desktop: cart opens on hover; search expands on click */
@media (min-width: 768px) {
	.cp-header__actions {
		flex: 0 0 auto;
		justify-content: flex-end;
		min-width: 0;
		--cp-header-icons-width: calc(3 * 44px + 2 * 0.5rem);
	}

	.cp-header__actions:not(:has(.cp-header-cart)) {
		--cp-header-icons-width: calc(2 * 44px + 2 * 0.5rem);
	}

	.cp-header-search.is-open {
		position: absolute;
		top: 50%;
		left: var(--cp-header-icons-width);
		right: auto;
		transform: translateY(-50%);
		width: min(20rem, 34vw);
		max-width: min(20rem, 34vw);
		min-width: 10rem;
		z-index: 246;
	}

	.cp-header-search.is-open .cp-header-search__trigger {
		display: none;
	}

	.cp-header-search.is-open .cp-header-search__panel {
		position: static;
		top: auto;
		inset-inline-end: auto;
		width: 100%;
	}

	.cp-header-search.is-open .cp-header-search__results {
		position: absolute;
		top: calc(100% + 0.45rem);
		left: 0;
		right: auto;
		width: min(24rem, calc(100vw - 1.7rem));
		inset-inline-end: auto;
	}

	.cp-header-cart__dropzone {
		top: calc((var(--cp-header-height) + 100%) / 2);
		margin-top: -1rem;
		padding-top: 1rem;
	}

	.cp-header-cart__panel-inner,
	.cp-header-cart__panel-inner--scrollable {
		display: flex;
		flex-direction: column;
		height: auto;
		max-height: none;
	}

	.cp-header-cart__content--clamp {
		flex: 0 0 auto;
		overflow-y: auto;
		max-height: var(--cp-header-cart-content-max, 12rem);
	}

	.cp-header-cart__footer-wrap {
		flex: 0 0 auto;
	}

	.cp-header-cart:hover .cp-header-cart__panel,
	.cp-header-cart:hover .cp-header-cart__dropzone {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
		pointer-events: auto;
	}

	.cp-header-cart:hover .cp-header-cart__panel {
		pointer-events: auto;
	}
}

/* Mobile: hide header cart (available in bottom navigation) */
@media (max-width: 767px) {
	.cp-header-cart {
		display: none !important;
	}

	.cp-header-cart__panel-inner--scrollable {
		max-height: min(28rem, 60vh);
	}

	.cp-header-cart__panel-inner--scrollable .cp-header-cart__content {
		flex: 1 1 auto;
		min-height: 0;
		overflow-y: auto;
	}

	.cp-header-cart__item {
		grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
		gap: 0.55rem 0.65rem;
		align-items: start;
	}

	.cp-header-cart__meta {
		gap: 0.3rem;
	}

	.cp-header-cart__meta .caseplus-cart-item-details {
		margin-top: 0;
	}

	.cp-header-cart__meta .caseplus-cart-item-tags {
		justify-content: flex-start;
	}

	.cp-header-cart__thumb img {
		width: 100%;
		height: auto;
		aspect-ratio: 1;
	}

	.cp-header-cart__name {
		font-size: 0.92rem;
	}

	.cp-header-cart__price {
		margin-top: 0.75rem;
	}

	.cp-header-cart .cp-header-cart__dropzone {
		position: fixed !important;
		top: calc(var(--cp-chrome-offset, calc(var(--cp-header-height, 76px) + 36px)) - 1rem);
		inset-inline: 0 !important;
		right: 0 !important;
		left: 0 !important;
		width: min(22rem, calc(100vw - 1.7rem)) !important;
		max-width: calc(100vw - 1.7rem);
		margin-inline: auto;
		margin-top: 0;
		padding-top: 1rem;
	}

	.cp-header-search__panel {
		position: static;
	}

	.cp-header-search.is-open {
		position: static;
	}

	.cp-header-search.is-open .cp-header-search__panel {
		position: fixed;
		top: calc(var(--cp-chrome-offset, calc(var(--cp-header-height, 76px) + 36px)) + 0.35rem);
		inset-inline: 0;
		right: 0;
		left: 0;
		width: min(24rem, calc(100vw - 1.7rem));
		max-width: calc(100vw - 1.7rem);
		margin-inline: auto;
	}
}
