/**
 * Group — inner padding only where a group reads as a surface (ISS-0052).
 *
 * theme.json used to give EVERY core/group the card padding. But <main>, sections and
 * plain wrappers are groups too: on a 390 px phone the paddings stacked (main 32 +
 * section 32 per side) and the text kept 262 px of the screen. A group is not a card.
 *
 * Structural groups now have no padding — the site gutter (styles.spacing.padding,
 * semantic.layout.gutter) keeps text off the screen edges, once. A group with a
 * background or a border colour still reads as a card, so it keeps the card padding,
 * capped on small screens so a Studio "airy" setting does not eat a phone width.
 *
 * Specificity: :where() = 0 — WordPress core gives `.wp-block-group.has-background`
 * its own padding with the same zero specificity; this file loads after it and wins.
 * Any padding set in the editor is an inline style and wins over both.
 */
:where(.wp-block-group.has-background, .wp-block-group.has-border-color) {
	padding: clamp(
		var(--wp--custom--semantic--spacing--base-200),
		5vw,
		var(--wp--custom--semantic--spacing--card--padding)
	);
}

/*
 * Phones: a card laid straight on a coloured page runs edge to edge (ISS-0053).
 *
 * Single training / place templates put one white card on a coloured <main>: on a
 * 390 px screen the text sat at 16 px (page gutter) + 16 px (card padding) = 32 px,
 * out of line with the header at 16 px. When <main> holds nothing but such cards,
 * it drops its own side padding below 600 px: the card spans the screen and its
 * padding becomes the gutter. Any other <main> keeps the gutter.
 */
@media (max-width: 599px) {
	main.wp-block-group.has-background:not(:has(> :not(.wp-block-group.has-background))) {
		padding-inline: 0;
	}
}

/*
 * A card nested in a constrained container keeps its side padding (ISS-0056).
 *
 * Core resets the side padding of a .has-global-padding group nested in another
 * one — `.has-global-padding :where(… > .has-global-padding:not(.alignfull))`,
 * (0,1,0) — to avoid a double gutter. Right for a plain wrapper, wrong for a card:
 * a group with a background or a border laid in a column (the parent-training card
 * of a seminar) lost its side padding and its icon touched the card edge. Such a
 * group keeps the card padding on all sides; an editor padding (inline) still wins.
 */
.wp-block-group.has-global-padding:is(.has-background, .has-border-color):not(.alignfull) {
	padding-inline: clamp(
		var(--wp--custom--semantic--spacing--base-200),
		5vw,
		var(--wp--custom--semantic--spacing--card--padding)
	);
}

/*
 * « Surface » — a group that reads as Apparence's card (`.card`, carte.css) (ISS-0075).
 *
 * The block style reads what Studio publishes for « Cartes des listes » and « Style des surfaces »: the card inset
 * (padding), the surface of elevation 1 mixed at the frame per cent (0 % is « no frame »: transparent, and no padding
 * at all), the card's shadow and border. Nothing applies until an editor picks the style, so sites built before it
 * look as they did. The border is an inset outline, not a box-shadow: `box-shadow` takes either `none` or a list, so
 * « no shadow » and « a hairline » could not share one declaration.
 *
 * Padding is capped on a phone like the card padding above (`min( inset, max( 5vw, 1rem ) )`, which `clamp()` cannot
 * express when the inset is 0: its floor would win).
 */
.wp-block-group.is-style-surface {
	padding: min(
		var(--wp--custom--semantic--list-card--inset),
		max(5vw, var(--wp--custom--semantic--spacing--base-200))
	);
	background-color: color-mix(
		in srgb,
		var(--wp--custom--semantic--elevated--1--surface) var(--wp--custom--semantic--list-card--frame),
		transparent
	);
	color: var(--wp--custom--semantic--elevated--1--on-surface);
	box-shadow: var(--wp--custom--semantic--list-card--shadow);
	outline: 1px solid var(--wp--custom--semantic--list-card--border);
	outline-offset: -1px;
}

/* Core resets the side padding of a constrained group nested in another one: a surface keeps its own. */
.wp-block-group.has-global-padding.is-style-surface:not(.alignfull) {
	padding-inline: min(
		var(--wp--custom--semantic--list-card--inset),
		max(5vw, var(--wp--custom--semantic--spacing--base-200))
	);
}
