/*
 * Styles of the allowed blocks, loaded on the site and in the editor.
 * Content selectors target .entry-content on the site and .is-root-container in the editor.
 */

/* Flow */

/* A long URL written as link text breaks instead of widening the page on mobile. */
:is(.entry-content, .is-root-container) {
	overflow-wrap: break-word;
}

:is(.entry-content, .is-root-container) > * {
	margin-block: 0;
}

:is(.entry-content, .is-root-container) > * + * {
	margin-block-start: var(--wp--preset--spacing--m);
}

:is(.entry-content, .is-root-container) > h2 {
	margin-block-start: var(--wp--preset--spacing--xl);
}

:is(.entry-content, .is-root-container) > :is(h3, h4, h5, h6) {
	margin-block-start: var(--wp--preset--spacing--l);
}

:is(.entry-content, .is-root-container) > h2 + * {
	margin-block-start: var(--wp--preset--spacing--m);
}

:is(.entry-content, .is-root-container) > :is(h3, h4, h5, h6) + * {
	margin-block-start: var(--wp--preset--spacing--s);
}

:is(.entry-content, .is-root-container) > .wp-block-separator {
	margin-block: var(--wp--preset--spacing--xl);
}

:is(.entry-content, .is-root-container) > :first-child {
	margin-block-start: 0;
}

/*
 * The constrained layout centres every block with "margin-inline: auto !important",
 * so text keeps the column width and its left edge, and limits its measure with an end padding.
 * The editor does not load main.css: box-sizing must be set here.
 */
:is(.entry-content, .is-root-container)
	> :is(p, ul, ol, blockquote):not(
		.alignwide,
		.alignfull,
		.has-text-align-center,
		.has-text-align-right
	) {
	box-sizing: border-box;
	padding-inline-end: max(0px, min(100%, var(--wp--style--global--content-size)) - 65ch);
}

/* Text */

:is(.entry-content, .is-root-container) :is(p, li) {
	color: var(--wp--custom--color--text-subtle);
	font-size: var(--wp--preset--font-size--body-m);
	line-height: var(--wp--custom--line-height--body-m-relaxed);
}

:is(.entry-content, .is-root-container) a:where(:not(.wp-element-button)) {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

:is(.entry-content, .is-root-container) a:where(:not(.wp-element-button)):hover {
	text-decoration-thickness: 2px;
}

/* Lists */

:is(.entry-content, .is-root-container) ul {
	list-style: square;
}

:is(.entry-content, .is-root-container) ol {
	list-style: decimal;
}

:is(.entry-content, .is-root-container) :is(ul, ol) {
	padding-inline-start: 1.25em;
}

:is(.entry-content, .is-root-container) li::marker {
	color: var(--wp--preset--color--accent-default);
}

:is(.entry-content, .is-root-container) li + li,
:is(.entry-content, .is-root-container) li > :is(ul, ol) {
	margin-block-start: var(--wp--preset--spacing--xs);
}

:is(.entry-content, .is-root-container) li > :is(ul, ol) {
	margin-block-end: 0;
}

/* Quote */

.wp-block-quote {
	margin-inline: 0;
	padding-inline-start: var(--wp--preset--spacing--m);
	border-inline-start: 4px solid var(--wp--preset--color--accent-default);
}

:is(.entry-content, .is-root-container) .wp-block-quote p {
	margin: 0;
	color: var(--wp--custom--color--text-default);
	font-size: var(--wp--preset--font-size--heading-5);
	font-weight: 800;
	line-height: var(--wp--custom--line-height--heading-5);
	letter-spacing: var(--wp--custom--letter-spacing--heading-5);
}

:is(.entry-content, .is-root-container) .wp-block-quote p + p {
	margin-block-start: var(--wp--preset--spacing--s);
}

.wp-block-quote cite {
	display: block;
	margin-block-start: var(--wp--preset--spacing--s);
	color: var(--wp--custom--color--text-muted);
	font-family: var(--wp--preset--font-family--secondary);
	font-size: var(--wp--preset--font-size--mono-s);
	font-style: normal;
	font-weight: 500;
	line-height: var(--wp--custom--line-height--mono);
	letter-spacing: var(--wp--custom--letter-spacing--mono-s);
}

/*
 * Testimonial style of the quote: a card, the client logo on the left, the text at body size.
 * The logo is an optional image block, first child of the quote. The citation reads
 * "Position, Company<br><strong>Name</strong>": a line of small capitals, then the name in bold.
 */

:is(.entry-content, .is-root-container) .wp-block-quote.is-style-testimonial {
	--tendra-rb-testimonial-padding: var(--wp--preset--spacing--l);
	--tendra-rb-testimonial-logo-width: 10rem;
	--tendra-rb-testimonial-logo-height: var(--wp--preset--spacing--2-xl);
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: center;
	box-sizing: border-box;
	padding: var(--tendra-rb-testimonial-padding);
	border: 0;
	background-color: var(--wp--preset--color--surface-card);
}

/* Decorative: the alternative text after the slash is empty, screen readers skip the mark. */
:is(.entry-content, .is-root-container) .wp-block-quote.is-style-testimonial::before {
	content: "\201C";
	content: "\201C" / "";
	display: block;
	height: 0.45em;
	margin-block-end: var(--wp--preset--spacing--m);
	color: var(--wp--preset--color--accent-default);
	font-family: var(--wp--preset--font-family--primary);
	font-size: var(--wp--preset--font-size--heading-1);
	font-weight: 900;
	line-height: 1;
}

/* The logo sits in a column of its own, the height of the card leaves room for it. */
:is(.entry-content, .is-root-container)
	.wp-block-quote.is-style-testimonial:has(> .wp-block-image:first-child) {
	min-height: calc(
		var(--tendra-rb-testimonial-logo-height) + 2 * var(--tendra-rb-testimonial-padding)
	);
	padding-inline-start: calc(
		2 * var(--tendra-rb-testimonial-padding) + var(--tendra-rb-testimonial-logo-width)
	);
}

:is(.entry-content, .is-root-container)
	.wp-block-quote.is-style-testimonial
	> .wp-block-image:first-child {
	position: absolute;
	inset-block-start: 50%;
	inset-inline-start: var(--tendra-rb-testimonial-padding);
	width: var(--tendra-rb-testimonial-logo-width);
	margin: 0;
	translate: 0 -50%;
}

:is(.entry-content, .is-root-container)
	.wp-block-quote.is-style-testimonial
	> .wp-block-image:first-child
	img {
	width: 100%;
	height: var(--tendra-rb-testimonial-logo-height);
	object-fit: contain;
	object-position: left center;
}

/* An image in the Rounded style of the block library is a portrait, not a logo: a disc as wide as the logo column. */
:is(.entry-content, .is-root-container)
	.wp-block-quote.is-style-testimonial:has(> .wp-block-image.is-style-rounded:first-child) {
	--tendra-rb-testimonial-logo-height: var(--tendra-rb-testimonial-logo-width);
}

:is(.entry-content, .is-root-container)
	.wp-block-quote.is-style-testimonial
	> .wp-block-image.is-style-rounded:first-child
	img {
	border-radius: 50%;
	object-fit: cover;
	object-position: center;
}

:is(.entry-content, .is-root-container) .wp-block-quote.is-style-testimonial p {
	color: var(--wp--custom--color--text-default);
	font-size: var(--wp--preset--font-size--body-l);
	font-weight: 400;
	line-height: var(--wp--custom--line-height--body-l);
	letter-spacing: normal;
}

:is(.entry-content, .is-root-container) .wp-block-quote.is-style-testimonial cite {
	margin-block-start: var(--wp--preset--spacing--m);
	color: var(--wp--custom--color--text-muted);
	line-height: 1.6;
	text-transform: uppercase;
}

:is(.entry-content, .is-root-container) .wp-block-quote.is-style-testimonial cite strong {
	color: var(--wp--custom--color--text-default);
	font-family: var(--wp--preset--font-family--primary);
	font-size: var(--wp--preset--font-size--heading-5);
	font-weight: 800;
	line-height: var(--wp--custom--line-height--heading-5);
	letter-spacing: var(--wp--custom--letter-spacing--heading-5);
	text-transform: none;
}

/* On a phone, the logo goes above the text, and a card of the carousel reads from its top. */
@media (width < 48rem) {
	:is(.entry-content, .is-root-container) .wp-block-quote.is-style-testimonial {
		--tendra-rb-testimonial-padding: var(--wp--preset--spacing--m);
		justify-content: flex-start;
	}

	:is(.entry-content, .is-root-container)
		.wp-block-quote.is-style-testimonial:has(> .wp-block-image:first-child) {
		min-height: 0;
		padding-inline-start: var(--tendra-rb-testimonial-padding);
	}

	/* Above the text, a smaller portrait leaves the words in view. */
	:is(.entry-content, .is-root-container)
		.wp-block-quote.is-style-testimonial:has(> .wp-block-image.is-style-rounded:first-child) {
		--tendra-rb-testimonial-logo-width: 6rem;
	}

	:is(.entry-content, .is-root-container)
		.wp-block-quote.is-style-testimonial
		> .wp-block-image:first-child {
		position: static;
		order: -1;
		margin-block-end: var(--wp--preset--spacing--m);
		translate: none;
	}
}

/*
 * Carousel of testimonials, built by assets/js/testimonials.js from two or more testimonials
 * that follow one another. One testimonial at a time, no automatic rotation.
 * Without JavaScript, the cards stay stacked.
 */

/* In the wide carousel, the logo gets a wider column and the text keeps a reading measure. */
@media (width >= 64rem) {
	.tendra-rb-testimonials .wp-block-quote.is-style-testimonial {
		--tendra-rb-testimonial-padding: var(--wp--preset--spacing--xl);
		--tendra-rb-testimonial-logo-width: 14rem;
	}

	.tendra-rb-testimonials .wp-block-quote.is-style-testimonial > :not(.wp-block-image) {
		max-width: 46rem;
	}
}

/* The script sets the height of the track to the card shown: taller cards beside it are clipped. */
.tendra-rb-testimonials__track {
	position: relative;
	display: flex;
	align-items: flex-start;
	gap: var(--wp--preset--spacing--m);
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}

.tendra-rb-testimonials__track::-webkit-scrollbar {
	display: none;
}

@media (prefers-reduced-motion: no-preference) {
	.tendra-rb-testimonials__track {
		scroll-behavior: smooth;
		transition: height 0.3s ease;
	}
}

.tendra-rb-testimonials__track:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent-default);
	outline-offset: 2px;
}

/* Each card keeps the height of its own text: a short testimonial leaves no empty space. */
.tendra-rb-testimonials__slide {
	display: flex;
	flex: 0 0 100%;
	scroll-snap-align: start;
	scroll-snap-stop: always;
}

.tendra-rb-testimonials__slide > .wp-block-quote {
	flex: 1;
	margin: 0;
}

.tendra-rb-testimonials__controls {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--s);
	margin-block-end: var(--wp--preset--spacing--m);
}

.tendra-rb-testimonials__button {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	padding: 0;
	border: 1px solid var(--wp--custom--color--border-inverse);
	border-radius: 0;
	background-color: transparent;
	color: var(--wp--custom--color--text-default);
	cursor: pointer;
}

.tendra-rb-testimonials__button::before {
	content: "";
	width: 1rem;
	height: 1rem;
	background-color: currentColor;
	mask: url("../icons/arrow-right.svg") center / contain no-repeat;
}

.tendra-rb-testimonials__button--previous::before {
	scale: -1 1;
}

.tendra-rb-testimonials__button:hover {
	border-color: var(--wp--preset--color--accent-default);
}

.tendra-rb-testimonials__button:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent-default);
	outline-offset: 2px;
}

.tendra-rb-testimonials__button[aria-disabled="true"] {
	border-color: var(--wp--custom--color--surface-card-subtle);
	color: var(--wp--custom--color--text-on-image-muted);
	cursor: default;
}

.tendra-rb-testimonials__status {
	min-width: 5ch;
	color: var(--wp--custom--color--text-muted);
	font-family: var(--wp--preset--font-family--secondary);
	font-size: var(--wp--preset--font-size--mono-m);
	font-weight: 500;
	font-variant-numeric: tabular-nums;
	line-height: var(--wp--custom--line-height--mono);
	letter-spacing: var(--wp--custom--letter-spacing--mono-m);
	text-align: center;
}

/* Image */

.wp-block-image img {
	border-radius: 0;
}

/* Images of the former editor sit inside a paragraph, often right after its text. */
.entry-content :is(p, li) > img,
.entry-content :is(p, li) > a > img {
	display: block;
	margin-block: var(--wp--preset--spacing--m);
}

.entry-content :is(p, li) > img + br {
	display: none;
}

.entry-content :is(img, .wp-caption).aligncenter {
	margin-inline: auto;
}

.entry-content :is(img, .wp-caption).alignleft {
	float: left;
	margin-inline: 0 var(--wp--preset--spacing--m);
}

.entry-content :is(img, .wp-caption).alignright {
	float: right;
	margin-inline: var(--wp--preset--spacing--m) 0;
}

/* The former editor gives a captioned image an inline width, that of the full-size image. */
.entry-content .wp-caption {
	max-width: 100%;
	margin-inline: 0;
}

/*
 * An aligned image block never exceeds the column. The block library draws it as a table, which ignores
 * max-width while the image is not loaded: the image keeps the width of its attribute, and the page
 * scrolls sideways. A box as wide as its image does the same job, and its caption wraps at the image width.
 */
.entry-content .wp-block-image:is(.aligncenter, .alignleft, .alignright),
.entry-content .wp-block-image > :is(.aligncenter, .alignleft, .alignright) {
	display: block;
	width: fit-content;
	max-width: 100%;
}

.entry-content .wp-block-image:is(.aligncenter, .alignleft, .alignright) > figcaption,
.entry-content .wp-block-image > :is(.aligncenter, .alignleft, .alignright) > figcaption {
	display: block;
	contain: inline-size;
}

/* On a phone, the text beside a floated image would be a few words wide. */
@media (width < 37.5rem) {
	.entry-content :is(img, figure, div):is(.alignleft, .alignright) {
		float: none;
		margin-inline: 0;
	}
}

/* The mono line height of 1 suits one-line labels, not captions that wrap. */
.wp-block-image .wp-element-caption,
.wp-block-table .wp-element-caption,
.entry-content .wp-block-image > figure > figcaption,
.entry-content .wp-caption-text {
	margin-block: var(--wp--preset--spacing--xs) 0;
	color: var(--wp--custom--color--text-muted);
	font-family: var(--wp--preset--font-family--secondary);
	font-size: var(--wp--preset--font-size--mono-s);
	font-weight: 500;
	line-height: 1.5;
	letter-spacing: var(--wp--custom--letter-spacing--mono-s);
	text-align: start;
}

.wp-block-image.alignfull .wp-element-caption {
	padding-inline: var(--wp--style--root--padding-left) var(--wp--style--root--padding-right);
}

/*
 * Gallery. The block library lays it out: two columns on a phone, the chosen number from 600 px.
 * The theme sets the gap and the captions.
 */

.wp-block-gallery {
	--wp--style--gallery-gap-default: var(--wp--preset--spacing--s);
}

/* A caption lies on the bottom of its photo, as in the block library. Shading keeps the white text readable. */
.wp-block-gallery.has-nested-images figure.wp-block-image .wp-element-caption {
	margin: 0;
	padding: var(--wp--preset--spacing--l) var(--wp--preset--spacing--xs)
		var(--wp--preset--spacing--xs);
	scrollbar-gutter: auto;
	background: linear-gradient(
		to top,
		color-mix(in srgb, var(--wp--preset--color--background-default) 85%, transparent),
		transparent
	);
	color: var(--wp--custom--color--text-on-image);
	font-size: var(--wp--preset--font-size--mono-s);
	text-align: start;
	text-shadow: none;
}

:is(.entry-content, .is-root-container)
	.wp-block-gallery.has-nested-images
	figure.wp-block-image:has(figcaption)::before {
	content: none;
}

/*
 * A photo alone on the last row keeps the width of a column. When the gallery crops its images,
 * every thumbnail has the same format: the block library would stretch a row to its tallest photo,
 * and crop the landscape ones beside it into portraits.
 */
:is(.entry-content, .is-root-container)
	.wp-block-gallery.has-nested-images:not(.is-style-logos)
	figure.wp-block-image:not(#individual-image) {
	flex-grow: 0;
}

:is(.entry-content, .is-root-container)
	.wp-block-gallery.has-nested-images.is-cropped:not(.is-style-logos)
	figure.wp-block-image:not(#individual-image) {
	align-self: flex-start;
}

:is(.entry-content, .is-root-container)
	.wp-block-gallery.has-nested-images.is-cropped:not(.is-style-logos)
	figure.wp-block-image:not(#individual-image)
	:is(a, img) {
	flex: none;
	height: auto;
}

:is(.entry-content, .is-root-container)
	.wp-block-gallery.has-nested-images.is-cropped:not(.is-style-logos)
	figure.wp-block-image:not(#individual-image)
	img {
	aspect-ratio: 4 / 3;
}

.wp-block-gallery.has-nested-images > .wp-element-caption {
	margin-block: var(--wp--preset--spacing--xs) 0;
	color: var(--wp--custom--color--text-muted);
	font-family: var(--wp--preset--font-family--secondary);
	font-size: var(--wp--preset--font-size--mono-s);
	font-weight: 500;
	line-height: 1.5;
	letter-spacing: var(--wp--custom--letter-spacing--mono-s);
	text-align: start;
}

/*
 * Logos style: every logo whole, in the same height, centred on as many rows as it takes.
 * The columns setting has no effect. The block library may load after the theme, and its column
 * widths and cropping carry an id: these selectors outweigh them.
 */

:is(.entry-content, .is-root-container) .wp-block-gallery.has-nested-images.is-style-logos {
	--tendra-rb-logo-height: var(--wp--preset--spacing--2-xl);
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: var(--wp--preset--spacing--l) var(--wp--preset--spacing--xl);
}

/* On a phone, two logos share a row even when one of them is a wide one. */
@media (width < 48rem) {
	:is(.entry-content, .is-root-container) .wp-block-gallery.has-nested-images.is-style-logos {
		column-gap: var(--wp--preset--spacing--m);
	}
}

:is(.entry-content, .is-root-container)
	.wp-block-gallery.has-nested-images.is-style-logos
	figure.wp-block-image:not(#individual-image) {
	flex: 0 1 auto;
	width: auto;
	max-width: min(100%, 2.5 * var(--tendra-rb-logo-height));
	margin: 0;
}

:is(.entry-content, .is-root-container)
	.wp-block-gallery.has-nested-images.is-style-logos
	figure.wp-block-image:not(#individual-image)
	> a {
	display: flex;
	flex: none;
	justify-content: center;
	width: auto;
	height: auto;
}

/* Logos keep the colours of their file: certification marks may not be recoloured. */
:is(.entry-content, .is-root-container)
	.wp-block-gallery.has-nested-images.is-style-logos
	figure.wp-block-image:not(#individual-image)
	img {
	flex: none;
	width: auto;
	height: var(--tendra-rb-logo-height);
	object-fit: contain;
}

:is(.entry-content, .is-root-container)
	.wp-block-gallery.has-nested-images.is-style-logos
	figure.wp-block-image:not(#individual-image)
	.wp-element-caption {
	position: static;
	max-height: none;
	margin-block-start: var(--wp--preset--spacing--xs);
	padding: 0;
	overflow: visible;
	background: none;
	color: var(--wp--custom--color--text-muted);
	text-align: center;
}

/*
 * Media and text: the image beside the text, on the left or on the right, stacked on a phone
 * from the block library breakpoint (600 px). Successive blocks alternate as the editor sets them.
 * A gap replaces the inner padding of 8 % on both sides: the text keeps the edge of the column.
 */

:is(.entry-content, .is-root-container) > :not(h2, h3, h4, h5, h6) + .wp-block-media-text,
:is(.entry-content, .is-root-container) > .wp-block-media-text + * {
	margin-block-start: var(--wp--preset--spacing--xl);
}

:is(.entry-content, .is-root-container) .wp-block-media-text > .wp-block-media-text__content {
	padding: 0 0 0 var(--wp--preset--spacing--xl);
}

:is(.entry-content, .is-root-container)
	.wp-block-media-text.has-media-on-the-right
	> .wp-block-media-text__content {
	padding: 0 var(--wp--preset--spacing--xl) 0 0;
}

.wp-block-media-text__content > * {
	margin-block: 0;
}

.wp-block-media-text__content > * + * {
	margin-block-start: var(--wp--preset--spacing--m);
}

.wp-block-media-text__content > :is(h2, h3, h4, h5, h6) + * {
	margin-block-start: var(--wp--preset--spacing--s);
}

.wp-block-media-text__media img {
	border-radius: 0;
}

/* An image narrower than its column (capped by tendra_rb_media_text_image_width()) keeps the outer edge of the block. */
@media (width > 37.5rem) {
	.wp-block-media-text.has-media-on-the-right > .wp-block-media-text__media img {
		margin-inline-start: auto;
	}
}

@media (width <= 37.5rem) {
	:is(.entry-content, .is-root-container)
		.wp-block-media-text.is-stacked-on-mobile
		> .wp-block-media-text__content {
		padding: var(--wp--preset--spacing--m) 0 0;
	}
}

/*
 * Buttons. The former editor saved them as links with the "button" class.
 * The submit buttons of forms, native or from a plugin, look the same.
 */

.wp-block-buttons {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--wp--preset--spacing--s);
}

.wp-block-button .wp-block-button__link,
:is(.entry-content, .is-root-container) a.button,
:is(.entry-content, .is-root-container) :is(input, button)[type="submit"] {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
	padding: 1rem 1.25rem;
	border: 1px solid var(--wp--preset--color--accent-default);
	border-radius: 0;
	background-color: var(--wp--preset--color--accent-default);
	color: var(--wp--custom--color--text-inverse);
	font-family: var(--wp--preset--font-family--secondary);
	font-size: var(--wp--preset--font-size--mono-m);
	font-weight: 500;
	line-height: var(--wp--custom--line-height--mono);
	letter-spacing: var(--wp--custom--letter-spacing--mono-m);
	text-decoration: none;
	text-transform: none;
}

.wp-block-button:not(.is-style-outline) .wp-block-button__link::after,
:is(.entry-content, .is-root-container) a.button::after {
	content: "";
	flex-shrink: 0;
	width: 1rem;
	height: 1rem;
	background-color: currentColor;
	mask: url("../icons/arrow-right.svg") center / contain no-repeat;
}

:is(.entry-content, .is-root-container) :is(input, button)[type="submit"] {
	width: auto;
	margin: 0;
	cursor: pointer;
}

.wp-block-button .wp-block-button__link:hover,
:is(.entry-content, .is-root-container) a.button:hover,
:is(.entry-content, .is-root-container) :is(input, button)[type="submit"]:hover {
	border-color: var(--wp--custom--color--text-default);
	background-color: var(--wp--custom--color--text-default);
}

.wp-block-button.is-style-outline .wp-block-button__link {
	border-color: var(--wp--custom--color--border-inverse);
	background-color: transparent;
	color: var(--wp--custom--color--text-default);
}

.wp-block-button.is-style-outline .wp-block-button__link:hover {
	border-color: var(--wp--preset--color--accent-default);
	background-color: transparent;
}

.wp-block-button .wp-block-button__link:focus-visible,
:is(.entry-content, .is-root-container) a.button:focus-visible,
:is(.entry-content, .is-root-container) :is(input, button)[type="submit"]:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent-default);
	outline-offset: 2px;
}

/* Separator */

.wp-block-separator {
	border: 0;
	border-block-start: 1px solid var(--wp--custom--color--surface-card-subtle);
	opacity: 1;
}

.wp-block-separator.is-style-dots {
	color: var(--wp--custom--color--text-muted);
}

/*
 * Table. The former editor saved tables without a header section: their first row is the header,
 * unless a cell of that row holds a list, or a paragraph beside other elements: the table then lays out text.
 * Selectors are more specific than the block library, which can load after this file.
 */

:is(.entry-content, .is-root-container) table {
	width: 100%;
	border-collapse: collapse;
	color: var(--wp--custom--color--text-subtle);
	font-size: var(--wp--preset--font-size--body-xs);
	font-variant-numeric: tabular-nums;
	line-height: var(--wp--custom--line-height--body-xs);
}

:is(.entry-content, .is-root-container) table :is(td, th) {
	padding: 0.75rem var(--wp--preset--spacing--s);
	border: 1px solid var(--wp--custom--color--surface-card-subtle);
	text-align: start;
	vertical-align: top;
}

:is(.entry-content, .is-root-container) table :is(td, th) p {
	margin: 0;
	color: inherit;
	font-size: inherit;
	line-height: inherit;
}

:is(.entry-content, .is-root-container) table :is(td, th) p + p {
	margin-block-start: var(--wp--preset--spacing--xs);
}

:is(.entry-content, .is-root-container)
	:is(
		table th,
		table:not(:has(thead, th))
			> tbody
			> tr:first-child:not(:has(> td :is(ul, ol), > td > :is(p, div):not(:only-child)))
			> td
	) {
	background-color: var(--wp--custom--color--surface-card-subtle);
	color: var(--wp--custom--color--text-muted);
	font-family: var(--wp--preset--font-family--secondary);
	font-size: var(--wp--preset--font-size--mono-m);
	font-weight: 500;
	letter-spacing: var(--wp--custom--letter-spacing--mono-m);
}

/* A column header sits on the bottom line of its row. A row header reads from the top, like the cells beside it. */
:is(.entry-content, .is-root-container)
	:is(
		table th:not([scope="row"]),
		table:not(:has(thead, th))
			> tbody
			> tr:first-child:not(:has(> td :is(ul, ol), > td > :is(p, div):not(:only-child)))
			> td
	) {
	vertical-align: bottom;
}

/* A row header takes the width of its label, and wraps on a phone. A fixed layout keeps the columns of the editor. */
@media (width >= 48rem) {
	:is(.entry-content, .is-root-container) table:not(.has-fixed-layout) th[scope="row"] {
		width: 1%;
		white-space: nowrap;
	}
}

:is(.entry-content, .is-root-container)
	:is(
		table th,
		table:not(:has(thead, th))
			> tbody
			> tr:first-child:not(:has(> td :is(ul, ol), > td > :is(p, div):not(:only-child)))
			> td
	)
	strong {
	font-weight: inherit;
}

:is(.entry-content, .is-root-container) table tfoot {
	color: var(--wp--custom--color--text-default);
	font-weight: 700;
}

:is(.entry-content, .is-root-container) .wp-block-table :is(thead, tfoot) {
	border: 0;
}

:is(.entry-content, .is-root-container) .wp-block-table.is-style-stripes {
	border-bottom-color: var(--wp--custom--color--surface-card-subtle);
}

:is(.entry-content, .is-root-container) .wp-block-table.is-style-stripes tbody tr:nth-child(odd) {
	background-color: var(--wp--preset--color--surface-card);
}

/* The block wraps its table in a scrolling figure, a table of the former editor scrolls itself. */
@media (width < 64rem) {
	.entry-content table:not(.wp-block-table table) {
		display: block;
		overflow-x: auto;
	}
}

/*
 * Forms, native or from a plugin, with no plugin required. Contact Form 7 is covered by its classes.
 * The fields are dark like the page: "color-scheme: dark" makes the browser draw its own parts
 * (select arrow, date picker, checkbox) light on dark.
 */

/* A form may wrap its fields in paragraphs or not: the rhythm does not depend on it. A label sits on its field. */
:is(.entry-content, .is-root-container) :is(form, fieldset) > * {
	margin-block: 0;
}

:is(.entry-content, .is-root-container) :is(form, fieldset) > * + * {
	margin-block-start: var(--wp--preset--spacing--m);
}

:is(.entry-content, .is-root-container) :is(form, fieldset) > label + * {
	margin-block-start: 0;
}

/* Contact Form 7 puts a line break between a label and its field: the empty line would push the label up, towards the field above. */
:is(.entry-content, .is-root-container) form label:not(:has(input, select, textarea)) + br {
	display: none;
}

:is(.entry-content, .is-root-container) :is(label, legend) {
	color: var(--wp--custom--color--text-default);
	font-family: var(--wp--preset--font-family--secondary);
	font-size: var(--wp--preset--font-size--mono-m);
	font-weight: 500;
	line-height: 1.5;
	letter-spacing: var(--wp--custom--letter-spacing--mono-m);
}

:is(.entry-content, .is-root-container) label {
	display: block;
}

:is(.entry-content, .is-root-container)
	:is(
		input:not(
			[type="checkbox"],
			[type="radio"],
			[type="submit"],
			[type="button"],
			[type="reset"],
			[type="image"],
			[type="range"],
			[type="color"],
			[type="hidden"]
		),
		select,
		textarea
	) {
	box-sizing: border-box;
	display: block;
	width: 100%;
	min-height: 3rem;
	margin: var(--wp--preset--spacing--xs) 0 0;
	padding: 0.75rem var(--wp--preset--spacing--s);
	border: 1px solid var(--wp--custom--color--text-muted);
	border-radius: 0;
	background-color: var(--wp--preset--color--surface-card);
	color: var(--wp--custom--color--text-default);
	color-scheme: dark;
	font-family: var(--wp--preset--font-family--primary);
	font-size: var(--wp--preset--font-size--body-m);
	font-weight: 400;
	line-height: var(--wp--custom--line-height--body-m);
	letter-spacing: normal;
	text-transform: none;
}

:is(.entry-content, .is-root-container) textarea {
	min-height: 9rem;
	resize: vertical;
}

/* Dimmer than a typed value, so that a hint is not read as an answer: 5.5:1 on the field. */
:is(.entry-content, .is-root-container) :is(input, textarea)::placeholder {
	color: var(--wp--custom--color--text-on-image-muted);
	opacity: 1;
}

:is(.entry-content, .is-root-container) :is(input, select, textarea):hover:not(:disabled) {
	border-color: var(--wp--custom--color--text-default);
}

:is(.entry-content, .is-root-container) :is(input, select, textarea):focus-visible {
	outline: 2px solid var(--wp--preset--color--accent-default);
	outline-offset: 2px;
}

/* An invalid field gets a thick edge as well as the accent: its state does not rest on colour alone. */
:is(.entry-content, .is-root-container)
	:is(input, select, textarea):is([aria-invalid="true"], :user-invalid, .wpcf7-not-valid) {
	border-color: var(--wp--preset--color--accent-default);
	box-shadow: inset 4px 0 0 var(--wp--preset--color--accent-default);
}

:is(.entry-content, .is-root-container) :is(input, select, textarea, button):disabled {
	cursor: not-allowed;
	opacity: 0.6;
}

:is(.entry-content, .is-root-container) input:is([type="checkbox"], [type="radio"]) {
	flex-shrink: 0;
	width: 1.25rem;
	height: 1.25rem;
	margin: 0.1rem 0 0;
	accent-color: var(--wp--preset--color--accent-default);
	color-scheme: dark;
}

/* A choice reads as text next to its box, in the body font. */
:is(.entry-content, .is-root-container) label:has(> input:is([type="checkbox"], [type="radio"])),
.wpcf7 .wpcf7-list-item {
	display: inline-flex;
	align-items: flex-start;
	gap: var(--wp--preset--spacing--xs);
	margin: 0 var(--wp--preset--spacing--m) 0 0;
	color: var(--wp--custom--color--text-subtle);
	font-family: var(--wp--preset--font-family--primary);
	font-size: var(--wp--preset--font-size--body-xs);
	line-height: var(--wp--custom--line-height--body-xs);
	letter-spacing: normal;
}

.wpcf7 .wpcf7-list-item label {
	margin: 0;
}

:is(.entry-content, .is-root-container) fieldset {
	min-width: 0;
	margin: 0;
	padding: var(--wp--preset--spacing--m);
	border: 1px solid var(--wp--custom--color--surface-card-subtle);
}

:is(.entry-content, .is-root-container) legend {
	padding-inline: var(--wp--preset--spacing--xs);
}

/* Contact Form 7. Its own stylesheet loads first: same specificity, and this file wins. */

.wpcf7 .wpcf7-form-control-wrap {
	display: block;
}

.wpcf7 .wpcf7-not-valid-tip {
	display: block;
	margin-block-start: var(--wp--preset--spacing--xs);
	color: var(--wp--custom--color--text-accent);
	font-size: var(--wp--preset--font-size--body-xs);
	line-height: var(--wp--custom--line-height--body-xs);
}

.wpcf7 form .wpcf7-response-output {
	margin: var(--wp--preset--spacing--m) 0 0;
	padding: var(--wp--preset--spacing--s) var(--wp--preset--spacing--m);
	border: 1px solid var(--wp--custom--color--text-muted);
	color: var(--wp--custom--color--text-default);
	font-size: var(--wp--preset--font-size--body-xs);
	line-height: var(--wp--custom--line-height--body-xs);
}

/* An error differs from the confirmation by its thick edge, not only by its colour. */
.wpcf7
	form:is(.invalid, .unaccepted, .payment-required, .spam, .failed, .aborted)
	.wpcf7-response-output {
	border-color: var(--wp--preset--color--accent-default);
	border-inline-start-width: 4px;
}

.wpcf7 form.sent .wpcf7-response-output {
	border-color: var(--wp--custom--color--text-muted);
}

.wpcf7 .wpcf7-spinner {
	background-color: var(--wp--custom--color--text-muted);
}

.wpcf7 .wpcf7-spinner::before {
	background-color: var(--wp--preset--color--background-default);
}
