/*
 * UpHive Commerce Toolkit — cards, grids, shop layout, filters and category tiles.
 * Loaded only where products are shown. All values come from --uct-* tokens.
 */

/* ---------- Grid ---------- */

:where(.uct-grid) {
	display: grid;
	grid-template-columns: repeat(var(--uct-cols-m, 2), minmax(0, 1fr));
	gap: clamp(1rem, 2.4vw, 2rem) clamp(.75rem, 2vw, 1.5rem);
	margin: 0;
	padding: 0;
	list-style: none;
}
@media (min-width: 700px) { :where(.uct-grid) { grid-template-columns: repeat(var(--uct-cols-t, 3), minmax(0, 1fr)); } }
@media (min-width: 1100px) { :where(.uct-grid) { grid-template-columns: repeat(var(--uct-cols-d, 4), minmax(0, 1fr)); } }
:where(.uct-grid[aria-busy="true"]) { opacity: .5; transition: opacity 150ms; }

/* ---------- Card ---------- */

:where(.uct-card) {
	position: relative;
	display: flex;
	flex-direction: column;
	min-width: 0;
	color: var(--uct-text);
	font-family: var(--uct-font);
}
:where(.uct-card--framed) { padding: .75rem; border: 1px solid var(--uct-border); border-radius: var(--uct-radius); background: var(--uct-surface); }
:where(.uct-card__media) {
	position: relative;
	overflow: hidden;
	aspect-ratio: var(--uct-card-ratio, 4/5);
	border-radius: var(--uct-radius);
	background: var(--uct-subtle);
}
:where(.uct-card__media a) { display: block; height: 100%; }
:where(.uct-card__media img) {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: opacity 400ms var(--uct-ease);
}
:where(.uct-card.is-soldout .uct-card__media img) { opacity: .6; }
:where(.uct-card__badges) { position: absolute; top: .65rem; left: .65rem; display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; padding: 0; list-style: none; }
:where(.uct-badge) {
	padding: .3em .7em;
	border-radius: var(--uct-pill);
	background: var(--uct-surface);
	color: var(--uct-text);
	font: 600 .6875rem/1.1 var(--uct-font);
	letter-spacing: .06em;
	text-transform: uppercase;
}
:where(.uct-badge--sale) { background: var(--uct-accent); color: #fff; }
:where(.uct-badge--soldout) { background: var(--uct-text); color: var(--uct-surface); }
:where(.uct-card__body) { display: flex; flex: 1; flex-direction: column; gap: .3rem; padding-top: .85rem; }
:where(.uct-card__eyebrow) { margin: 0; color: var(--uct-muted); font-size: .6875rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
:where(.uct-card__title) { margin: 0; font: 500 1rem/1.3 var(--uct-heading-font); }
:where(.uct-card__title a) { color: inherit; text-decoration: none; }
:where(.uct-card__title a)::after { content: ""; position: absolute; inset: 0 0 auto; aspect-ratio: var(--uct-card-ratio, 4/5); }
:where(.uct-card__title a:hover) { text-decoration: underline; text-underline-offset: .2em; }
:where(.uct-card__title a:focus-visible) { outline: none; text-decoration: underline; }
:where(.uct-card:has(.uct-card__title a:focus-visible) .uct-card__media) { box-shadow: var(--uct-focus); }
:where(.uct-card__excerpt) { margin: 0; color: var(--uct-muted); font-size: .8125rem; line-height: 1.45; }
:where(.uct-card__price) { margin: 0; font-size: .9375rem; font-variant-numeric: tabular-nums; }
:where(.uct-card__price del) { margin-right: .35em; color: var(--uct-muted); font-size: .9em; }
:where(.uct-card__price ins) { color: var(--uct-accent); text-decoration: none; }
:where(.uct-card__buy) { position: relative; z-index: 1; display: grid; gap: .5rem; margin-top: auto; padding-top: .6rem; }
:where(.uct-card__add) { width: 100%; min-height: 2.5rem; padding-block: .55em; font-size: .875rem; }
:where(.uct-card__added) { display: none; }
:where(.uct-card__add.is-added .uct-card__added) { display: block; }
:where(.uct-card__add.is-added .uct-card__add-label) { display: none; }
:where(.uct-card__hint) { margin: 0; color: var(--uct-danger); font-size: .75rem; }
:where(.uct-card__hint:empty) { display: none; }

:where(.uct-choices) { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; padding: 0; border: 0; min-width: 0; }
:where(.uct-choice) { position: relative; }
:where(.uct-choice input) { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
:where(.uct-choice span) {
	display: inline-block;
	padding: .3em .7em;
	border: 1px solid var(--uct-border);
	border-radius: var(--uct-pill);
	font-size: .75rem;
	line-height: 1.3;
}
:where(.uct-choice input:checked + span) { border-color: var(--uct-primary); background: var(--uct-primary); color: var(--uct-on-primary); }
:where(.uct-choice input:focus-visible + span) { box-shadow: var(--uct-focus); }
:where(.uct-card.needs-choice .uct-choice span) { border-color: var(--uct-danger); }

/* Overlay style: quick add sits over the image on hover-capable screens */
@media (hover: hover) and (min-width: 1100px) {
	:where(.uct-card--overlay .uct-card__buy) {
		position: absolute;
		left: .75rem;
		right: .75rem;
		top: 0;
		transform: translateY(calc(var(--uct-overlay-offset, 0px) - 100%));
		opacity: 0;
		transition: opacity 200ms, transform 200ms var(--uct-ease);
	}
	:where(.uct-card--overlay:hover .uct-card__buy, .uct-card--overlay:focus-within .uct-card__buy) { opacity: 1; }
}

/* ---------- Grid shortcode toolbar ---------- */

:where(.uct-products__bar) { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; margin-bottom: 1.5rem; }
:where(.uct-products__bar nav) { flex: 1 1 100%; }
:where(.uct-products__count) { margin: 0; color: var(--uct-muted); font-size: .875rem; }
:where(.uct-products__empty) { padding: 2rem; text-align: center; color: var(--uct-muted); }
:where(.uct-products__more, .uct-shop__more) { display: flex; justify-content: center; margin-top: 2rem; }
.uct-products__more[hidden] { display: none; }

:where(.uct-sort) { display: flex; align-items: center; gap: .5rem; margin: 0 0 0 auto; font-size: .875rem; }
:where(.uct-sort label) { color: var(--uct-muted); white-space: nowrap; }
:where(.uct-select) {
	min-height: 2.5rem;
	padding: .4em 2.2em .4em .9em;
	border: 1px solid var(--uct-border);
	border-radius: var(--uct-pill);
	background: var(--uct-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right .7em center / 1em;
	color: var(--uct-text);
	font: 500 .875rem/1.2 var(--uct-font);
	appearance: none;
	cursor: pointer;
}

/* ---------- Shop layout ---------- */

:where(.uct-shop) { font-family: var(--uct-font); color: var(--uct-text); }
:where(.uct-shop__bar) {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .75rem 1.25rem;
	padding: .75rem 0;
	margin-bottom: 1.5rem;
	border-bottom: 1px solid var(--uct-border);
}
:where(.uct-shop__count) { margin: 0; color: var(--uct-muted); font-size: .875rem; }
:where(.uct-shop__filter-count) {
	display: inline-grid;
	place-items: center;
	min-width: 1.3rem;
	height: 1.3rem;
	border-radius: var(--uct-pill);
	background: var(--uct-primary);
	color: var(--uct-on-primary);
	font-size: .6875rem;
}
.uct-shop__filter-count[hidden] { display: none; }
:where(.uct-shop__filter-btn:hover .uct-shop__filter-count) { background: var(--uct-on-primary); color: var(--uct-primary); }
:where(.uct-shop__layout) { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2.5rem; }
:where(.uct-shop__results) { min-width: 0; transition: opacity 150ms; }
:where(.uct-shop.is-loading .uct-shop__results) { opacity: .45; }
:where(.uct-active) { margin-bottom: 1.5rem; }
:where(.uct-active .uct-chips) { align-items: center; }
:where(.uct-chip--remove) { background: var(--uct-subtle); border-color: transparent; }
:where(.uct-chip--remove .uct-icon) { width: .9em; height: .9em; }

:where(.uct-empty) { display: grid; justify-items: center; gap: .9rem; padding: 4rem 1rem; border-radius: var(--uct-radius); background: var(--uct-subtle); text-align: center; }
:where(.uct-empty__title) { margin: 0; font: 500 1.25rem/1.3 var(--uct-heading-font); }

:where(.uct-pages) { margin-top: 2.5rem; }
:where(.uct-pages ul) { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; margin: 0; padding: 0; list-style: none; }
:where(.uct-pages a, .uct-pages span) {
	display: grid;
	place-items: center;
	min-width: 2.5rem;
	height: 2.5rem;
	padding: 0 .5rem;
	border-radius: var(--uct-pill);
	color: var(--uct-text);
	text-decoration: none;
	font-variant-numeric: tabular-nums;
}
:where(.uct-pages a:hover) { background: var(--uct-subtle); }
:where(.uct-pages .current) { background: var(--uct-primary); color: var(--uct-on-primary); }

/* Filter panel: sidebar on wide screens (sidebar mode), drawer otherwise */
:where(.uct-filterpanel__head) { display: none; }
:where(.uct-filterpanel__foot) { display: none; }
:where(.uct-filterpanel .uct-layer__scrim) { display: none; }

@media (min-width: 1024px) {
	:where(.uct-shop--sidebar .uct-shop__layout) { grid-template-columns: 15.5rem minmax(0, 1fr); }
	:where(.uct-shop--sidebar .uct-filterpanel) { position: sticky; top: var(--uct-sticky-top, 6rem); align-self: start; max-height: calc(100vh - var(--uct-sticky-top, 6rem) - 1rem); overflow-y: auto; }
	:where(.uct-shop--sidebar .uct-shop__filter-btn) { display: none; }
}

@media (max-width: 1023.98px) {
	.uct-filterpanel { position: fixed; inset: 0; z-index: var(--uct-z); visibility: hidden; transition: visibility 0s linear var(--uct-dur); }
	.uct-filterpanel.is-open { visibility: visible; transition: none; }
	:where(.uct-filterpanel .uct-layer__scrim) { display: block; }
}
.uct-shop--drawer .uct-filterpanel { position: fixed; inset: 0; z-index: var(--uct-z); visibility: hidden; transition: visibility 0s linear var(--uct-dur); }
.uct-shop--drawer .uct-filterpanel.is-open { visibility: visible; transition: none; }
:where(.uct-shop--drawer .uct-filterpanel .uct-layer__scrim) { display: block; }
.uct-filterpanel.is-open > .uct-layer__scrim { opacity: 1; }

@media (max-width: 1023.98px) {
	:where(.uct-filterpanel__inner) {
		position: absolute;
		top: 0;
		bottom: 0;
		left: 0;
		display: flex;
		flex-direction: column;
		width: min(92vw, 24rem);
		background: var(--uct-surface);
		box-shadow: var(--uct-shadow);
		transform: translateX(-100%);
		transition: transform var(--uct-dur) var(--uct-ease);
		outline: none;
	}
	:where(.uct-filterpanel__head) { display: flex; }
	:where(.uct-filterpanel__foot) { display: block; }
	:where(.uct-filterpanel__body) { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 1.25rem 1rem; }
}
:where(.uct-shop--drawer .uct-filterpanel__inner) {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	display: flex;
	flex-direction: column;
	width: min(92vw, 24rem);
	background: var(--uct-surface);
	box-shadow: var(--uct-shadow);
	transform: translateX(-100%);
	transition: transform var(--uct-dur) var(--uct-ease);
	outline: none;
}
:where(.uct-shop--drawer .uct-filterpanel__head) { display: flex; }
:where(.uct-shop--drawer .uct-filterpanel__foot) { display: block; }
:where(.uct-shop--drawer .uct-filterpanel__body) { flex: 1; overflow-y: auto; padding: 0 1.25rem 1rem; }
.uct-filterpanel.is-open .uct-filterpanel__inner { transform: none; }
:where(.uct-filterpanel__head) { align-items: center; justify-content: space-between; padding: .75rem .75rem .75rem 1.25rem; border-bottom: 1px solid var(--uct-border); }
:where(.uct-filterpanel__title) { margin: 0; font: 500 1.25rem/1.2 var(--uct-heading-font); }
:where(.uct-filterpanel__foot) { padding: 1rem 1.25rem; border-top: 1px solid var(--uct-border); }
:where(.uct-filterpanel__foot .uct-button) { width: 100%; }

:where(.uct-facet) { padding: 1.1rem 0; border-bottom: 1px solid var(--uct-border); }
:where(.uct-facet:first-child) { padding-top: .25rem; }
:where(.uct-facet__title) { margin: 0 0 .6rem; font: 600 .75rem/1.2 var(--uct-font); letter-spacing: .12em; text-transform: uppercase; color: var(--uct-muted); }
:where(.uct-facet__list) { display: grid; gap: .1rem; margin: 0; padding: 0; list-style: none; }
:where(.uct-opt) {
	display: flex;
	align-items: center;
	gap: .65rem;
	min-height: 2.25rem;
	padding: .3rem .4rem;
	margin-inline: -.4rem;
	border-radius: var(--uct-radius-sm);
	color: var(--uct-text);
	font-size: .9375rem;
	text-decoration: none;
}
:where(.uct-opt:hover) { background: var(--uct-subtle); }
:where(.uct-opt:focus-visible) { outline: none; box-shadow: var(--uct-focus); }
:where(.uct-opt__label) { flex: 1; }
:where(.uct-opt__count) { color: var(--uct-muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
:where(.uct-opt__box) {
	display: grid;
	place-items: center;
	width: 1.125rem;
	height: 1.125rem;
	border: 1.5px solid var(--uct-border);
	border-radius: calc(var(--uct-radius-sm) * .5);
	flex: none;
}
:where(.uct-opt__tick) { width: .8rem; height: .8rem; opacity: 0; stroke-width: 2.4; }
:where(.uct-opt.is-on .uct-opt__box) { background: var(--uct-primary); border-color: var(--uct-primary); color: var(--uct-on-primary); }
:where(.uct-opt.is-on .uct-opt__tick) { opacity: 1; }
:where(.uct-opt--back) { color: var(--uct-muted); font-size: .875rem; }

:where(.uct-price__fields) { display: flex; align-items: flex-end; gap: .5rem; }
:where(.uct-price label) { display: grid; gap: .25rem; flex: 1; min-width: 0; font-size: .75rem; color: var(--uct-muted); }
:where(.uct-price input) {
	width: 100%;
	min-height: 2.5rem;
	padding: .4em .7em;
	border: 1px solid var(--uct-border);
	border-radius: var(--uct-radius-sm);
	background: var(--uct-surface);
	color: var(--uct-text);
	font: 500 .9375rem/1 var(--uct-font);
}
:where(.uct-price__dash) { padding-bottom: .6rem; color: var(--uct-muted); }
:where(.uct-price__apply) { width: 100%; margin-top: .6rem; min-height: 2.5rem; font-size: .875rem; }

/* ---------- Category tiles ---------- */

:where(.uct-cats--tiles) {
	display: grid;
	grid-template-columns: repeat(var(--uct-cols-m, 2), minmax(0, 1fr));
	gap: clamp(.6rem, 1.6vw, 1.25rem);
	margin: 0;
	padding: 0;
	list-style: none;
}
@media (min-width: 700px) { :where(.uct-cats--tiles) { grid-template-columns: repeat(var(--uct-cols-t, 3), minmax(0, 1fr)); } }
@media (min-width: 1100px) { :where(.uct-cats--tiles) { grid-template-columns: repeat(var(--uct-cols-d, 3), minmax(0, 1fr)); } }
:where(.uct-cat) { min-width: 0; }
:where(.uct-cat__link) {
	position: relative;
	display: grid;
	gap: .65rem;
	color: var(--uct-text);
	text-decoration: none;
}
:where(.uct-cat__media) { display: block; overflow: hidden; aspect-ratio: 1; border-radius: var(--uct-radius); background: var(--uct-subtle); }
:where(.uct-cat__media img) { display: block; width: 100%; height: 100%; object-fit: cover; }
:where(.uct-cat__text) { display: grid; gap: .2rem; }
:where(.uct-cat__title) { margin: 0; font: 500 1.0625rem/1.25 var(--uct-heading-font); }
:where(.uct-cat__desc) { color: var(--uct-muted); font-size: .8125rem; line-height: 1.4; }
:where(.uct-cat__count) { color: var(--uct-muted); font-size: .75rem; }
:where(.uct-cat__arrow) { position: absolute; top: .75rem; right: .75rem; padding: .35rem; width: 2rem; height: 2rem; border-radius: var(--uct-pill); background: var(--uct-surface); }
:where(.uct-cat__link:focus-visible) { outline: none; }
:where(.uct-cat__link:focus-visible .uct-cat__media) { box-shadow: var(--uct-focus); }
:where(.uct-cat__children) { display: flex; flex-wrap: wrap; gap: .25rem .75rem; margin: .4rem 0 0; padding: 0; list-style: none; font-size: .8125rem; }
:where(.uct-cats--list) { margin: 0; padding: 0; list-style: none; }
:where(.uct-cats__row) { display: flex; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--uct-border); color: var(--uct-text); text-decoration: none; }

/* ---------- Recommendations (grid) ---------- */

:where(.uct-recs--grid .uct-recs__title) { margin: 0 0 1.25rem; font: 500 1.5rem/1.2 var(--uct-heading-font); }

/* WooCommerce loop fallback (themes without their own shop layout) */
:where(ul.products:has(.uct-loop-item)) { display: grid !important; grid-template-columns: repeat(var(--uct-cols-m, 2), minmax(0, 1fr)); gap: 1.5rem; }
@media (min-width: 700px) { :where(ul.products:has(.uct-loop-item)) { grid-template-columns: repeat(var(--uct-cols-t, 3), minmax(0, 1fr)); } }
@media (min-width: 1100px) { :where(ul.products:has(.uct-loop-item)) { grid-template-columns: repeat(var(--uct-cols-d, 4), minmax(0, 1fr)); } }
:where(ul.products:has(.uct-loop-item))::before, :where(ul.products:has(.uct-loop-item))::after { display: none; }
:where(.uct-loop-item) { list-style: none; margin: 0 !important; width: auto !important; float: none !important; }

@media (prefers-reduced-motion: reduce) {
	.uct-filterpanel, .uct-filterpanel * { transition: none !important; }
}
.uct-no-motion .uct-filterpanel, .uct-no-motion .uct-filterpanel * { transition: none !important; }
