/*
Theme Name: Klauw
Theme URI: https://klauw.be
Author: Jens Clauwaert
Author URI: https://klauw.be
Description: Bloktheme voor Klauw. Kleuren, typografie en ruimte staan in theme.json; deze stylesheet bevat de kleurregisters en wat theme.json niet kan uitdrukken.
Version: 0.7.8
Requires at least: 6.7
Tested up to: 7.1
Requires PHP: 8.1
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: klauw
*/

/*
 * Fallback faces with adjusted metrics, so the swap to the web fonts does not
 * move the layout. Values read from the font files, measured against Arial.
 */
@font-face {
	font-family: "Archivo fallback";
	src: local("Arial"), local("Helvetica"), local("Liberation Sans");
	size-adjust: 112.7%;
	ascent-override: 77.9%;
	descent-override: 18.6%;
	line-gap-override: 0%;
}

@font-face {
	font-family: "Schibsted fallback";
	src: local("Arial"), local("Helvetica"), local("Liberation Sans");
	size-adjust: 107%;
	ascent-override: 91.3%;
	descent-override: 24.1%;
	line-gap-override: 0%;
}

/*
 * Colour registers. A register is one complete set of roles: paper, ink, one
 * accent, and the tones derived from them. Note and muted were searched per
 * register for contrast (at least 5.0 and 4.6 on paper), not mixed by eye.
 *
 * Everything on the site paints with the semantic --k-* roles below, never
 * with a literal colour. That is what lets a section, or the whole page while
 * scrolling, change register by rewriting seven variables.
 */
:root {
	--reg-boter-paper: var(--wp--preset--color--cream);
	--reg-boter-ink: var(--wp--preset--color--ink);
	--reg-boter-accent: var(--wp--preset--color--ember);
	--reg-boter-card: var(--wp--preset--color--sand);
	--reg-boter-rule: #D4CAAB;
	--reg-boter-note: #66604F;
	--reg-boter-muted: #6C6654;

	--reg-mint-paper: var(--wp--preset--color--mint);
	--reg-mint-ink: #0A1712;
	--reg-mint-accent: var(--wp--preset--color--jade);
	--reg-mint-card: #D7E5DF;
	--reg-mint-rule: #C4D2CC;
	--reg-mint-note: #5A6762;
	--reg-mint-muted: #5E6C66;

	--reg-ash-paper: var(--wp--preset--color--ash);
	--reg-ash-ink: #16150F;
	--reg-ash-accent: var(--wp--preset--color--ember);
	--reg-ash-card: #CECBC3;
	--reg-ash-rule: #BDBAB2;
	--reg-ash-note: #58564F;
	--reg-ash-muted: #5C5A53;

	/* The fire plane is the accent turned 8% towards ink, so light text clears AA on it. */
	--reg-fire-paper: var(--wp--preset--color--fire);
	--reg-fire-ink: #FFF6F2;
	--reg-fire-accent: #F4E3B8;
	--reg-fire-card: #CF4425;
	--reg-fire-rule: #D35538;
	--reg-fire-note: #FFF6F2;
	--reg-fire-muted: #FEF4F0;

	--reg-ink-paper: var(--wp--preset--color--ink);
	--reg-ink-ink: var(--wp--preset--color--cream);
	--reg-ink-accent: var(--wp--preset--color--ember);
	--reg-ink-card: #25211A;
	--reg-ink-rule: #37332A;
	--reg-ink-note: #958C7C;
	--reg-ink-muted: #958C7C;

	/* The register in force. Boter unless a section or the scroll says otherwise. */
	--k-paper: var(--reg-boter-paper);
	--k-ink: var(--reg-boter-ink);
	--k-accent: var(--reg-boter-accent);
	--k-card: var(--reg-boter-card);
	--k-rule: var(--reg-boter-rule);
	--k-note: var(--reg-boter-note);
	--k-muted: var(--reg-boter-muted);

	--k-edge: var(--wp--preset--spacing--edge, 1.25rem);

	/* The mark as a mask, for places that only need its silhouette in the current colour. */
	--k-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 11'%3E%3Cpath d='M0 1h1v6H0zM1 1h1v8H1zM2 1h1v4H2zM2 6h1v3H2zM4 0h1v3H4zM5 0h2v11H5zM7 2h1v4H7zM9 1h2v8H9zM11 1h1v4h-1z'/%3E%3C/svg%3E");
	--k-label-spacing: 0.16em;
}

/*
 * A section carries its own register, except while page.js is flipping the
 * whole page between registers on scroll: then the roles live on the root.
 */
[class*="is-style-reg-"] {
	background-color: var(--k-paper);
	color: var(--k-ink);
}

html:not(.has-flip) .is-style-reg-boter {
	--k-paper: var(--reg-boter-paper);
	--k-ink: var(--reg-boter-ink);
	--k-accent: var(--reg-boter-accent);
	--k-card: var(--reg-boter-card);
	--k-rule: var(--reg-boter-rule);
	--k-note: var(--reg-boter-note);
	--k-muted: var(--reg-boter-muted);
}

html:not(.has-flip) .is-style-reg-mint {
	--k-paper: var(--reg-mint-paper);
	--k-ink: var(--reg-mint-ink);
	--k-accent: var(--reg-mint-accent);
	--k-card: var(--reg-mint-card);
	--k-rule: var(--reg-mint-rule);
	--k-note: var(--reg-mint-note);
	--k-muted: var(--reg-mint-muted);
}

html:not(.has-flip) .is-style-reg-ash {
	--k-paper: var(--reg-ash-paper);
	--k-ink: var(--reg-ash-ink);
	--k-accent: var(--reg-ash-accent);
	--k-card: var(--reg-ash-card);
	--k-rule: var(--reg-ash-rule);
	--k-note: var(--reg-ash-note);
	--k-muted: var(--reg-ash-muted);
}

html:not(.has-flip) .is-style-reg-fire {
	--k-paper: var(--reg-fire-paper);
	--k-ink: var(--reg-fire-ink);
	--k-accent: var(--reg-fire-accent);
	--k-card: var(--reg-fire-card);
	--k-rule: var(--reg-fire-rule);
	--k-note: var(--reg-fire-note);
	--k-muted: var(--reg-fire-muted);
}

html:not(.has-flip) .is-style-reg-ink {
	--k-paper: var(--reg-ink-paper);
	--k-ink: var(--reg-ink-ink);
	--k-accent: var(--reg-ink-accent);
	--k-card: var(--reg-ink-card);
	--k-rule: var(--reg-ink-rule);
	--k-note: var(--reg-ink-note);
	--k-muted: var(--reg-ink-muted);
}

/* Base. */
html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-behavior: smooth;
}

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

::selection {
	background: var(--k-ink);
	color: var(--k-paper);
}

:focus-visible {
	outline: 2px solid var(--k-accent);
	outline-offset: 2px;
}

:where(h1, h2, h3) {
	text-wrap: balance;
	/* A word longer than the screen is wide ("webdesigntraject" at 320 pixels) breaks instead of being cut off. */
	overflow-wrap: break-word;
}

/* On a phone the big type may hyphenate, so long Dutch compounds break where a reader expects it. */
@media (max-width: 520px) {
	:where(h1, h2, h3, .klauw-statement) {
		-webkit-hyphens: auto;
		hyphens: auto;
	}
}

:where(h2, h3) {
	scroll-margin-top: 7rem;
}

/* Links in running text stay ink; the accent is only the line under them. */
:where(p, li, summary) > a {
	text-decoration-color: var(--k-accent);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.22em;
}

/* Paragraph styles: Label, Status, Sectielabel. Mono is for labels only. */
.is-style-label,
.is-style-status,
.is-style-section {
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--label);
	font-weight: 400;
	letter-spacing: var(--k-label-spacing);
	line-height: 1.4;
	text-transform: uppercase;
}

.is-style-status,
.is-style-section {
	display: flex;
	align-items: center;
	gap: 0.9em;
}

.is-style-status::before {
	content: "";
	flex: none;
	inline-size: 0.7em;
	block-size: 0.7em;
	background: var(--k-accent);
	animation: klauw-blink 1.4s steps(1, end) infinite;
}

/* A section label is bare text with the mark in front: never a pill, never a number. */
.is-style-section {
	color: var(--k-muted);
}

.is-style-section::before {
	content: "";
	flex: none;
	inline-size: 1.25em;
	block-size: 1.15em;
	background: var(--k-accent);
	-webkit-mask: var(--k-mark) center / contain no-repeat;
	mask: var(--k-mark) center / contain no-repeat;
}

@keyframes klauw-blink {
	50% {
		opacity: 0;
	}
}

/* Paragraph style: Resultaat. The one sentence with the figure, against an accent line. */
.is-style-result {
	padding-inline-start: 1rem;
	border-inline-start: 3px solid var(--k-accent);
}

.is-style-result strong {
	display: block;
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--row);
	font-weight: 800;
	letter-spacing: -0.03em;
	line-height: 1.1;
}

/* List style: Tags. */
.is-style-tags {
	margin-block: 0;
}

.wp-block-list.is-style-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35em 1.4em;
	margin-inline: 0;
	padding: 0;
	list-style: none;
	color: var(--k-muted);
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--label);
	letter-spacing: var(--k-label-spacing);
	text-transform: uppercase;
}

/* The canvas reveal.js lays over an image while it opens or sharpens. */
.klauw-reveal-layer {
	position: absolute;
	inset: 0 auto auto 0;
	inline-size: 100%;
	pointer-events: none;
	image-rendering: crisp-edges;
	image-rendering: pixelated;
}

/* Buttons: stepped state changes instead of eased ones, like the pixel field. */
.wp-block-button__link,
.wp-element-button {
	text-decoration-thickness: 1px;
	text-underline-offset: 0.45em;
	transition: background-color 0.12s steps(2, end), color 0.12s steps(2, end);
}

.wp-block-button__link:active {
	transform: translate(2px, 2px);
}

/* Button style: Licht. */
.wp-block-button.is-style-light > .wp-block-button__link {
	background-color: var(--k-paper);
	color: var(--k-ink);
}

.wp-block-button.is-style-light > .wp-block-button__link:is(:hover, :focus) {
	background-color: var(--k-ink);
	box-shadow: inset 0 -3px 0 0 var(--k-accent);
	color: var(--k-paper);
}

/* Details. Closed text stays in the document; only its box is folded away. */
.wp-block-details > summary {
	cursor: pointer;
	list-style: none;
}

.wp-block-details > summary::-webkit-details-marker {
	display: none;
}

/* Details style: Vraag. A question in the display face with a plus that becomes a minus. */
.wp-block-details.is-style-question {
	margin: 0;
	border-block-start: 1px solid var(--k-rule);
}

.is-style-question > summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1.5rem;
	padding-block: 1.25rem;
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--row);
	font-weight: 600;
	letter-spacing: -0.02em;
	line-height: 1.15;
}

.is-style-question > summary:is(:hover, :focus-visible) {
	text-decoration: underline;
	text-decoration-color: var(--k-accent);
	text-decoration-thickness: 2px;
	text-underline-offset: 0.2em;
}

.is-style-question > summary::after {
	content: "";
	flex: none;
	inline-size: 0.8rem;
	block-size: 0.8rem;
	background:
		linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat,
		linear-gradient(currentColor, currentColor) center / 2px 100% no-repeat;
}

.is-style-question[open] > summary::after {
	background: linear-gradient(var(--k-accent), var(--k-accent)) center / 100% 2px no-repeat;
}

/* Room under an open answer is padding, not margin: the block's own rules reset margins here. */
.wp-block-details.is-style-question > :not(summary) {
	max-width: 38em;
	margin-block: 0;
}

.wp-block-details.is-style-question > :not(summary) + :not(summary) {
	margin-block-start: 1rem;
}

.wp-block-details.is-style-question[open] {
	padding-block-end: 1.75rem;
}

/* Motion is switched off by the visitor, or by their system setting. */
:root[data-klauw-motion="off"] .is-style-status::before {
	animation: none;
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	:root:not([data-klauw-motion="on"]) .is-style-status::before {
		animation: none;
	}

	.wp-block-button__link,
	.wp-element-button {
		transition: none;
	}
}

/*
 * The cookie banner (iubenda) paints its buttons in ember. White on ember is
 * 4.4:1, a shade under WCAG AA; three percent darker reaches 4.65:1 and looks
 * the same. The id twice outweighs the banner's own rule, which it injects
 * later with !important.
 */
#iubenda-cs-banner#iubenda-cs-banner .iubenda-cs-opt-group button.iubenda-cs-btn-primary,
#iubenda-cs-banner#iubenda-cs-banner .iubenda-cs-opt-group button.iubenda-cs-accept-btn,
#iubenda-cs-banner#iubenda-cs-banner .iubenda-cs-opt-group button.iubenda-cs-reject-btn {
	border-color: #d53d1a !important;
	background-color: #d53d1a !important;
}
