/*
 * Entangle Records — engagements: the list of the ways people can take part, and its page.
 *
 * Written to stand on any block theme. Nothing here names a class of a theme: colours, spacing and shape come from
 * custom properties with fallbacks — the theme's own where it has them (--color-*, --radius, --gutter,
 * --wp--preset--spacing--*), else values derived from the colour of the text around. Override the --en-* properties
 * (below) to restyle the whole thing at once.
 *
 *   --en-gap      the air between cards
 *   --en-pad      the air inside a card
 *   --en-rule     the line round a card
 *   --en-muted    the colour of the secondary lines
 *   --en-accent   what can be done: the arrow of a card when pointed at, the way to all of them; --en-tint its ground
 *   --en-ring     the ring round the arrow of a card
 *   --en-alert    a term that runs out ("Until …")
 *   --en-surface  the ground of a card; --en-ground the ground under its picture
 *   --en-radius   the roundness of a card
 *   --en-min      the narrowest a card may be (the grid fits as many as there is room for)
 */

.entangle-engagements,
.entangle-engagements-page {
	--en-gap: var(--wp--preset--spacing--50, 1.5rem);
	--en-pad: var(--wp--preset--spacing--50, 1.5rem);
	--en-rule: var(--color-rule, color-mix(in srgb, currentColor 18%, transparent));
	--en-muted: var(--color-ink-soft, color-mix(in srgb, currentColor 68%, transparent));
	--en-accent: var(--color-brand, currentColor);
	--en-accent-deep: var(--color-brand-deep, var(--en-accent));
	--en-surface: var(--color-card, transparent);
	--en-radius: var(--radius, 0px);
	--en-radius-sm: var(--radius-sm, calc(var(--en-radius) / 2));
	--en-radius-control: var(--radius-control, min(var(--en-radius), 10px));
	--en-on-accent: var(--color-on-brand, #fff);
	--en-tint: var(--color-brand-soft, color-mix(in srgb, var(--en-accent) 12%, transparent));
	--en-ground: var(--color-bg-alt, color-mix(in srgb, currentColor 6%, transparent));
	--en-faint: color-mix(in srgb, currentColor 38%, transparent);
	--en-alert: var(--color-danger, #b42318);
	--en-ring: color-mix(in srgb, currentColor 26%, transparent);
	/* The air under the heading of the list: a theme names it once for every list (--entangle-head-gap). */
	--en-head-gap: var(--entangle-head-gap, var(--wp--preset--spacing--50, 1.5rem));
	--en-min: 16.5rem;
}

/* ===== The page the template draws: the archive ===== */
.entangle-engagements-page {
	box-sizing: border-box;
	width: 100%;
	max-width: var(--container, var(--wp--custom--container, 75rem));
	margin-inline: auto;
	padding-inline: var(--gutter, var(--wp--custom--gutter, 1.25rem));
	padding-block-start: var(--wp--preset--spacing--70, 3rem);
	padding-block-end: var(--entangle-footer-space, var(--wp--preset--spacing--80, 4rem));
}
.entangle-engagements-page > .wp-block-query-title {
	margin-block: 0 var(--wp--preset--spacing--50, 1.5rem);
}

/* ===== The list ===== */
.entangle-engagements {
	box-sizing: border-box;
	min-width: 0;
}
.entangle-engagements__title {
	margin: 0 0 var(--en-head-gap);
}
.entangle-engagements__list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--en-min)), 1fr));
	gap: var(--en-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}
.entangle-engagements__item {
	display: flex;
	min-width: 0;
}
.entangle-engagements__item[hidden] {
	display: none;
}

/* What the visitor chooses between: what runs now, what has been. Two links, the chosen one underlined by the accent. */
.entangle-engagements__switch {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.75rem;
	margin: 0 0 var(--wp--preset--spacing--50, 1.5rem);
	border-block-end: 1px solid var(--en-rule);
}
.entangle-engagements__switch-link {
	margin-block-end: -1px;
	padding-block: 0.75rem;
	border-block-end: 3px solid transparent;
	color: var(--en-muted);
	font-weight: 600;
	text-decoration: none;
}
.entangle-engagements__switch-link:hover {
	color: inherit;
}
.entangle-engagements__switch-link[aria-current="page"] {
	border-block-end-color: var(--en-accent);
	color: inherit;
}

.entangle-engagements__more {
	margin: var(--en-gap) 0 0;
	text-align: center;
}
.entangle-engagements__more > [hidden] {
	display: none;
}
.entangle-engagements__empty {
	margin: 0;
	color: var(--en-muted);
}
.entangle-engagements__all {
	margin: var(--en-gap) 0 0;
}

/* ===== The heading of the list and the way to all of them in ONE row (`--headed`, the owner, 18. 11.) =====
   A list that has both: the way to all of them is a small outlined button, and where the window has the width it
   stands at the end of the heading's row, on the heading's own middle — the list is then read as "this, and there
   is more of it over there". In a narrow window it stays where the markup has it, under the cards, the whole width:
   the one thing left to do after the last card. One link in the markup, moved by the grid. */
.entangle-engagements--headed > .entangle-engagements__all > a {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	box-sizing: border-box;
	min-height: 2.75rem;
	padding: 0.4em 1.125em;
	border: 1px solid var(--en-accent);
	border-radius: var(--en-radius-control);
	color: var(--en-accent-deep);
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
}
.entangle-engagements--headed > .entangle-engagements__all > a::after {
	content: "\2192";
	content: "\2192" / "";
}
@media (hover: hover) {
	.entangle-engagements--headed > .entangle-engagements__all > a:hover {
		background: var(--en-tint);
	}
}
@media (min-width: 48rem) {
	.entangle-engagements--headed {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		column-gap: var(--en-gap);
	}
	.entangle-engagements--headed > * {
		grid-column: 1 / -1;
	}
	.entangle-engagements--headed > .entangle-engagements__title {
		grid-row: 1;
		grid-column: 1;
	}
	.entangle-engagements--headed > .entangle-engagements__all {
		grid-row: 1;
		grid-column: 2;
		align-self: center;
		/* The heading's own air under it: the row is then as tall for the button as for the heading, and the middle
		   of one is the middle of the other. */
		margin: 0 0 var(--en-head-gap);
	}
	.entangle-engagements--headed > .entangle-engagements__all > a {
		display: inline-flex;
		min-height: 2.5rem;
	}
}

/* ===== One engagement =====
   A card on its own surface; the whole of it leads where the engagement leads (the stretched link of its title), so
   nothing else in it is a link while it runs. Read from the top (the owner, 18. 11.: simpler, and not all in the
   tint of the accent): a picture — its own, of what it leads to, of its record, else the picture of its kind —
   then ONE quiet line of what kind it is and when it runs, its name and a sentence, and at the foot the record it
   belongs to and, at its end, an arrow in a ring: the card leads somewhere. The accent comes when it is pointed at. */
.entangle-engagement {
	position: relative;
	display: flex;
	flex: 1;
	flex-direction: column;
	box-sizing: border-box;
	min-width: 0;
	border: 1px solid var(--en-rule);
	border-radius: var(--en-radius);
	background: var(--en-surface);
	overflow: hidden;
	overflow-wrap: break-word;
}
.entangle-engagement:focus-within {
	outline: 2px solid var(--en-accent);
	outline-offset: 2px;
}
@media (hover: hover) {
	.entangle-engagement {
		transition: border-color 0.15s ease, box-shadow 0.15s ease;
	}
	.entangle-engagement:hover {
		border-color: color-mix(in srgb, currentColor 32%, transparent);
		box-shadow: 0 10px 24px -14px color-mix(in srgb, currentColor 45%, transparent);
	}
}

/* The picture: one shape whatever the picture is, flush with the card. Where there is none, the picture of the kind,
   large and faint, on the ground of the page's bands — so the cards of a row begin at one height. */
.entangle-engagement__media {
	display: grid;
	flex: none;
	place-items: center;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	background: var(--en-ground);
	color: var(--en-faint);
}
.entangle-engagement__media > svg {
	width: 3rem;
	height: 3rem;
	stroke-width: 1.25;
}
.entangle-engagement__image {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.entangle-engagement__image {
		transition: transform 0.4s ease;
	}
	.entangle-engagement:hover .entangle-engagement__image {
		transform: scale(1.04);
	}
}

/* The air inside the card is named (--en-pad-y, --en-pad-x): the layouts of the list set the two, not the padding. */
.entangle-engagement__body {
	--en-pad-y: var(--en-pad);
	--en-pad-x: var(--en-pad);
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 0.625rem;
	padding: var(--en-pad-y) var(--en-pad-x);
}

/* What kind it is and when it runs: one line of small words read as one — the picture of the kind, its name, a dash,
   the date (the owner, 19. 11.: the date stood at the far end of the line, away from what it is the date of). Where
   the card is narrow the date goes to a second line and the dash stays at the end of the first. */
.entangle-engagement__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.125rem 0.5rem;
	font-size: 0.875rem;
	line-height: 1.4;
}
/* The picture stands on the middle of the LETTERS beside it, not of their line: a word with no letter under the
   line ("Událost") has its middle a little above the middle of its line, and the picture sat low against it. */
.entangle-engagement__icon {
	display: grid;
	flex: none;
	color: var(--en-muted);
	transform: translateY(-0.07em);
}
.entangle-engagement__icon svg {
	display: block;
	width: 1.125rem;
	height: 1.125rem;
}
.entangle-engagement__kind {
	font-weight: 600;
}
.entangle-engagement__kind:not(:last-child)::after {
	content: "\2014";
	content: "\2014" / "";
	margin-inline-start: 0.5rem;
	color: var(--en-faint);
	font-weight: 400;
}
.entangle-engagement__when {
	margin: 0;
	color: var(--en-muted);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
/* A term that runs out is a warning: "Until …" in the colour of one. */
.entangle-engagement__when[data-when="until"] {
	color: var(--en-alert);
	font-weight: 600;
}

.entangle-engagement__title {
	margin: 0;
	font-size: 1.1875rem;
	line-height: 1.3;
	text-wrap: balance;
}
.entangle-engagement__title a {
	color: inherit;
	text-decoration: none;
}
.entangle-engagement__title a::after {
	content: "";
	position: absolute;
	inset: 0;
}
.entangle-engagement__title a:focus-visible {
	outline: none;
}
.entangle-engagement__lead {
	display: -webkit-box;
	margin: 0;
	overflow: hidden;
	color: var(--en-muted);
	font-size: 0.9375rem;
	line-height: 1.5;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
}

/* The foot: at the bottom of the card whatever the length of what stands above it — the record it belongs to at its
   start, the arrow of the card at its end. No line parts them from the words above (the owner, 19. 11.). */
.entangle-engagement__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 0.75rem 1rem;
	margin-top: auto;
	padding-top: 0.5rem;
}
/* The record it belongs to: one quiet line, the name of the record in the colour of the text. */
.entangle-engagement__about {
	flex: 1 1 10rem;
	min-width: 0;
	margin: 0;
	color: var(--en-muted);
	font-size: 0.8125rem;
	line-height: 1.4;
}
.entangle-engagement__about-label::after {
	content: ":";
}
.entangle-engagement__about-name {
	color: var(--color-ink, currentColor);
	font-weight: 600;
}
/* What to do: an arrow in a ring at the lower end of the card (the owner, 19. 11.: not a button — the words of the
   action are gone from sight, the card says them in its name and its kind). Quiet: a ring of one pixel in a faint
   line and a grey arrow; pointed at, the card fills the ring with the accent. It is no link while the engagement
   runs — the card is the link, and a press anywhere on it goes there. The outcome of what is over IS a link of its
   own: its words stay, the ring follows them. */
.entangle-engagement__action {
	flex: none;
	margin: 0 0 0 auto;
}
.entangle-engagement__go,
.entangle-engagement__result {
	display: inline-flex;
	align-items: center;
	gap: 0.625rem;
	color: var(--en-accent-deep);
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
}
/* The words of the action are not drawn (they are hidden from a screen reader in the markup already). */
.entangle-engagement__go {
	gap: 0;
	font-size: 0;
}
.entangle-engagement__go::after,
.entangle-engagement__result::after {
	content: "\2192";
	content: "\2192" / "";
	display: grid;
	flex: none;
	place-items: center;
	box-sizing: border-box;
	width: 2.25rem;
	height: 2.25rem;
	border: 1px solid var(--en-ring);
	border-radius: 50%;
	color: var(--en-muted);
	font-size: 1rem;
	font-weight: 400;
	line-height: 1;
}
/* The outcome is a link of its own (above the stretched one). */
.entangle-engagement__result {
	position: relative;
	z-index: 1;
}
@media (hover: hover) {
	.entangle-engagement:hover .entangle-engagement__go::after,
	.entangle-engagement__result:hover::after {
		border-color: var(--en-accent);
		background: var(--en-accent);
		color: var(--en-on-accent);
	}
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.entangle-engagement__go::after,
	.entangle-engagement__result::after {
		transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
	}
}

/* What is over is said more quietly: its picture loses its colour. */
.entangle-engagement--closed .entangle-engagement__image {
	filter: grayscale(1);
	opacity: 0.8;
}

/* ===== Wide cards (`layout: wide`; the owner, 18. 11.) =====
   A short list — what people can take part in NOW is one thing, two, seldom more than four — set so that it fills
   the width whatever it holds, and so that it is not one more row of standing cards on a page of rows of cards.
   Every card lies down: its picture at its start, its words beside it. All of them are the same size (a first card
   larger than the rest was tried and stood over the page), and they share the width by their number:
     one    across the whole width, its picture on one half, its name as large as a headline;
     two    side by side;
     three  side by side where the window is wide; else two, and the third across under them;
     four   two rows of two (and so on: an odd last card lies across).
   A card says what it is, when, its name and what to do; its sentence and the record it belongs to are on the
   page it leads to (the owner, 19. 11.: no sentence under the name — the one card of a list of one has room for
   both). On a phone the cards stand under each other.
   The count is read by the stylesheet (:has(), :nth-child). */
.entangle-engagements--wide .entangle-engagements__list {
	grid-template-columns: minmax(0, 1fr);
}
.entangle-engagements--wide .entangle-engagement {
	flex-direction: row;
}
/* The picture is laid over its frame, not into it: the frame is as tall as the words beside it, whatever the
   photograph. */
.entangle-engagements--wide .entangle-engagement__media {
	position: relative;
	flex: 0 0 34%;
	aspect-ratio: auto;
}
.entangle-engagements--wide .entangle-engagement__image {
	position: absolute;
	inset: 0;
}
.entangle-engagements--wide .entangle-engagement__media > svg {
	width: 2.25rem;
	height: 2.25rem;
}
.entangle-engagements--wide .entangle-engagement__body {
	--en-pad-y: 1rem;
	--en-pad-x: 1.125rem;
	gap: 0.5rem;
}
.entangle-engagements--wide .entangle-engagement__title {
	font-size: 1.0625rem;
}
.entangle-engagements--wide .entangle-engagement__lead,
.entangle-engagements--wide .entangle-engagement__about {
	display: none;
}

@media (min-width: 48rem) {
	.entangle-engagements--wide .entangle-engagements__list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
	/* An odd last card has no neighbour: it lies across. */
	.entangle-engagements--wide .entangle-engagements__item:last-child:nth-child(odd) {
		grid-column: 1 / -1;
	}
	.entangle-engagements--wide .entangle-engagement__media {
		flex-basis: 38%;
	}
	.entangle-engagements--wide .entangle-engagement__body {
		--en-pad-y: 1.25rem;
		--en-pad-x: 1.5rem;
	}
	.entangle-engagements--wide .entangle-engagement__title {
		font-size: 1.1875rem;
	}

	/* One: a headline with its picture. */
	.entangle-engagements--wide .entangle-engagements__item:only-child .entangle-engagement__media {
		flex-basis: 50%;
		min-height: 18rem;
	}
	/* Its words stand in the middle of its height and its button in its corner: the free height is shared by the
	   air over the first line and the air over the foot. */
	.entangle-engagements--wide .entangle-engagements__item:only-child .entangle-engagement__body {
		--en-pad-y: clamp(1.5rem, 4vw, 3rem);
		--en-pad-x: clamp(1.5rem, 4vw, 3rem);
		gap: 0.875rem;
	}
	.entangle-engagements--wide .entangle-engagements__item:only-child .entangle-engagement__head {
		margin-top: auto;
	}
	.entangle-engagements--wide .entangle-engagements__item:only-child .entangle-engagement__title {
		font-size: clamp(1.5rem, 1.1rem + 1.1vw, 1.875rem);
		line-height: 1.2;
	}
	.entangle-engagements--wide .entangle-engagements__item:only-child .entangle-engagement__lead {
		display: -webkit-box;
		font-size: 1.0625rem;
		-webkit-line-clamp: 4;
		line-clamp: 4;
	}
	.entangle-engagements--wide .entangle-engagements__item:only-child .entangle-engagement__about {
		display: block;
	}
}

/* Three in a row need the width of a desk. */
@media (min-width: 72rem) {
	.entangle-engagements--wide .entangle-engagements__list:has(> :nth-child(3):last-child) {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
	.entangle-engagements--wide .entangle-engagements__list:has(> :nth-child(3):last-child) > .entangle-engagements__item {
		grid-column: auto;
	}
	.entangle-engagements--wide .entangle-engagements__list:has(> :nth-child(3):last-child) .entangle-engagement__body {
		--en-pad-y: 1.125rem;
		--en-pad-x: 1.25rem;
	}
}
