/* The heading row is .section-head, the status is .chip and the facts of the
   cards are .facts, all in the theme's components.css. Here: the featured
   view, one challenge as a large dark green card with a list of three beside
   it, and at the end of the file the grid of cards of the views latest and
   all. */

.wp-block-greenably-challenges__featured {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--space-24);
}

.wp-block-greenably-challenges a {
	color: inherit;
	text-decoration: none;
}

/* The image of a challenge. On hover of the challenge (the whole card or row
   is the link) it grows a little and darkens, and a "Läs mer" button slides
   up onto it. The darkening and the button are quicker than the growing. The
   button is for show: the link is what is clicked. None of it on small
   screens and touch screens, see the media query below. */

.wp-block-greenably-challenges__media {
	position: relative;
	overflow: hidden;
	border-radius: var(--radius-m);
	background: var(--color-surface-off-white);
}

.wp-block-greenably-challenges__media img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border-radius: 0;
	object-fit: cover;
	transition: transform var(--transition-long);
}

.wp-block-greenably-challenges__media::after {
	content: "";
	position: absolute;
	inset: 0;
	background: var(--color-scrim);
	opacity: 0;
	transition: opacity 0.3s ease-out;
}

/* The block's name first, so this goes over what .button has of its own:
   components.css loads after this file. Not shown at all outside the media
   query below. */
.wp-block-greenably-challenges .wp-block-greenably-challenges__more {
	display: none;
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 1;
	opacity: 0;
	/* Not a button of its own: it has no hover state, whatever the pointer
	   is over. */
	pointer-events: none;
	transform: translate(-50%, calc(-50% + var(--space-12)));
	transition: opacity 0.3s ease-out, transform 0.3s ease-out;
	white-space: nowrap;
}

/* The hover is for a mouse on a wide screen only. On a phone or a tablet a
   tap would leave it stuck on the image, so there the image just is a link. */
@media (hover: hover) and (min-width: 901px) {
	.wp-block-greenably-challenges .wp-block-greenably-challenges__more {
		display: inline-flex;
	}

	.wp-block-greenably-challenges a:hover .wp-block-greenably-challenges__media img,
	.wp-block-greenably-challenges a:focus-visible .wp-block-greenably-challenges__media img {
		transform: scale(1.1);
	}

	.wp-block-greenably-challenges a:hover .wp-block-greenably-challenges__media::after,
	.wp-block-greenably-challenges a:focus-visible .wp-block-greenably-challenges__media::after,
	.wp-block-greenably-challenges a:hover .wp-block-greenably-challenges__more,
	.wp-block-greenably-challenges a:focus-visible .wp-block-greenably-challenges__more {
		opacity: 1;
	}

	.wp-block-greenably-challenges a:hover .wp-block-greenably-challenges__more,
	.wp-block-greenably-challenges a:focus-visible .wp-block-greenably-challenges__more {
		transform: translate(-50%, -50%);
	}
}

/* The facts of a challenge: two boxes side by side, each a label over a
   value. */

.wp-block-greenably-challenges__facts {
	display: flex;
	gap: var(--space-12);
	margin: 0;
}

.wp-block-greenably-challenges__facts > div {
	display: flex;
	flex: 1 1 0;
	flex-direction: column;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--space-8);
	min-width: 0;
	min-height: 7rem;
	padding: var(--space-8) var(--space-12);
	border-radius: var(--radius-m);
	background: var(--color-surface-off-white);
}

.wp-block-greenably-challenges__facts dt {
	font: var(--type-text-xs);
	text-transform: uppercase;
}

.wp-block-greenably-challenges__facts dd {
	margin: 0;
	font: var(--type-h5);
}

/* The featured challenge: its title beside its image, the facts below. */

.wp-block-greenably-challenges__feature {
	display: flex;
	flex-direction: column;
	gap: var(--space-16);
	min-height: 50.8rem;
	padding: var(--space-16);
	border-radius: var(--radius-l);
	background: var(--color-brand-dark-green);
}

.wp-block-greenably-challenges a.wp-block-greenably-challenges__feature {
	color: var(--color-surface-off-white);
}

.wp-block-greenably-challenges__feature-top {
	display: flex;
	flex: 1;
	align-items: center;
	gap: var(--space-16);
}

.wp-block-greenably-challenges__feature-title {
	flex: 1 1 0;
	min-width: 0;
	margin: 0;
	color: var(--color-brand-yellow);
}

.wp-block-greenably-challenges__feature-top .wp-block-greenably-challenges__media {
	flex: 1 1 0;
	align-self: stretch;
	min-width: 0;
}

.wp-block-greenably-challenges__feature .wp-block-greenably-challenges__facts {
	gap: var(--space-16);
}

.wp-block-greenably-challenges__feature .wp-block-greenably-challenges__facts > div {
	min-height: 9.6rem;
	padding: var(--space-12) var(--space-16);
	background: var(--color-tint-light-green);
}

.wp-block-greenably-challenges__feature .wp-block-greenably-challenges__facts dt {
	font: var(--type-text-s);
}

.wp-block-greenably-challenges__feature .wp-block-greenably-challenges__facts dd,
.wp-block-greenably-challenges__feature .chip {
	font: var(--type-h4);
}

.wp-block-greenably-challenges__feature .chip {
	padding: var(--space-4) var(--space-12);
}

/* Pågående, which is beige elsewhere, is the card's own dark green here, with
   the card's light text: darker than the box it is in. Avslutad stays
   green. */
.wp-block-greenably-challenges__feature .chip:not(.chip-green) {
	background: var(--color-brand-dark-green);
	color: inherit;
}

/* The list beside it: an image, the title and the facts per row. */

.wp-block-greenably-challenges__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.wp-block-greenably-challenges__list li {
	/* The margin is what a general rule for list items used to add here. Kept,
	   so the start page is as it was; without it the rows are the design's
	   175px. */
	margin-bottom: 0.4em;
	padding-block: var(--space-16);
	border-top: 1px solid var(--color-line);
}

.wp-block-greenably-challenges__list a {
	display: flex;
	gap: var(--space-24);
}

.wp-block-greenably-challenges__list .wp-block-greenably-challenges__media {
	flex: 0 0 20.6rem;
	min-height: 14.2rem;
}

.wp-block-greenably-challenges__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	justify-content: space-between;
	gap: var(--space-12);
	min-width: 0;
}

.wp-block-greenably-challenges__body h3 {
	margin: 0;
}

/* Small screens: one column. The featured challenge has its title over its
   image, and the rows show the status only. The heading row's button moves
   below the challenges: the row's own box is dropped (display: contents), so
   the heading and the button can be placed apart. */
@media (max-width: 900px) {
	.wp-block-greenably-challenges__inner {
		display: flex;
		flex-direction: column;
	}

	.wp-block-greenably-challenges__inner > * {
		order: 1;
	}

	.wp-block-greenably-challenges .section-head {
		display: contents;
	}

	.wp-block-greenably-challenges .section-head h2 {
		margin-bottom: var(--space-24);
	}

	.wp-block-greenably-challenges .section-head .button {
		order: 2;
		align-self: flex-start;
		margin-top: var(--space-24);
	}

	.wp-block-greenably-challenges__featured {
		grid-template-columns: minmax(0, 1fr);
	}

	.wp-block-greenably-challenges__feature {
		min-height: 0;
	}

	.wp-block-greenably-challenges__feature-top {
		flex-direction: column;
		align-items: stretch;
	}

	.wp-block-greenably-challenges__feature-title,
	.wp-block-greenably-challenges__feature-top .wp-block-greenably-challenges__media {
		flex: none;
	}

	.wp-block-greenably-challenges__feature-top .wp-block-greenably-challenges__media {
		aspect-ratio: 2 / 1;
	}

	.wp-block-greenably-challenges__feature .wp-block-greenably-challenges__facts {
		gap: var(--space-12);
	}

	.wp-block-greenably-challenges__feature .wp-block-greenably-challenges__facts > div {
		min-height: 8rem;
		padding: var(--space-12);
	}

	.wp-block-greenably-challenges__feature .wp-block-greenably-challenges__facts dd,
	.wp-block-greenably-challenges__feature .chip {
		font: var(--type-h5);
	}

	.wp-block-greenably-challenges__feature .chip {
		padding: var(--space-2) var(--space-8);
	}

	.wp-block-greenably-challenges__list a {
		gap: var(--space-12);
	}

	/* The button that follows belongs to the list: the last row has no space
	   of its own under it, only the button's above it. */
	.wp-block-greenably-challenges__list li:last-child {
		margin-bottom: 0;
		padding-bottom: 0;
	}

	.wp-block-greenably-challenges__list .wp-block-greenably-challenges__media {
		flex-basis: 10rem;
		min-height: 12.6rem;
	}

	.wp-block-greenably-challenges__list .wp-block-greenably-challenges__facts > div:not(:last-child) {
		display: none;
	}
}

.wp-block-greenably-challenges__empty {
	margin: 0;
}

/* A text under the heading row. */

.wp-block-greenably-challenges__text {
	max-width: var(--measure);
	margin-bottom: var(--space-32);
	font: var(--type-text-l);
}

.wp-block-greenably-challenges__text > :last-child {
	margin-bottom: 0;
}

/* The filter of the view with all challenges: a row with a label and two
   boxes to tick at the left, and the number of challenges shown at the right.

   Each box is a pill. A ticked one is dark green with a green box and a check
   mark in it; an unticked one is outlined with an empty box. The real
   checkbox lies over the whole pill, unseen, so the pill is clicked and
   reached by keyboard as any checkbox. */

.wp-block-greenably-challenges__filter-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: var(--space-12) var(--space-24);
	margin-bottom: var(--space-32);
}

/* Until view.js shows it. Written out, since display: flex above would
   otherwise show an element with the hidden attribute. */
.wp-block-greenably-challenges__filter-bar[hidden] {
	display: none;
}

.wp-block-greenably-challenges__filter {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-12);
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

/* The block's name first, so this goes over .eyebrow's own margin:
   components.css loads after this file. */
.wp-block-greenably-challenges .wp-block-greenably-challenges__filter legend {
	margin: 0 0 var(--space-12);
	padding: 0;
}

/* In line with the middle of the pills. */
.wp-block-greenably-challenges__count {
	margin: 0 0 var(--space-12);
	font: var(--type-text-s);
}

.wp-block-greenably-challenges__filter label {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: var(--space-12);
	padding: var(--space-8) var(--space-24);
	border: 1px solid var(--color-neutral-black);
	border-radius: var(--radius-pill);
	font: var(--type-text-m);
	cursor: pointer;
	transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.wp-block-greenably-challenges__filter input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

/* The box. */
.wp-block-greenably-challenges__filter label::before {
	content: "";
	flex: none;
	width: 1.6rem;
	height: 1.6rem;
	border: 1px solid currentColor;
	border-radius: var(--radius-s);
	transition: background-color var(--transition), border-color var(--transition);
}

/* The check mark: two sides of a small box, turned. */
.wp-block-greenably-challenges__filter label::after {
	content: "";
	position: absolute;
	top: 50%;
	left: calc(var(--space-24) + 0.55rem);
	width: 0.5rem;
	height: 0.9rem;
	border: solid var(--color-neutral-black);
	border-width: 0 2px 2px 0;
	opacity: 0;
	transform: translateY(-60%) rotate(45deg);
	transition: opacity var(--transition);
}

.wp-block-greenably-challenges__filter label:has(input:checked) {
	border-color: var(--color-brand-dark-green);
	background: var(--color-brand-dark-green);
	color: var(--color-neutral-white);
}

.wp-block-greenably-challenges__filter label:has(input:checked)::before {
	border-color: var(--color-brand-light-green);
	background: var(--color-brand-light-green);
}

.wp-block-greenably-challenges__filter label:has(input:checked)::after {
	opacity: 1;
}

.wp-block-greenably-challenges__filter label:has(input:focus-visible) {
	outline: 2px solid var(--focus-color, var(--color-neutral-black));
	outline-offset: 3px;
}

/* On hover the box shows what a click would do: an unticked one gets its
   green ground and check mark, a ticked one loses them. The pill's own colour
   changes with the click only. Not right after a click, while the pointer is
   still on the pill (view.js sets is-clicked until it leaves): the box would
   otherwise show the opposite of what was just chosen. For a mouse only: on a
   touch screen the hover would stay on after a tap. */
@media (hover: hover) {
	.wp-block-greenably-challenges__filter label:not(.is-clicked):not(:has(input:checked)):hover::before {
		border-color: var(--color-brand-light-green);
		background: var(--color-brand-light-green);
	}

	.wp-block-greenably-challenges__filter label:not(.is-clicked):not(:has(input:checked)):hover::after {
		opacity: 1;
	}

	.wp-block-greenably-challenges__filter label:not(.is-clicked):has(input:checked):hover::before {
		border-color: currentColor;
		background: transparent;
	}

	.wp-block-greenably-challenges__filter label:not(.is-clicked):has(input:checked):hover::after {
		opacity: 0;
	}
}

/* The grid of cards (the views all and latest): each a challenge's image, its
   title and its facts. The facts sit at the bottom of the card, so they line
   up along a row whatever the titles' length. Three cards across, two on a
   medium screen and one on a small, as .card-grid in components.css. */

.wp-block-greenably-challenges__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 6rem var(--space-24);
	margin: 0;
	padding: 0;
	list-style: none;
}

.wp-block-greenably-challenges__card {
	display: flex;
	flex-direction: column;
	gap: var(--space-16);
	height: 100%;
}

.wp-block-greenably-challenges__card .wp-block-greenably-challenges__media {
	aspect-ratio: 3 / 2;
}

.wp-block-greenably-challenges__card h3 {
	margin: 0;
}

.wp-block-greenably-challenges__card .facts {
	margin-top: auto;
}

@media (max-width: 900px) {
	.wp-block-greenably-challenges__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 600px) {
	.wp-block-greenably-challenges__grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

