/*
 * villas-more/vm-card — front-end styles (Task 018).
 *
 * RULE (TASK-018 §6.1): not one colour, font, font size or spacing
 * value is written here. Every appearance value is a theme token —
 * `--wp--preset--*`, and, where the theme has no preset to reach for,
 * `--wp--custom--*`. Task 018-1 added the first two of those and,
 * in its second pass against the design reference, three more and a
 * changed one, all of them typographic and
 * all of them values an editor should never be offered in a picker
 * (0.62rem, 0.75rem, a font weight), which is the same argument that
 * put `ink` in settings.custom rather than the palette — DECISIONS.md
 * 87 §1. Change any of them in theme.json and this block changes.
 * None carries a literal fallback: under a theme that does not define
 * the token the declaration is simply invalid and the browser uses its
 * own default, which is the honest degradation and keeps this file free
 * of appearance values.
 * The only literals are structural and carry no appearance:
 * aspect-ratio, object-fit, display, position, and the 1px hairline
 * whose colour is a token.
 *
 * The four styles are expressed as custom properties, not as separate
 * rule sets, so the grid can re-declare "inherited" cards (see the
 * grid's style.css) and the featured layouts can force a style without
 * restating any structure.
 *
 * Loaded by WordPress only on pages where the block appears, because it
 * is declared in the `style` field of block.json (§6.2).
 */

/* --------------------------------------------------------------
   1. The four styles, as property sets.
   Each set is complete, never a delta — a forced style must be able
   to overwrite any other one entirely.
   -------------------------------------------------------------- */

/*
 * Standard (Task 018-2): the sentence is three quarters of the title —
 * 12.75px under 17px, a ratio of 1.33 where the drawing has 1.31 — written
 * as arithmetic on the title's preset rather than a new size. The inside
 * gap is 16px, tighter than the 24px between cards, so the card has an
 * edge. The 2px radius is the photograph's (the card itself has no ground).
 */
.vmc-card,
.vmc-card--standard,
.vmc-card--inherit {
	--vmc-ratio: 5 / 4;
	--vmc-columns: minmax( 0, 1fr );
	--vmc-align: stretch;
	--vmc-title-size: var(--wp--preset--font-size--medium);
	--vmc-text-size: calc( var(--wp--preset--font-size--medium) * 0.75 );
	--vmc-inner-gap: var(--wp--preset--spacing--20);
	--vmc-pad: 0px;
	--vmc-bg: transparent;
	--vmc-border-width: 0px;
	--vmc-border-color: transparent;
	--vmc-radius: 2px;
	--vmc-rule-width: 0px;
}

/*
 * Panel is the homepage's Offers panel (Task 018-2): a 3:2 photograph
 * flush to the frame, and the padding around the TEXT only. --vmc-pad is
 * the text's inset (top, sides, bottom); the top is added to the 24px
 * media gap, so the eyebrow sits 40px under the photograph.
 */
.vmc-card--panel {
	--vmc-ratio: 3 / 2;
	--vmc-columns: minmax( 0, 1fr );
	--vmc-align: stretch;
	--vmc-title-size: var(--wp--preset--font-size--intro);
	--vmc-text-size: var(--wp--preset--font-size--small);
	--vmc-inner-gap: var(--wp--preset--spacing--30);
	--vmc-pad: var(--wp--preset--spacing--20) calc( var(--wp--preset--spacing--20) + var(--wp--preset--spacing--10) / 2 ) calc( var(--wp--preset--spacing--20) + var(--wp--preset--spacing--10) / 2 );
	--vmc-bg: var(--wp--preset--color--white);
	--vmc-border-width: 1px;
	--vmc-border-color: var(--wp--preset--color--border);
	--vmc-radius: 2px;
	--vmc-rule-width: 2px;
}

.vmc-card--compact {
	--vmc-ratio: 1 / 1;
	--vmc-columns: minmax( 0, 1fr );
	--vmc-align: stretch;
	--vmc-title-size: var(--wp--preset--font-size--small);
	--vmc-text-size: var(--wp--preset--font-size--small);
	--vmc-inner-gap: var(--wp--preset--spacing--30);
	--vmc-pad: 0px;
	--vmc-bg: transparent;
	--vmc-border-width: 0px;
	--vmc-border-color: transparent;
	--vmc-radius: 0px;
	--vmc-rule-width: 0px;
}

.vmc-card--editorial {
	--vmc-ratio: 4 / 5;
	--vmc-columns: minmax( 0, 1fr );
	--vmc-align: stretch;
	--vmc-title-size: var(--wp--preset--font-size--large);
	--vmc-text-size: var(--wp--preset--font-size--medium);
	--vmc-inner-gap: var(--wp--preset--spacing--30);
	--vmc-pad: 0px;
	--vmc-bg: transparent;
	--vmc-border-width: 0px;
	--vmc-border-color: transparent;
	--vmc-radius: 0px;
	--vmc-rule-width: 0px;
}

/* --------------------------------------------------------------
   2. Structure. Identical for every style; only the properties above
   differ. `position: relative` is what the stretched title link needs.
   -------------------------------------------------------------- */

.vmc-card {
	position: relative;
	display: grid;
	grid-template-columns: var(--vmc-columns);
	align-items: var(--vmc-align);
	/*
	 * Found on the real page in Task 018-1, and not visible in the
	 * headless harness because every test card had a one-line title.
	 *
	 * The grid stretches every card in a row to the tallest one. Inside
	 * a card that is taller than its own content, `align-content:
	 * normal` hands the spare height to the auto rows — so the media of
	 * the card with the SHORTER text grew: an Editorial media measured
	 * 247x308 beside its neighbour's 224x280. The ratio was still 4:5,
	 * because aspect-ratio then widened the box to match, which is why
	 * the image also overflowed the card and was clipped.
	 *
	 * `start` keeps the tracks at their content size and leaves the
	 * spare height at the bottom of the card, where it belongs. The card
	 * itself still stretches, so Panel's white ground still fills the
	 * row. Measured on all seven grids: only the two grids with uneven
	 * text changed, and both changed to the correct ratio.
	 */
	align-content: start;

	/*
	 * FOUR RELATIONSHIPS, FOUR STEPS (Task 018-1; regrouped in 018-2).
	 * media -> text is `--vmc-inner-gap`, the card's own grid gap (per
	 * style). The other three live here, on the card, for every style:
	 *
	 *   eyebrow -> title      8px  spacing--10. Air ABOVE the name, so
	 *                              the label reads as a label, not as
	 *                              the first word of the name.
	 *   title -> description  4px  half of spacing--10: the name and its
	 *                              sentence are one unit. No scale value
	 *                              is that small, so it is arithmetic on
	 *                              the scale rather than a literal or a
	 *                              token — the same calc 018-1 wrote for
	 *                              the eyebrow step, moved one step down.
	 *   description -> action 16px spacing--20. A separate act.
	 *
	 * 018-1 had the first two the other way round (4 / 8), which glued
	 * the eyebrow to the name and pushed the sentence away.
	 */
	--vmc-gap-label: var(--wp--preset--spacing--10);
	--vmc-gap-text: calc( var(--wp--preset--spacing--10) / 2 );
	--vmc-gap-action: var(--wp--preset--spacing--20);

	gap: var(--vmc-inner-gap);
	/*
	 * No padding on the card: the photograph is the top of the card and
	 * touches its edges. The inset belongs to the text — see the body.
	 * (Task 018-2 reverses Task 018-1's card padding; DECISIONS.md 132.)
	 */
	background-color: var(--vmc-bg);
	border: var(--vmc-border-width) solid var(--vmc-border-color);
	border-radius: var(--vmc-radius);
	overflow: hidden;
}

/*
 * The rule above the media is Panel's own, from DECISIONS.md 89. It is
 * drawn in the theme's Property colour — `--vm-color-primary`, which
 * resolves to the collection olive site-wide and to the Property's own
 * Core on a Property page — so a Panel card belongs to whatever page it
 * is on without one line of per-Property CSS. Under a theme that does
 * not define it, the preset primary stands in.
 */
.vmc-card__media {
	aspect-ratio: var(--vmc-ratio);
	overflow: hidden;
	border-radius: var(--vmc-radius);
	background-color: var(--wp--preset--color--surface);
	border-top: var(--vmc-rule-width) solid
		var(--vm-color-primary, var(--wp--preset--color--primary));
}

.vmc-card__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/*
 * No gap here on purpose: the four steps above are set as margins between
 * adjacent elements instead, because a flex `gap` can only say one thing.
 */
.vmc-card__body {
	display: flex;
	flex-direction: column;
	gap: 0;
	padding: var(--vmc-pad);
}

/*
 * With no image the body is the card's only child, so it takes the whole
 * width rather than sitting in the media column.
 */
.vmc-card__body:first-child {
	grid-column: 1 / -1;
}

/*
 * The steps, written between adjacent elements rather than as one gap.
 *
 * Adjacent-sibling selectors are what makes this survive missing content:
 * an empty field is not rendered at all (and an emptied action label is
 * `display: none`), so the step simply moves to whichever pair actually
 * exists. A card with no eyebrow puts its title first and takes no step;
 * a card with no description puts the action after the title and takes
 * the action step.
 */
.vmc-card__eyebrow + .vmc-card__title {
	margin-top: var(--vmc-gap-label);
}

.vmc-card__title + .vmc-card__description,
.vmc-card__eyebrow + .vmc-card__description {
	margin-top: var(--vmc-gap-text);
}

.vmc-card__description + .vmc-card__action,
.vmc-card__title + .vmc-card__action,
.vmc-card__eyebrow + .vmc-card__action {
	margin-top: var(--vmc-gap-action);
}

/*
 * THE SECOND ACTION'S STEP (Task 024-2).
 *
 * Two actions are one act, so the step between them is the label step,
 * 8px — not the 16px that separates the words of the card from what it
 * asks you to do. When there is no first action, the second one takes
 * that 16px instead, exactly as the first one would have.
 *
 * The third rule is the one that is easy to miss. An emptied first
 * action is `display: none`, but `display: none` does NOT stop it
 * matching `+`, so without this the second action would sit 8px below a
 * first action nobody can see. Written after the 8px rule at the same
 * specificity (0,2,0), which is the same source-order argument the
 * `:empty` rule at the foot of this file is written out in full for.
 */
.vmc-card__description + .vmc-card__action-secondary,
.vmc-card__title + .vmc-card__action-secondary,
.vmc-card__eyebrow + .vmc-card__action-secondary {
	margin-top: var(--vmc-gap-action);
}

.vmc-card__action + .vmc-card__action-secondary {
	margin-top: var(--vmc-gap-label);
}

.vmc-card__action:empty + .vmc-card__action-secondary {
	margin-top: var(--vmc-gap-action);
}

/*
 * Compact is a vertical card everywhere: a 1:1 image above the name and
 * its words, at whatever width its column happens to be.
 *
 * It used to be a row above 601px, and Task 018-1 took that out on Ana's
 * ruling. The row was introduced in Task 018 (§7 item 4) for one real
 * reason — the "Half and half" right-hand column read as a stack of
 * large squares rather than as a list — but it was applied to every
 * Compact card, and outside that layout it does harm: in a three-column
 * grid inside a 720px content area the media measured 76x76px, a
 * thumbnail rather than a picture.
 *
 * The row survives exactly where it was earned, as one rule scoped to
 * `.vmc-grid--featured-half` in the grid's own stylesheet (§6). Nothing
 * here needs to know about it. DECISIONS.md 125.
 */

/* --------------------------------------------------------------
   3. Content.
   -------------------------------------------------------------- */

/*
 * The eyebrow, brought in line with docs/design/components-reference.html
 * (Task 018-1, second pass — the design reference). The drawing sets it in the DISPLAY face, not the body one —
 * theme.json's own name for that preset is "Display (wordmark, navigation,
 * eyebrows, labels)", so the build had been reaching for the wrong family
 * rather than making a judgement call.
 *
 * It is also much smaller than it was: 0.62rem against the `small` preset's
 * 0.875rem, with the letter-spacing opened from 0.08em to 0.17em. There is no
 * font-size preset anywhere near 0.62rem and there should not be — an editor
 * has no business picking 10px from a size list — so it is a settings.custom
 * value, exactly as `ink` is a settings.custom colour for the same reason
 * (DECISIONS.md 87 §1).
 *
 * No font-weight: the display face is Marcellus, which ships one weight, and
 * asking for 500 would only make the browser synthesise a fake bold.
 *
 * The COLOUR is deliberately unchanged and is an open question — see
 * TASK-018-1.md §11. The reference's addendum calls for a muted olive; the
 * only eyebrow actually drawn in that file is #696663, which is this very
 * token; and the palette's collection olive measures 4.01:1 on the tinted
 * band, under the AA floor DECISIONS.md 87 §1 refuses to cross.
 */
.vmc-card__eyebrow {
	margin: 0;
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--custom--typography--eyebrow-size);
	color: var(--wp--preset--color--muted);
	text-transform: uppercase;
	letter-spacing: var(--wp--custom--typography--eyebrow-letter-spacing);
	/*
	 * Measured before this was set: 9.92px of type inside a 16.37px line
	 * box, because the eyebrow was inheriting the theme's body
	 * line-height of 1.65. That is 3.2px of dead space above and below,
	 * and it added itself to whatever gap was specified — so the spacing
	 * written was never the spacing seen. A label one line long does not
	 * need leading for reading; it needs to sit where it is put.
	 */
	line-height: var(--wp--custom--typography--eyebrow-line-height);
}

/*
 * The two line-heights were the wrong way round, and both are set here
 * rather than in a style set, because they are the card's typography and
 * every style shares it.
 *
 * Measured before: title 17px in a 19.55px box (1.15) and description
 * 14px in a 23.1px box (1.65). So the NAME was set tight enough that a
 * two-line house name would collide, while the description — the part
 * nobody reads twice — sprawled. Names run to two lines constantly here:
 * "Boutique Villa Filaus" already does at three columns.
 */
.vmc-card__title {
	margin: 0;
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--vmc-title-size);
	line-height: var(--wp--custom--typography--title-line-height);
	color: var(--wp--preset--color--contrast);
}

.vmc-card__description {
	margin: 0;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--vmc-text-size);
	line-height: var(--wp--custom--typography--description-line-height);
	color: var(--wp--preset--color--muted);
}

/* --------------------------------------------------------------
   4. How the card is clicked (§3.4).
   One link, on the title, stretched over the whole card. The card is
   never wrapped in an <a> — a screen reader would announce a link with
   no name — and the bottom action is deliberately not a second link.
   -------------------------------------------------------------- */

.vmc-card__link {
	color: inherit;
	text-decoration: none;
}

.vmc-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
}

.vmc-card__link:focus-visible {
	outline: none;
}

.vmc-card:has(.vmc-card__link:focus-visible) {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 3px;
}

.vmc-card:has(.vmc-card__link:hover) .vmc-card__title {
	color: var(--wp--preset--color--primary);
}

/* --------------------------------------------------------------
   5. The bottom action. A visual affordance for the card's one link,
   not a link of its own — hence aria-hidden in the markup.

   Its text is a content field (Task 018-1), and an empty field prints
   nothing. The span is still written into the saved markup when it is
   empty — that is what stops the attribute falling back to "Explore" on
   the next parse — so it is hidden here instead. Without this rule an
   emptied Button action would still draw its padded coloured box, and an
   emptied Quiet link would still consume one gap of the card's column.
   -------------------------------------------------------------- */

/*
 * The action, brought in line with the reference (Task 018-1, second pass — the design reference). This is the
 * single biggest reason the built grid read like a page of search results:
 * in the drawing the action is the QUIETEST thing on the card, and the build
 * made it the loudest — underlined lowercase text at body size, sitting under
 * every card like a row of links.
 *
 * The drawing's treatment, and it is shared by both variants: ~0.75rem,
 * uppercase, letter-spacing ~0.09em, weight 500, olive, and NO underline.
 * Small uppercase with open letter-spacing reads as a label; underlined
 * sentence case reads as a link, and a card that already carries one stretched
 * link over the whole of it does not need a second thing that looks like one.
 *
 * Size, letter-spacing and weight are settings.custom values because the theme
 * has no preset at any of them and should not grow one: 0.75rem is below the
 * `small` preset, and a font-weight list is not something an editor picks per
 * card. Same reasoning as `ink` (DECISIONS.md 87 §1).
 *
 * The colour stays `primary` rather than moving to the palette's collection
 * olive the drawing suggests, and rather than following the Property through
 * `--vm-color-primary`. Measured, not assumed: accent is 4.01:1 on the tinted
 * band, and Villa Filaus's own Mark is 3.42:1 on the page ground — both under
 * AA for text this size. `primary` is 8.92:1 at its worst. See TASK-018-1.md
 * §11; this is flagged for Ana, not decided here.
 */
.vmc-card__action,
.vmc-card__action-secondary {
	align-self: start;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--custom--typography--action-size);
	font-weight: var(--wp--custom--typography--action-weight);
	color: var(--wp--preset--color--primary);
	text-transform: uppercase;
	letter-spacing: var(--wp--custom--typography--action-letter-spacing);
	text-decoration: none;
}

/*
 * Quiet needs nothing of its own any more — it IS the shared treatment above.
 * `.vmc-card--action-quiet` stays in the markup because it is written into
 * saved content and because it is what the Button variant is not; giving it an
 * empty rule here would only invite someone to fill it.
 *
 * Button is the same label inside a frame: transparent ground, a 1px border and
 * a 2px radius — the project's frame, stated as such for Panel in DECISIONS.md
 * 89 and already accepted as a literal in this file for that reason. The border
 * is `currentColor` so it cannot drift away from the text it surrounds, which
 * also means the hover below moves both together.
 */
.vmc-card--action-button .vmc-card__action {
	display: inline-flex;
	align-items: center;
	padding: var(--wp--preset--spacing--10) var(--wp--preset--spacing--20);
	border: 1px solid currentColor;
	border-radius: 2px;
	background-color: transparent;
}

/*
 * One hover rule for both variants. It replaces two selectors, the first of
 * which could never match: `.vmc-card--action-button` is the card itself, so it
 * was never a descendant of `.vmc-card`. Dead since Task 018.
 */
.vmc-card:has(.vmc-card__link:hover) .vmc-card__action {
	color: var(--wp--preset--color--primary-dark);
}

/* --------------------------------------------------------------
   5b. The SECOND action (Task 024-2). Unlike the first one this is a
   real link to a place of its own — Accommodation's "Check
   availability" beside "View this room" — so it is not aria-hidden and
   it must be reachable.

   `position: relative` and `z-index` are not decoration. The card's one
   link is stretched over the whole card with `.vmc-card__link::after {
   inset: 0 }`; anything that has to stay clickable underneath it has to
   be lifted above it, or the second action is drawn, focusable and
   completely unclickable. That is the single fault this whole block
   would have shipped with.

   It shares the first action's typography above and adds nothing to it:
   the two actions look like one pair, which is the point.
   -------------------------------------------------------------- */

.vmc-card__action-secondary {
	position: relative;
	z-index: 1;
}

.vmc-card__action-secondary--button {
	display: inline-flex;
	align-items: center;
	padding: var(--wp--preset--spacing--10) var(--wp--preset--spacing--20);
	border: 1px solid currentColor;
	border-radius: 2px;
	background-color: transparent;
}

/*
 * Its own hover, and only its own. Hovering the CARD moves the first
 * action, because the first action is that link's affordance; the second
 * action goes somewhere else and must not answer to a hover that is not
 * aimed at it.
 */
.vmc-card__action-secondary:hover,
.vmc-card__action-secondary:focus-visible {
	color: var(--wp--preset--color--primary-dark);
}

.vmc-card__action-secondary:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 3px;
}

/* --------------------------------------------------------------
   6. Panel's own details — the homepage Offers panel (Task 018-2).
   An olive eyebrow (--vm-color-deep, the theme's eyebrow colour; 8.06:1
   on white, 5.81:1 for Villa Filaus), the text filling the card so the
   hairlines line up across a row, and the quiet action as a sentence-case
   link with an arrow under a hairline.
   Written twice on purpose: above 781px a featured layout takes its cards
   over and forces another style on them, so they are excluded there.
   -------------------------------------------------------------- */

@media (max-width: 781px) {
	:is( .vmc-card--panel, .vmc-grid--cardstyle-panel > .vmc-card--inherit ):has( > .vmc-card__media ) {
		grid-template-rows: auto 1fr;
	}

	:is( .vmc-card--panel, .vmc-grid--cardstyle-panel > .vmc-card--inherit ) .vmc-card__eyebrow {
		color: var(--vm-color-deep, var(--wp--preset--color--primary));
	}

	:is( .vmc-card--panel, .vmc-grid--cardstyle-panel > .vmc-card--inherit ) .vmc-card__description {
		flex-grow: 1;
	}

	:is( .vmc-card--panel, .vmc-grid--cardstyle-panel > .vmc-card--inherit ).vmc-card--action-quiet .vmc-card__action {
		align-self: stretch;
		padding-top: calc( var(--wp--preset--spacing--10) * 1.5 );
		border-top: 1px solid var(--wp--preset--color--border);
		font-size: var(--wp--preset--font-size--small);
		text-transform: none;
		letter-spacing: inherit;
	}

	:is( .vmc-card--panel, .vmc-grid--cardstyle-panel > .vmc-card--inherit ).vmc-card--action-quiet .vmc-card__action::after {
		content: "\00a0\2192";
	}
}

@media (min-width: 782px) {
	:is( .vmc-card--panel, .vmc-grid--cardstyle-panel > .vmc-card--inherit ):not( .vmc-grid--featured-half > .vmc-card, .vmc-grid--featured-wide > .vmc-card:first-child ):has( > .vmc-card__media ) {
		grid-template-rows: auto 1fr;
	}

	:is( .vmc-card--panel, .vmc-grid--cardstyle-panel > .vmc-card--inherit ):not( .vmc-grid--featured-half > .vmc-card, .vmc-grid--featured-wide > .vmc-card:first-child ) .vmc-card__eyebrow {
		color: var(--vm-color-deep, var(--wp--preset--color--primary));
	}

	:is( .vmc-card--panel, .vmc-grid--cardstyle-panel > .vmc-card--inherit ):not( .vmc-grid--featured-half > .vmc-card, .vmc-grid--featured-wide > .vmc-card:first-child ) .vmc-card__description {
		flex-grow: 1;
	}

	:is( .vmc-card--panel, .vmc-grid--cardstyle-panel > .vmc-card--inherit ):not( .vmc-grid--featured-half > .vmc-card, .vmc-grid--featured-wide > .vmc-card:first-child ).vmc-card--action-quiet .vmc-card__action {
		align-self: stretch;
		padding-top: calc( var(--wp--preset--spacing--10) * 1.5 );
		border-top: 1px solid var(--wp--preset--color--border);
		font-size: var(--wp--preset--font-size--small);
		text-transform: none;
		letter-spacing: inherit;
	}

	:is( .vmc-card--panel, .vmc-grid--cardstyle-panel > .vmc-card--inherit ):not( .vmc-grid--featured-half > .vmc-card, .vmc-grid--featured-wide > .vmc-card:first-child ).vmc-card--action-quiet .vmc-card__action::after {
		content: "\00a0\2192";
	}
}

/*
 * An empty label prints nothing — including no button.
 *
 * This rule sits last on purpose. `.vmc-card--action-button
 * .vmc-card__action` above sets `display: inline-flex` at the same
 * specificity (0,2,0) as `.vmc-card__action:empty`, so an earlier
 * placement would silently lose on source order and an emptied Button
 * would still draw its padded coloured box. Moving it up requires
 * raising its specificity; leaving it here does not.
 */
.vmc-card__action:empty,
.vmc-card__action-secondary:empty {
	display: none;
}
