/*
 * KVision One Theme base styles. Only role custom properties (var(--kv-…)); every colour,
 * size and duration comes from the site pack's tokens. Element and block typography is in
 * theme.json.
 */

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

/* The footer stays at the bottom of short pages. */
.wp-site-blocks {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
}

.wp-site-blocks > main {
	flex-grow: 1;
}

/* Header, main and footer meet without a gap: each template's main has its own padding,
   and a full-width section with a background at either end touches the header or footer. */
.wp-site-blocks > * + * {
	margin-block-start: 0;
}

/* Full-width sections follow each other without a strip of page colour between them; each
   has its own padding. */
.wp-block-post-content > .alignfull + .alignfull {
	margin-block-start: 0;
}

/* A page whose content ends with a full-width section with a background meets the footer
   without a strip of page colour: the template's bottom padding is dropped (it is set
   inline on main, hence !important). */
.wp-site-blocks > main:has(> .wp-block-post-content:last-child > :is(.alignfull.has-background, .alignfull[class*="is-style-kv-scheme-"], .wp-block-cover.alignfull):last-child) {
	padding-bottom: 0 !important;
}

::selection {
	color: var(--kv-accent-contrast);
	background: var(--kv-accent);
}

/* Links */
a {
	text-decoration-thickness: var(--kv-border-width);
	text-underline-offset: var(--kv-space-2xs);
	transition: color var(--kv-motion-fast) var(--kv-motion-easing);
}

/* Focus: always visible for keyboard users. */
:focus-visible {
	outline: var(--kv-focus-width) solid var(--kv-focus);
	outline-offset: var(--kv-focus-width);
}

:focus:not(:focus-visible) {
	outline: none;
}

/* Skip link (rendered by WordPress before the page). */
.skip-link.screen-reader-text:focus {
	padding: var(--kv-space-sm) var(--kv-space-md);
	color: var(--kv-text);
	font-size: var(--kv-text-size);
	background: var(--kv-background);
	border-radius: var(--kv-button-radius);
	outline: var(--kv-focus-width) solid var(--kv-focus);
	box-shadow: var(--kv-popover-shadow);
}

/* Buttons: filled buttons turn to outline on hover, outline buttons fill. */
.wp-element-button,
.wp-block-button__link {
	cursor: pointer;
	transition:
		color var(--kv-motion-fast) var(--kv-motion-easing),
		background-color var(--kv-motion-fast) var(--kv-motion-easing),
		border-color var(--kv-motion-fast) var(--kv-motion-easing);
}

.wp-element-button:hover,
.wp-block-button__link:hover {
	color: var(--kv-accent);
	background-color: transparent;
	border-color: var(--kv-accent);
}

.wp-block-button.is-style-outline > .wp-block-button__link:hover {
	color: var(--kv-accent-contrast);
	background-color: var(--kv-accent);
}

/* Forms */
input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="reset"], [type="range"], [type="color"], [type="file"], [type="image"]),
select,
textarea {
	box-sizing: border-box;
	max-width: 100%;
	padding: var(--kv-space-xs) var(--kv-space-sm);
	color: var(--kv-text);
	font: inherit;
	background-color: var(--kv-background);
	border: var(--kv-border-width) solid var(--kv-control-border);
	border-radius: var(--kv-field-radius);
	transition: border-color var(--kv-motion-fast) var(--kv-motion-easing);
}

input:hover,
select:hover,
textarea:hover {
	border-color: var(--kv-text);
}

input[type="checkbox"],
input[type="radio"] {
	accent-color: var(--kv-accent);
}

::placeholder {
	color: var(--kv-text-muted);
	opacity: 1;
}

label {
	font-weight: var(--kv-heading-weight);
}

:where(input, select, textarea)[aria-invalid="true"] {
	border-color: var(--kv-danger);
}

.wp-block-search__input {
	border-radius: var(--kv-field-radius);
}

.wp-block-search__button {
	margin-inline-start: var(--kv-space-xs);
}

/* Text */
:where(p, li) {
	overflow-wrap: break-word;
}

small,
figcaption,
.wp-element-caption {
	font-size: var(--kv-small-size);
}

mark {
	color: inherit;
	background-color: var(--kv-surface);
}

code,
kbd,
pre {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

table {
	border-collapse: collapse;
}

:where(.wp-block-table) th,
:where(.wp-block-table) td {
	padding: var(--kv-space-xs) var(--kv-space-sm);
	border: var(--kv-border-width) solid var(--kv-border);
}

/* Sections with a colour scheme get room to breathe. */
:where(.wp-block-group, .wp-block-columns, .wp-block-cover, .wp-block-media-text)[class*="is-style-kv-scheme-"]:not(.has-background) {
	background-color: var(--kv-background);
}

/* Cards: groups with the surface colour. */
.has-kv-surface-background-color {
	border-radius: var(--kv-card-radius);
	box-shadow: var(--kv-card-shadow);
}

/* Pagination */
.wp-block-query-pagination .page-numbers.current,
.wp-block-comments-pagination .page-numbers.current {
	font-weight: var(--kv-heading-weight);
	text-decoration: underline;
}

/* Comments */
.wp-block-post-comments-form input:not([type="submit"], [type="checkbox"]),
.wp-block-post-comments-form textarea {
	width: 100%;
}

/* Theme classes any block may carry (contract, section 4): hidden below or from 782 px,
   WordPress's small-screen breakpoint. */
@media (max-width: 781px) {
	.kv-hide-small {
		display: none !important;
	}
}

@media (min-width: 782px) {
	.kv-hide-large {
		display: none !important;
	}
}

/* Icons of theme blocks: WordPress's own icons, or a pack image drawn in the text colour. */
.kv-icon {
	display: inline-flex;
	flex-shrink: 0;
	width: 1.25em;
	height: 1.25em;
}

.kv-icon svg {
	width: 100%;
	height: 100%;
	fill: currentColor;
}

.kv-icon__glyph {
	display: block;
	width: 100%;
	height: 100%;
	background-color: currentColor;
	-webkit-mask: var(--kv-icon) center / contain no-repeat;
	mask: var(--kv-icon) center / contain no-repeat;
}

/* F04: a details block's question as a heading (kvHeading) looks like the summary it was. */
.kv-details__heading {
	display: inline;
	margin: 0;
	font: inherit;
	letter-spacing: inherit;
	text-transform: inherit;
}
