/*
 * Hubka Theme
 *
 * Phase: 11B.4 — WooCommerce Styling (Component Class Rule audit, corrected)
 * Purpose: The canonical Book Card component itself (parts/book-card.html).
 * This is the ONLY place Book Card is styled — contexts that display it
 * (archive, search, collections) style their surrounding grid only, in
 * their own files, never the card itself.
 *
 * Correction note: a prior revision added Hubka semantic classes
 * (`__cover`, `__price`, `__badge`, `__action`) directly to WooCommerce's
 * dynamic cover/price/badge/button blocks. Per architectural clarification,
 * this was over-application — those are WooCommerce-owned dynamic
 * internals, not Hubka-owned layout, and stable WooCommerce classes
 * scoped under `.hubka-book-card` already identify them precisely with
 * no loss of clarity. Reverted to that approach; the classNames were
 * removed from `parts/book-card.html` accordingly.
 *
 * Rules:
 * - Reuse theme.json tokens.
 * - Use logical properties.
 * - Keep selectors shallow.
 * - Do not duplicate component styling.
 */

/* Both Featured Collection's and New Arrivals' product-template <li>
 * cells stretch to equal height by default (flex containers' align-items
 * initial value is stretch) — confirmed live, every <li> in a row is
 * already the same height. But this article itself was plain block flow,
 * sized to its own content, so it just sat at the top of that stretched
 * cell instead of filling it — meaning cards with more metadata lines
 * (e.g. a book with a series, which others lack) grew taller, and every
 * card's commerce row landed at a different vertical position, breaking
 * the row's alignment. Filling the cell and pinning commerce to the
 * bottom (below) fixes both contexts from this one file, per this
 * component's own "styled only here" rule — no changes needed in
 * featured-collection.css or new-arrivals.css. */
.hubka-book-card {
	display: flex;
	flex-direction: column;
	block-size: 100%;
	padding-block-end: var(--wp--preset--spacing--30);
}

/* WordPress core's own "constrained" layout CSS (this block's own
 * `layout:{type:"constrained"}`) sets `margin-left/right: auto !important`
 * on every direct child — harmless in normal block flow (auto-width block
 * elements fill 100% regardless), but now that the card above is a flex
 * column, those same auto margins defeat align-items:stretch on the
 * cross axis and center each child at its own content width instead.
 * Confirmed live: title survives because its long text wraps and fills
 * the width anyway, but a short single-line author/publisher/series
 * shrinks to content and visibly centers — measured margins of ~48px on
 * both sides, splitting the leftover space evenly. Zeroing the inline
 * margins here (same specificity as core's rule, !important required to
 * match; theme stylesheet loads after core's so the tie goes to this
 * rule) restores stretch, so every child fills the card's full width and
 * each one's own text-align:start then resolves against that full width,
 * not a shrink-wrapped box. */
.hubka-book-card > * {
	margin-inline: 0 !important;
}

/* Cover: the dominant visual element. Resting shadow + radius reuse the
 * same book-cover tokens Author Spotlight's portrait already uses, so a
 * cover reads as a physical object instead of a flat rectangle pasted on
 * the page background. Subtle lift on hover, per DESIGN_SYSTEM.md's motion
 * philosophy — physical-feeling, not decorative. */
.hubka-book-card .wc-block-components-product-image {
	margin-block-end: var(--wp--preset--spacing--30);
	border-radius: var(--wp--custom--book-cover--radius);
	box-shadow: var(--wp--custom--book-cover--shadow);
	overflow: hidden;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hubka-book-card:hover .wc-block-components-product-image {
	transform: translateY(-2px);
	box-shadow: var(--wp--custom--book-cover--shadow-hover);
}

/* Title: second most prominent element after the cover. */
.hubka-book-card__title {
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 600;
	line-height: 1.4;
	margin-block-end: var(--wp--preset--spacing--20);
	text-align: start;
}

.hubka-book-card__title a {
	color: var(--wp--preset--color--text);
}

/* Author: subordinate to title, still legible — core to recognition. */
.hubka-book-card__author {
	font-size: var(--wp--preset--font-size--small);
	margin-block-end: var(--wp--preset--spacing--20);
	text-align: start;
}

.hubka-book-card__author a {
	color: var(--wp--preset--color--muted);
}

/* Optional metadata (publisher, series, year, page count): quietest tier.
 * Individually empty items are already suppressed at the template/PHP
 * level (post-terms and the render_block filter) — this only handles
 * layout for whichever ones are actually present.
 *
 * direction:rtl is a deliberate, narrow exception to "no hardcoded
 * direction" — not a repeat of the whole-card mistake reverted earlier
 * in this file's history. dir="auto" cannot work here: per the bidi
 * spec it skips descendants that already carry their own dir attribute,
 * and this row's only text-bearing children (publisher, series) already
 * do, so its own auto-detection always finds nothing and defaults to
 * ltr — confirmed live (see inc/language-rendering.php's doc comment).
 * Unlike the reverted card-wide rule, this one is safe: every possible
 * child of this specific row is catalog data (publisher, series, year,
 * page count) — never WooCommerce UI chrome, which lives in the
 * sibling __commerce group, untouched. */
.hubka-book-card__meta {
	direction: rtl;
	gap: var(--wp--preset--spacing--20);
	margin-block-end: var(--wp--preset--spacing--30);
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

.hubka-book-card__meta > * {
	color: var(--wp--preset--color--muted);
}

/* Publisher/series render as wp:post-terms links to their taxonomy
 * archive — the rule above only colors their wrapper, not the nested <a>,
 * so without this they inherit the sitewide brand-green link color
 * instead of sitting quiet like the rest of this row (matches the same
 * override already applied to __author a below). */
.hubka-book-card__publisher a,
.hubka-book-card__series a {
	color: var(--wp--preset--color--muted);
}

/* Commerce row: price and Add to Cart support the decision, never
 * dominate it. Sale badge sits quietly above, not shouting.
 * margin-block-start:auto absorbs the leftover space from the card fill
 * above, pinning this row to the bottom so it lines up across every card
 * in a row regardless of how many metadata lines each one has. */
.hubka-book-card__commerce {
	align-items: center;
	gap: var(--wp--preset--spacing--20);
	margin-block-start: auto;
}

/* The block's own layout attribute (parts/book-card.html) sets
 * justify-content:space-between — reads fine on a narrow desktop grid
 * column, but stretches price and Add to Cart to opposite edges with an
 * ungainly dead gap on a mobile-width card. Confirmed live on both
 * Featured Collection's (then-full-width) and New Arrivals' rail cards
 * before this fix. Tightened at mobile only; desktop untouched. */
@media (max-width: 782px) {
	.hubka-book-card__commerce {
		justify-content: flex-start;
	}
}

.hubka-book-card .wc-block-components-product-price {
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 600;
	color: var(--wp--preset--color--text);
}

.hubka-book-card .wc-block-components-product-button__button {
	font-size: var(--wp--preset--font-size--small);
	padding-block: var(--wp--preset--spacing--20);
	padding-inline: var(--wp--preset--spacing--30);
}

.hubka-book-card .wc-block-components-product-sale-badge {
	margin-block-end: var(--wp--preset--spacing--20);
}

/* Keyboard focus: the whole card's primary links get a clear indicator. */
.hubka-book-card a:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}
