/**
 * ZAI COFFEE — Shop archive
 * -----------------------------------------------------------------------------
 * Shop page, product category/tag archives and product search results. Loaded
 * only on those views (see zai_is_shop_archive() in inc/assets.php).
 *
 * The product card itself lives in 09-home.css, because the archive reuses the
 * homepage card component. Only archive chrome and card actions are here.
 *
 * All values resolve through tokens from 01-tokens.css.
 *
 * @package zaicoffeetheme
 * @since   1.2.0
 */

/* ==========================================================================
   1. Shop shell
   ========================================================================== */

.zai-shop {
	padding-block: var(--zai-space-7) var(--zai-space-9);
}

/*
 * PHASE 8.2 — use the available horizontal space.
 *
 * The shop previously inherited the standard 1320px container, which left the
 * catalogue reading narrow next to the full-bleed header. A product archive is
 * a browsing surface and earns a wider measure, so the shop container alone is
 * allowed to grow to 1440px. Every other view keeps --zai-container (1320px);
 * this override is scoped to .zai-shop and changes nothing else.
 *
 * The toolbar (result count + ordering) is a child of the SAME container, so it
 * stays flush with the product grid by construction — no separate alignment
 * rule is needed or wanted.
 */
.zai-shop > .zai-container {
	max-width: min(1440px, 100%);
}

/* ==========================================================================
   2. Header block
   ========================================================================== */

.zai-shop__header {
	margin-block-end: var(--zai-space-6);
	padding-block-end: var(--zai-space-5);
	border-block-end: var(--zai-border-width) solid var(--zai-border-color);
}

.zai-shop__title {
	margin: 0;
	font-family: var(--zai-font-display);
	font-size: var(--zai-fs-h1);
	font-weight: var(--zai-fw-light);
	line-height: var(--zai-lh-tight);
	letter-spacing: var(--zai-ls-tighter);
	color: var(--zai-ink);
	text-wrap: balance;
}

.zai-shop__intro {
	max-width: 58ch;
	margin: var(--zai-space-4) 0 0;
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-md);
	line-height: var(--zai-lh-relaxed);
	color: var(--zai-text-muted);
}

/* Category description inherits the same measure. */
.zai-shop__intro p {
	margin-block: 0 var(--zai-space-3);
}

.zai-shop__intro p:last-child {
	margin-block-end: 0;
}

/* ==========================================================================
   3. Toolbar (result count + ordering)
   ========================================================================== */

.zai-shop__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--zai-space-3) var(--zai-space-5);
	margin-block-end: var(--zai-space-6);
	padding-block-end: var(--zai-space-4);
	border-block-end: var(--zai-border-width) solid var(--zai-border-color);
}

.zai-shop__count,
.woocommerce-result-count {
	margin: 0;
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-xs);
	letter-spacing: var(--zai-ls-wide);
	text-transform: uppercase;
	color: var(--zai-text-subtle);
	font-variant-numeric: tabular-nums;
}

/* --- Ordering select ------------------------------------------------------ */

.woocommerce-ordering {
	margin: 0;
}

.woocommerce-ordering select {
	min-height: var(--zai-touch-target);
	padding: var(--zai-space-2) var(--zai-space-6) var(--zai-space-2) var(--zai-space-3);
	background-color: var(--zai-bg);
	border: var(--zai-border-width) solid var(--zai-border-color-strong);
	border-radius: var(--zai-radius);
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-sm);
	color: var(--zai-text);
	cursor: pointer;
	/* The native arrow is kept: a custom one would need an inline SVG data URI. */
	appearance: auto;
}

.woocommerce-ordering select:focus-visible {
	outline: var(--zai-focus-width) solid var(--zai-focus-color);
	outline-offset: var(--zai-focus-offset);
}

/* ==========================================================================
   4. Notices
   ========================================================================== */

.woocommerce-notices-wrapper:empty {
	display: none;
}

.woocommerce-message,
.woocommerce-info,
.woocommerce-error {
	margin-block-end: var(--zai-space-5);
	padding: var(--zai-space-4) var(--zai-space-5);
	border: var(--zai-border-width) solid var(--zai-border-color);
	border-inline-start-width: 3px;
	border-radius: var(--zai-radius);
	background-color: var(--zai-bg-soft);
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-sm);
	line-height: var(--zai-lh-normal);
	color: var(--zai-text);
	list-style: none;
}

.woocommerce-message {
	border-inline-start-color: var(--zai-success);
	background-color: var(--zai-success-bg);
}

.woocommerce-info {
	border-inline-start-color: var(--zai-notice);
	background-color: var(--zai-notice-bg);
}

.woocommerce-error {
	border-inline-start-color: var(--zai-error);
	background-color: var(--zai-error-bg);
}

.woocommerce-message .button,
.woocommerce-info .button,
.woocommerce-error .button {
	margin-inline-start: var(--zai-space-3);
}

/* ==========================================================================
   5. Product grid — FIXED TRACKS, INDEPENDENT OF PRODUCT COUNT
   -----------------------------------------------------------------------------
   Phase 8.1 requirement: a card's dimensions must be determined by VIEWPORT
   WIDTH ONLY, never by how many products the catalogue happens to contain.

   The previous implementation shipped `data-zai-product-count` rules that
   widened a single product to fill a narrower grid. The owner rejected that:
   one product then looked like an oversized featured banner instead of one item
   in a catalogue, so 1 / 2 / 6 / 12 products produced four different card sizes
   at the same viewport.

   REMOVED: every `[data-zai-product-count]` selector, the `:has()`-style
   reasoning behind it, and the intermediate 22rem/24rem single-product tracks.

   NOW: the track count changes only at breakpoints, so a card measures the same
   at 1280px whether the catalogue holds one product or twelve. Only the number
   of OCCUPIED cells changes. `justify-content: start` keeps remaining cells
   empty on the inline-end side rather than stretching the filled ones.
   ========================================================================== */

ul.products.zai-product-grid {
	display: grid;
	gap: var(--zai-grid-gap);
	/* Mobile-first: one track, then narrow two-up, then the fixed steps. */
	grid-template-columns: minmax(0, 1fr);
	justify-content: start;
	align-items: start;
	/* The grid owns placement; WooCommerce's float model is fully released. */
	float: none;
	clear: none;
	width: 100%;
	margin: 0;
	padding: 0;
	list-style: none;
}

/*
 * PHASE 8.2 — remove WooCommerce's clearfix pseudo-items.
 *
 * woocommerce.css ships:
 *   .woocommerce ul.products::before,
 *   .woocommerce ul.products::after { content:" "; display:table }
 *   .woocommerce ul.products::after { clear:both }
 *
 * Those two generated boxes are REAL grid items once `display:grid` is applied
 * to the container. ::before occupies the first cell and pushes every product
 * one track to the right — the owner's "conspicuous empty column or large blank
 * area on the left" and the row-1-indented / row-2-flush misalignment visible in
 * the Phase 8.2 screenshots. They exist only to clear floats, which a grid does
 * not need, so they are disabled here rather than overridden with placement.
 */
ul.products.zai-product-grid::before,
ul.products.zai-product-grid::after,
.woocommerce ul.products.zai-product-grid::before,
.woocommerce ul.products.zai-product-grid::after {
	content: none;
	display: none;
}

/*
 * Two columns from 480px. This is the narrowest width at which a card keeps a
 * readable title and a full-width button, and it applies equally to 1 product
 * and to 12.
 */
@media (min-width: 480px) {
	ul.products.zai-product-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* Tablet / small desktop: three fixed tracks. */
@media (min-width: 1024px) {
	ul.products.zai-product-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* Large desktop: four fixed tracks. */
@media (min-width: 1280px) {
	ul.products.zai-product-grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/*
 * WooCommerce floats loop items and sizes them by percentage in
 * woocommerce-layout.css with the selector
 *   .woocommerce ul.products li.product   (specificity 0,3,2)
 * so a plain `ul.products.zai-product-grid > li` (0,2,1) loses and the card
 * collapses to a floated, shrink-to-fit box inside the grid cell.
 *
 * The `.woocommerce` prefix raises specificity to 0,4,2 so the grid owns
 * placement. `width: auto` also releases WooCommerce's percentage widths.
 */
ul.products.zai-product-grid > li,
ul.products.zai-product-grid > li.product,
.woocommerce ul.products.zai-product-grid > li.product {
	float: none;
	width: auto;
	max-width: none;
	min-width: 0;
	margin: 0;
}


/* ==========================================================================
   5b. Product card component — archive copy
   -----------------------------------------------------------------------------
   PHASE 8.2 — the card component used to be styled ONLY in 09-home.css, which
   inc/assets.php enqueues exclusively on is_front_page(). The shop archive
   therefore rendered `.zai-product-card` markup with NO card styles at all:
   no 4:5 image stage, unstyled title/category/price. Confirmed by fetching
   /magaza/ and finding 09-home.css absent from the <head>.

   These rules are a deliberate DUPLICATE of the homepage definitions so that
   09-home.css can remain byte-identical for this corrective release (zero
   homepage regression risk). Selectors are scoped under the archive grid so
   they can never leak onto the homepage even if both sheets ever load:

     ul.zai-product-grid .zai-product-card…

   Only the card's own box model, media stage and type are reproduced. Hover
   motion is intentionally NOT duplicated — the archive is a list view and the
   reduced-motion contract from 09-home.css stays the single source for it.
   ========================================================================== */

ul.zai-product-grid .zai-product-card {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

ul.zai-product-grid .zai-product-card__media {
	position: relative;
	display: block;
	overflow: hidden;
	/* 4:5 brand product ratio — identical to the homepage card. */
	aspect-ratio: 4 / 5;
	background-color: var(--zai-surface);
	border-radius: var(--zai-radius);
	text-decoration: none;
}

ul.zai-product-grid .zai-product-card__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--zai-dur-slow) var(--zai-ease);
}

/* Neutral surface when a product genuinely has no image. */
ul.zai-product-grid .zai-product-card__noimage {
	display: block;
	width: 100%;
	height: 100%;
	background-color: var(--zai-surface-deep);
}

ul.zai-product-grid .zai-product-card__flag {
	position: absolute;
	inset-block-start: var(--zai-space-3);
	inset-inline-start: var(--zai-space-3);
}

ul.zai-product-grid .zai-product-card__body {
	padding-block-start: var(--zai-space-4);
}

ul.zai-product-grid .zai-product-card__category {
	margin: 0 0 var(--zai-space-1);
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-eyebrow);
	font-weight: var(--zai-fw-medium);
	letter-spacing: var(--zai-ls-caps);
	text-transform: uppercase;
	color: var(--zai-text-subtle);
}

ul.zai-product-grid .zai-product-card__title {
	margin: 0 0 var(--zai-space-2);
	font-family: var(--zai-font-display);
	font-size: var(--zai-fs-h5);
	font-weight: var(--zai-fw-regular);
	line-height: var(--zai-lh-snug);
	letter-spacing: var(--zai-ls-tight);
}

ul.zai-product-grid .zai-product-card__link {
	color: var(--zai-ink);
	text-decoration: none;
}

ul.zai-product-grid .zai-product-card__link:hover {
	color: var(--zai-green);
}

ul.zai-product-grid .zai-product-card__link:focus-visible {
	outline: var(--zai-focus-width) solid var(--zai-focus-color);
	outline-offset: var(--zai-focus-offset);
}

ul.zai-product-grid .zai-product-card__price {
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-sm);
	font-weight: var(--zai-fw-medium);
	font-variant-numeric: tabular-nums;
	color: var(--zai-text);
}

ul.zai-product-grid .zai-product-card__price del {
	color: var(--zai-text-subtle);
	text-decoration-thickness: 1px;
}

ul.zai-product-grid .zai-product-card__price ins {
	color: var(--zai-green);
	text-decoration: none;
	font-weight: var(--zai-fw-semibold);
}

/*
 * Every card in a row must be the same height so the buttons line up, even when
 * one title wraps to two lines. The body absorbs the slack and the actions are
 * pushed to the bottom.
 */
ul.zai-product-grid .zai-product-card {
	height: 100%;
}

ul.zai-product-grid .zai-product-card__body {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
}

ul.zai-product-grid .zai-product-card__actions {
	margin-block-start: auto;
	padding-block-start: var(--zai-space-3);
}

/* ==========================================================================
   6. Card purchase action
   -----------------------------------------------------------------------------
   The card action must read as a real button: full card width, comfortable
   height and a label that can never break into a narrow vertical stack.

   Phase 8: the button is given the full control height and the larger `sm` font
   step, and `white-space` is explicitly allowed to wrap. Font-size was `xs` and
   the padding was tighter, which is what produced the cramped, near-vertical
   labels in the owner's screenshot.
   ========================================================================== */

.zai-product-card__actions {
	margin-block-start: var(--zai-space-3);
}

.zai-product-card__action {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: var(--zai-control-height);
	padding: var(--zai-space-3) var(--zai-space-4);
	border: var(--zai-border-width) solid var(--zai-border-color-strong);
	border-radius: var(--zai-radius);
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-sm);
	font-weight: var(--zai-fw-semibold);
	line-height: var(--zai-lh-normal);
	letter-spacing: var(--zai-ls-wide);
	text-align: center;
	text-decoration: none;
	white-space: normal;
	overflow-wrap: anywhere;
	color: var(--zai-ink);
	background-color: transparent;
	cursor: pointer;
	transition:
		background-color var(--zai-dur-fast) var(--zai-ease),
		border-color var(--zai-dur-fast) var(--zai-ease),
		color var(--zai-dur-fast) var(--zai-ease);
}

.zai-product-card__action:hover {
	background-color: var(--zai-ink);
	border-color: var(--zai-ink);
	color: var(--zai-text-inverse);
}

.zai-product-card__action:focus-visible {
	outline: var(--zai-focus-width) solid var(--zai-focus-color);
	outline-offset: var(--zai-focus-offset);
}

/* Add-to-cart is the primary action; options read as secondary. */
.zai-product-card__action--add {
	background-color: var(--zai-green);
	border-color: var(--zai-green);
	color: var(--zai-text-inverse);
}

.zai-product-card__action--add:hover {
	background-color: var(--zai-green-hover);
	border-color: var(--zai-green-hover);
	color: var(--zai-text-inverse);
}

/* WooCommerce's own AJAX loading and added states. */
.zai-product-card__action.loading {
	opacity: 0.7;
	pointer-events: none;
}

.zai-product-card__action.added::after {
	content: "";
	display: inline-block;
	width: 0.7em;
	height: 0.7em;
	margin-inline-start: var(--zai-space-2);
	border-block-start: var(--zai-border-width-strong) solid currentColor;
	border-inline-end: var(--zai-border-width-strong) solid currentColor;
	transform: rotate(45deg);
}

/* Out-of-stock cards carry no action, so only the image is softened. */
.zai-is-out-of-stock .zai-product-card__media {
	opacity: 0.85;
}

/* ==========================================================================
   7. Empty shop state
   ========================================================================== */

.zai-shop__empty {
	max-width: 46rem;
	padding-block: var(--zai-space-8);
}

.zai-shop__empty-title {
	margin: 0 0 var(--zai-space-3);
	font-family: var(--zai-font-display);
	font-size: var(--zai-fs-h3);
	font-weight: var(--zai-fw-light);
	line-height: var(--zai-lh-tight);
	letter-spacing: var(--zai-ls-tight);
	color: var(--zai-ink);
}

.zai-shop__empty-text {
	margin: 0 0 var(--zai-space-5);
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-base);
	line-height: var(--zai-lh-relaxed);
	color: var(--zai-text-muted);
}


/* ==========================================================================
   8. Pagination
   ========================================================================== */

.woocommerce-pagination {
	margin-block-start: var(--zai-space-8);
}

.woocommerce-pagination ul.page-numbers {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--zai-space-2);
	margin: 0;
	padding: 0;
	border: 0;
	list-style: none;
}

.woocommerce-pagination ul.page-numbers li {
	margin: 0;
	border: 0;
}

.woocommerce-pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: var(--zai-touch-target);
	min-height: var(--zai-touch-target);
	padding: var(--zai-space-2) var(--zai-space-3);
	border: var(--zai-border-width) solid var(--zai-border-color);
	border-radius: var(--zai-radius);
	font-family: var(--zai-font-body);
	font-size: var(--zai-fs-sm);
	font-variant-numeric: tabular-nums;
	color: var(--zai-text);
	text-decoration: none;
}

.woocommerce-pagination .page-numbers:hover {
	border-color: var(--zai-ink);
	color: var(--zai-ink);
}

.woocommerce-pagination .page-numbers.current {
	background-color: var(--zai-green);
	border-color: var(--zai-green);
	color: var(--zai-text-inverse);
}

.woocommerce-pagination .page-numbers.dots {
	border-color: transparent;
}

/* ==========================================================================
   9. Breadcrumbs inside the shop
   ========================================================================== */

.zai-breadcrumbs--shop {
	margin-block-end: var(--zai-space-5);
}

/* WooCommerce emits this delimiter span between trail items. */
.zai-breadcrumbs--shop .zai-breadcrumbs__sep {
	display: inline-block;
	width: 0.75rem;
	height: 1px;
	background-color: var(--zai-border-color-strong);
	vertical-align: middle;
}

/* ==========================================================================
   10. Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	.zai-product-card__action,
	.woocommerce-ordering select {
		transition: none;
	}
}

