/*
 * Type and shared classes, built on the tokens in tokens.css. Loaded after it
 * and before style.css on the site, and in the editor's content iframe (see
 * inc/assets.php), so blocks look the same in both.
 */

/* Fonts: Lora for headings, Inter for text. The -ext files hold the letters
   outside Western European languages and are only fetched when a page has
   one. */

@font-face {
	font-family: "Lora";
	font-style: normal;
	font-weight: 400 700;
	font-display: swap;
	src: url("fonts/lora-ext.woff2") format("woff2");
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
	font-family: "Lora";
	font-style: normal;
	font-weight: 400 700;
	font-display: swap;
	src: url("fonts/lora.woff2") format("woff2");
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
	font-family: "Lora";
	font-style: italic;
	font-weight: 400 700;
	font-display: swap;
	src: url("fonts/lora-ext-italic.woff2") format("woff2");
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
	font-family: "Lora";
	font-style: italic;
	font-weight: 400 700;
	font-display: swap;
	src: url("fonts/lora-italic.woff2") format("woff2");
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
	font-family: "Inter";
	font-style: normal;
	font-weight: 100 900;
	font-display: swap;
	src: url("fonts/inter.woff2") format("woff2");
}
@font-face {
	font-family: "Inter";
	font-style: italic;
	font-weight: 100 900;
	font-display: swap;
	src: url("fonts/inter-italic.woff2") format("woff2");
}

/* Type. Each tag has its own style, and each style is also a class, so any
   element can take any style: <h2 class="h4"> is an h2 set as an h4. */

body {
	color: var(--color-text);
	font: var(--type-text-m);
	-webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5 {
	margin: 0 0 var(--space-24);
	text-wrap: balance;
}

h1, .h1 { font: var(--type-h1); }
h2, .h2 { font: var(--type-h2); }
h3, .h3 { font: var(--type-h3); }
h4, .h4 { font: var(--type-h4); }
h5, .h5 { font: var(--type-h5); }

/* A heading has one weight. Bold set on a heading's text in the editor
   changes nothing, in the headings there are and in any written later. */
:is(h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5) :is(strong, b) {
	font-weight: inherit;
}

.text-xl { font: var(--type-text-xl); }
.text-l { font: var(--type-text-l); }
.text-m { font: var(--type-text-m); }
.text-s { font: var(--type-text-s); }
.text-xs { font: var(--type-text-xs); }

p {
	margin: 0 0 var(--space-24);
	text-wrap: pretty;
}

a {
	color: var(--color-link);
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
}

/* Keyboard focus: an outline around what is in focus. Black, and white on the
   dark surfaces listed here, so it can be seen on either. (The variable is
   inherited, so everything inside a dark surface gets the white one.) */

:focus-visible {
	outline: 2px solid var(--focus-color, var(--color-neutral-black));
	outline-offset: 3px;
}

.skip-link,
.site-menu,
.site-footer,
.wp-block-greenably-hero,
.wp-block-greenably-vision,
.wp-block-greenably-cta:not(.is-style-light) .wp-block-greenably-cta__inner {
	--focus-color: var(--color-neutral-white);
}

img {
	max-width: 100%;
	height: auto;
}

/* Eyebrow: a small label in capitals. In the editor it is the Etikett style
   of the Paragraph block. */

.eyebrow,
p.is-style-eyebrow {
	margin: 0 0 var(--space-12);
	font: var(--type-text-s);
	text-transform: uppercase;
}

/* Statement: one large serif sentence. The Stor mening style of the Paragraph
   block. */

p.is-style-statement {
	font: var(--type-quote);
	text-wrap: balance;
}

/* Buttons: a pill with an arrow after the text. .button is the green one;
   .button-ghost is outlined and .button-light white. The Buttons block looks
   the same, with its Outline style as ghost.

   A link to another site gets .is-external (added by greenably_buttons() in
   inc/template-tags.php) and the arrow turns into an outward one. A link that
   opens in a new tab gets it too. .has-no-icon leaves the arrow out.

   On hover the arrow moves a little to the right; the outward one stays
   where it is. On the outlined button, which turns dark green, the text goes
   white and the arrow yellow. */

.button,
.wp-block-button__link {
	display: inline-flex;
	align-items: center;
	gap: var(--space-12);
	padding: var(--space-8) var(--space-24);
	border: 1px solid var(--color-brand-light-green);
	border-radius: var(--radius-pill);
	background: var(--color-brand-light-green);
	color: var(--color-neutral-black);
	font: var(--type-text-m);
	text-decoration: none;
	cursor: pointer;
	transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.button::after,
.wp-block-button__link::after {
	content: "";
	flex: none;
	width: 1.8rem;
	height: 1.4rem;
	background: currentColor;
	mask: url("images/icon-arrow.svg") center / contain no-repeat;
	transition: transform var(--transition), background-color var(--transition);
}

.button.is-external::after,
.button[target="_blank"]::after,
.wp-block-button__link[target="_blank"]::after {
	width: 1.7rem;
	height: 1.7rem;
	mask-image: url("images/icon-external.svg");
}

.button.has-no-icon::after {
	content: none;
}

.button:hover,
.wp-block-button__link:hover {
	border-color: var(--color-brand-yellow);
	background: var(--color-brand-yellow);
	color: var(--color-neutral-black);
}

.button:hover::after,
.wp-block-button__link:hover::after {
	transform: translateX(var(--space-4));
}

.button.is-external:hover::after,
.button[target="_blank"]:hover::after,
.wp-block-button__link[target="_blank"]:hover::after {
	transform: none;
}

/* The Buttons block's own Outline style has a thicker border and other
   padding; the longer selector puts this theme's over it. */
.button-ghost,
.wp-block-button.is-style-outline > a.wp-block-button__link {
	padding: var(--space-8) var(--space-24);
	border: 1px solid var(--color-neutral-black);
	background: transparent;
	color: var(--color-neutral-black);
}

.button-ghost:hover,
.wp-block-button.is-style-outline > a.wp-block-button__link:hover {
	border-color: var(--color-brand-dark-green);
	background: var(--color-brand-dark-green);
	color: var(--color-neutral-white);
}

.button-ghost:hover::after,
.wp-block-button.is-style-outline > a.wp-block-button__link:hover::after {
	background: var(--color-brand-yellow);
}

.button-light {
	border-color: var(--color-neutral-white);
	background: var(--color-neutral-white);
	color: var(--color-neutral-black);
}

.button-row {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-12);
	margin: 0;
}

/* Chip: a short word on a coloured ground, such as a status. */

.chip {
	display: inline-block;
	padding: var(--space-2) var(--space-8);
	border-radius: var(--radius-s);
	background: var(--color-surface-beige);
	color: var(--color-neutral-black);
	font: var(--type-h5);
}

.chip-green {
	background: var(--color-brand-light-green);
}

/* Container: the content width with the page margin on each side. */

.container {
	box-sizing: border-box;
	width: 100%;
	max-width: calc(var(--container) + 2 * var(--gutter));
	margin-inline: auto;
	padding-inline: var(--gutter);
}

/* Section head: a heading with an optional button to its right. */

.section-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-12) var(--space-32);
	margin-bottom: var(--space-24);
}

.section-head h2 {
	margin: 0;
}

/* External link: a text link to another site, with the outward arrow after
   it. */

.link-external {
	display: inline-flex;
	align-items: center;
	gap: var(--space-8);
}

.link-external::after {
	content: "";
	flex: none;
	width: 1.6rem;
	height: 1.6rem;
	background: currentColor;
	mask: url("images/icon-external.svg") center / contain no-repeat;
}

/* Fit: one line of text that gets smaller, instead of breaking, when its box
   is too narrow for it, such as the contact address in the footer.

   .fit is the box that is measured (100cqi is its width). .fit-text, inside
   it, gets --fit-size: the font size at which its --fit-chars characters are
   as wide as the box, less --fit-pad, the text's own padding at both sides
   together. 0.52 is how wide a character of a mail address is on average in
   Lora, in em. The text uses it as font-size: min(its own size,
   var(--fit-size)), after its font, which would otherwise reset the size.

   An address with unusually wide letters may still be too wide: it then
   breaks, as it did before. */

.fit {
	container-type: inline-size;
}

.fit-text {
	--fit-size: calc((100cqi - var(--fit-pad, 0rem)) / (var(--fit-chars, 24) * 0.52));
	overflow-wrap: anywhere;
}

/* Facts: boxes side by side, each a small label over a value, such as the
   company and the status of a challenge (greenably_challenge_facts() in
   inc/template-tags.php). */

.facts {
	display: flex;
	gap: var(--space-12);
	margin: 0;
}

.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);
}

.facts dt {
	font: var(--type-text-xs);
	text-transform: uppercase;
}

.facts dd {
	margin: 0;
	font: var(--type-h5);
}

/* Card: a white card, all one link, with an image across its top and a title
   under it. Used by the News block and under a news post (single.php). On
   hover the image grows a little and darkens, and a "Läs mer" button slides
   up onto it, as on the start page's cases. The button is for show: the card
   is the link. */

/* Three cards across, two on a medium screen and one on a small, as the grid
   of the Challenges block. More space between the rows than between the
   cards of a row, so a row reads as one; in a single column every card is a
   row of its own, and the space is the same as it would be beside it. */
.card-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: var(--space-40) var(--space-24);
	margin: 0;
	padding: 0;
	list-style: none;
}

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

@media (max-width: 600px) {
	.card-grid {
		grid-template-columns: minmax(0, 1fr);
		gap: var(--space-24);
	}
}

.card {
	display: flex;
	flex-direction: column;
	height: 100%;
	border-radius: var(--radius-l);
	background: var(--color-neutral-white);
	color: inherit;
	text-decoration: none;
}

/* Edge to edge in the card, with the card's own corners at the top. */
.card-media {
	position: relative;
	overflow: hidden;
	aspect-ratio: 3 / 2;
	border-radius: var(--radius-l) var(--radius-l) 0 0;
	background: var(--color-surface-off-white);
}

.card-media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--transition-long);
}

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

.card-more {
	display: none; /* shown only inside the media query below */
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 1;
	opacity: 0;
	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. */
@media (hover: hover) and (min-width: 901px) {
	.card-more {
		display: inline-flex;
	}

	.card:hover .card-media img,
	.card:focus-visible .card-media img {
		transform: scale(1.1);
	}

	.card:hover .card-media::after,
	.card:focus-visible .card-media::after,
	.card:hover .card-more,
	.card:focus-visible .card-more {
		opacity: 1;
	}

	.card:hover .card-more,
	.card:focus-visible .card-more {
		transform: translate(-50%, -50%);
	}
}

/* Shown when a post has no image: the logo's arcs. */
.card-media-empty {
	display: grid;
	place-items: center;
}

.card-media-empty::before {
	content: "";
	width: 6.4rem;
	height: 6.4rem;
	border: 1.2rem solid var(--color-brand-light-green);
	border-right-color: transparent;
	border-bottom-color: var(--color-brand-yellow);
	border-radius: 50%;
	transform: rotate(-20deg);
}

.card-title {
	margin: 0;
	padding: var(--space-16);
	font: var(--type-h4);
}

/* Screen reader only. */
.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
	* {
		transition-duration: 0s !important;
	}
}
