/**
 * Stillpoint — shared UI primitives (SPEC §6).
 *
 * Loaded on the front end AND in the editor (add_editor_style), so server-side
 * rendered previews of the custom blocks look exactly like the site. Every module
 * builds its markup from these classes; module stylesheets only add layout.
 *
 * Rules of the house:
 * - Design tokens only (SPEC §5). color-mix() on tokens is used for tints.
 * - Selectors stay simple (mostly one class) so module CSS can refine them.
 * - Works in light and dark presets, in "inverted" sections and with long content.
 * - Motion is gated on `.sp-has-motion` (body) and prefers-reduced-motion.
 *
 * Contents
 *  1. Context tokens (toned sections, islands)
 *  2. Accessibility helpers
 *  3. Layout: container, section, grid
 *  4. Type: eyebrow, section header, icon
 *  5. Buttons
 *  6. Badges
 *  7. Filter chips
 *  8. Meta list
 *  9. Media
 * 10. Card
 * 11. Forms and notices
 * 12. Empty state
 * 13. Reveal on scroll
 * 14. Safety nets: [hidden], forced colors, print
 */

/* ==========================================================================
   1. Context tokens
   ========================================================================== */

/*
 * Page-level helpers. Declared on body (and on the editor canvas) so they are
 * resolved against the live design tokens, including Customizer previews.
 *
 * --sp-*-base keep a copy of the real token values so "islands" (cards, notices)
 * can restore them inside toned sections, where the tokens are remapped below.
 *
 * The icon masks are data URIs used as alpha masks only: the drawn color is
 * always `background-color: currentColor` (no colors live in the SVGs).
 */
/*
 * Native controls, scrollbars and pickers follow the palette: the design engine
 * sets --wp--custom--color-scheme to "dark" for dark presets such as Midnight.
 */
:root,
.editor-styles-wrapper {
	color-scheme: var(--wp--custom--color-scheme, light);
}

body,
.editor-styles-wrapper {
	--sp-link-base: var(--wp--custom--color--link);
	--sp-muted-base: var(--wp--preset--color--muted);
	--sp-border-base: var(--wp--preset--color--hairline);
	--sp-border-strong-base: var(--wp--custom--color--border-strong, var(--wp--preset--color--muted));
	--sp-text: var(--wp--preset--color--contrast);
	--sp-error: color-mix(in srgb, var(--wp--preset--color--accent) 55%, var(--wp--preset--color--contrast));
	--sp-radius-arch: var(--wp--custom--radius--pill) var(--wp--custom--radius--pill) var(--wp--custom--radius--small) var(--wp--custom--radius--small);
	--sp-icon-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12h15.5M13.5 6l6 6-6 6'/%3E%3C/svg%3E");
	--sp-icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
	--sp-icon-leaf: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19.5 4.5C11 4.5 5 9 5 15.5c0 1.6.3 3 .9 4.2 7.6-.2 13.6-5.4 13.6-15.2z'/%3E%3Cpath d='M5.5 19.5c2.5-5 6-8.5 10.5-11'/%3E%3C/svg%3E");
}

/*
 * Every palette color can be a background (blocks, sections, buttons, the
 * newsletter). Each one has a matching text color, and inside it links,
 * secondary text, hairlines and focus rings follow that text color:
 *
 *   background              text            role
 *   base, surface           contrast        island (real page tokens)
 *   contrast (+ Inverted)   base            toned
 *   cover overlay           its "on" color  toned (on the inner container; blocks.css)
 *   primary                 on-primary      toned
 *   accent                  on-accent       toned
 *   muted                   base            toned
 *   on-primary              primary         toned (the inverse of a primary band)
 *   on-accent               accent          toned (the inverse of an accent band)
 *   hairline                contrast        toned
 *
 * The design engine keeps each pair at 4.5:1 or more (muted on base, on-primary
 * on primary, on-accent on accent; contrast on base/surface/hairline).
 * Never remap a token on the element whose background uses it: muted and
 * hairline backgrounds remap those two tokens for their children only.
 */
.sp-section--inverted,
.is-style-inverted:not(.has-background),
.has-contrast-background-color,
.wp-block-cover__inner-container {
	--wp--custom--color--link: currentColor;
	--wp--preset--color--muted: color-mix(in srgb, currentColor 80%, transparent);
	--wp--preset--color--hairline: color-mix(in srgb, currentColor 24%, transparent);
	--wp--custom--color--border-strong: color-mix(in srgb, currentColor 55%, transparent);
	--sp-text: currentColor;
}

/* On the other colors secondary text stays full strength. */
.has-primary-background-color,
.has-accent-background-color,
.has-on-primary-background-color,
.has-on-accent-background-color {
	--wp--custom--color--link: currentColor;
	--wp--preset--color--muted: currentColor;
	--wp--preset--color--hairline: color-mix(in srgb, currentColor 30%, transparent);
	--wp--custom--color--border-strong: color-mix(in srgb, currentColor 60%, transparent);
	--sp-text: currentColor;
}

.has-muted-background-color,
.has-hairline-background-color {
	--wp--custom--color--link: currentColor;
	--wp--custom--color--border-strong: color-mix(in srgb, currentColor 60%, transparent);
	--sp-text: currentColor;
}

:is(.has-muted-background-color, .has-hairline-background-color) > * {
	--wp--preset--color--muted: currentColor;
	--wp--preset--color--hairline: color-mix(in srgb, currentColor 30%, transparent);
}

/* Theme backgrounds without an explicit text color get their matching text color. */
.wp-block-group.is-style-inverted:not(.has-background):not(.has-text-color),
.has-contrast-background-color:not(.has-text-color),
.has-muted-background-color:not(.has-text-color) {
	color: var(--wp--preset--color--base);
}

.has-primary-background-color:not(.has-text-color) {
	color: var(--wp--preset--color--on-primary);
}

.has-accent-background-color:not(.has-text-color) {
	color: var(--wp--preset--color--on-accent);
}

.has-on-primary-background-color:not(.has-text-color) {
	color: var(--wp--preset--color--primary);
}

.has-on-accent-background-color:not(.has-text-color) {
	color: var(--wp--preset--color--accent);
}

.has-hairline-background-color:not(.has-text-color) {
	color: var(--wp--preset--color--contrast);
}

/*
 * Islands: page-colored surfaces nested anywhere get the real tokens back.
 * A Card group is an island only while it keeps its own surface color; given a
 * background color it follows that color's rules instead.
 */
.sp-section--surface,
.has-base-background-color,
.has-surface-background-color,
.sp-card,
.wp-block-group.is-style-card:not(.has-background),
.sp-notice,
.sp-field__input {
	--wp--custom--color--link: var(--sp-link-base);
	--wp--preset--color--muted: var(--sp-muted-base);
	--wp--preset--color--hairline: var(--sp-border-base);
	--wp--custom--color--border-strong: var(--sp-border-strong-base);
	--sp-text: var(--wp--preset--color--contrast);
}

.has-base-background-color:not(.has-text-color),
.has-surface-background-color:not(.has-text-color) {
	color: var(--wp--preset--color--contrast);
}

/*
 * Focus ring color (--sp-ring). A ring is painted OUTSIDE the focused element,
 * on whatever is behind it, so its color must come from the element's
 * surroundings, never from the element's own background. Every colored
 * container therefore sets the ring for its CHILDREN only (`> *`); deeper
 * descendants inherit it, so the nearest colored ancestor always wins, and an
 * element's own background never decides its own ring. The page level sets it
 * too, so the fallback (the element's own link token) is never reached.
 * Outlines read var(--sp-ring, var(--wp--custom--color--link)).
 */
body,
.editor-styles-wrapper {
	--sp-ring: var(--sp-link-base);
}

:is(.sp-section--surface, .has-base-background-color, .has-surface-background-color, .sp-card, .wp-block-group.is-style-card:not(.has-background), .sp-notice) > * {
	--sp-ring: var(--sp-link-base);
}

:is(.sp-section--inverted, .is-style-inverted:not(.has-background), .has-contrast-background-color, .has-muted-background-color) > * {
	--sp-ring: var(--wp--preset--color--base);
}

.has-primary-background-color > * {
	--sp-ring: var(--wp--preset--color--on-primary);
}

.has-accent-background-color > * {
	--sp-ring: var(--wp--preset--color--on-accent);
}

.has-on-primary-background-color > * {
	--sp-ring: var(--wp--preset--color--primary);
}

.has-on-accent-background-color > * {
	--sp-ring: var(--wp--preset--color--accent);
}

.has-hairline-background-color > * {
	--sp-ring: var(--wp--preset--color--contrast);
}

/*
 * Theme components size with border-box everywhere, including the editor canvas
 * where the front-end reset (main.css) is not loaded. Zero specificity.
 */
:where([class^="sp-"], [class*=" sp-"]),
:where([class^="sp-"], [class*=" sp-"])::before,
:where([class^="sp-"], [class*=" sp-"])::after {
	box-sizing: border-box;
}

/* ==========================================================================
   2. Accessibility helpers
   ========================================================================== */

/* WordPress standard. Wins over any component styles (e.g. .sp-field__label). */
.screen-reader-text,
.sp-field__label.screen-reader-text {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	border: 0 !important;
	overflow: hidden !important;
	clip: rect(1px, 1px, 1px, 1px) !important;
	clip-path: inset(50%) !important;
	white-space: nowrap !important;
	word-wrap: normal !important;
}

/* Focusable screen-reader text (e.g. skip links) becomes visible on focus. */
.screen-reader-text:focus {
	top: var(--wp--preset--spacing--20);
	left: var(--wp--preset--spacing--20);
	z-index: 100000;
	display: block;
	width: auto !important;
	height: auto !important;
	margin: 0 !important;
	padding: var(--wp--preset--spacing--20) var(--wp--preset--spacing--30) !important;
	clip: auto !important;
	clip-path: none !important;
	border-radius: var(--wp--custom--radius--small);
	background-color: var(--wp--preset--color--base);
	box-shadow: var(--wp--preset--shadow--lifted);
	color: var(--wp--preset--color--contrast);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	line-height: 1.4;
	text-decoration: none;
	white-space: normal !important;
}

/* ==========================================================================
   3. Layout: container, section, grid
   ========================================================================== */

/* Content box = wide size, so module templates line up with `alignwide` blocks. */
:where(.sp-container) {
	box-sizing: border-box;
	width: 100%;
	max-width: calc(var(--wp--style--global--wide-size) + 2 * var(--wp--custom--gutter));
	margin-inline: auto;
	padding-inline: var(--wp--custom--gutter);
}

:where(.sp-container--narrow) {
	max-width: calc(var(--wp--style--global--content-size) + 2 * var(--wp--custom--gutter));
}

:where(.sp-container .sp-container) {
	padding-inline: 0;
}

/* Spacing has zero specificity: templates trim it (e.g. padding-block-start: 0). */
:where(.sp-section) {
	box-sizing: border-box;
	margin-block: 0;
	padding-block: var(--wp--custom--section--padding);
}

.sp-section--surface {
	background-color: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
}

.sp-section--inverted {
	background-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

/*
 * Responsive grid. Without a modifier: as many ~280px columns as fit.
 * --2/--3/--4 cap the column count; columns never get narrower than the minimum,
 * so grids inside narrow content columns simply wrap.
 */
:where(.sp-grid) {
	--sp-grid-min: 17.5rem;
	--sp-grid-gap: var(--wp--preset--spacing--40);
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--sp-grid-min)), 1fr));
	gap: var(--wp--preset--spacing--50) var(--sp-grid-gap);
	align-items: stretch;
	min-inline-size: 0;
}

:where(.sp-grid--2, .sp-grid--3, .sp-grid--4) {
	grid-template-columns: repeat(auto-fill, minmax(min(100%, max(var(--sp-grid-min), (100% - (var(--sp-grid-cols) - 1) * var(--sp-grid-gap)) / var(--sp-grid-cols))), 1fr));
}

:where(.sp-grid--2) {
	--sp-grid-cols: 2;
}

:where(.sp-grid--3) {
	--sp-grid-cols: 3;
}

:where(.sp-grid--4) {
	--sp-grid-cols: 4;
	--sp-grid-min: 14rem;
}

:where(.sp-grid) > * {
	min-inline-size: 0;
}

/* ==========================================================================
   4. Type: eyebrow, section header, icon
   ========================================================================== */

.sp-eyebrow,
.sp-card__eyebrow,
.sp-section-header__eyebrow {
	margin-block: 0;
	color: var(--wp--custom--color--link);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--x-small);
	font-style: normal;
	font-weight: 600;
	letter-spacing: var(--wp--custom--eyebrow--letter-spacing);
	line-height: 1.4;
	text-transform: uppercase;
	overflow-wrap: anywhere;
}

.sp-eyebrow a,
.sp-card__eyebrow a {
	color: inherit;
	text-decoration: none;
}

.sp-eyebrow a:hover,
.sp-eyebrow a:focus-visible,
.sp-card__eyebrow a:hover,
.sp-card__eyebrow a:focus-visible {
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

:where(.sp-section-header) {
	margin-block: 0 var(--wp--preset--spacing--60);
}

:where(.sp-section-header) > * {
	margin-block: 0;
}

.sp-section-header__eyebrow {
	margin-block-end: var(--wp--preset--spacing--20);
}

.sp-section-header__title {
	overflow-wrap: break-word;
	text-wrap: balance;
}

.sp-section-header__title em {
	color: var(--wp--custom--color--link);
	font-style: italic;
}

.sp-section-header__text {
	max-inline-size: 60ch;
	margin-block-start: var(--wp--preset--spacing--30);
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.55;
	text-wrap: pretty;
}

.sp-section-header--center {
	text-align: center;
}

.sp-section-header--center .sp-section-header__text {
	margin-inline: auto;
}

/* Inline SVG icons (stillpoint_icon()): 1em, currentColor. */
.sp-icon {
	display: inline-block;
	flex-shrink: 0;
	width: 1em;
	height: 1em;
	overflow: visible;
	vertical-align: -0.125em;
}

/* ==========================================================================
   5. Buttons — same look as the core button (theme.json `button` element)
   ========================================================================== */

/* Variants only change these properties; the declarations below read them. */
.sp-button {
	--sp-btn-bg: var(--wp--preset--color--primary);
	--sp-btn-fg: var(--wp--preset--color--on-primary);
	--sp-btn-border: var(--wp--preset--color--primary);
	--sp-btn-bg-hover: var(--wp--custom--color--primary-hover, color-mix(in srgb, var(--wp--preset--color--primary) 84%, var(--wp--preset--color--contrast)));
	--sp-btn-fg-hover: var(--wp--preset--color--on-primary);
	--sp-btn-border-hover: var(--sp-btn-bg-hover);
	--sp-btn-decoration: none;
	--sp-btn-decoration-hover: none;
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	min-block-size: 2.75rem;
	max-inline-size: 100%;
	padding: var(--wp--custom--button--padding-block) var(--wp--custom--button--padding-inline);
	border-width: 1px;
	border-style: solid;
	border-radius: var(--wp--custom--radius--button);
	box-shadow: none;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--small);
	font-style: normal;
	font-weight: var(--wp--custom--button--weight);
	letter-spacing: var(--wp--custom--button--letter-spacing);
	line-height: 1.2;
	text-align: center;
	text-transform: var(--wp--custom--button--text-transform);
	text-underline-offset: 0.3em;
	overflow-wrap: anywhere;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
	transition:
		background-color var(--wp--custom--transition--fast),
		border-color var(--wp--custom--transition--fast),
		color var(--wp--custom--transition--fast),
		text-decoration-color var(--wp--custom--transition--fast),
		box-shadow var(--wp--custom--transition--base),
		transform var(--wp--custom--transition--base);
}

/* `a.sp-button` outranks the theme.json link rules (color + underline). */
.sp-button,
a.sp-button {
	border-color: var(--sp-btn-border);
	background-color: var(--sp-btn-bg);
	color: var(--sp-btn-fg);
	text-decoration: var(--sp-btn-decoration);
}

.sp-button:hover,
a.sp-button:hover {
	border-color: var(--sp-btn-border-hover);
	background-color: var(--sp-btn-bg-hover);
	color: var(--sp-btn-fg-hover);
	text-decoration: var(--sp-btn-decoration-hover);
}

.sp-button:focus-visible {
	outline: 2px solid var(--sp-ring, var(--wp--custom--color--link));
	outline-offset: 3px;
}

button.sp-button {
	margin: 0;
}

.sp-button .sp-icon {
	width: 1.15em;
	height: 1.15em;
}

/* Outline: transparent with a hairline in the link color; a soft tint on hover. */
.sp-button--outline {
	--sp-btn-bg: transparent;
	--sp-btn-fg: var(--wp--custom--color--link);
	--sp-btn-border: currentColor;
	--sp-btn-bg-hover: transparent;
	--sp-btn-fg-hover: var(--wp--custom--color--link);
	--sp-btn-border-hover: currentColor;
}

/* Hover: a doubled border instead of a tint, so the text keeps its contrast. */
.sp-button--outline:hover {
	box-shadow: inset 0 0 0 1px currentColor;
}

/* Text: a quiet link with its own arrow. Keeps a 44px tap height. */
.sp-button--text {
	--sp-btn-bg: transparent;
	--sp-btn-fg: var(--wp--custom--color--link);
	--sp-btn-border: transparent;
	--sp-btn-bg-hover: transparent;
	--sp-btn-fg-hover: var(--wp--custom--color--link);
	--sp-btn-border-hover: transparent;
	--sp-btn-decoration: underline 1px transparent;
	--sp-btn-decoration-hover: underline 1px currentColor;
	gap: 0.55em;
	padding-inline: 0;
	padding-block: 0.25rem;
	border-radius: 0;
	text-align: start;
}

.sp-button--text::after {
	content: "";
	flex: none;
	width: 1.15em;
	height: 1.15em;
	background-color: currentColor;
	-webkit-mask: var(--sp-icon-arrow) center / contain no-repeat;
	mask: var(--sp-icon-arrow) center / contain no-repeat;
	transition: transform var(--wp--custom--transition--fast);
}

.sp-button--text:dir(rtl)::after {
	transform: scaleX(-1);
}

.sp-button--small {
	gap: 0.4em;
	padding: 0.5rem 1.15rem;
	font-size: var(--wp--preset--font-size--x-small);
	letter-spacing: calc(var(--wp--custom--button--letter-spacing) + 0.02em);
}

.sp-button--small.sp-button--text {
	padding-inline: 0;
}

.sp-button--block {
	display: flex;
	width: 100%;
}

/* Disabled: dashed hairline + muted text (not color alone), no hover change. */
.sp-button.is-disabled,
.sp-button[aria-disabled="true"],
.sp-button:disabled {
	--sp-btn-bg: color-mix(in srgb, var(--wp--preset--color--muted) 12%, transparent);
	--sp-btn-fg: var(--wp--preset--color--muted);
	--sp-btn-border: color-mix(in srgb, var(--wp--preset--color--muted) 55%, transparent);
	--sp-btn-bg-hover: var(--sp-btn-bg);
	--sp-btn-fg-hover: var(--sp-btn-fg);
	--sp-btn-border-hover: var(--sp-btn-border);
	--sp-btn-decoration-hover: var(--sp-btn-decoration);
	border-style: dashed;
	box-shadow: none;
	transform: none;
}

.sp-button.is-disabled,
.sp-button:disabled {
	cursor: not-allowed;
}

.sp-button--text.is-disabled,
.sp-button--text[aria-disabled="true"],
.sp-button--text:disabled {
	--sp-btn-bg: transparent;
	--sp-btn-border: transparent;
}

/* On a primary band a primary button would vanish: use the page colors instead. */
.has-primary-background-color .sp-button:not(.sp-button--outline):not(.sp-button--text):not(.is-disabled):not([aria-disabled="true"]) {
	--sp-btn-bg: var(--wp--preset--color--base);
	--sp-btn-fg: var(--wp--preset--color--contrast);
	--sp-btn-border: var(--wp--preset--color--base);
	--sp-btn-bg-hover: color-mix(in srgb, var(--wp--preset--color--base) 86%, var(--wp--preset--color--contrast));
	--sp-btn-fg-hover: var(--wp--preset--color--contrast);
	--sp-btn-border-hover: var(--sp-btn-bg-hover);
}

@media (prefers-reduced-motion: no-preference) {
	.sp-has-motion .sp-button:not(.sp-button--text):not(.is-disabled):not([aria-disabled="true"]):not(:disabled):hover {
		transform: translateY(-1px);
	}

	.sp-has-motion .sp-button--text:not(.is-disabled):not([aria-disabled="true"]):hover::after {
		transform: translateX(0.25em);
	}

	.sp-has-motion .sp-button--text:not(.is-disabled):not([aria-disabled="true"]):dir(rtl):hover::after {
		transform: scaleX(-1) translateX(0.25em);
	}
}

/* ==========================================================================
   6. Badges — small pill labels
   ========================================================================== */

:where(.sp-badge) {
	--sp-badge-bg: var(--wp--preset--color--surface);
	--sp-badge-fg: var(--wp--preset--color--contrast);
	--sp-badge-border: var(--wp--preset--color--hairline);
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.35em;
	min-block-size: 1.625rem;
	max-inline-size: 100%;
	padding: 0.25em 0.8em;
	border: 1px solid var(--sp-badge-border);
	border-radius: var(--wp--custom--radius--pill);
	background-color: var(--sp-badge-bg);
	color: var(--sp-badge-fg);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--x-small);
	font-style: normal;
	font-weight: 600;
	letter-spacing: 0.06em;
	line-height: 1.25;
	text-align: center;
	text-decoration: none;
	text-transform: uppercase;
	vertical-align: middle;
	overflow-wrap: anywhere;
}

.sp-badge .sp-icon {
	width: 1.1em;
	height: 1.1em;
}

.sp-badge--accent {
	--sp-badge-bg: var(--wp--preset--color--accent);
	--sp-badge-fg: var(--wp--preset--color--on-accent);
	--sp-badge-border: var(--wp--preset--color--accent);
}

.sp-badge--primary {
	--sp-badge-bg: var(--wp--preset--color--primary);
	--sp-badge-fg: var(--wp--preset--color--on-primary);
	--sp-badge-border: var(--wp--preset--color--primary);
}

.sp-badge--outline {
	--sp-badge-bg: transparent;
	--sp-badge-fg: var(--sp-text);
	--sp-badge-border: var(--wp--custom--color--border-strong, var(--wp--preset--color--muted));
}

.sp-badge--muted {
	--sp-badge-bg: color-mix(in srgb, var(--wp--preset--color--muted) 14%, transparent);
	--sp-badge-fg: var(--sp-text);
	--sp-badge-border: transparent;
}

/* ==========================================================================
   7. Filter chips (toggle buttons with aria-pressed)
   ========================================================================== */

:where(.sp-filter) {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--wp--preset--spacing--10);
}

.sp-chip {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.45em;
	min-block-size: 2.75rem;
	max-inline-size: 100%;
	margin: 0;
	padding: 0.4rem 1.15rem;
	border: 1px solid color-mix(in srgb, var(--wp--custom--color--border-strong, var(--wp--preset--color--muted)) 55%, var(--wp--preset--color--hairline));
	border-radius: var(--wp--custom--radius--pill);
	background-color: transparent;
	color: var(--sp-text);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--small);
	font-style: normal;
	font-weight: 500;
	letter-spacing: 0.01em;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	text-transform: none;
	overflow-wrap: anywhere;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
	transition:
		background-color var(--wp--custom--transition--fast),
		border-color var(--wp--custom--transition--fast),
		color var(--wp--custom--transition--fast);
}

.sp-chip:hover {
	border-color: var(--sp-text);
	background-color: color-mix(in srgb, var(--sp-text) 6%, transparent);
	color: var(--sp-text);
}

.sp-chip:focus-visible {
	outline: 2px solid var(--sp-ring, var(--wp--custom--color--link));
	outline-offset: 2px;
}

/* Pressed: filled ink + a check mark, so the state never relies on color alone. */
.sp-chip[aria-pressed="true"] {
	border-color: var(--wp--preset--color--contrast);
	background-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

.sp-chip[aria-pressed="true"]:hover {
	border-color: color-mix(in srgb, var(--wp--preset--color--contrast) 86%, var(--wp--preset--color--base));
	background-color: color-mix(in srgb, var(--wp--preset--color--contrast) 86%, var(--wp--preset--color--base));
	color: var(--wp--preset--color--base);
}

.sp-chip[aria-pressed="true"]::before {
	content: "";
	flex: none;
	width: 0.95em;
	height: 0.95em;
	margin-inline-start: -0.2em;
	background-color: currentColor;
	-webkit-mask: var(--sp-icon-check) center / contain no-repeat;
	mask: var(--sp-icon-check) center / contain no-repeat;
}

.sp-chip .sp-icon {
	width: 1.1em;
	height: 1.1em;
}

.sp-chip:disabled,
.sp-chip[aria-disabled="true"] {
	border-style: dashed;
	opacity: 0.6;
	cursor: not-allowed;
}

/* In toned sections the pressed chip uses the page colors instead of ink. */
:is(.sp-section--inverted, .is-style-inverted:not(.has-background), .has-contrast-background-color, .has-primary-background-color, .has-accent-background-color, .has-muted-background-color, .has-on-primary-background-color, .has-on-accent-background-color, .has-hairline-background-color, .wp-block-cover__inner-container) .sp-chip[aria-pressed="true"] {
	border-color: var(--wp--preset--color--base);
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}

/* ==========================================================================
   8. Meta list (icon + text items: time, place, price…)
   ========================================================================== */

:where(.sp-meta) {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35em var(--wp--preset--spacing--30);
	line-height: 1.45;
}

.sp-meta,
ul.sp-meta {
	margin: 0;
	padding: 0;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	list-style: none;
}

.sp-meta > li {
	margin: 0;
}

:where(.sp-meta__item) {
	display: inline-flex;
	align-items: center;
	gap: 0.45em;
	min-inline-size: 0;
	overflow-wrap: anywhere;
}

.sp-meta__item > .sp-icon {
	flex: none;
	width: 1.1em;
	height: 1.1em;
}

/* ==========================================================================
   9. Media — image wrapper following the image-shape setting
   ========================================================================== */

.sp-media {
	position: relative;
	isolation: isolate;
	overflow: hidden;
	margin: 0;
	border-radius: var(--wp--custom--radius--image);
	background-color: var(--wp--preset--color--surface);
}

.sp-media > img,
.sp-media > picture > img,
.sp-media > a > img,
.sp-media > video,
.sp-media > iframe {
	display: block;
	width: 100%;
	max-width: 100%;
	border-radius: 0;
	object-fit: cover;
}

/* Body classes from the "Image style" setting. */
.sp-images--arch .sp-media {
	border-radius: var(--sp-radius-arch);
}

.sp-images--square .sp-media {
	border-radius: 0;
}

/* Forced shapes win over the setting. */
.sp-media.sp-media--arch {
	border-radius: var(--sp-radius-arch);
}

.sp-media.sp-media--circle {
	aspect-ratio: 1;
	border-radius: 50%;
}

.sp-media--circle > img,
.sp-media--circle > picture > img,
.sp-media--circle > a > img {
	height: 100%;
}

/* ==========================================================================
   10. Card — surface card with a stretched link
   ========================================================================== */

.sp-card {
	position: relative;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	min-inline-size: 0;
	padding: var(--wp--preset--spacing--20);
	border: 1px solid var(--wp--preset--color--hairline);
	border-radius: var(--wp--custom--radius--large);
	background-color: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
	transition:
		border-color var(--wp--custom--transition--base),
		box-shadow var(--wp--custom--transition--base),
		transform var(--wp--custom--transition--base);
}

/* On surface-colored sections a card sits on the page color so it still reads as a card. */
.sp-section--surface .sp-card,
.has-surface-background-color .sp-card {
	background-color: var(--wp--preset--color--base);
}

.sp-card__media {
	margin: 0;
}

:where(.sp-card__body) {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: var(--wp--preset--spacing--10);
	min-inline-size: 0;
	padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--20) var(--wp--preset--spacing--20);
}

:where(.sp-card__body) > * {
	margin-block: 0;
}

.sp-card__title {
	margin-block: 0;
	color: inherit;
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: var(--wp--custom--heading--weight);
	letter-spacing: var(--wp--custom--heading--letter-spacing);
	line-height: var(--wp--custom--heading--line-height);
	text-transform: var(--wp--custom--heading--text-transform);
	overflow-wrap: anywhere;
	text-wrap: balance;
}

.sp-card__link,
a.sp-card__link {
	color: inherit;
	text-decoration: none;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
}

/* The whole card is clickable through the title link (one link, one tab stop). */
.sp-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	border-radius: inherit;
}

.sp-card:hover .sp-card__link,
.sp-card__link:focus-visible {
	color: inherit;
	text-decoration-line: underline;
}

.sp-card__link:focus-visible {
	outline: 2px solid var(--sp-ring, var(--wp--custom--color--link));
	outline-offset: 2px;
}

@supports selector(:has(*)) {
	.sp-card:has(.sp-card__link:focus-visible) {
		outline: 2px solid var(--sp-ring, var(--wp--custom--color--link));
		outline-offset: 3px;
	}

	.sp-card .sp-card__link:focus-visible {
		outline: none;
	}

	.sp-card:has(.sp-card__link):hover {
		border-color: color-mix(in srgb, var(--wp--preset--color--primary) 35%, var(--wp--preset--color--hairline));
		box-shadow: var(--wp--preset--shadow--soft);
	}
}

.sp-card__meta {
	margin-block: 0;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
}

.sp-card__excerpt {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.6;
	overflow-wrap: anywhere;
}

:where(.sp-card__footer) {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--wp--preset--spacing--10) var(--wp--preset--spacing--20);
	margin-block-start: auto;
	padding-block-start: var(--wp--preset--spacing--30);
	border-block-start: 1px solid var(--wp--preset--color--hairline);
}

/* Footer placed directly in the card (outside the body) lines up with the body text. */
:where(.sp-card > .sp-card__footer) {
	margin-inline: var(--wp--preset--spacing--20);
	margin-block-end: var(--wp--preset--spacing--20);
}

@media (prefers-reduced-motion: no-preference) {
	@supports selector(:has(*)) {
		.sp-has-motion .sp-card:has(.sp-card__link):hover {
			transform: translateY(-3px);
		}
	}
}

/* ==========================================================================
   11. Forms and notices
   ========================================================================== */

:where(.sp-form) {
	margin: 0;
}

:where(.sp-field) {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--10);
	min-inline-size: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.sp-field__label {
	display: block;
	color: inherit;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	letter-spacing: 0.01em;
	line-height: 1.4;
}

.sp-field__hint {
	margin: 0;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.5;
}

.sp-field__input {
	box-sizing: border-box;
	display: block;
	width: 100%;
	min-block-size: 3rem;
	margin: 0;
	padding: 0.75em 1em;
	border: 1px solid var(--wp--custom--color--border-strong, var(--wp--preset--color--muted));
	border-radius: min(var(--wp--custom--radius--button), 1.5rem);
	background-color: var(--wp--preset--color--base);
	box-shadow: none;
	color: var(--wp--preset--color--contrast);
	font-family: var(--wp--preset--font-family--body);
	/* At least 16px so iOS does not zoom into the field. */
	font-size: max(1rem, var(--wp--preset--font-size--small));
	font-style: normal;
	font-weight: 400;
	letter-spacing: normal;
	line-height: 1.4;
	text-transform: none;
	-webkit-appearance: none;
	appearance: none;
	transition:
		border-color var(--wp--custom--transition--fast),
		box-shadow var(--wp--custom--transition--fast),
		background-color var(--wp--custom--transition--fast);
}

textarea.sp-field__input {
	min-block-size: 9rem;
	border-radius: min(var(--wp--custom--radius--button), var(--wp--custom--radius--large));
	line-height: var(--wp--custom--body--line-height);
	resize: vertical;
}

/* A thin chevron drawn with two currentColor strokes (no images). */
select.sp-field__input {
	padding-inline-end: 2.75em;
	background-image:
		linear-gradient(45deg, transparent calc(50% - 0.75px), currentColor calc(50% - 0.75px), currentColor calc(50% + 0.75px), transparent calc(50% + 0.75px)),
		linear-gradient(135deg, transparent calc(50% - 0.75px), currentColor calc(50% - 0.75px), currentColor calc(50% + 0.75px), transparent calc(50% + 0.75px));
	background-position:
		calc(100% - 1.4em) 55%,
		calc(100% - 1em) 55%;
	background-repeat: no-repeat;
	background-size: 0.4em 0.4em;
	cursor: pointer;
}

select.sp-field__input:dir(rtl) {
	background-position:
		1em 55%,
		1.4em 55%;
}

.sp-field__input::placeholder {
	color: var(--wp--preset--color--muted);
	opacity: 1;
}

.sp-field__input:hover {
	border-color: color-mix(in srgb, var(--wp--preset--color--contrast) 55%, var(--wp--custom--color--border-strong, var(--wp--preset--color--muted)));
}

/* Focus: a 2px ink edge inside the field (visible on any section) + a soft halo. */
.sp-field__input:focus {
	border-color: var(--wp--preset--color--contrast);
	outline: 2px solid transparent;
	outline-offset: 2px;
	box-shadow:
		0 0 0 1px var(--wp--preset--color--contrast),
		0 0 0 5px color-mix(in srgb, var(--wp--custom--color--link) 28%, transparent);
}

/* On a toned band the soft halo vanishes: draw a solid ring in the band's ring color. */
:is(.sp-section--inverted, .is-style-inverted:not(.has-background), .has-contrast-background-color, .wp-block-cover__inner-container, .has-primary-background-color, .has-accent-background-color, .has-muted-background-color, .has-on-primary-background-color, .has-on-accent-background-color, .has-hairline-background-color) .sp-field__input:focus {
	box-shadow:
		0 0 0 1px var(--wp--preset--color--contrast),
		0 0 0 4px var(--sp-ring, var(--wp--custom--color--link));
}

.sp-field__input:disabled,
.sp-field__input[readonly] {
	border-style: dashed;
	background-color: color-mix(in srgb, var(--wp--preset--color--muted) 8%, var(--wp--preset--color--base));
	cursor: not-allowed;
}

/* Invalid: error-tone edge + a thick start bar (a shape cue, not color alone). */
.sp-field.is-invalid .sp-field__input,
.sp-field__input[aria-invalid="true"] {
	border-color: var(--sp-error);
	box-shadow: inset 4px 0 0 var(--sp-error);
}

.sp-field.is-invalid .sp-field__input:dir(rtl),
.sp-field__input[aria-invalid="true"]:dir(rtl) {
	box-shadow: inset -4px 0 0 var(--sp-error);
}

.sp-field.is-invalid .sp-field__input:focus,
.sp-field__input[aria-invalid="true"]:focus {
	box-shadow:
		inset 4px 0 0 var(--sp-error),
		0 0 0 1px var(--sp-error),
		0 0 0 5px color-mix(in srgb, var(--sp-error) 25%, transparent);
}

.sp-field__error {
	display: flex;
	align-items: flex-start;
	gap: 0.5em;
	margin: 0;
	color: var(--sp-text);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	line-height: 1.45;
}

/* "!" marker; empty alt text keeps it out of the accessible name. */
.sp-field__error::before {
	content: "!";
	content: "!" / "";
	display: inline-grid;
	flex: none;
	place-items: center;
	width: 1.45em;
	height: 1.45em;
	margin-block-start: 0.05em;
	border-radius: 50%;
	background-color: var(--sp-error);
	color: var(--wp--preset--color--base);
	font-size: 0.8em;
	font-weight: 700;
	line-height: 1;
}

/* Checkbox: box in the first column; label, hint and error in the second. */
.sp-field--checkbox {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	align-items: start;
	gap: var(--wp--preset--spacing--10) var(--wp--preset--spacing--20);
}

.sp-field--checkbox > .sp-field__checkbox,
.sp-field--checkbox > input[type="checkbox"] {
	grid-row: 1;
	grid-column: 1;
	width: 1.25em;
	height: 1.25em;
	margin: 0.15em 0 0;
	accent-color: var(--wp--preset--color--primary);
	cursor: pointer;
}

.sp-field--checkbox > :not(.sp-field__checkbox):not(input) {
	grid-column: 2;
}

.sp-field--checkbox > .sp-field__label {
	font-weight: 400;
	letter-spacing: normal;
	cursor: pointer;
}

.sp-field__checkbox:focus-visible,
.sp-form input[type="checkbox"]:focus-visible,
.sp-form input[type="radio"]:focus-visible {
	outline: 2px solid var(--sp-ring, var(--wp--custom--color--link));
	outline-offset: 2px;
}

.sp-form input[type="checkbox"],
.sp-form input[type="radio"] {
	accent-color: var(--wp--preset--color--primary);
}

.sp-field--checkbox.is-invalid > .sp-field__checkbox {
	outline: 2px solid var(--sp-error);
	outline-offset: 2px;
}

:where(.sp-form__actions) {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--wp--preset--spacing--20) var(--wp--preset--spacing--30);
	margin: 0;
}

/* Notices: hairline box with a toned start bar. */
:where(.sp-notice) {
	margin: 0;
}

.sp-notice {
	--sp-notice-tone: color-mix(in srgb, var(--wp--preset--color--contrast) 55%, var(--wp--preset--color--base));
	box-sizing: border-box;
	padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--40);
	border: 1px solid color-mix(in srgb, var(--sp-notice-tone) 30%, var(--wp--preset--color--hairline));
	border-inline-start: 4px solid var(--sp-notice-tone);
	border-radius: var(--wp--custom--radius--medium);
	background-color: color-mix(in srgb, var(--sp-notice-tone) 8%, var(--wp--preset--color--base));
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.55;
	overflow-wrap: anywhere;
}

.sp-notice > :first-child {
	margin-block-start: 0;
}

.sp-notice > :last-child {
	margin-block-end: 0;
}

.sp-notice a:not(.sp-button) {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.sp-notice > .sp-icon,
.sp-notice :is(h2, h3, h4, p, strong) > .sp-icon {
	color: var(--sp-notice-tone);
}

.sp-notice--success {
	--sp-notice-tone: var(--wp--custom--color--link);
}

.sp-notice--error {
	--sp-notice-tone: var(--sp-error);
}

.sp-notice--info {
	--sp-notice-tone: color-mix(in srgb, var(--wp--preset--color--contrast) 55%, var(--wp--preset--color--base));
}

/* ==========================================================================
   12. Empty state
   ========================================================================== */

:where(.sp-empty) {
	margin: 0;
}

.sp-empty {
	box-sizing: border-box;
	padding: var(--wp--preset--spacing--60) var(--wp--preset--spacing--50);
	border: 1px dashed color-mix(in srgb, var(--wp--custom--color--border-strong, var(--wp--preset--color--muted)) 45%, var(--wp--preset--color--hairline));
	border-radius: var(--wp--custom--radius--large);
	background-color: color-mix(in srgb, var(--wp--preset--color--surface) 55%, transparent);
	color: var(--sp-text);
	text-align: center;
	overflow-wrap: anywhere;
}

.sp-section--surface .sp-empty,
.has-surface-background-color .sp-empty {
	background-color: color-mix(in srgb, var(--wp--preset--color--base) 60%, transparent);
}

.sp-empty > :first-child {
	margin-block-start: 0;
}

.sp-empty > :last-child {
	margin-block-end: 0;
}

.sp-empty p {
	max-inline-size: 52ch;
	margin-inline: auto;
}

/* ==========================================================================
   13. Reveal on scroll
   Hidden only when JS runs (html.sp-js), animations are on (body.sp-has-motion)
   and the visitor allows motion. theme.js adds `.is-revealed` to each element
   as it enters the viewport (`.is-visible` is accepted too) and puts
   `html.sp-reveal-ready` once its observer runs. Until then a delayed CSS
   animation is the safety net: if the script never runs, content still fades
   in after a moment. Never applies in the editor (no sp-js / sp-has-motion).
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
	.sp-js .sp-has-motion .sp-reveal:not(.is-revealed):not(.is-visible) {
		opacity: 0;
		transform: translate3d(0, 1.5rem, 0);
		animation: sp-reveal-fallback 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) 2.5s forwards;
	}

	.sp-js.sp-reveal-ready .sp-has-motion .sp-reveal:not(.is-revealed):not(.is-visible) {
		animation: none;
	}

	.sp-js .sp-has-motion .sp-reveal {
		transition:
			opacity var(--wp--custom--transition--slow, var(--wp--custom--transition--base)),
			transform var(--wp--custom--transition--slow, var(--wp--custom--transition--base));
	}
}

@keyframes sp-reveal-fallback {
	to {
		opacity: 1;
		transform: none;
	}
}

/* ==========================================================================
   14. Safety nets
   ========================================================================== */

/* Components set `display`, which would otherwise beat the hidden attribute. */
:is(.sp-button, .sp-badge, .sp-chip, .sp-filter, .sp-meta, .sp-meta__item, .sp-card, .sp-grid, .sp-field, .sp-form__actions, .sp-notice, .sp-empty, .sp-section-header, .sp-icon)[hidden] {
	display: none !important;
}

/* Masked pseudo-icons draw with currentColor, which forced colors already maps. */
.sp-button--text::after,
.sp-chip[aria-pressed="true"]::before {
	forced-color-adjust: none;
}

@media (forced-colors: active) {
	.sp-button,
	.sp-chip,
	.sp-badge,
	.sp-card,
	.sp-notice,
	.sp-empty,
	.sp-field__input {
		border-color: CanvasText;
	}

	.sp-button--text {
		border-color: transparent;
	}

	.sp-chip[aria-pressed="true"] {
		outline: 2px solid Highlight;
		outline-offset: 1px;
	}

	.sp-field__error::before {
		forced-color-adjust: none;
		background-color: CanvasText;
		color: Canvas;
	}
}

@media print {
	.sp-reveal {
		opacity: 1 !important;
		transform: none !important;
	}

	.sp-card,
	.sp-notice {
		break-inside: avoid;
		box-shadow: none;
	}

	.sp-button {
		border-color: currentColor;
		background: none;
		color: inherit;
	}
}
