*,
*::before,
*::after {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

/* :where() keeps the specificity at 0, so .button and other classes on an <a> can set the color */
:where(a) {
	text-decoration: none;
	color: inherit;
}

html {
	font-size: 100%;
}

body {
	/* ------------------------------ TYPOGRAPHY ------------------------------ */
	/* Rules for readable text */
	--line-height-default: 1.6;
	--line-height-headings: 1.2;
	--font-size-small: 0.875rem;
	--font-size-default: 1rem;
	--font-size-large: 1.125rem;
	--letter-spacing: calc(var(--font-size-default) * 0.06);
	--word-spacing: calc(var(--font-size-default) * 0.15);
	--paragraph-clamp: clamp(25ch, 90%, 65ch);

	--font-sans: 'DMSans', sans-serif;
	--font-serif: 'DMSerifDisplay', serif;

	font-family: var(--font-sans);
	font-size: var(--font-size-default);
	line-height: var(--line-height-default);
	letter-spacing: var(--letter-spacing);
	word-spacing: var(--word-spacing);

	/* Responsive headings */
	--font-size-h1: clamp(2.125rem, calc(1.786vw + 1.768rem), 3.375rem); /* 34 → 54px */
	--font-size-h2: clamp(1.75rem, calc(1.071vw + 1.536rem), 2.5rem); /* 28 → 40px */
	--font-size-h3: clamp(1.75rem, calc(0.893vw + 1.571rem), 2.375rem); /* 28 → 38px */
	--font-size-h4: clamp(1.5rem, calc(1.071vw + 1.286rem), 2.25rem); /* 24 → 36px */
	--font-size-h5: clamp(1.25rem, calc(0.357vw + 1.179rem), 1.5rem); /* 20 → 24px */
	--font-size-h6: clamp(1.25rem, calc(0.179vw + 1.214rem), 1.375rem); /* 20 → 22px */

	/* ------------------------------ SPACING ------------------------------ */
	--spacing-base-unit: 0.5rem;
	--space-0: calc(0 * var(--spacing-base-unit));
	--space-025: calc(0.25 * var(--spacing-base-unit));
	--space-050: calc(0.5 * var(--spacing-base-unit));
	--space-075: calc(0.75 * var(--spacing-base-unit));
	--space-100: calc(1 * var(--spacing-base-unit));
	--space-150: calc(1.5 * var(--spacing-base-unit));
	--space-200: calc(2 * var(--spacing-base-unit));
	--space-250: calc(2.5 * var(--spacing-base-unit));
	--space-300: calc(3 * var(--spacing-base-unit));
	--space-400: calc(4 * var(--spacing-base-unit));
	--space-500: calc(5 * var(--spacing-base-unit));
	--space-600: calc(6 * var(--spacing-base-unit));
	--space-700: calc(7 * var(--spacing-base-unit));
	--space-800: calc(8 * var(--spacing-base-unit));
	--space-900: calc(9 * var(--spacing-base-unit));
	--space-1000: calc(10 * var(--spacing-base-unit));

	/* ------------------------------ Border ------------------------------ */
	--radius-16: 1rem;
	--radius-16-child: calc(var(--radius-16) * 0.5);

	--radius-12: 0.75rem;
	--radius-12-child: calc(var(--radius-12) * 0.5);

	--radius-8: 0.5rem;
	--radius-8-child: calc(var(--radius-8) * 0.5);

	/* ------------------------------ COLORS ------------------------------ */
	--brand-red: #c8102e;
	--brand-red-light: #f9e6e9;

	--cream: #eadbc8;
	--cream-light: #f5f0e9;

	--ink: #1a1a1a;
	--white: #ffffff;

	--grey-warm: #8a8175;
	--grey-light: #e0ddd9;
	--grey-dark: #6b645b;
}

@font-face {
	font-family: 'DMSans';
	src: url('/fonts/DMSans-VariableFont_opsz,wght.woff2') format('woff2');
	font-weight: 100 900;
	font-style: normal;
}

@font-face {
	font-family: 'DMSerifDisplay';
	src: url('/fonts/DMSerifDisplay-Italic.woff2') format('woff2');
	font-style: italic;
	font-weight: 400;
}

@font-face {
	font-family: 'DMSerifDisplay';
	src: url('/fonts/DMSerifDisplay-Regular.woff2') format('woff2');
	font-style: normal;
	font-weight: 400;
}

/* ------------------------------ APPLY STYLES ------------------------------ */
h1,
h2,
h3,
h4,
h5,
h6 {
	font-family: var(--font-serif);
	/* DMSerifDisplay heeft alleen 400; zonder dit maakt de browser nep-bold */
	font-weight: 400;
	line-height: var(--line-height-headings);
}

h1 {
	font-size: var(--font-size-h1);
}

h2 {
	font-size: var(--font-size-h2);
}

h3 {
	font-size: var(--font-size-h3);
}

h4 {
	font-size: var(--font-size-h4);
}

h5 {
	font-size: var(--font-size-h5);
}

h6 {
	font-size: var(--font-size-h6);
}

.visually-hidden {
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	height: 1px;
	overflow: hidden;
	position: absolute;
	white-space: nowrap;
	width: 1px;
}

/* ------------------------------ EYEBROW ------------------------------ */
/* Small label above or instead of a heading: SectionHeading, HomeHero slogan, Footer columns.
   The knobs have specificity 0 like the other classes; the properties are on .eyebrow itself,
   because the label is usually an h2 and has to beat the h1–h6 rules above (serif, 400, h2 size) */
:where(.eyebrow) {
	--_eyebrow-size: var(--font-size-default);
	--_eyebrow-letter-spacing: var(--letter-spacing);
	--_eyebrow-case: uppercase;
}

.eyebrow {
	font-family: var(--font-sans);
	font-size: var(--_eyebrow-size);
	font-weight: 700;
	letter-spacing: var(--_eyebrow-letter-spacing);
	text-transform: var(--_eyebrow-case);
}

/* ------------------------------ SECTIONS ------------------------------ */
/* :where() keeps specificity at 0, so component styles always override these defaults */
:where(.page-section) {
	/* colors */
	--_background: var(--white);
	--_color: var(--ink);
	--_highlight: var(--brand-red);

	/* spacing */
	/* padding-block = top + bottom */
	--_padding-block: var(--space-200) var(--space-900);
	/* padding-inline = left + right */
	--_padding-inline: max(var(--space-300), 8%);
	--_gap: var(--space-200);
	--_row-gap: var(--_gap);
	--_column-gap: var(--_gap);
	/* space above the section heading, also used to align elements next to or above it */
	--_heading-offset: var(--space-500);

	background-color: var(--_background);
	color: var(--_color);
	padding-block: var(--_padding-block);
	padding-inline: var(--_padding-inline);
	row-gap: var(--_row-gap);
	column-gap: var(--_column-gap);
}

/* ------------------------------ CARD ------------------------------ */
/* appearance only; layout (grid, width, row span) lives in the component */
:where(.card) {
	--_background: var(--white);
	--_color: var(--grey-warm);
	--_border-color: var(--cream-light);

	background-color: var(--_background);
	outline: 2px solid var(--_border-color);
	border-radius: var(--radius-12);
	padding: var(--space-200);
	transition: 300ms ease-out;

	&:hover,
	&:has(:focus-visible) {
		--_background: var(--cream);
	}

	p {
		color: var(--_color);
	}
}

/* ------------------------------ BUTTON ------------------------------ */
/* for <button> and for links: CtaLink puts this class on its <a>; layout (width, height) lives in the component.
   States only change the knobs, so a modifier or component can override them. */
:where(.button) {
	--_background: var(--brand-red);
	--_color: var(--white);
	--_border-color: var(--brand-red);
	/* block inline, like the padding shorthand */
	--_padding: var(--space-075) var(--space-200);
	/* line around the button; an outline, so it never changes the size. 0 = no line */
	--_outline-width: 0px;
	--_outline-offset: 0px;

	padding: var(--_padding);
	border: none;
	border-radius: var(--radius-8);
	outline: var(--_outline-width) solid var(--_border-color);
	outline-offset: var(--_outline-offset);
	background-color: var(--_background);
	color: var(--_color);
	font: inherit;
	cursor: pointer;
	transition: 0.2s ease-out;

	&:hover {
		--_background: transparent;
		--_color: var(--ink);
		--_outline-width: 1px;
	}

	/* thicker than the hover line and a bit away from the button; colors: see below */
	&:focus-visible {
		--_outline-width: 2px;
		--_outline-offset: 2px;
	}

	&:disabled {
		--_background: var(--grey-light);
		--_color: var(--grey-dark);
		--_outline-width: 0px;
		cursor: not-allowed;
	}
}

/* Keyboard focus also gets the hover colors. A separate rule, so its specificity stays 0:
   a modifier (.outline, admin .secondary) or a component keeps its own colors on focus */
:where(.button:focus-visible) {
	--_background: transparent;
	--_color: var(--ink);
}

/* Modifier: red text and line, filled on hover and focus (like the reset link of the news filters).
   The line is drawn on the inside, like a border, so the button lines up with the fields. */
:where(.button.outline) {
	--_background: transparent;
	--_color: var(--brand-red);
	--_outline-width: 1px;
	--_outline-offset: -1px;

	&:is(:hover, :focus-visible) {
		--_background: var(--brand-red);
		--_color: var(--white);
	}
}

/* ------------------------------ FIELD ------------------------------ */
/* Knobs on body (like the admin panel sets them on main), not on the field itself:
   a parent (form, label) can set them and every field inside inherits them */
:where(body) {
	--_field-border-width: 2px;
	--_field-border: var(--grey-light);
	--_field-border-hover: var(--grey-warm);
	--_field-border-focus: var(--brand-red);
	--_field-background: var(--white);
	--_field-background-disabled: var(--cream-light);
	/* block inline, like the padding shorthand */
	--_field-padding: var(--space-100) var(--space-150);
}

/* appearance of input, textarea and the trigger of Select; layout (width, height) lives in the component */
:where(.field) {
	padding: var(--_field-padding);
	border: var(--_field-border-width) solid var(--_field-border);
	border-radius: var(--radius-8);
	background-color: var(--_field-background);
	color: var(--ink);
	/* form controls don't inherit the page font by default (textarea falls back to monospace) */
	font: inherit;
	font-size: var(--font-size-default);
	font-weight: 400;
	transition: border-color 0.15s ease-out;

	&:hover {
		--_field-border: var(--_field-border-hover);
	}

	/* the red border is the focus indicator */
	&:focus-visible {
		--_field-border: var(--_field-border-focus);
		outline: none;
	}

	&:disabled {
		--_field-background: var(--_field-background-disabled);
		cursor: not-allowed;
	}
}

/* ------------------------------ FRAME ------------------------------ */
/* soft frame: line, radius and shadow; no background, padding or hover (ContactInfo cards, LocationMap) */
:where(.frame) {
	border: 1px solid var(--cream);
	border-radius: var(--radius-16);
	box-shadow: 0 var(--space-100) var(--space-300) color-mix(in srgb, var(--ink) 3%, transparent);
}

/* ------------------------------ TABLE ------------------------------ */
/* cellen en kop; voor .table (admin-overzichten) en tabellen in .markdown-content (die hebben geen class).
   Rand om de tabel, zebrastrepen en scrollen staan bij .markdown-content */
:where(.table, .markdown-content table) {
	/* separate: border-radius werkt en de rand onder een sticky kop scrolt niet weg */
	border-collapse: separate;
	border-spacing: 0;

	:where(th, td) {
		padding-block: var(--space-100);
		padding-inline: var(--space-200);
		border-block-end: 1px solid var(--grey-light);
		white-space: nowrap;
	}

	/* uitlijning uit markdown (align-attribuut) respecteren */
	:where(th:not([align])) {
		text-align: start;
	}

	:where(thead th) {
		background-color: var(--cream-light);
		font-weight: 700;
		border-block-end: 2px solid var(--cream);
	}
}

/* ------------------------------ MARKDOWN CONTENT ------------------------------ */
/* HTML uit het adminpanel (via {@html}), bv. diensten en nieuwsartikelen */
:where(.markdown-content) {
	--_max-width: var(--paragraph-clamp);
	--_color: var(--ink);
	--_muted: var(--grey-dark);
	--_highlight: var(--brand-red);
	--_surface: var(--cream-light);

	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space-200);
	width: min(100%, var(--_max-width));
	align-self: start;
	color: var(--_color);
	overflow-wrap: break-word;

	/* ---------- Koppen ---------- */
	h1,
	h2,
	h3,
	h4,
	h5,
	h6 {
		margin-block-start: var(--space-200);
		text-wrap: balance;
	}

	/* geen extra ruimte boven het eerste element */
	> :first-child {
		margin-block-start: 0;
	}

	/* koppen in lopende tekst iets kleiner dan paginakoppen */
	h1 {
		font-size: var(--font-size-h2);
	}
	h2 {
		font-size: var(--font-size-h3);
	}
	h3 {
		font-size: var(--font-size-h4);
	}
	h4 {
		font-size: var(--font-size-h5);
	}
	h5 {
		font-size: var(--font-size-h6);
	}
	h6 {
		font-family: var(--font-sans);
		font-size: var(--font-size-default);
		font-weight: 700;
		text-transform: uppercase;
		color: var(--_muted);
	}

	/* ---------- Tekst ---------- */
	:where(p) {
		text-wrap: pretty;
	}

	:where(strong, b) {
		font-weight: 700;
	}

	:where(del, s) {
		color: var(--_muted);
		text-decoration-thickness: 1px;
	}

	:where(mark) {
		background-color: var(--brand-red-light);
		color: var(--_color);
		padding-inline: var(--space-050);
		border-radius: var(--radius-8-child);
	}

	:where(sub, sup) {
		font-size: 0.75em;
		line-height: 0;
	}

	:where(abbr[title]) {
		text-decoration: underline dotted;
		cursor: help;
	}

	/* ---------- Links ---------- */
	a {
		color: var(--_highlight);
		text-decoration: underline;
		text-decoration-thickness: 1px;
		text-underline-offset: 0.2em;
		transition: text-decoration-thickness 200ms ease-out;

		&:hover {
			text-decoration-thickness: 2px;
		}

		&:focus-visible {
			outline: 2px solid var(--_highlight);
			outline-offset: 2px;
			border-radius: var(--radius-8-child);
		}
	}

	/* ---------- Lijsten ---------- */
	:where(ul, ol) {
		list-style-position: inside;
		display: grid;
		gap: var(--space-075);
	}

	:where(li)::marker {
		color: var(--_highlight);
	}

	:where(ol > li)::marker {
		font-weight: 700;
	}

	/* Geneste lijsten iets laten inspringen */
	:where(li > ul, li > ol) {
		padding-inline-start: 1.5em;
		margin-block-start: var(--space-075);
	}

	/* takenlijst (GFM) */
	:where(li:has(> input[type='checkbox'])) {
		list-style: none;
	}

	:where(input[type='checkbox']) {
		accent-color: var(--_highlight);
		margin-inline-end: var(--space-075);
		vertical-align: middle;
	}

	/* ---------- Definitielijst ---------- */
	:where(dl) {
		display: grid;
		gap: var(--space-050);
	}

	:where(dt) {
		font-weight: 700;

		&:not(:first-child) {
			margin-block-start: var(--space-100);
		}
	}

	:where(dd) {
		padding-inline-start: var(--space-200);
		border-inline-start: 2px solid var(--cream);
		color: var(--_muted);
	}

	/* ---------- Citaat ---------- */
	:where(blockquote) {
		display: grid;
		gap: var(--space-150);
		padding-block: var(--space-200);
		padding-inline: var(--space-300);
		background-color: var(--_surface);
		border-inline-start: 4px solid var(--_highlight);
		border-start-end-radius: var(--radius-12);
		border-end-end-radius: var(--radius-12);
		font-family: var(--font-serif);
		font-style: italic;
		font-size: var(--font-size-large);

		/* genest citaat */
		:where(blockquote) {
			background-color: var(--white);
			border-inline-start-color: var(--cream);
			font-size: var(--font-size-default);
		}

		:where(ul, ol) {
			font-family: var(--font-sans);
			font-style: normal;
		}
	}

	/* ---------- Scheidingslijn ---------- */
	:where(hr) {
		border: none;
		height: 2px;
		background-color: var(--cream);
		margin-block: var(--space-200);
	}

	/* ---------- Code ---------- */
	:where(code, kbd, samp, pre) {
		font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
		font-size: 0.875em;
		letter-spacing: 0;
		word-spacing: 0;
	}

	:where(:not(pre) > code) {
		background-color: var(--_surface);
		color: var(--_highlight);
		padding-block: 0.1em;
		padding-inline: 0.4em;
		border: 1px solid var(--cream);
		border-radius: var(--radius-8-child);
	}

	:where(pre) {
		background-color: var(--ink);
		color: var(--cream-light);
		padding-block: var(--space-200);
		padding-inline: var(--space-250);
		border-radius: var(--radius-12);
		overflow-x: auto;
		line-height: 1.5;
		tab-size: 4;

		/* anders telt 0.875em twee keer (pre én code) */
		:where(code) {
			font-size: inherit;
		}
	}

	:where(kbd) {
		display: inline-block;
		padding-block: 0.1em;
		padding-inline: 0.5em;
		background-color: var(--white);
		border: 1px solid var(--grey-light);
		border-block-end-width: 3px;
		border-radius: var(--radius-8-child);
		line-height: 1.4;
	}

	/* ---------- Afbeeldingen ---------- */
	:where(img, video) {
		display: block;
		max-width: 100%;
		height: auto;
		border-radius: var(--radius-12);
	}

	:where(p:has(> img:only-child)) {
		margin-block: var(--space-100);
	}

	:where(a:has(> img)) {
		display: inline-block;
		border-radius: var(--radius-12);

		img {
			transition: opacity 200ms ease-out;
		}

		&:hover img {
			opacity: 0.85;
		}
	}

	:where(figure) {
		display: grid;
		gap: var(--space-100);
	}

	:where(figcaption) {
		font-size: var(--font-size-small);
		color: var(--_muted);
	}

	/* ---------- Tabel ---------- */
	/* cellen en kop: zie TABLE hierboven */
	:where(table) {
		/* block + max-content: rand sluit om de tabel, te brede tabellen scrollen */
		display: block;
		width: max-content;
		max-width: 100%;
		overflow-x: auto;
		border: 2px solid var(--cream-light);
		border-radius: var(--radius-12);
	}

	:where(tbody tr:last-child) :where(td) {
		border-block-end: none;
	}

	:where(tbody tr:nth-child(even)) {
		background-color: color-mix(in srgb, var(--cream-light) 50%, transparent);
	}

	/* ---------- Uitklapblok ---------- */
	:where(details) {
		border: 2px solid var(--cream-light);
		border-radius: var(--radius-12);
		padding-block: var(--space-150);
		padding-inline: var(--space-200);
		transition: background-color 300ms ease-out;

		&[open] {
			background-color: var(--_surface);

			> summary {
				margin-block-end: var(--space-150);
			}
		}

		> :not(summary) + * {
			margin-block-start: var(--space-150);
		}
	}

	:where(summary) {
		cursor: pointer;
		font-weight: 700;

		&::marker {
			color: var(--_highlight);
		}

		&:focus-visible {
			outline: 2px solid var(--_highlight);
			outline-offset: 4px;
			border-radius: var(--radius-8-child);
		}
	}
}
