/*
 * product-card.css - the canonical catalogue card.
 *
 * LAYER 5. Owns the card in both arrangements:
 *   - grid  : vertical card with a 3:4 portrait media box (desktop default, and mobile grid
 *             view) - deliberate deviation from the approved screen's square box, per
 *             owner request: product packshots are portrait, so a square frame cropped/
 *             squeezed them.
 *   - list  : compact row with a 64px thumb (the approved mobile default, and desktop
 *             "قائمة مختصرة")
 *
 * ONE set of markup drives both - the layouts differ by CSS only.
 *
 * PROVENANCE
 *   grid card : screens/03-products-desktop-default.html (AR_Card) - media box aspect ratio
 *               overridden, see above
 *   list row  : screens/04-products-mobile-default.html
 *
 * Logical properties throughout. No physical left/right.
 */

/* ---------------------------------------------------------------------------
 * Derived implementation tokens
 *
 * Used repeatedly by the card but never declared in the design's :root - part of the
 * "30 hex values outside :root" recorded in docs/01-design/tokens/colors.md. Named here so
 * the card does not scatter literals. A NAMING decision, not an approval: values are copied
 * verbatim and the pending consolidation task still owns them.
 * ------------------------------------------------------------------------- */

:root {
	--zahra-color-chip-border: #E9E2D2;   /* card meta chip border */
}

/* ---------------------------------------------------------------------------
 * Shared
 * ------------------------------------------------------------------------- */

.zahra-card {
	display: flex;
	flex-direction: column;
	background: var(--zahra-color-surface);
	border: 1px solid var(--zahra-color-line);
	color: var(--zahra-color-ink);
	block-size: 100%;
	min-inline-size: 0;
}

.zahra-card__media {
	position: relative;
	aspect-ratio: 3 / 4;
	background: var(--zahra-color-surface);
	border-block-end: 1px solid var(--zahra-color-line);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	/*
	 * Inset the packshot from the box edges (TASK-054) - previously the image was sized to
	 * 100%/100% of this exact box, so any near-square product photo touched all four sides
	 * with no breathing room. Padding shrinks the flex content box the image is measured
	 * against; object-fit: contain still centers and letterboxes it, now inside a smaller,
	 * evenly-inset area instead of the full box.
	 */
	padding: 16px;
}

/*
 * contain, not cover: product packshots must not be cropped. The surface backdrop fills the
 * remaining box.
 */
.zahra-card__img {
	inline-size: 100%;
	block-size: 100%;
	object-fit: contain;
	display: block;
	transition: transform 0.25s ease;
}

/*
 * Packshot zoom on hover/focus - .zahra-card__media's own overflow: hidden (above) keeps the
 * scaled image clipped to the existing box, so nothing grows outside the card. Also fires on
 * :focus-within so keyboard users get the same cue when tabbing to the card's link, not only
 * mouse users. Skipped under reduced motion, per this project's accessibility standard.
 */
@media (prefers-reduced-motion: no-preference) {
	.zahra-card:hover .zahra-card__img,
	.zahra-card:focus-within .zahra-card__img {
		transform: scale(1.05);
	}
}

.zahra-card__body {
	padding: 12px 13px 13px;
	display: flex;
	flex-direction: column;
	gap: 7px;
	flex: 1 1 auto;
	min-inline-size: 0;
}

.zahra-card__brand {
	font-size: 11px;
	font-weight: 600;
	color: var(--zahra-color-brand);
}

.zahra-card__title {
	margin: 0;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.5;
}

/*
 * min-block-size reserves two lines so cards in a row align regardless of name length -
 * the approved card sets 42px for exactly this reason. Names are never truncated.
 */
.zahra-card__link {
	display: block;
	min-block-size: 42px;
	color: var(--zahra-color-ink);
	text-decoration: none;
}

.zahra-card__link:hover,
.zahra-card__link:focus-visible {
	color: var(--zahra-color-brand);
	text-decoration: underline;
}

.zahra-card__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0;
}

/*
 * No box (owner instruction, chat): the pill background/border/padding was removed so this
 * reads as plain metadata text, not a badge. Kept clearly distinct from .zahra-card__title
 * (14px/600/ink) by staying smaller, lighter-weight, and muted-colored rather than by a
 * container - the same "boxless but still legible" treatment this file's list/auto view
 * already used below (.zahra-shop--list/--auto .zahra-card__chip).
 */
.zahra-card__chip {
	font-size: 11.5px;
	font-weight: 500;
	color: var(--zahra-color-muted);
}

.zahra-card__chip--pack {
	font-weight: 500;
	color: var(--zahra-color-muted);
}

.zahra-card__chip--cat {
	font-weight: 500;
	color: var(--zahra-color-muted);
}

.zahra-card__chip--cat::before {
	content: " · ";
	white-space: pre;
}

/*
 * Availability. The dot is decorative - the state is carried by the text beside it, so the
 * cue survives without colour perception (ACCESSIBILITY.md section 2).
 */
.zahra-card__stock {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	font-size: 11.5px;
	font-weight: 500;
}

.zahra-card__stock-dot {
	inline-size: 7px;
	block-size: 7px;
	flex: 0 0 auto;
}

.zahra-card__stock.is-in-stock {
	color: var(--zahra-color-success);
}

.zahra-card__stock.is-in-stock .zahra-card__stock-dot {
	background: var(--zahra-color-success);
}

.zahra-card__stock.is-out-of-stock {
	color: var(--zahra-color-muted);
}

.zahra-card__stock.is-out-of-stock .zahra-card__stock-dot {
	background: var(--zahra-color-muted);
}

/* ---------------------------------------------------------------------------
 * Order actions (TASK-065)
 *
 * Reuses the same primary CTA treatment already established for Quick Order's own submit/
 * search-submit buttons (assets/css/pages/quick-order.css: --zahra-color-brand fill, white
 * text) - no new button system, no new radius, no new hover language.
 * ------------------------------------------------------------------------- */

.zahra-card__actions {
	margin-block-start: 2px;
}

.zahra-card__add {
	display: flex;
	align-items: center;
	justify-content: center;
	inline-size: 100%;
	block-size: 40px;
	padding-inline: 12px;
	background: var(--zahra-color-brand);
	color: #fff;
	border: 0;
	font-size: 12.5px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
}

.zahra-card__add:hover:not(:disabled) {
	background: var(--zahra-color-brand-dark);
}

.zahra-card__add:disabled {
	cursor: not-allowed;
	opacity: 0.75;
}

.zahra-card__add.is-added {
	background: var(--zahra-color-success);
}

.zahra-card__add--disabled {
	background: none;
	color: var(--zahra-color-muted);
	border: 1px solid var(--zahra-color-line);
}

.zahra-card__add-status {
	display: block;
	margin-block-start: 4px;
	font-size: 11px;
	color: var(--zahra-color-brand);
}

.zahra-card__add-status:empty {
	display: none;
}

/* ---------------------------------------------------------------------------
 * List arrangement
 *
 * The approved mobile default, and the desktop "قائمة مختصرة" view. Same markup: the card
 * becomes a two-column row, the square media collapses to a 64px thumb, and the meta chips
 * become an inline "·"-separated line.
 *
 * .zahra-shop--auto (no explicit view chosen) is included below the desktop breakpoint,
 * because the approved MOBILE archive opens as rows while the approved DESKTOP archive opens
 * as a grid. The desktop rule at the end of this file returns --auto to the grid.
 * ------------------------------------------------------------------------- */

.zahra-shop--list .zahra-card,
.zahra-shop--auto .zahra-card,
.zahra-shop-list .zahra-card {
	display: grid;
	grid-template-columns: 64px 1fr;
	gap: 12px;
	padding: 12px 0;
	border: 0;
	border-block-end: 1px solid var(--zahra-color-line-2);
	block-size: auto;
}

.zahra-shop--list .zahra-card__media,
.zahra-shop--auto .zahra-card__media,
.zahra-shop-list .zahra-card__media {
	aspect-ratio: auto;
	block-size: 64px;
	border: 1px solid var(--zahra-color-line);
	/* The 64px mobile-row thumb has no room to spare for the grid card's inset (TASK-054). */
	padding: 0;
}

.zahra-shop--list .zahra-card__body,
.zahra-shop--auto .zahra-card__body,
.zahra-shop-list .zahra-card__body {
	padding: 0;
	gap: 5px;
}

.zahra-shop--list .zahra-card__link,
.zahra-shop--auto .zahra-card__link,
.zahra-shop-list .zahra-card__link {
	min-block-size: 0;
}

/* Chips lose their box and read as one line, matching the approved mobile row. */
.zahra-shop--list .zahra-card__meta,
.zahra-shop--auto .zahra-card__meta,
.zahra-shop-list .zahra-card__meta {
	gap: 0;
	font-size: 12px;
	color: var(--zahra-color-ink-2);
}

.zahra-shop--list .zahra-card__chip,
.zahra-shop--auto .zahra-card__chip,
.zahra-shop-list .zahra-card__chip {
	font-size: 12px;
	font-weight: 500;
	color: var(--zahra-color-ink-2);
	background: none;
	border: 0;
	padding: 0;
}

.zahra-shop--list .zahra-card__chip--cat::before,
.zahra-shop--auto .zahra-card__chip--cat::before,
.zahra-shop-list .zahra-card__chip--cat::before {
	content: " · ";
	white-space: pre;
}

/* ---------------------------------------------------------------------------
 * Desktop - IMPLEMENTATION PROVISIONAL breakpoint (Q-013)
 *
 * With no explicit view chosen, the desktop archive returns to the approved card grid.
 * An explicit .zahra-shop--list choice is respected at every width.
 * ------------------------------------------------------------------------- */

@media (min-width: 1024px) {

	.zahra-shop--auto .zahra-card {
		display: flex;
		flex-direction: column;
		grid-template-columns: none;
		gap: 0;
		padding: 0;
		border: 1px solid var(--zahra-color-line);
		block-size: 100%;
	}

	.zahra-shop--auto .zahra-card__media {
		aspect-ratio: 3 / 4;
		block-size: auto;
		border: 0;
		border-block-end: 1px solid var(--zahra-color-line);
		/* Desktop reverts to the portrait grid card - restore the inset the mobile row reset. */
		padding: 16px;
	}

	.zahra-shop--auto .zahra-card__body {
		padding: 12px 13px 13px;
		gap: 7px;
	}

	.zahra-shop--auto .zahra-card__link {
		min-block-size: 42px;
	}

	.zahra-shop--auto .zahra-card__meta {
		gap: 0;
		font-size: inherit;
	}

	/*
	 * No box here either (owner instruction, chat) - this desktop-grid override previously
	 * re-added the pill background/border/padding the base rule above just removed.
	 */
	.zahra-shop--auto .zahra-card__chip {
		font-size: 11.5px;
		font-weight: 500;
		color: var(--zahra-color-muted);
	}

	.zahra-shop--auto .zahra-card__chip--pack {
		font-weight: 500;
		color: var(--zahra-color-muted);
	}
}
