/**
 * Core Group block: card, band and callout styles (inc/block-styles.php).
 *
 * Loaded only on pages that use a Group block, and in the editor.
 * Tokens come from assets/css/base.css (--pfa-*). Text and background pairs
 * are the "Allowed" pairs in ux-journey.md 0.3 only:
 *   card            Royal Sapphire on Arctic White      10.98:1
 *   card-sapphire   Arctic White on Royal Sapphire      10.98:1, emphasis Soft Lavender 4.78:1
 *   card-iris       White on Iris Violet                 5.48:1, nothing else on Iris
 *   card-turquoise  Royal Sapphire on Turquoise          6.77:1
 *   card-lavender   Royal Sapphire on Lavender tint      7.53:1 (tint, not Soft Lavender:
 *                   body text on Soft Lavender is only 4.78:1, kept for chips)
 *   band-lavender   Royal Sapphire on Lavender wash      9.06:1, emphasis Iris 700 5.89:1
 *                   (Iris on the wash is 4.37:1 and fails)
 *
 * Surfaces nest (a white card inside a Royal Sapphire band), so each surface
 * sets custom properties and the nearest one wins:
 *   --pfa-focus        focus ring colour
 *   --pfa-em           italic emphasis colour in H1 and H2 (UX D19)
 *   --pfa-btn-bg, --pfa-btn-fg, --pfa-btn-bg-hover, --pfa-btn-tile,
 *   --pfa-btn-arrow    primary button colours (core-button.css reads them)
 *   --pfa-rule         hairline colour (separators, table lines)
 *   --pfa-bullet       soft bullet colour (core-list.css)
 * base.css sets the same values on the same surfaces, plus --pfa-text,
 * --pfa-text-muted, --pfa-link and --pfa-link-hover (lane T1a).
 * Any other dark surface (footer, plugin cards) can set the same properties.
 *
 * Flat bento cards: no shadows (contract 3.3). A transparent border keeps
 * every card's edge visible in Windows high contrast (forced colours).
 */

/* -------------------------------------------------------------------------
 * Surface properties
 * ---------------------------------------------------------------------- */

/* Light surfaces: Royal Sapphire text and buttons. */
.wp-block-group:is(
	.is-style-card,
	.is-style-card-turquoise,
	.is-style-card-lavender,
	.is-style-band-lavender,
	.is-style-band-canvas,
	.is-style-callout-note,
	.is-style-callout-important,
	.is-style-callout-medication
) {
	--pfa-focus: var(--pfa-sapphire);
	--pfa-em: var(--pfa-iris);
	--pfa-btn-bg: var(--pfa-sapphire);
	--pfa-btn-fg: var(--pfa-arctic);
	--pfa-btn-bg-hover: var(--pfa-sapphire-700);
	--pfa-btn-tile: var(--pfa-arctic);
	--pfa-btn-arrow: var(--pfa-sapphire);
	--pfa-rule: var(--pfa-border);
	--pfa-bullet: var(--pfa-iris);
}

/* Iris on Turquoise, Lavender tint and the wash fails: emphasis keeps the text colour. */
.wp-block-group:is(.is-style-card-turquoise, .is-style-card-lavender, .is-style-callout-note) {
	--pfa-em: currentColor;
}

.wp-block-group.is-style-card-turquoise {
	--pfa-bullet: var(--pfa-sapphire);
}

.wp-block-group.is-style-band-lavender {
	--pfa-em: var(--pfa-iris-700);
}

/* Dark surfaces: Arctic White text, light buttons, Turquoise focus. */
.wp-block-group:is(.is-style-card-sapphire, .is-style-band-sapphire),
:is(
	.has-sapphire-background-color,
	.has-sapphire-700-background-color,
	.has-navy-background-color
) {
	--pfa-focus: var(--pfa-turquoise);
	--pfa-em: var(--pfa-lavender);
	--pfa-btn-bg: var(--pfa-arctic);
	--pfa-btn-fg: var(--pfa-sapphire);
	--pfa-btn-bg-hover: var(--pfa-lavender-tint);
	--pfa-btn-tile: var(--pfa-sapphire);
	--pfa-btn-arrow: var(--pfa-arctic);
	--pfa-rule: color-mix(in srgb, var(--pfa-arctic) 28%, transparent);
	--pfa-bullet: var(--pfa-lavender);
}

/* Iris Violet: only white or Arctic White on it (contract 3.1). */
.wp-block-group.is-style-card-iris,
:is(.has-iris-background-color, .has-iris-700-background-color) {
	--pfa-focus: var(--pfa-arctic);
	--pfa-em: currentColor;
	--pfa-btn-bg: var(--pfa-arctic);
	--pfa-btn-fg: var(--pfa-sapphire);
	--pfa-btn-bg-hover: var(--pfa-lavender-tint);
	--pfa-btn-tile: var(--pfa-sapphire);
	--pfa-btn-arrow: var(--pfa-arctic);
	--pfa-rule: color-mix(in srgb, var(--pfa-white) 32%, transparent);
	--pfa-bullet: var(--pfa-white);
}

/* -------------------------------------------------------------------------
 * Cards (B3)
 * ---------------------------------------------------------------------- */

.wp-block-group:is(
	.is-style-card,
	.is-style-card-sapphire,
	.is-style-card-iris,
	.is-style-card-turquoise,
	.is-style-card-lavender
) {
	box-sizing: border-box;
	padding: var(--pfa-space-5);
	border: 1px solid transparent;
	border-radius: var(--pfa-radius-card);
}

.wp-block-group:is(
	.is-style-card,
	.is-style-card-sapphire,
	.is-style-card-iris,
	.is-style-card-turquoise,
	.is-style-card-lavender,
	.is-style-callout-note,
	.is-style-callout-important,
	.is-style-callout-medication
) > :first-child {
	margin-block-start: 0;
}

.wp-block-group:is(
	.is-style-card,
	.is-style-card-sapphire,
	.is-style-card-iris,
	.is-style-card-turquoise,
	.is-style-card-lavender,
	.is-style-callout-note,
	.is-style-callout-important,
	.is-style-callout-medication
) > :last-child {
	margin-block-end: 0;
}

.wp-block-group.is-style-card {
	background-color: var(--pfa-arctic);
	color: var(--pfa-ink);
}

.wp-block-group.is-style-card-sapphire {
	background-color: var(--pfa-sapphire);
	color: var(--pfa-arctic);
}

.wp-block-group.is-style-card-iris {
	background-color: var(--pfa-iris);
	color: var(--pfa-white);
}

.wp-block-group.is-style-card-turquoise {
	background-color: var(--pfa-turquoise);
	color: var(--pfa-sapphire);
}

.wp-block-group.is-style-card-lavender {
	background-color: var(--pfa-lavender-tint);
	color: var(--pfa-sapphire);
}

@media (min-width: 768px) {
	.wp-block-group:is(
		.is-style-card,
		.is-style-card-sapphire,
		.is-style-card-iris,
		.is-style-card-turquoise,
		.is-style-card-lavender
	) {
		padding: var(--pfa-space-6);
	}
}

/* -------------------------------------------------------------------------
 * Bands: full-width sections (B2)
 * ---------------------------------------------------------------------- */

.wp-block-group:is(.is-style-band-sapphire, .is-style-band-lavender, .is-style-band-canvas) {
	box-sizing: border-box;
	padding-block: var(--pfa-section-y);
}

/*
 * Full-width bands span the window up to --pfa-max (1440px), then sit
 * centred as one large rounded card on very wide screens. Below 1440px the
 * margin works out to minus the page gutter, as core's alignfull rule does.
 */
.has-global-padding > .wp-block-group.alignfull:is(.is-style-band-sapphire, .is-style-band-lavender, .is-style-band-canvas) {
	margin-inline: calc((100% - min(100% + var(--wp--style--root--padding-left, 0px) + var(--wp--style--root--padding-right, 0px), var(--pfa-max))) / 2);
}

@media (min-width: 1500px) {
	.has-global-padding > .wp-block-group.alignfull:is(.is-style-band-sapphire, .is-style-band-lavender, .is-style-band-canvas) {
		border-radius: var(--pfa-radius-card);
	}
}

/* A band used inside the content column becomes a rounded panel. */
.wp-block-group:not(.alignfull):is(.is-style-band-sapphire, .is-style-band-lavender, .is-style-band-canvas) {
	padding: var(--pfa-space-7) var(--pfa-space-5);
	border: 1px solid transparent;
	border-radius: var(--pfa-radius-card);
}

@media (min-width: 768px) {
	.wp-block-group:not(.alignfull):is(.is-style-band-sapphire, .is-style-band-lavender, .is-style-band-canvas) {
		padding: var(--pfa-space-8) var(--pfa-space-7);
	}
}

.wp-block-group.is-style-band-sapphire {
	background-color: var(--pfa-sapphire);
	color: var(--pfa-arctic);
}

.wp-block-group.is-style-band-lavender {
	background-color: var(--pfa-lavender-wash);
	color: var(--pfa-sapphire);
}

.wp-block-group.is-style-band-canvas {
	background-color: var(--pfa-canvas);
	color: var(--pfa-ink);
}

/* -------------------------------------------------------------------------
 * Headings, emphasis and links on every surface
 * ---------------------------------------------------------------------- */

/* Heading blocks take the surface's text colour (the nearest surface wins). */
.wp-block-group[class*="is-style-"] :is(h1, h2, h3, h4, h5, h6).wp-block-heading {
	color: inherit;
}

/*
 * Emphasis (--pfa-em), links (--pfa-link, --pfa-link-hover) and the focus
 * ring (--pfa-focus) are drawn by base.css and theme.json from the surface
 * properties above, so they follow the nearest surface automatically.
 */

/* -------------------------------------------------------------------------
 * Callouts: note, important, medication
 * The coloured rule is an inset shadow so it follows the rounded corner; the
 * transparent border shows the box in forced colours.
 * ---------------------------------------------------------------------- */

.wp-block-group:is(.is-style-callout-note, .is-style-callout-important, .is-style-callout-medication) {
	box-sizing: border-box;
	padding: var(--pfa-space-5) var(--pfa-space-5) var(--pfa-space-5) calc(var(--pfa-space-5) + 4px);
	border: 1px solid transparent;
	border-radius: var(--pfa-radius-inner);
	color: var(--pfa-ink);
}

.wp-block-group.is-style-callout-note {
	background-color: var(--pfa-lavender-wash);
	box-shadow: inset 4px 0 0 var(--pfa-iris);
	color: var(--pfa-sapphire);
}

.wp-block-group.is-style-callout-important {
	background-color: var(--pfa-arctic);
	box-shadow: inset 6px 0 0 var(--pfa-sapphire);
}

.wp-block-group.is-style-callout-medication {
	background-color: var(--pfa-arctic);
	border-color: var(--pfa-lavender-tint);
	box-shadow: inset 4px 0 0 var(--pfa-iris);
}

.wp-block-group:is(.is-style-callout-note, .is-style-callout-important, .is-style-callout-medication) :is(h2, h3, h4) {
	font-size: var(--pfa-fs-h4);
	line-height: 1.3;
}

.wp-block-group.is-style-callout-important :is(h2, h3, h4) {
	font-weight: 700;
}

@media (min-width: 768px) {
	.wp-block-group:is(.is-style-callout-note, .is-style-callout-important, .is-style-callout-medication) {
		padding: var(--pfa-space-6) var(--pfa-space-6) var(--pfa-space-6) calc(var(--pfa-space-6) + 4px);
	}
}

/* -------------------------------------------------------------------------
 * No-CTA zones (UX D13): no button may show inside a medication section.
 * Patterns add "pfa-no-cta-zone" alongside the medication callout style.
 * On the site the buttons are hidden; in the editor they stay visible with a
 * dashed outline so the editor can see and remove them.
 * ---------------------------------------------------------------------- */

.pfa-no-cta-zone .wp-block-buttons,
.pfa-no-cta-zone .pfa-cta,
.is-style-callout-medication .wp-block-buttons,
.is-style-callout-medication .pfa-cta,
[data-pfa-no-cta-zone] .wp-block-buttons,
[data-pfa-no-cta-zone] .pfa-cta {
	display: none;
}

.editor-styles-wrapper .pfa-no-cta-zone .wp-block-buttons,
.editor-styles-wrapper .is-style-callout-medication .wp-block-buttons {
	display: flex;
	outline: 2px dashed var(--pfa-error);
	outline-offset: 4px;
}

.editor-styles-wrapper .pfa-no-cta-zone .pfa-cta,
.editor-styles-wrapper .is-style-callout-medication .pfa-cta {
	display: inline-flex;
	outline: 2px dashed var(--pfa-error);
	outline-offset: 4px;
}

/* -------------------------------------------------------------------------
 * Forced colours: keep edges and rules visible.
 * ---------------------------------------------------------------------- */

@media (forced-colors: active) {
	.wp-block-group:is(
		.is-style-card,
		.is-style-card-sapphire,
		.is-style-card-iris,
		.is-style-card-turquoise,
		.is-style-card-lavender,
		.is-style-callout-note,
		.is-style-callout-important,
		.is-style-callout-medication
	) {
		border-color: CanvasText;
	}

	.wp-block-group:is(.is-style-callout-note, .is-style-callout-important, .is-style-callout-medication) {
		border-inline-start-width: 4px;
	}
}
