/*
 * UpHive Commerce Toolkit — core components: buttons, mini-cart, side cart, search, layers.
 * Every colour, radius and font comes from a --uct-* token. Neutral fallbacks keep the
 * components usable on an unconfigured store; themes set the tokens to restyle everything.
 */

:where(:root) {
	--uct-primary: #1f1f1f;
	--uct-on-primary: #ffffff;
	--uct-accent: #b4502f;
	--uct-text: #1f1f1f;
	--uct-muted: #5f5f5f;
	--uct-surface: #ffffff;
	--uct-subtle: #f4f2ef;
	--uct-border: #dedad4;
	--uct-danger: #a12a1a;
	--uct-success: #2f6b3a;
	--uct-radius: 10px;
	--uct-radius-sm: calc(var(--uct-radius) * 0.6);
	--uct-pill: 999px;
	--uct-font: inherit;
	--uct-heading-font: var(--uct-font);
	--uct-shadow: 0 24px 60px -24px rgb(0 0 0 / 0.35);
	--uct-focus: 0 0 0 2px var(--uct-surface), 0 0 0 4px var(--uct-primary);
	--uct-ease: cubic-bezier(.2, .8, .2, 1);
	--uct-dur: 280ms;
	--uct-drawer-width: 26rem;
	--uct-z: 9990;
}

.uct-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.uct-icon { width: 1.25em; height: 1.25em; flex: none; }
.uct-muted { color: var(--uct-muted); }
.uct-locked, .uct-locked body { overflow: hidden; }

/* ---------- Buttons ---------- */

:where(.uct-button) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .5em;
	min-height: 2.875rem;
	padding: .75em 1.4em;
	border: 1px solid var(--uct-primary);
	border-radius: var(--uct-radius);
	font: 600 .9375rem/1.2 var(--uct-font);
	letter-spacing: .01em;
	text-decoration: none;
	cursor: pointer;
	transition: background-color var(--uct-dur) var(--uct-ease), color var(--uct-dur) var(--uct-ease), border-color var(--uct-dur) var(--uct-ease), transform 120ms ease;
}
:where(.uct-button--solid) { background: var(--uct-primary); color: var(--uct-on-primary); }
:where(.uct-button--solid:hover) { background: color-mix(in srgb, var(--uct-primary) 86%, var(--uct-surface)); color: var(--uct-on-primary); }
:where(.uct-button--outline) { background: transparent; color: var(--uct-primary); }
:where(.uct-button--outline:hover) { background: var(--uct-primary); color: var(--uct-on-primary); }
:where(.uct-button:active) { transform: translateY(1px); }
:where(.uct-button.is-loading) { opacity: .65; pointer-events: none; }
:where(.uct-button .uct-icon) { width: 1.1em; height: 1.1em; }

:where(.uct-icon-button) {
	display: inline-grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 0;
	border-radius: var(--uct-pill);
	background: transparent;
	color: inherit;
	cursor: pointer;
}
:where(.uct-icon-button:hover) { background: var(--uct-subtle); }

:where(.uct-link-button) {
	padding: .25em 0;
	border: 0;
	background: none;
	color: var(--uct-muted);
	font: inherit;
	font-size: .8125rem;
	text-decoration: underline;
	text-underline-offset: .2em;
	cursor: pointer;
}
:where(.uct-link-button:hover) { color: var(--uct-text); }

:where(.uct-button, .uct-icon-button, .uct-link-button, .uct-mini-cart, .uct-search-trigger, .uct-chip, .uct-qty__btn, .uct-qty__input, .uct-search__input, .uct-select):focus-visible {
	outline: none;
	box-shadow: var(--uct-focus);
}

:where(.uct-chips) { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; }
:where(.uct-chip) {
	display: inline-flex;
	align-items: center;
	gap: .4em;
	min-height: 2.25rem;
	padding: .35em .95em;
	border: 1px solid var(--uct-border);
	border-radius: var(--uct-pill);
	background: var(--uct-surface);
	color: var(--uct-text);
	font: 500 .875rem/1.2 var(--uct-font);
	text-decoration: none;
}
:where(.uct-chip:hover) { border-color: var(--uct-text); }
:where(.uct-chip[aria-current="true"]) { background: var(--uct-primary); border-color: var(--uct-primary); color: var(--uct-on-primary); }
:where(.uct-chip__count) { color: var(--uct-muted); font-size: .8em; }

/* ---------- Mini-cart trigger ---------- */

:where(.uct-mini-cart) {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: .5rem;
	min-height: 2.75rem;
	padding: 0 .5rem;
	border-radius: var(--uct-pill);
	color: inherit;
	font: 500 .9375rem/1 var(--uct-font);
	text-decoration: none;
}
:where(.uct-mini-cart__icon) { position: relative; display: inline-grid; }
:where(.uct-mini-cart__count) {
	position: absolute;
	top: -.45rem;
	right: -.6rem;
	display: grid;
	place-items: center;
	min-width: 1.15rem;
	height: 1.15rem;
	padding: 0 .3rem;
	border-radius: var(--uct-pill);
	background: var(--uct-accent);
	color: #fff;
	font: 700 .6875rem/1 var(--uct-font);
	font-variant-numeric: tabular-nums;
	transition: transform 200ms var(--uct-ease);
}
:where(.uct-mini-cart__count[data-count="0"]) { transform: scale(0); }

/* ---------- Layers ---------- */

.uct-layer { position: fixed; inset: 0; z-index: var(--uct-z); }
.uct-layer[hidden] { display: none; }
:where(.uct-layer__scrim) {
	position: absolute;
	inset: 0;
	background: rgb(10 10 10 / .42);
	opacity: 0;
	transition: opacity var(--uct-dur) var(--uct-ease);
}
.uct-layer.is-open > .uct-layer__scrim { opacity: 1; }

/* ---------- Side cart ---------- */

:where(.uct-drawer__panel) {
	position: absolute;
	top: 0;
	bottom: 0;
	right: 0;
	display: flex;
	flex-direction: column;
	width: min(100%, var(--uct-drawer-width));
	background: var(--uct-surface);
	color: var(--uct-text);
	font-family: var(--uct-font);
	box-shadow: var(--uct-shadow);
	transform: translateX(100%);
	transition: transform var(--uct-dur) var(--uct-ease);
	outline: none;
}
:where(.uct-drawer--left .uct-drawer__panel) { right: auto; left: 0; transform: translateX(-100%); }
.uct-drawer.is-open .uct-drawer__panel { transform: none; }
:where(.uct-drawer__header) {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 1rem 1rem 1.5rem;
	border-bottom: 1px solid var(--uct-border);
}
:where(.uct-drawer__title) { margin: 0; font: 500 1.375rem/1.2 var(--uct-heading-font); }
:where(.uct-drawer__count) { color: var(--uct-muted); font-size: .7em; font-family: var(--uct-font); }
:where(.uct-drawer__notice) {
	margin: .75rem 1.5rem 0;
	padding: .7rem .9rem;
	border-radius: var(--uct-radius-sm);
	background: color-mix(in srgb, var(--uct-danger) 10%, var(--uct-surface));
	color: var(--uct-danger);
	font-size: .875rem;
}
.uct-drawer__notice[hidden] { display: none; }
:where(.uct-drawer__content) { display: flex; flex: 1; flex-direction: column; min-height: 0; }
:where(.uct-drawer__scroll) { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 1.5rem 1.5rem; }
:where(.uct-drawer__loading) { display: grid; gap: .75rem; padding: 1.5rem; }
:where(.uct-skeleton) { height: 4.5rem; border-radius: var(--uct-radius-sm); background: linear-gradient(90deg, var(--uct-subtle), var(--uct-border), var(--uct-subtle)); background-size: 200% 100%; animation: uct-shimmer 1.2s linear infinite; }
:where(.uct-skeleton--short) { width: 60%; height: 1.25rem; }
@keyframes uct-shimmer { to { background-position: -200% 0; } }

:where(.uct-drawer__footer) { padding: 1.25rem 1.5rem 1.5rem; border-top: 1px solid var(--uct-border); background: var(--uct-surface); }
:where(.uct-drawer__subtotal) { display: flex; justify-content: space-between; align-items: baseline; font-size: 1rem; }
:where(.uct-drawer__subtotal strong) { font-size: 1.125rem; font-variant-numeric: tabular-nums; }
:where(.uct-drawer__note) { margin: .35rem 0 1rem; color: var(--uct-muted); font-size: .8125rem; }
:where(.uct-drawer__actions) { display: grid; grid-template-columns: 1fr 1.4fr; gap: .6rem; }

:where(.uct-progress) { margin: 1.25rem 0 .25rem; }
:where(.uct-progress__text) { margin: 0 0 .5rem; font-size: .8125rem; }
:where(.uct-progress__bar) { height: 4px; border-radius: var(--uct-pill); background: var(--uct-subtle); overflow: hidden; }
:where(.uct-progress__bar span) { display: block; height: 100%; border-radius: inherit; background: var(--uct-primary); transition: width 400ms var(--uct-ease); }

:where(.uct-lines) { margin: 0; padding: 0; list-style: none; }
:where(.uct-line) {
	display: grid;
	grid-template-columns: 5rem minmax(0, 1fr) auto;
	gap: .9rem;
	padding: 1.25rem 0;
	border-bottom: 1px solid var(--uct-border);
	transition: opacity 200ms;
}
:where(.uct-line.is-updating) { opacity: .5; pointer-events: none; }
:where(.uct-line__media img) { display: block; width: 5rem; height: 6.25rem; object-fit: cover; border-radius: var(--uct-radius-sm); background: var(--uct-subtle); }
:where(.uct-line__name) { margin: 0; font: 500 .9375rem/1.3 var(--uct-heading-font); }
:where(.uct-line__name a) { color: inherit; text-decoration: none; }
:where(.uct-line__name a:hover) { text-decoration: underline; }
:where(.uct-line__meta, .uct-line__unit) { margin: .2rem 0 0; color: var(--uct-muted); font-size: .8125rem; }
:where(.uct-line__meta dl, .uct-line__meta dd, .uct-line__meta dt, .uct-line__meta p) { display: inline; margin: 0; }
:where(.uct-line__actions) { display: flex; align-items: center; gap: 1rem; margin-top: .7rem; }
:where(.uct-line__subtotal) { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

:where(.uct-qty) {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--uct-border);
	border-radius: var(--uct-pill);
}
:where(.uct-qty__btn) {
	display: grid;
	place-items: center;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	border: 0;
	border-radius: var(--uct-pill);
	background: none;
	color: inherit;
	cursor: pointer;
}
:where(.uct-qty__btn .uct-icon) { width: 1rem; height: 1rem; }
:where(.uct-qty__btn:disabled) { opacity: .35; cursor: not-allowed; }
:where(.uct-qty__input) {
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: 600 .875rem/1 var(--uct-font);
	text-align: center;
	-moz-appearance: textfield;
	appearance: textfield;
}
:where(.uct-qty__input)::-webkit-inner-spin-button, :where(.uct-qty__input)::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

:where(.uct-cart-empty) { display: grid; justify-items: center; gap: 1rem; padding: 3.5rem 1rem 2rem; text-align: center; }
:where(.uct-cart-empty__icon) { display: grid; place-items: center; width: 4rem; height: 4rem; border-radius: var(--uct-pill); background: var(--uct-subtle); }
:where(.uct-cart-empty__icon .uct-icon) { width: 1.75rem; height: 1.75rem; }
:where(.uct-cart-empty__text) { margin: 0; font: 500 1.125rem/1.3 var(--uct-heading-font); }

/* Compact recommendation rows */
:where(.uct-recs--compact) { margin-top: 1.75rem; }
:where(.uct-recs--compact .uct-recs__title) { margin: 0 0 .5rem; font: 600 .75rem/1.2 var(--uct-font); letter-spacing: .12em; text-transform: uppercase; color: var(--uct-muted); }
:where(.uct-recs__list) { display: grid; gap: .5rem; }
:where(.uct-mini) {
	display: grid;
	grid-template-columns: 3.5rem minmax(0, 1fr) auto;
	align-items: center;
	gap: .8rem;
	padding: .5rem;
	border-radius: var(--uct-radius-sm);
	background: var(--uct-subtle);
}
:where(.uct-mini__media img) { display: block; width: 3.5rem; height: 3.5rem; object-fit: cover; border-radius: calc(var(--uct-radius-sm) * .8); }
:where(.uct-mini__name) { margin: 0; font-size: .875rem; line-height: 1.3; }
:where(.uct-mini__name a) { color: inherit; text-decoration: none; }
:where(.uct-mini__price) { margin: .15rem 0 0; color: var(--uct-muted); font-size: .8125rem; }
:where(.uct-mini__add) { background: var(--uct-surface); }
:where(.uct-mini__add.is-added) { background: var(--uct-primary); color: var(--uct-on-primary); }

/* ---------- Search ---------- */

:where(.uct-search) { position: relative; width: 100%; font-family: var(--uct-font); }
:where(.uct-search__field) {
	display: flex;
	align-items: center;
	gap: .5rem;
	min-height: 2.875rem;
	padding: 0 .35rem 0 1rem;
	border: 1px solid var(--uct-border);
	border-radius: var(--uct-pill);
	background: var(--uct-surface);
	color: var(--uct-text);
	transition: border-color var(--uct-dur);
}
:where(.uct-search__field:focus-within) { border-color: var(--uct-text); }
:where(.uct-search__icon) { color: var(--uct-muted); }
:where(.uct-search__input) {
	flex: 1;
	min-width: 0;
	height: 2.75rem;
	padding: 0;
	border: 0 !important;
	background: transparent !important;
	color: inherit;
	font: 400 1rem/1 var(--uct-font);
	box-shadow: none !important;
	outline: none;
}
:where(.uct-search__input)::-webkit-search-cancel-button { -webkit-appearance: none; }
:where(.uct-search__submit) {
	display: grid;
	place-items: center;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	border: 0;
	border-radius: var(--uct-pill);
	background: var(--uct-primary);
	color: var(--uct-on-primary);
	cursor: pointer;
}
:where(.uct-search__submit .uct-icon) { width: 1rem; height: 1rem; }
:where(.uct-search__spinner) { display: none; width: 1rem; height: 1rem; border: 2px solid var(--uct-border); border-top-color: var(--uct-text); border-radius: 50%; animation: uct-spin .7s linear infinite; }
:where(.uct-search.is-loading .uct-search__spinner) { display: block; }
@keyframes uct-spin { to { transform: rotate(360deg); } }

:where(.uct-search__panel) {
	position: absolute;
	top: calc(100% + .5rem);
	left: 0;
	right: 0;
	z-index: 50;
	max-height: min(70vh, 32rem);
	overflow-y: auto;
	padding: .5rem;
	border: 1px solid var(--uct-border);
	border-radius: var(--uct-radius);
	background: var(--uct-surface);
	color: var(--uct-text);
	box-shadow: var(--uct-shadow);
}
.uct-search__panel[hidden] { display: none; }
:where(.uct-search__status) { margin: 0; padding: .4rem .6rem; color: var(--uct-muted); font-size: .8125rem; }
:where(.uct-search:not(.is-empty) .uct-search__status) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:where(.uct-search__list) { margin: 0; padding: 0; list-style: none; }
:where(.uct-search__option a) {
	display: grid;
	grid-template-columns: 3.5rem minmax(0, 1fr) auto;
	align-items: center;
	gap: .8rem;
	padding: .5rem .6rem;
	border-radius: var(--uct-radius-sm);
	color: inherit;
	text-decoration: none;
}
:where(.uct-search__option[aria-selected="true"] a, .uct-search__option a:hover) { background: var(--uct-subtle); }
:where(.uct-search__option img) { width: 3.5rem; height: 3.5rem; object-fit: cover; border-radius: calc(var(--uct-radius-sm) * .8); background: var(--uct-subtle); }
:where(.uct-search__text) { display: grid; gap: .15rem; min-width: 0; }
:where(.uct-search__name) { font-weight: 500; line-height: 1.3; }
:where(.uct-search__meta) { overflow: hidden; color: var(--uct-muted); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
:where(.uct-search__price) { font-size: .875rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
:where(.uct-search__price del) { color: var(--uct-muted); font-size: .85em; }
:where(.uct-search__price ins) { text-decoration: none; }
:where(.uct-search__option a.uct-search__all) { display: block; padding: .75rem .6rem; font-weight: 600; text-align: center; }

:where(.uct-search-trigger) {
	display: inline-grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	border-radius: var(--uct-pill);
	color: inherit;
}

:where(.uct-search-overlay__panel) {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	padding: clamp(1rem, 4vw, 3rem) clamp(1rem, 5vw, 4rem) 2rem;
	background: var(--uct-surface);
	color: var(--uct-text);
	box-shadow: var(--uct-shadow);
	transform: translateY(-100%);
	transition: transform var(--uct-dur) var(--uct-ease);
}
.uct-search-overlay.is-open .uct-search-overlay__panel { transform: none; }
:where(.uct-search-overlay__inner) { display: flex; align-items: flex-start; gap: .75rem; max-width: 56rem; margin: 0 auto; }
:where(.uct-search-overlay .uct-search__field) { min-height: 3.5rem; }
:where(.uct-search-overlay .uct-search__input) { font-size: 1.125rem; }
:where(.uct-search-overlay .uct-search__panel) { position: static; margin-top: .75rem; box-shadow: none; }
:where(.uct-search-overlay__popular) { max-width: 56rem; margin: 1.25rem auto 0; }
:where(.uct-search-overlay__label) { margin: 0 0 .6rem; color: var(--uct-muted); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; }

@media (max-width: 600px) {
	:where(.uct-drawer__panel) { width: 100%; }
	:where(.uct-drawer__scroll) { padding: 0 1rem 1rem; }
	:where(.uct-drawer__footer) { padding: 1rem; }
	:where(.uct-drawer__header) { padding-left: 1rem; }
	:where(.uct-line) { grid-template-columns: 4.25rem minmax(0, 1fr); }
	:where(.uct-line__media img) { width: 4.25rem; height: 5.25rem; }
	:where(.uct-line__subtotal) { grid-column: 2; }
	:where(.uct-search__option a) { grid-template-columns: 3rem minmax(0, 1fr); }
	:where(.uct-search__option img) { width: 3rem; height: 3rem; }
	:where(.uct-search__price) { grid-column: 2; }
}

/* Motion off: by preference or by setting. */
@media (prefers-reduced-motion: reduce) {
	.uct-layer *, .uct-layer { transition: none !important; animation: none !important; }
}
.uct-no-motion .uct-layer, .uct-no-motion .uct-layer * { transition: none !important; }
