/**
 * Atom Product Search — palette styles.
 *
 * Self-contained (no Tailwind build coupling): all theme alignment happens
 * through matcha's emitted CSS custom properties, with hard fallbacks so the
 * palette still looks right if the theme changes.
 */

.atps-root {
	position: fixed;
	inset: 0;
	z-index: 9990; /* below atom-side-cart's 9999 so the drawer opens on top */
	display: flex;
	flex-direction: column;
	align-items: center;
}

.atps-root[hidden] {
	display: none;
}

html.atps-scroll-lock {
	overflow: hidden;
	scrollbar-gutter: stable;
}

.atps-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(5, 10, 3, 0.5);
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
	opacity: 0;
	transition: opacity 220ms ease-out;
}

.atps-open .atps-backdrop {
	opacity: 1;
}

.atps-panel {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(640px, calc(100vw - 2rem));
	max-height: min(72vh, 640px);
	margin-top: 10vh;
	background: var(--color-white, #fff9f7);
	color: var(--color-black, #050a03);
	border: 1px solid var(--color-neutral-200, #e8e0cb);
	border-radius: 0.75rem;
	box-shadow: 0 25px 50px -12px rgba(5, 10, 3, 0.25);
	overflow: hidden;
	opacity: 0;
	transform: translateY(8px) scale(0.96);
	transition: opacity 220ms cubic-bezier(0.16, 1, 0.3, 1), transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.atps-open .atps-panel {
	opacity: 1;
	transform: none;
}

.atps-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---------------------------------------------------------------- input */

.atps-inputrow {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.875rem 1rem;
	border-bottom: 1px solid var(--color-neutral-200, #e8e0cb);
	background: var(--color-white, #fff9f7);
}

.atps-input-icon {
	display: flex;
	flex: 0 0 auto;
	width: 1.375rem;
	height: 1.375rem;
	color: var(--color-black, #050a03);
}

.atps-input-icon .atps-icon,
.atps-close .atps-icon {
	width: 100%;
	height: 100%;
}

.atps-input {
	flex: 1 1 auto;
	min-width: 0;
	border: 0;
	background: transparent;
	font-family: var(--font-sans, 'Brandon Grotesque Condensed', sans-serif);
	font-size: 1.125rem; /* never below 16px — iOS zooms focused smaller inputs */
	letter-spacing: 0.025em;
	color: inherit;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.atps-input::placeholder {
	text-transform: uppercase;
	letter-spacing: 0.05em;
	font-size: 0.9375rem;
	color: rgba(5, 10, 3, 0.62);
}

.atps-input::-webkit-search-cancel-button {
	display: none;
}

.atps-close {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	padding: 0.3125rem;
	border: 0;
	border-radius: 0.5rem;
	background: transparent;
	color: var(--color-black, #050a03);
	cursor: pointer;
	transition: background-color 120ms ease-out;
}

.atps-close:hover,
.atps-close:focus-visible {
	background: var(--color-neutral-100, #f2eee2);
}

/* -------------------------------------------------------------- results */

.atps-scroll {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 0.5rem;
}

.atps-group + .atps-group {
	margin-top: 0.75rem;
}

.atps-group-label {
	padding: 0.5rem 0.625rem 0.375rem;
	font-family: var(--font-sans, 'Brandon Grotesque Condensed', sans-serif);
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: rgba(5, 10, 3, 0.62);
}

.atps-option-wrap {
	position: relative;
}

.atps-option {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.5rem 0.625rem;
	border-radius: 0.5rem;
	text-decoration: none;
	color: inherit;
	transition: background-color 80ms ease-out;
}

.atps-option:hover,
.atps-option.is-active {
	background: var(--color-neutral-100, #f2eee2);
}

.atps-option.is-active {
	outline: 2px solid var(--color-brand, #d9f1c9);
	outline-offset: -2px;
}

.atps-thumb {
	flex: 0 0 auto;
	width: 3.5rem;
	height: 3.5rem;
	border-radius: 0.5rem;
	object-fit: cover;
	background: var(--color-neutral-100, #f2eee2);
}

.atps-body {
	display: flex;
	flex: 1 1 auto;
	min-width: 0;
	flex-direction: column;
	gap: 0.125rem;
	/* leave room for the absolutely-positioned add-to-cart button */
	padding-right: 2.75rem;
}

.atps-title {
	font-family: var(--font-sans, 'Brandon Grotesque Condensed', sans-serif);
	font-size: 0.875rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.atps-mark {
	background: var(--color-brand, #d9f1c9);
	color: inherit;
	border-radius: 2px;
	padding: 0 1px;
}

.atps-meta {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
	font-family: var(--font-sans, 'Brandon Grotesque Condensed', sans-serif);
	font-size: 0.875rem;
}

.atps-price {
	font-weight: 700;
	letter-spacing: 0.025em;
}

.atps-badge-sale {
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	padding: 0.0625rem 0.375rem;
	border-radius: 9999px;
	background: var(--color-rouge-100, #fdf2f6);
	color: var(--color-rouge-700, #a41440);
}

.atps-stock {
	font-size: 0.75rem;
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

.atps-stock-in {
	color: #356b1e;
}

.atps-stock-out {
	color: rgba(5, 10, 3, 0.6);
}

.atps-atc {
	position: absolute;
	top: 50%;
	right: 0.625rem;
	transform: translateY(-50%);
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0.5rem;
	border: 0;
	border-radius: 0.75rem;
	background: var(--color-black, #050a03);
	color: var(--color-pure, #ffffff);
	cursor: pointer;
	transition: transform 100ms ease-out, background-color 120ms ease-out;
}

.atps-atc .atps-icon {
	width: 100%;
	height: 100%;
}

.atps-atc:hover,
.atps-atc:focus-visible {
	background: var(--color-matcha-600, #458a26);
}

.atps-atc:active {
	transform: translateY(-50%) scale(0.92);
}

.atps-atc.is-loading {
	opacity: 0.6;
	pointer-events: none;
}

.atps-atc.is-done {
	background: var(--color-matcha-600, #458a26);
}

.atps-option-wrap .added_to_cart {
	display: none;
}

.atps-option-cat {
	justify-content: space-between;
}

.atps-option-cat .atps-title {
	white-space: normal;
}

.atps-count {
	font-family: var(--font-sans, 'Brandon Grotesque Condensed', sans-serif);
	font-size: 0.75rem;
	font-weight: 700;
	color: rgba(5, 10, 3, 0.62);
	background: var(--color-neutral-100, #f2eee2);
	border-radius: 9999px;
	padding: 0.125rem 0.5rem;
}

/* --------------------------------------------------------------- states */

.atps-state {
	padding: 2.25rem 1.25rem;
	text-align: center;
	font-family: var(--font-sans, 'Brandon Grotesque Condensed', sans-serif);
	font-size: 0.9375rem;
	letter-spacing: 0.025em;
	color: rgba(5, 10, 3, 0.65);
}

.atps-state[hidden] {
	display: none;
}

.atps-state-zero .atps-zero-q {
	font-weight: 700;
	color: var(--color-black, #050a03);
}

.atps-zero-all {
	display: inline-block;
	margin-top: 0.875rem;
	padding: 0.625rem 1.25rem;
	border-radius: 0.75rem;
	background: var(--color-black, #050a03);
	color: var(--color-pure, #ffffff);
	font-weight: 700;
	font-size: 0.8125rem;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	text-decoration: none;
	transition: background-color 120ms ease-out;
}

.atps-zero-all:hover {
	background: var(--color-matcha-700, #3a7520);
	color: var(--color-pure, #ffffff);
}

.atps-skeleton {
	height: 4.25rem;
	margin: 0.375rem 0.125rem;
	border-radius: 0.5rem;
	background: linear-gradient(90deg, rgba(5, 10, 3, 0.05) 25%, rgba(5, 10, 3, 0.1) 50%, rgba(5, 10, 3, 0.05) 75%);
	background-size: 200% 100%;
	animation: atps-shimmer 1.2s ease-in-out infinite;
}

@keyframes atps-shimmer {
	from { background-position: 200% 0; }
	to { background-position: -200% 0; }
}

/* --------------------------------------------------------------- footer */

.atps-footer {
	display: flex;
	gap: 1.25rem;
	padding: 0.625rem 1rem;
	border-top: 1px solid var(--color-neutral-200, #e8e0cb);
	font-family: var(--font-sans, 'Brandon Grotesque Condensed', sans-serif);
	font-size: 0.75rem;
	letter-spacing: 0.05em;
	color: rgba(5, 10, 3, 0.62);
}

.atps-hint {
	display: flex;
	align-items: center;
	gap: 0.375rem;
}

.atps-footer kbd {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.25rem;
	height: 1.25rem;
	padding: 0 0.25rem;
	border: 1px solid var(--color-neutral-200, #e8e0cb);
	border-radius: 0.25rem;
	background: var(--color-pure, #ffffff);
	font-family: inherit;
	font-size: 0.6875rem;
}

/* --------------------------------------------------------------- mobile */

@media (max-width: 767px) {
	.atps-panel {
		width: 100%;
		max-height: none;
		height: 100%;
		margin-top: 0;
		border: 0;
		border-radius: 0;
	}

	.atps-inputrow {
		position: sticky;
		top: 0;
		z-index: 1;
	}

	.atps-footer {
		display: none;
	}

	.atps-group {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 0.5rem;
	}

	.atps-group-label {
		grid-column: 1 / -1;
	}

	/* Category rows stay full-width lists */
	.atps-group:has(.atps-option-cat) {
		display: block;
	}

	.atps-option-wrap {
		display: flex;
		flex-direction: column;
	}

	.atps-option-product {
		flex-direction: column;
		align-items: stretch;
		gap: 0.5rem;
		height: 100%;
	}

	.atps-option-product .atps-thumb {
		width: 100%;
		height: auto;
		aspect-ratio: 1 / 1;
	}

	.atps-option-product .atps-body {
		padding-right: 0;
	}

	.atps-option-product .atps-title {
		white-space: normal;
	}

	.atps-atc {
		position: static;
		transform: none;
		width: auto;
		margin: 0 0.625rem 0.625rem;
		height: 2.5rem;
	}

	.atps-atc:active {
		transform: scale(0.97);
	}

	.atps-atc .atps-icon {
		width: 1.25rem;
		height: 1.25rem;
	}
}

/* ------------------------------------------------------ reduced motion */

@media (prefers-reduced-motion: reduce) {
	.atps-backdrop,
	.atps-panel,
	.atps-option,
	.atps-atc,
	.atps-close,
	.atps-zero-all {
		transition: none;
	}

	.atps-panel {
		transform: none;
	}

	.atps-skeleton {
		animation: none;
	}
}
