/**
 * Accordion: the item colour fades in. Panels slide open and closed via assets/js/aufklappen.js.
 */

/*
 * Hover of the front page's desktop sidebar rows, tunable as one block written by
 * dev/knopf-spielwiese.html ("Save to theme", via dev/verlauf-server.py, which only replaces what is
 * between the two marker comments): drop shadow (x/y/blur/spread/opacity), growth of the white fill
 * around the entry, corner radius at rest and on hover, fade in/out times and easings. The card values
 * (--karte-*, the Überblick cards) live in karte.css, which every page loads.
 * No lift (removed 2026-11-18): a transform moves the card onto its own compositor layer while it
 * animates, the text is redrawn there with other antialiasing and visibly shakes.
 */
/* knopf-spielwiese: start */
:root {
	--reihe-schatten-x: 0px;
	--reihe-schatten-y: 0px;
	--reihe-schatten-blur: 0px;
	--reihe-schatten-spread: 0px;
	--reihe-schatten-deckkraft: 30%;
	--reihe-wachsen: 0px;
	--reihe-rund-ruhe: 0px;
	--reihe-rund-hover: 0px;
	--reihe-ein: 0.1s;
	--reihe-aus: 0.25s;
	--reihe-kurve-ein: ease-out;
	--reihe-kurve-aus: ease-out;
}
/* knopf-spielwiese: end */

@media (prefers-reduced-motion: no-preference) {
	.wp-block-accordion-item {
		transition: background-color 0.1s ease-out;
	}
}

/*
 * Service descriptions wrap normally: core's `text-wrap: pretty` on paragraphs pulls words onto the
 * next line early to even out the lines, which leaves visible gaps in these narrow columns.
 */
.is-style-dienst p {
	text-wrap: wrap;
}

/*
 * Desktop sidebar: the group colour (open group, or a hovered one) runs out to the left screen edge
 * when the page is wider than the layout box (wideSize, 1920px), like the current service in the
 * Dienste-Liste. A border-image with an outset paints the item and the strip in one piece: the
 * absolutely placed ::before strip used before met the item at a fractional pixel (a faint vertical
 * line at the box edge) and could leave colour behind below the group. --flaeche is the group
 * colour while the group shows it (open, hovered or keyboard-focused label; closed groups are
 * transparent otherwise, accordion-dienste.json). The border-image is the only thing painting the
 * colour (the item's own background stays transparent): a separate background and border-image
 * fading side by side ran out of step and showed the box edge on every hover. --flaeche is
 * registered as a colour, so the one paint fades as a whole.
 */
@property --flaeche {
	syntax: "<color>";
	inherits: false;
	initial-value: transparent;
}

main > aside .wp-block-accordion.is-style-dienste .wp-block-accordion-item {
	--flaeche: transparent;
	background-color: transparent !important;
	/* Right outset: over the seam to the content column's cards (see the end of this file). */
	border-image: linear-gradient(var(--flaeche) 0 0) fill 0 / / 0 var(--wp--preset--spacing--50) 0 100vw;
	transition: none;
}

@media (prefers-reduced-motion: no-preference) {
	main > aside .wp-block-accordion.is-style-dienste .wp-block-accordion-item {
		transition: --flaeche 0.1s ease-out;
	}
}

main > aside .wp-block-accordion.is-style-dienste .wp-block-accordion-item:is(.is-open, :has(> .wp-block-accordion-heading .wp-block-accordion-heading__toggle:is(:hover, :focus-visible))) {
	&.has-kinder-eltern-background-color { --flaeche: var(--wp--preset--color--kinder-eltern); }
	&.has-junge-menschen-background-color { --flaeche: var(--wp--preset--color--junge-menschen); }
	&.has-alltag-wohnen-background-color { --flaeche: var(--wp--preset--color--alltag-wohnen); }
	&.has-tagesstaetten-background-color { --flaeche: var(--wp--preset--color--tagesstaetten); }
	&.has-arbeit-teilhabe-background-color { --flaeche: var(--wp--preset--color--arbeit-teilhabe); }
}

/*
 * Desktop sidebar on the front page, placement:
 * - Starts right below the header, so an open first group's colour meets it (spacing below).
 * - Rows, the services in an open group and the gap between a service's title and description
 *   grow with the screen height (spacing below), so tall screens don't show a cramped block above
 *   a lot of empty grey and laptops can still fit the whole list.
 * - On screens tall enough for the longest open group (Alltag & Wohnen) plus the header that comes
 *   back when scrolling up (about 900px at the default text size) it stays in view while
 *   scrolling, flush with the top edge (below the header while it is shown,
 *   and below the admin bar when logged in);
 *   the first row's padding keeps its text off the edge, and an open first group's colour runs
 *   to the edge. The height check is in em, which follows the visitor's text size setting: with
 *   larger text the list grows and sticking needs a correspondingly taller screen, so the list's
 *   end can't be cut off. Browser zoom shrinks the viewport, which has the same effect.
 * - The part around it fills the sidebar (on other pages a drawing sits below it; the front page
 *   has none, the drawing is in its "Wer wir sind" section).
 */
@media (min-width: 1281px) {
	main > aside > .wp-block-template-part:has(> .wp-block-accordion.is-style-dienste) {
		flex-grow: 1;
	}

	/*
	 * Spacing, all fixed ratios of --zeilenabstand, so the relationships stay the same at every size:
	 * - --geschlossen: above and below a closed group's label.
	 * - --aussen: an open group's colour edge to its label and below its last service. The same as a
	 *   closed row's, so a label never moves when its group opens or closes (closed rows were 1.3×
	 *   and open edges 1.7×, which made the text jump; both are 1.7× since 2026-11-18).
	 * - --innen: half the gap between label and service and between services, tighter than the edges
	 *   so the services read as belonging together.
	 * --zeilenabstand shrinks steeply with the screen height (28px from about 1180px, 12px at about
	 * 900px), sized so the longest open group plus the header still fits on the screen: more laptops
	 * get the sticky list (min-height below), big screens keep the roomy look.
	 */
	main > aside .wp-block-accordion.is-style-dienste {
		--zeilenabstand: clamp(0.75rem, 5.6vh - 2.4rem, 1.75rem);
		--geschlossen: calc(var(--zeilenabstand) * 1.7);
		--aussen: var(--geschlossen);
		--innen: calc(var(--zeilenabstand) * 0.6);
	}

	/*
	 * Right edge: spacing|40 instead of the page edge's spacing|50, so labels, icons and text use more of
	 * the narrow column (no hover box needs that room any more); the seam still separates it from the hero.
	 */
	main > aside .wp-block-accordion.is-style-dienste .wp-block-accordion-heading__toggle {
		padding-block: var(--geschlossen);
		padding-inline-end: var(--wp--preset--spacing--40);
	}

	main > aside .wp-block-accordion.is-style-dienste .is-open .wp-block-accordion-heading__toggle {
		padding-block: var(--aussen) var(--innen);
	}

	main > aside .wp-block-accordion.is-style-dienste .is-style-dienst {
		padding-block: var(--innen);
	}

	/* The rest of the bottom edge, so it matches the top whatever the last block is (KOMPASS teaser too). */
	main > aside .wp-block-accordion.is-style-dienste .is-open .wp-block-accordion-panel {
		padding-block-end: calc(var(--aussen) - var(--innen));
	}

	/* Descriptions end at the + / × icon's edge instead of running past it (toggle padding + the icon's inset). */
	main > aside .wp-block-accordion.is-style-dienste .is-style-dienst {
		padding-right: calc(var(--wp--preset--spacing--40) + 0.4rem);
	}

	/*
	 * Text sized by the sidebar's width (tokens in theme.json's global CSS). !important only for the
	 * KOMPASS teaser, whose "Mittel" preset class carries core's !important.
	 */
	main > aside .wp-block-accordion.is-style-dienste .wp-block-accordion-heading,
	main > aside .wp-block-accordion.is-style-dienste .is-style-dienst .wp-block-heading {
		font-size: var(--sidebar-text-gross);
	}

	main > aside .wp-block-accordion.is-style-dienste .wp-block-accordion-panel p {
		font-size: var(--sidebar-text-klein) !important;
	}

	/*
	 * Hover and keyboard focus on a service: the row fades in as a white card (shadow, growth and
	 * corners from the --reihe-* values at the top of this file). No underline, no arrow. The whole row is the link (the title's link stretches over it), so
	 * the card always means "you can click here".
	 */
	main > aside .wp-block-accordion.is-style-dienste .is-style-dienst .wp-block-heading > .listen-pfeil,
	main > aside .wp-block-accordion.is-style-dienste .is-style-dienst .wp-block-heading:has(a)::after {
		display: none;
	}

	main > aside .wp-block-accordion.is-style-dienste .is-style-dienst .wp-block-heading a::after {
		content: "";
		position: absolute;
		inset: 0;
	}

	main > aside .wp-block-accordion.is-style-dienste .is-style-dienst {
		background-color: rgb(255 255 255 / 0);
		border-radius: var(--reihe-rund-ruhe);
		box-shadow: 0 0 0 0 rgb(255 255 255 / 0), 0 0 0 0 transparent;
	}

	main > aside .wp-block-accordion.is-style-dienste .is-style-dienst:is(:hover, :has(a:focus-visible)) {
		background-color: var(--wp--preset--color--base);
		border-radius: var(--reihe-rund-hover);
		box-shadow: 0 0 0 var(--reihe-wachsen) var(--wp--preset--color--base), var(--reihe-schatten-x) var(--reihe-schatten-y) var(--reihe-schatten-blur) calc(var(--reihe-schatten-spread) + var(--reihe-wachsen)) color-mix(in srgb, var(--wp--preset--color--contrast) var(--reihe-schatten-deckkraft), transparent);
	}

	@media (prefers-reduced-motion: no-preference) {
		main > aside .wp-block-accordion.is-style-dienste .is-style-dienst {
			transition: background-color var(--reihe-aus) var(--reihe-kurve-aus), box-shadow var(--reihe-aus) var(--reihe-kurve-aus), border-radius var(--reihe-aus) var(--reihe-kurve-aus);
		}

		main > aside .wp-block-accordion.is-style-dienste .is-style-dienst:is(:hover, :has(a:focus-visible)) {
			transition: background-color var(--reihe-ein) var(--reihe-kurve-ein), box-shadow var(--reihe-ein) var(--reihe-kurve-ein), border-radius var(--reihe-ein) var(--reihe-kurve-ein);
		}
	}

	/* Gap between a service's title and its description: 0.25em up to laptop heights, up to 0.6em on tall screens. */
	main > aside .wp-block-accordion.is-style-dienste .is-style-dienst > .wp-block-heading + p {
		margin-block-start: max(0.25em, min(1.2vh - 5px, 0.6em));
	}
}

@media (min-width: 1281px) and (min-height: 57em) {
	main > aside .wp-block-accordion.is-style-dienste {
		position: sticky;
		/* Below the header while it is shown (it comes back on scrolling up, kopfzeile.js). */
		--anheft-oben: calc(var(--wp-admin--admin-bar--height, 0px) + var(--kopf-hoehe, 0px));
		top: var(--anheft-oben);
		/*
		 * Slides up with the header when it hides, by translate (moved on the GPU in step with the
		 * header's own translate). An animated `top` was laid out again every frame at fractional
		 * offsets and the text shook while scrolling. Pinned by assets/js/anheften.js (fixed
		 * instead of sticky, see kopfzeile.css); at the end of the column the shift is dropped.
		 */
		translate: 0 calc(var(--kopf-sichtbar, 0px) - var(--kopf-hoehe, 0px));
	}

	@media (prefers-reduced-motion: no-preference) {
		main > aside .wp-block-accordion.is-style-dienste {
			transition: translate 0.25s ease;
		}
	}
}

/* Dienste: hover shows the group colour (accordion-dienste.json) instead of core's underline. */
.wp-block-accordion.is-style-dienste .wp-block-accordion-heading__toggle:hover .wp-block-accordion-heading__toggle-title {
	text-decoration: none;
}

/*
 * Dienste on phones and tablets (the accordion in the content column): wider group-colour edge and
 * more white before the service text. 0.6 and 0.8 × spacing|50 = 12px and 16px at phone width.
 */
@media (max-width: 1280px) {
	/* Room above and below the group labels (spacing|40 instead of the style's spacing|30). */
	.wp-block-accordion.is-style-dienste .wp-block-accordion-heading__toggle {
		padding-block: var(--wp--preset--spacing--40);
	}

	.wp-block-accordion.is-style-dienste {
		/* The colour edge around the cards, the same on all four sides (12px at phone width). */
		--rand-mobil: calc(var(--wp--preset--spacing--50) * 0.6);
	}

	.wp-block-accordion.is-style-dienste .wp-block-accordion-panel {
		/*
		 * Front page: the white cards start where the label's text starts (the page edge, spacing|50) and
		 * keep the same colour edge at the right and below, so the open group reads as a band like on the
		 * Überblick. The cards themselves are the Überblick's cards (padding, corners, press state: the
		 * shared rules below, 2026-11-19; until then they ran to the right screen edge, square).
		 */
		padding: 0 var(--wp--preset--spacing--50) var(--wp--preset--spacing--50);
	}

	/*
	 * Closed groups stay neutral (the page grey, accordion-dienste.json); only the open group shows its
	 * colour, as a solid fill (the fade into grey was removed 2026-11-13, see git history).
	 */

	/* Front page: the KOMPASS teaser gets spacing|30 above it (the pattern's spacing|20 is right for the desktop sidebar). */
	.wp-block-accordion.is-style-dienste .wp-block-accordion-panel > .wp-block-group:not(:has(.is-style-dienst)) {
		padding-top: var(--wp--preset--spacing--30) !important;
	}

	/*
	 * Each service is its own white card, spacing|20 apart, so the group colour shows between them
	 * like on the Dienste overview. Only the wrapper holding services stacks; the KOMPASS teaser is a
	 * separate group after it.
	 */
	.wp-block-accordion.is-style-dienste .wp-block-accordion-panel > .wp-block-group:has(> .is-style-dienst) {
		display: flex;
		flex-direction: column;
		gap: var(--wp--preset--spacing--20);
	}
}

/*
 * Dienste overview page (functions.php renders the groups open, headings without toggle button).
 * Every group is a band in its colour, the bands meeting without a gap; the label sits on the band
 * (no tab), above the cards on phones and tablets, in a column of its own on desktop (below).
 * Phones and tablets match the front page's open group exactly: the label with the toggle's
 * padding and the Dienste style's type, the cards with the panel's colour edge on the left
 * (rule above), running to the right edge and the end of the band.
 */
.is-dienste-uebersicht .wp-block-accordion {
	display: flex;
	flex-direction: column;
	gap: 0;
}

.is-dienste-uebersicht .wp-block-accordion-heading {
	margin: 0;
	padding: 0 0 var(--rand-mobil, 12px);
	font-size: var(--wp--preset--font-size--small);
}

/* The overview lists services only: the KOMPASS teaser of the shared Dienste content is left out here. */
.is-dienste-uebersicht .wp-block-accordion-panel > .wp-block-group:not(:has(.is-style-dienst)) {
	display: none;
}

/*
 * Every service is its own white card on the group colour, spacing|20 apart like all cards, so the
 * colour shows between them. Only the wrapper holding services is a stack: the KOMPASS teaser group is hidden above.
 */
.is-dienste-uebersicht .wp-block-accordion.is-style-dienste .wp-block-accordion-panel {
	padding: 0;
}

/* The cards' inner edge, the same on the Überblick and the front page (phones/tablets). */
:is(.is-dienste-uebersicht, .is-dienste-mobil) .wp-block-accordion.is-style-dienste .wp-block-accordion-panel {
	--dienst-einzug: calc(var(--wp--preset--spacing--50) * 0.8);
}

/*
 * Phones: each band has the same colour edge on all sides, the page edge (spacing|50), so the label
 * and the cards line up with the title and intro above (and with the front page's open group);
 * 12px until 2026-11-19 (card R08). A small label.
 */
.is-dienste-uebersicht .wp-block-accordion-item {
	padding: var(--wp--preset--spacing--50);
}

.is-dienste-uebersicht .wp-block-accordion-panel > .wp-block-group:has(.is-style-dienst) {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--20);
}

:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst,
:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst:is(:hover, :focus-within) {
	background-color: var(--wp--preset--color--base);
}

/*
 * The whole card is the link (the title's link stretches over it), so the hover shadow below always
 * means "you can click here". New-tab links keep their ↗ and stay as small as the title.
 */
:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst .wp-block-heading a:not([target="_blank"])::after {
	content: "";
	position: absolute;
	inset: 0;
}

/*
 * Hover and keyboard focus: the shared card hover (values: --karte-* in button.css; the Jobs page's
 * cards have the same, post-template.css): a soft shadow below the card, see-through dark so it
 * shades the colour it falls on. A fill growth is a white spread around the card, so the card's text
 * doesn't move. Nothing moves the card itself (see the note at the top of this file).
 */
:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst {
	border-radius: var(--karte-rund-ruhe);
	box-shadow: 0 0 0 0 rgb(255 255 255 / 0), 0 0 0 0 transparent;
}

:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst:is(:hover, :has(a:focus-visible)) {
	border-radius: var(--karte-rund-hover);
	box-shadow: 0 0 0 var(--karte-wachsen) var(--wp--preset--color--base), var(--karte-schatten-x) var(--karte-schatten-y) var(--karte-schatten-blur) calc(var(--karte-schatten-spread) + var(--karte-wachsen)) color-mix(in srgb, var(--wp--preset--color--contrast) var(--karte-schatten-deckkraft), transparent);
}

@media (prefers-reduced-motion: no-preference) {
	:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst {
		transition: box-shadow var(--karte-aus) var(--karte-kurve-aus), border-radius var(--karte-aus) var(--karte-kurve-aus);
	}

	:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst:is(:hover, :has(a:focus-visible)) {
		transition: box-shadow var(--karte-ein) var(--karte-kurve-ein), border-radius var(--karte-ein) var(--karte-kurve-ein);
	}
}

/*
 * Overview on desktop and tablets (template "Angebote-Überblick", title and intro in the sidebar): every group is
 * a band in its colour across the content column, the bands meeting without a gap. Like the white
 * sections (abschnitt-zweispaltig), the label sits in the left third and the service cards in the
 * right two thirds. Hover shows the shadow (above) plus an arrow at the
 * card's right edge, no underline. Phones and tablets: label above the cards; the arrow sits in the
 * title row and fades in on hover too (the "Dienst" style in theme.json).
 */
@media (min-width: 1281px) {
	/* The first band starts level with the title in the sidebar (its group's top padding). */
	main.ist-uebersicht > .is-style-inhaltsspalte {
		padding-top: var(--wp--preset--spacing--20);
	}
}

/* From 850px up (wide tablets, desktop) the bands are two-column, with title and intro on top instead of in the sidebar below 1281px. */
@media (min-width: 850px) {
	.is-dienste-uebersicht .wp-block-accordion-item {
		--band-abstand: var(--wp--preset--spacing--40);
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
		align-items: start;
		column-gap: var(--band-abstand);
		padding: var(--band-abstand);
	}

	/* The label's top sits on the first card's top edge. */
	.is-dienste-uebersicht .wp-block-accordion-heading {
		padding: 0;
		font-size: var(--wp--preset--font-size--large);
	}

	:is(.is-dienste-uebersicht, .is-dienste-mobil) .wp-block-accordion-panel {
		--dienst-einzug: var(--wp--preset--spacing--40);
	}
}

/* Tablet bands: label and cards on the page edge, in line with the title and intro above. */
@media (min-width: 850px) and (max-width: 1280px) {
	.is-dienste-uebersicht .wp-block-accordion-item {
		padding-inline: var(--wp--preset--spacing--50);
	}
}

@media (min-width: 850px) {
	/*
	 * Hover and keyboard focus: besides the shadow, an arrow fades in at the card's right edge (no
	 * slide: the text must stay still), as far
	 * in as the text on the left, sized with the title and as tall as its line (1.2), so it sits on the
	 * first line even when a title wraps. Titles keep clear of it (12px gap).
	 * The ::after is the editor's fallback (no SVG there, functions.php).
	 */
	:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst .wp-block-heading {
		padding-right: calc(1.2em + var(--dienst-einzug) - var(--wp--preset--spacing--30) + 12px);
	}

	:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst .wp-block-heading > .listen-pfeil,
	:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst .wp-block-heading:has(a):not(:has(> .listen-pfeil))::after {
		position: absolute;
		top: var(--wp--preset--spacing--30);
		right: var(--dienst-einzug);
		width: 1.2em;
		height: 1.2em;
		margin: 0;
		opacity: 0;
	}

	:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst .wp-block-heading:has(a):not(:has(> .listen-pfeil))::after {
		-webkit-mask-size: contain;
		mask-size: contain;
	}

	:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst:is(:hover, :has(a:focus-visible)) .wp-block-heading > .listen-pfeil,
	:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst:is(:hover, :has(a:focus-visible)) .wp-block-heading:has(a):not(:has(> .listen-pfeil))::after {
		opacity: 1;
	}

	@media (prefers-reduced-motion: no-preference) {
		:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst .wp-block-heading > .listen-pfeil,
		:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst .wp-block-heading:has(a):not(:has(> .listen-pfeil))::after {
			transition: opacity 0.07s ease-in;
		}

		:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst:is(:hover, :has(a:focus-visible)) .wp-block-heading > .listen-pfeil,
		:is(.is-dienste-uebersicht, .is-dienste-mobil) .is-style-dienst:is(:hover, :has(a:focus-visible)) .wp-block-heading:has(a):not(:has(> .listen-pfeil))::after {
			transition: opacity 0.1s ease-out;
		}
	}
}

/*
 * The Überblick template: title and intro sit in the sidebar on desktop. On phones and tablets the
 * sidebar stays (other templates hide it) and stacks above the groups as the page head.
 */
@media (max-width: 1280px) {
	main.ist-uebersicht {
		flex-direction: column;
	}

	main.ist-uebersicht > aside {
		flex-basis: auto !important;
	}
}

/*
 * Front page sidebar on desktop: the open group is a solid fill in its group colour, reaching over
 * the seam to meet the column's cards (the item's border-image outset at the right; the column
 * paints its own colour only inside its padding, startseite.css). On screens wider than the layout
 * box the fill runs out to the left screen edge through the same border-image (the one a hovered
 * row uses, top of this file). Hovering a
 * closed group still fills that row with its colour (accordion-dienste.json); phones and tablets
 * colour just the open group. (A band that faded out from the open group through the hero, with
 * grain, was removed 2026-11-14; see git history.)
 */
