/**
 * Front page components.
 *
 * These rules used to live inside the stat section's own GenerateBlocks `css`
 * attribute. That was a trap: in GB v2 `css` is generated cache rebuilt from the
 * block's `styles` object on every edit, so the first time anyone opened that
 * section in the editor the whole stat band would have lost its styling. A plain
 * CSS component keyed to its own class names has no block to be regenerated
 * from, so it belongs here, where an edit cannot destroy it.
 *
 * Loaded on the front page only — see vim_enqueue_assets() in functions.php,
 * alongside hero.css and stats.js.
 *
 * @package generatepress_child
 */

/* ---------------------------------------------------------------------------
 * Access to Care band — mobile
 *
 * On a phone the band is roughly 375x579, and `background-size: cover` on a
 * 1920x1281 landscape photograph scales it to fit the HEIGHT — so only the
 * middle ~41% of its width is on screen, under a 68% --ink overlay. The result
 * reads as dark foliage rather than as the clinic entrance, and Tom's verdict
 * on 2026-08-26 was simply that the image was not visible.
 *
 * Below 768px the photograph therefore comes out from behind the copy: it is
 * shown whole as a bar across the top of the band, at its own aspect ratio,
 * with the copy on solid --ink underneath. Same treatment as the homepage hero
 * on mobile, and the same reason — a wide photograph cropped to a phone-shaped
 * box stops being a photograph of anything.
 *
 * The rules are here rather than in the block's `styles` because they are
 * component behaviour, which this file exists to hold; the block's own
 * `styles` and `css` are deliberately untouched, so GenerateBlocks cannot
 * regenerate something that disagrees with this. `section.vim-access-band`
 * carries one element's worth of specificity more than the generated
 * `.gb-element-vimsec5a`, so it wins wherever the two stylesheets land in the
 * cascade.
 * ------------------------------------------------------------------------- */

@media (max-width: 767px) {

	section.vim-access-band {
		/*
		 * `100% auto` is the whole trick: the photograph is scaled to the band's
		 * full width and keeps its natural height, which makes it a bar rather
		 * than a crop. The background positioning area is the padding box, so it
		 * runs edge to edge regardless of the band's own inline padding.
		 *
		 * background-repeat: no-repeat is already set on the block. Without it
		 * the photograph would tile down the whole band.
		 */
		background-size: 100% auto;
		background-position: center top;
		/* Everything below the bar. The block sets no background-color of its
		   own — the overlay used to supply the darkness, and it is off below. */
		background-color: var(--ink);
		/*
		 * 66.72vw is 1281/1920 — the photograph's own height at full width —
		 * plus the band's authored 4.5rem mobile top padding as the gap under
		 * it. ⚠️ Keep this in step with the image: a replacement photo of a
		 * different shape needs this number recomputed, or the copy will start
		 * too high or leave a gap.
		 *
		 * vw is the viewport, while `100%` above is the element. On a phone they
		 * are the same. Where a classic scrollbar exists the element is
		 * narrower, so the padding is very slightly generous — which errs
		 * towards a little extra space, never towards text over the photograph.
		 */
		padding-top: calc(66.72vw + 4.5rem);
	}

	/*
	 * The 68% --ink scrim exists to hold white text off the photograph. With the
	 * two separated it has nothing to do but dim the picture, which is the
	 * complaint. The copy's contrast is now carried by the solid --ink above.
	 */
	section.vim-access-band::before {
		display: none;
	}
}

/* ---------------------------------------------------------------------------
 * Four-column care cards — mobile
 *
 * "reduce the spacing top and bottom on there for mobile only" (Tom,
 * 2026-08-26). The two text cards carried ~75px of empty colour above the
 * heading and below the button on a phone.
 *
 * Two things made it, and both have to go:
 *
 *   1. `min-height: 430px` — which exists to match the card's height to the
 *      320px-min image BESIDE it. Once the band drops to one column the image
 *      is stacked above instead, so there is nothing left to match and the
 *      floor is just dead space. `justify-content: center` then splits the
 *      surplus evenly top and bottom, which is why it read as symmetrical
 *      padding rather than as a too-tall box.
 *   2. The 2.75rem block padding on top of that.
 *
 * 🚨 Scoped to 639px, which is the band's OWN single-column breakpoint, not the
 * 768px used elsewhere in this build. Between 640 and 1200 the grid is two
 * columns of image-beside-text and the min-height is still doing its job —
 * lifting this to 768px would unpair every card in that range.
 *
 * Horizontal padding is deliberately left alone: Tom asked for top and bottom.
 * ------------------------------------------------------------------------- */

@media (max-width: 639px) {

	/* div. — one element's worth more specificity than the generated
	   .gb-element-vimsec4b / -4c, so this wins wherever the two stylesheets
	   land in the cascade. */
	div.vim-care-card {
		min-height: 0;
		padding-block: 1.75rem;
	}
}

/* ---------------------------------------------------------------------------
 * Stat band
 *
 * The figures are authored into the markup; assets/stats.js only animates up to
 * them, so the band is correct with JavaScript off.
 * ------------------------------------------------------------------------- */

.vim-stat {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	row-gap: 0.25rem;
}

/*
 * The 20px bottom margin is deliberate breathing room between the icon and its
 * figure (Tom, 2026-08-24) — the label stays tucked under the number, and only
 * the circle is pushed away from the pair.
 */
.vim-stat__circle {
	width: 156px;
	height: 156px;
	max-width: 100%;
	aspect-ratio: 1;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 20px;
}

@media (max-width: 1279px) {

	.vim-stat__circle {
		width: 124px;
		height: 124px;
	}
}

.vim-stat__circle svg {
	width: 52%;
	height: 52%;
	fill: var(--white);
}

/*
 * The label sits directly under its number, so both drop their inherited
 * bottom margin and the gap is controlled solely by .vim-stat's row-gap.
 * GeneratePress's typography gives every paragraph a bottom margin, which was
 * stacking on top of the row-gap and leaving roughly 75px of dead space between
 * a figure and its caption (Tom: "the titles need to be closer to the numbers").
 *
 * Sizes are set here rather than taken from --fs-display / --fs-heading: this
 * band needed to come down further than the site-wide heading scale, and the
 * label has a contrast floor the shared tokens must not be pinned to.
 */
.vim-stat__number {
	font-size: clamp(1.75rem, 1.55rem + 0.8vw, 2.25rem); /* 28 -> 36 */
	color: var(--body-alt);
	line-height: 1.1;
	margin-bottom: 0;
}

/*
 * 🚨 20px ExtraBold, and it must not go below that.
 *
 * The label colours below include --olive, which is 4.00:1 on --sand rather
 * than the 4.5:1 normal text requires. It passes only as *large* text, and the
 * threshold for bold text is 18.66px. At 20px/800 there is margin; at 18px it
 * would fail outright. Do not shrink this or lighten its weight.
 */
.vim-stat__label {
	font-size: 1.25rem;
	font-weight: 800;
	line-height: 1.2;
	margin-bottom: 0;
}

.vim-stat--0 .vim-stat__circle {
	background-color: var(--plum);
}

.vim-stat--0 .vim-stat__label {
	color: var(--plum);
}

.vim-stat--1 .vim-stat__circle {
	background-color: var(--teal-700);
}

.vim-stat--1 .vim-stat__label {
	color: var(--teal-700);
}

.vim-stat--2 .vim-stat__circle {
	background-color: var(--green-600);
}

.vim-stat--2 .vim-stat__label {
	color: var(--green-600);
}

.vim-stat--3 .vim-stat__circle {
	background-color: var(--teal-500);
}

.vim-stat--3 .vim-stat__label {
	color: var(--teal-500);
}

.vim-stat--4 .vim-stat__circle {
	background-color: var(--olive);
}

.vim-stat--4 .vim-stat__label {
	color: var(--olive);
}

/*
 * Below 1024px the band's container becomes a centred flex wrap instead of a
 * grid (set on the block itself), because CSS grid cannot centre an incomplete
 * final row — five items left a ragged 3+2 on tablet and 2+2+1 on mobile, both
 * hanging against the left edge.
 *
 * With the container flexing, the items have to carry their own width. The
 * subtraction is the column gap: three across leaves two 1.5rem gaps, two
 * across leaves one. Keep these in step with the block's `gap` if it changes.
 */
@media (max-width: 1023px) {

	.vim-stat {
		flex: 0 1 calc((100% - 3rem) / 3);
	}
}

@media (max-width: 639px) {

	.vim-stat {
		flex: 0 1 calc((100% - 1.5rem) / 2);
	}
}
