/**
 * Contextes de couleur (ISS-0037).
 *
 * Un style de fond — section ou callout « Inversé », section « Surface » ou
 * « Atténuée » — n'est pas qu'un fond : tout ce qu'il contient doit être lisible
 * dessus. Titres, liens et boutons lisent des jetons globaux
 * (theme.json : elements.heading → semantic.text.primary, elements.link →
 * semantic.text.link, elements.button → semantic.action.primary.*) qui ignoraient
 * le fond : titre presque noir et bouton rouge de marque sur brun foncé (monmat).
 *
 * Plutôt qu'une règle par élément, le contexte REDÉFINIT ces jetons : les
 * propriétés personnalisées s'héritent, et chaque descendant — titre, lien,
 * icône en currentColor, bouton — les relit avec la valeur du contexte. Les
 * valeurs viennent de settings.custom.zone.{inverse,surface,muted} : sûres dans
 * le thème seul, ajustées à la marque et vérifiées par Studio.
 */

/* ── Inversé ─────────────────────────────────────────────────────────────── */
.wp-block-tc-section.is-style-inverse,
.wp-block-jetstream-callout.is-style-inverse {
	--wp--custom--semantic--text--primary: var(--wp--custom--zone--inverse--heading);
	--wp--custom--semantic--text--secondary: var(--wp--custom--zone--inverse--muted);
	--wp--custom--semantic--text--muted: var(--wp--custom--zone--inverse--muted);
	--wp--custom--semantic--text--link: var(--wp--custom--zone--inverse--link);
	--wp--custom--semantic--text--brand: var(--wp--custom--zone--inverse--link);
	--wp--custom--semantic--action--primary--surface: var(--wp--custom--zone--inverse--action--surface);
	--wp--custom--semantic--action--primary--text: var(--wp--custom--zone--inverse--action--on-surface);
	--wp--custom--semantic--action--primary--hover: var(--wp--custom--zone--inverse--action--hover);
	--wp--custom--semantic--action--primary--active: var(--wp--custom--zone--inverse--action--hover);
	--wp--custom--semantic--action--primary--border-color: var(--wp--custom--zone--inverse--action--surface);
	color: var(--wp--custom--zone--inverse--on-surface);
}

/* ── Surface et Atténué (sections) ───────────────────────────────────────── */
/* Gris clairs en mode clair, surfaces sombres en mode sombre (rampes « mode »). */
.wp-block-tc-section.is-style-surface {
	--wp--custom--semantic--text--primary: var(--wp--custom--zone--surface--heading);
	--wp--custom--semantic--text--secondary: var(--wp--custom--zone--surface--muted);
	--wp--custom--semantic--text--link: var(--wp--custom--zone--surface--link);
	--wp--custom--semantic--text--brand: var(--wp--custom--zone--surface--link);
	--wp--custom--semantic--action--primary--surface: var(--wp--custom--zone--surface--action--surface);
	--wp--custom--semantic--action--primary--text: var(--wp--custom--zone--surface--action--on-surface);
	--wp--custom--semantic--action--primary--hover: var(--wp--custom--zone--surface--action--hover);
	--wp--custom--semantic--action--primary--active: var(--wp--custom--zone--surface--action--hover);
	--wp--custom--semantic--action--primary--border-color: var(--wp--custom--zone--surface--action--surface);
	color: var(--wp--custom--zone--surface--on-surface);
}

.wp-block-tc-section.is-style-muted {
	--wp--custom--semantic--text--primary: var(--wp--custom--zone--muted--heading);
	--wp--custom--semantic--text--secondary: var(--wp--custom--zone--muted--muted);
	--wp--custom--semantic--text--link: var(--wp--custom--zone--muted--link);
	--wp--custom--semantic--text--brand: var(--wp--custom--zone--muted--link);
	--wp--custom--semantic--action--primary--surface: var(--wp--custom--zone--muted--action--surface);
	--wp--custom--semantic--action--primary--text: var(--wp--custom--zone--muted--action--on-surface);
	--wp--custom--semantic--action--primary--hover: var(--wp--custom--zone--muted--action--hover);
	--wp--custom--semantic--action--primary--active: var(--wp--custom--zone--muted--action--hover);
	--wp--custom--semantic--action--primary--border-color: var(--wp--custom--zone--muted--action--surface);
	color: var(--wp--custom--zone--muted--on-surface);
}

/*
 * Bouton « Contour » dans un contexte : le texte et la bordure suivent la
 * couleur du contexte, jamais la marque brute. Par ses jetons (ISS-0048), et
 * non par une règle de couleur : une couleur choisie sur le bouton
 * (button-tones.css) les redéfinit plus près et reste maîtresse.
 */
:is(.wp-block-tc-section, .wp-block-jetstream-callout):is(.is-style-inverse, .is-style-surface, .is-style-muted) {
	--wp--custom--semantic--action--secondary--text: var(--wp--custom--semantic--text--primary);
	--wp--custom--semantic--action--secondary--border-color: var(--wp--custom--semantic--text--primary);
}

/*
 * Titres dans un contexte (ISS-0042) : la couleur du contexte, même quand
 * Styles → Éléments → H1…H6 leur en donne une autre. Ce réglage (ISS-0040)
 * pose une couleur de PALETTE — `h2 { color: var(--wp--preset--color--primary) }`
 * — que le contexte ne redéfinit pas : titre #312782 sur fond inversé (monmat).
 *
 * Restent maîtres d'eux-mêmes : un titre coloré à la main (`.has-text-color`),
 * choix explicite sur ce bloc, et le style Display, qui suit déjà le contexte
 * par ses propres jetons (heading-display.css).
 */
:is(.wp-block-tc-section, .wp-block-jetstream-callout):is(.is-style-inverse, .is-style-surface, .is-style-muted)
	:is(h1, h2, h3, h4, h5, h6):not(.has-text-color):not(.is-style-display) {
	color: var(--wp--custom--semantic--text--primary);
}
