/*
Theme Name: Greenably 2026
Author: Markus Bergman
Version: 1.1.0
Requires at least: 6.6
Requires PHP: 8.0
Text Domain: greenably
*/

/* The tokens (colours, spacing, type, 1rem = 10px) are in tokens.css, and the
   fonts, text styles and shared classes such as .button, .container and .chip
   in components.css. Both load before this file. Each block's own styles are
   in its folder in blocks/. */

/* Base */

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

html {
	scroll-behavior: smooth;
	/* What is scrolled to ends up below the header, and below the admin bar for
	   a logged-in editor (WordPress gives its height in this variable). */
	scroll-padding-top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--header-top) + var(--header-height) + var(--header-top));
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--color-page);
}

/* While the menu panel is open on a small screen (js/menu.js). */
.has-menu-open {
	overflow: hidden;
}

/* Skip link: shown when it has keyboard focus. */
.skip-link {
	position: absolute;
	top: var(--space-8);
	left: var(--space-8);
	z-index: 200;
	padding: var(--space-12) var(--space-24);
	border-radius: var(--radius-l);
	background: var(--color-brand-dark-green);
	color: var(--color-neutral-white);
	transform: translateY(-300%);
}

.skip-link:focus {
	transform: none;
}

/* Header: two white cards that float over the page and stay at the top of the
   screen, the logos in one and the menu in the other. The header itself lets
   clicks through to the page; only the cards take them. */

.site-header {
	position: fixed;
	top: 0;
	right: 0;
	left: 0;
	z-index: 100;
	padding: var(--header-top) var(--space-24) 0;
	pointer-events: none;
}

/* Below the admin bar for logged-in editors. Under 600px the admin bar
   scrolls away, so the header goes back to the top. */
.admin-bar .site-header {
	top: 32px;
}

@media (max-width: 782px) {
	.admin-bar .site-header {
		top: 46px;
	}
}

@media (max-width: 600px) {
	.admin-bar .site-header {
		top: 0;
	}

	.admin-bar .site-menu {
		top: 0;
	}
}

.site-header-bar {
	position: relative;
	z-index: 1; /* above the menu panel */
	display: flex;
	align-items: stretch;
	justify-content: center;
	gap: var(--space-8);
}

.site-header-bar > * {
	pointer-events: auto;
}

.site-header-brand {
	display: flex;
	align-items: center;
	gap: var(--space-32);
	min-width: 0;
	min-height: var(--header-height);
	padding: var(--space-8) var(--space-16);
	border-radius: var(--radius-l);
	background: var(--color-neutral-white);
}

/* The logos have a set width and may shrink, so both fit on a narrow phone. */
.site-logo {
	flex: 0 1 12.1rem;
	min-width: 0;
}

.site-logo img,
.site-eu {
	display: block;
	width: 100%;
	height: auto;
}

.site-eu {
	flex: 0 1 17.2rem;
	min-width: 0;
}

.site-nav {
	display: flex;
	align-items: center;
	padding: var(--space-8) calc(var(--space-32) - var(--space-12));
	border-radius: var(--radius-l);
	background: var(--color-neutral-white);
}

.site-nav ul {
	display: flex;
	align-items: center;
	gap: var(--space-12);
	margin: 0;
	padding: 0;
	list-style: none;
}

.site-nav a {
	display: flex;
	align-items: center;
	gap: var(--space-6);
	padding: var(--space-6) var(--space-12);
	border-radius: var(--radius-m);
	color: var(--color-text);
	font: var(--type-text-m);
	text-decoration: none;
	white-space: nowrap;
	transition: background-color var(--transition);
}

.site-nav a:hover,
.site-nav .current-menu-item > a {
	background: var(--color-surface-off-white);
}

/* The language link: a menu item with the CSS class menu-item-lang
   (Appearance > Menus > Screen options > CSS classes) gets the globe. */
.menu-item-lang > a::before {
	content: "";
	flex: none;
	width: 1.8rem;
	height: 1.9rem;
	background: currentColor;
	mask: url("images/icon-globe.svg") center / contain no-repeat;
}

/* Menu button: small screens only, see the media query below. */
.site-nav-toggle {
	display: none;
	place-items: center;
	flex: none;
	width: 5rem;
	padding: 0;
	border: 0;
	border-radius: var(--radius-l);
	background: var(--color-neutral-white);
	color: var(--color-neutral-black);
	cursor: pointer;
	transition: background-color var(--transition);
}

.site-nav-toggle[aria-expanded="true"] {
	background: var(--color-brand-light-green);
}

/* Inside the button, where it is seen whatever the page has behind it. */
.site-nav-toggle:focus-visible {
	outline-offset: calc(-1 * var(--space-4));
}

.site-nav-toggle-close,
.site-nav-toggle[aria-expanded="true"] .site-nav-toggle-open {
	display: none;
}

.site-nav-toggle[aria-expanded="true"] .site-nav-toggle-close {
	display: inline;
}

/* Menu panel: small screens only, opened with the menu button (js/menu.js).
   It covers the whole screen, behind the header's cards, from the top (or
   from under the admin bar, whose height WordPress gives in the variable)
   to the bottom. The legal links are at the bottom of it, under a thin line
   as in the footer; on a screen too low for it all, the panel scrolls.

   Fixed itself, not absolute in the fixed header: Safari on iOS 26 colours
   its status bar and toolbar after the fixed element at the screen's edge,
   and keeps that colour for as long as the element is there. Absolute, the
   green was put down to the header, which stays, so the bars stayed green
   after the menu closed. Fixed, it is put down to the panel, which goes. */
.site-menu {
	position: fixed;
	top: var(--wp-admin--admin-bar--height, 0px);
	right: 0;
	bottom: 0;
	left: 0;
	display: none;
	flex-direction: column;
	gap: var(--space-32);
	overflow-y: auto;
	padding: var(--space-104) var(--space-24) var(--space-24);
	background: var(--color-brand-dark-green);
	color: var(--color-neutral-white);
	pointer-events: auto;
}

.site-menu ul {
	display: grid;
	gap: var(--space-12);
	margin: 0;
	padding: 0;
	list-style: none;
}

.site-menu a {
	color: inherit;
	text-decoration: none;
}

.site-menu a:hover {
	text-decoration: underline;
}

.site-menu-main ul {
	gap: var(--space-16);
}

.site-menu-main a {
	color: var(--color-brand-yellow);
	font: var(--type-h3);
}

.site-menu-partners h2 {
	margin: 0 0 var(--space-16);
	font: var(--type-h5);
}

.site-menu-partners a {
	font: var(--type-text-l);
}

.site-menu-lang a {
	display: inline-flex;
	align-items: center;
	gap: var(--space-6);
}

/* At the bottom of the panel: the auto margin takes the room left over. */
.site-menu-legal {
	margin-top: auto;
	padding-top: var(--space-24);
	border-top: 1px solid var(--color-line-light);
}

.site-menu-legal ul {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-8) var(--space-16);
	font: var(--type-text-s);
}

@keyframes site-menu-in {
	from {
		opacity: 0;
	}
}

/* Below this width the menu no longer fits beside the logos. */
@media (max-width: 900px) {
	.site-header-bar {
		justify-content: space-between;
		gap: var(--space-12);
	}

	.site-header-brand {
		gap: var(--space-24);
		min-height: 5rem;
	}

	.site-logo {
		flex-basis: 9.9rem;
	}

	.site-eu {
		flex-basis: 12.6rem;
	}

	.site-nav {
		display: none;
	}

	.site-nav-toggle {
		display: grid;
	}

	/* The panel fades in when it opens and out when it closes. Out is a
	   transition: allow-discrete holds display for as long as the opacity
	   takes. A browser that doesn't know the word drops the whole line, and
	   the panel then closes at once. */
	.site-menu {
		opacity: 0;
		transition: opacity 0.15s ease-out, display 0.15s allow-discrete;
	}

	.site-menu.is-open {
		display: flex;
		opacity: 1;
		animation: site-menu-in 0.15s ease-out;
	}

	/* The header slides up out of sight when the page is scrolled down, and
	   comes back when it is scrolled up: js/menu.js sets the class. */
	.site-header {
		transition: transform var(--transition);
	}

	.site-header.is-away {
		transform: translateY(-100%);
	}
}

/* The rule in components.css only stops transitions, not this animation. */
@media (prefers-reduced-motion: reduce) {
	.site-menu.is-open {
		animation: none;
	}
}

@media (max-width: 400px) {
	.site-header {
		padding-inline: var(--space-16);
	}

	.site-header-brand {
		gap: var(--space-16);
	}
}

/* Main: a page that opens with a Hero block has it under the floating header.
   Any other page starts below the header. */

body:not(.has-hero) .site-main {
	padding-top: calc(var(--header-top) + var(--header-height));
}

/* Page header: the title of a page without a Hero block. */

.page-header {
	padding-top: var(--space-56);
	padding-bottom: var(--space-32);
}

.page-header h1 {
	max-width: 22ch;
	margin: 0;
}

/* Content: text blocks sit in a reading column that starts at the container's
   left edge, as the text on the start page does; the theme's blocks are full
   width sections with their own container.

   Sections are spaced by the space above them, --section-space; a block that
   follows running text sits closer to it. A block with
   the class section-space-s, section-space-xs or section-space-none (the
   block's Advanced > Additional CSS class field) gets the smaller space above
   it instead. */

.entry-content {
	padding-bottom: var(--section-space);
}

.entry-content::after {
	content: "";
	display: table;
	clear: both;
}

/* The left margin is what the container has on each side when the screen is
   wider than it. */
.entry-content > :not([class*="wp-block-greenably-"]) {
	box-sizing: content-box;
	max-width: var(--measure);
	margin-right: auto;
	margin-left: max(0rem, calc((100% - var(--container) - 2 * var(--gutter)) / 2));
	padding-inline: var(--gutter);
}

.entry-content > [class*="wp-block-greenably-"],
.entry-content > [class*="wp-block-greenably-"] + :not([class*="wp-block-greenably-"]) {
	margin-top: var(--section-space);
}

/* A block right after running text belongs to it, as the cards under the
   text that introduces them: the space between a heading's text and its
   content on the start page. (:where keeps this rule no stronger than the
   one above, so the section-space classes below still go over it.) */
.entry-content > :where(:not([class*="wp-block-greenably-"])) + [class*="wp-block-greenably-"] {
	margin-top: var(--space-56);
}

.entry-content > .section-space-s {
	margin-top: var(--section-space-s);
}

.entry-content > .section-space-xs {
	margin-top: var(--section-space-xs);
}

.entry-content > .section-space-none {
	margin-top: var(--section-space-none);
}

.entry-content > :first-child {
	margin-top: 0;
}

/* A page that ends with a full-width image band has it against the footer. */
.entry-content:has(> .wp-block-greenably-vision:last-child) {
	padding-bottom: 0;
}

/* A page that opens with its own H1 (no Hero block): the same space above it
   as above a page title, see .page-header. */
.entry-content > h1:first-child {
	padding-top: var(--space-56);
}

.entry-content > :last-child {
	margin-bottom: 0;
}

/* Running text is set as on the start page. The Paragraph block's own styles
   (Etikett, Stor mening) keep theirs. */
.entry-content > p:not([class*="is-style-"]),
.entry-content > ul,
.entry-content > ol {
	font: var(--type-text-l);
}

/* A heading starts a new part of the text: more space above it than between
   paragraphs. */
.entry-content > * + h2 {
	margin-top: var(--space-56);
}

.entry-content > * + h3,
.entry-content > * + h4 {
	margin-top: var(--space-40);
}

/* Bullets and numbers inside the reading column: the list is indented, and
   narrower by as much, so its text ends where the paragraphs' does. (The
   :not() is the reading column's own, from the rule above: without it that
   rule is the stronger one, and the list gets the paragraphs' left edge.) */
.entry-content > :is(ul, ol):not([class*="wp-block-greenably-"]) {
	max-width: calc(var(--measure) - var(--space-24));
	margin-block: 0 var(--space-24);
	padding-left: calc(var(--gutter) + var(--space-24));
}

/* Bullets: a green dot, drawn, in the middle of the item's first line. The
   list's own bullet is still there, unseen. */
.entry-content > ul > li {
	position: relative;
}

.entry-content > ul > li::marker {
	color: transparent;
}

.entry-content > ul > li::before {
	content: "";
	position: absolute;
	top: calc((1lh - var(--space-8)) / 2);
	left: calc(-1 * var(--space-16));
	width: var(--space-8);
	height: var(--space-8);
	border-radius: var(--radius-pill);
	background: var(--color-brand-light-green);
}

/* Forced colours (the contrast themes in Windows) take the colour off a
   drawn dot: there the list has its own bullet instead. */
@media (forced-colors: active) {
	.entry-content > ul > li::marker {
		color: CanvasText;
	}

	.entry-content > ul > li::before {
		content: none;
	}
}

/* Only the text's own lists: a list inside one of the theme's blocks is
   that block's to space. */
.entry-content > ul li,
.entry-content > ol li {
	margin-bottom: var(--space-8);
}

.entry-content > figure {
	margin-block: var(--space-32);
}

/* Images in the text have rounded corners. :where keeps this weaker than any
   block's own rule, so a block that sets its images' corners, such as a logo's
   square ones, has its way: this file loads after the blocks' stylesheets, and
   an equally strong rule here would go over theirs. */
:where(.entry-content) img {
	border-radius: var(--radius-m);
}

.entry-content iframe {
	max-width: 100%;
}

.entry-content > blockquote {
	margin-block: var(--space-32);
	font: var(--type-h3);
}

/* A label and what it labels (a heading or a large sentence) belong
   together, with a section's space above the pair. */
.entry-content > p.is-style-eyebrow {
	margin-top: var(--section-space);
	margin-bottom: var(--space-12);
}

.entry-content > p.is-style-eyebrow:first-child {
	margin-top: 0;
}

.entry-content > p.is-style-eyebrow + * {
	margin-top: 0;
}

.entry-content > p.is-style-statement {
	max-width: 78.4rem;
	margin-bottom: 0;
}

/* News post: the title, the image across the container, then the text. */

.article-header {
	padding-top: var(--space-56);
	padding-bottom: var(--space-32);
}

.article-header h1 {
	max-width: 96rem;
	margin: 0;
	font: var(--type-h2);
}

.article-media {
	margin-bottom: var(--space-56);
}

.article-media img {
	display: block;
	width: 100%;
	max-height: 60rem;
	border-radius: var(--radius-m);
	object-fit: cover;
}

/* "Foto: …" under the featured image of a news post or a challenge
   (greenably_photo_credit()). */
.photo-credit {
	margin: var(--space-8) 0 0;
	font: var(--type-text-s);
	font-style: italic;
}

/* Under the text: the news posts before this one, as cards (.card in
   components.css), and a link to all news. The space above it is the text's
   own, see .entry-content. */
.article-more {
	padding-bottom: var(--section-space);
}

/* Challenge: the image beside the title, the summary, the facts (company and
   status, .facts in components.css) and the buttons. */

.challenge-header {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	align-items: center;
	gap: var(--space-32) var(--space-48);
	padding-block: var(--space-56);
}

.challenge-media {
	position: relative;
	overflow: hidden;
	aspect-ratio: 4 / 3;
	border-radius: var(--radius-m);
	background: var(--color-surface-off-white);
}

.challenge-media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.challenge-intro h1 {
	font: var(--type-h2);
}

.challenge-excerpt {
	margin-bottom: var(--space-32);
	font: var(--type-text-l);
}

.challenge-intro .facts {
	margin-bottom: var(--space-32);
}

/* Larger here than on a card: the sizes of the featured challenge on the
   start page (blocks/challenges/style.css). */
.challenge-intro .facts > div {
	min-height: 9.6rem;
	padding: var(--space-12) var(--space-16);
}

.challenge-intro .facts dt {
	font: var(--type-text-s);
}

.challenge-intro .facts dd,
.challenge-intro .chip {
	font: var(--type-h4);
}

.challenge-intro .chip {
	padding: var(--space-4) var(--space-12);
}

.challenge-closed {
	display: inline-block;
	margin: 0;
	padding: var(--space-12) var(--space-24);
	border-radius: var(--radius-m);
	background: var(--color-surface-off-white);
}

.challenge .entry-content {
	padding-top: var(--space-56);
	border-top: 1px solid var(--color-line);
}

/* The mail button at the end of an open challenge's text: set apart from the
   last paragraph, as a heading is. */
.challenge .entry-content > .challenge-end-button {
	margin-top: var(--space-40);
}

/* The text of a challenge is often pasted in from a document, and its
   headings then lie inside boxes of their own (div in div), where the rules
   for a text's headings (.entry-content > * + h2, above) do not reach. A
   heading starts a new part there too: more space above it than between
   paragraphs, unless it is the first thing in its box. */
.challenge .entry-content :is(h1, h2):not(:first-child) {
	margin-top: var(--space-56);
}

.challenge .entry-content :is(h3, h4):not(:first-child) {
	margin-top: var(--space-40);
}

/* And less space under it than between paragraphs, so it is read with the
   text it stands over. */
.challenge .entry-content :is(h1, h2, h3, h4, h5) {
	margin-bottom: var(--space-12);
}

@media (max-width: 800px) {
	.challenge-header {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Footer: dark green with the logo's arc as a large shape in its top right
   corner. The contact address is a big green button; under it are the menu,
   the partners and the links (the last two from the Greenably options page),
   and last, under a thin line, the legal links. */

.site-footer {
	position: relative;
	overflow: hidden;
	background: var(--color-brand-dark-green);
	color: var(--color-neutral-white);
}

.site-footer::before {
	content: "";
	position: absolute;
	top: 0;
	right: 0;
	width: 59.5rem;
	height: 54.5rem;
	background: url("images/footer-arc.svg") top right / contain no-repeat;
	pointer-events: none; /* a decoration: takes no clicks */
}

.site-footer-inner {
	position: relative;
	display: grid;
	grid-template-columns: 33.5rem auto 1fr;
	grid-template-areas:
		"logo  email email"
		"nav   lists ."
		"legal legal legal";
	align-items: start;
	gap: var(--space-56) var(--space-24);
	padding-block: var(--space-56) var(--space-32);
}

/* The links are always underlined, in a colour that cannot be seen: on hover
   the line fades to the text's colour, and fades out again after. Quicker
   than the theme's other transitions. */
.site-footer a {
	color: inherit;
	text-decoration: underline;
	text-decoration-color: transparent;
	transition: text-decoration-color 0.1s ease-out;
}

.site-footer a:hover {
	text-decoration-color: currentColor;
}

.site-footer h2 {
	margin: 0 0 var(--space-24);
	font: var(--type-h3);
}

.site-footer ul {
	display: grid;
	justify-items: start;
	gap: var(--space-16);
	margin: 0;
	padding: 0;
	list-style: none;
}

/* As wide as the logo, not as the grid area it is in. */
.site-footer-logo {
	grid-area: logo;
	align-self: center;
	justify-self: start;
}

.site-footer-logo img {
	display: block;
	width: 24.7rem;
	height: auto;
}

/* The contact address, at the right edge of the room beside the logo. When
   that room is too narrow for it, the address gets smaller rather than break
   (.fit and .fit-text in components.css). */
.site-footer-email {
	grid-area: email;
	display: flex;
	justify-content: flex-end;
}

/* The address is a button, not an underlined link: its ground changes on
   hover. */
.site-footer .site-footer-email a {
	--fit-pad: calc(2 * var(--space-24));
	max-width: 100%;
	padding: var(--space-16) var(--space-24);
	border-radius: var(--radius-l);
	background: var(--color-brand-light-green);
	color: var(--color-brand-dark-green);
	font: var(--type-h2);
	font-size: min(var(--font-size-h2), var(--fit-size));
	text-decoration: none;
	transition: background-color var(--transition);
}

.site-footer .site-footer-email a:hover {
	background: var(--color-brand-yellow);
}

.site-footer-nav {
	grid-area: nav;
}

.site-footer-lists {
	grid-area: lists;
	display: grid;
	gap: var(--space-48);
}

/* A link to another site, with the outward arrow after it: the partners and
   links, which have the class, and those in the menu at the bottom, which
   are known by opening in a new tab (greenably_open_external_links()). */
.site-footer-external,
.site-footer-legal a[target="_blank"] {
	display: inline-flex;
	align-items: center;
	gap: var(--space-12);
}

.site-footer-external::after,
.site-footer-legal a[target="_blank"]::after {
	content: "";
	flex: none;
	width: 1.7rem;
	height: 1.7rem;
	background: currentColor;
	mask: url("images/icon-external.svg") center / contain no-repeat;
}

.site-footer .menu-item-lang > a {
	display: inline-flex;
	align-items: center;
	gap: var(--space-6);
}

/* The links at the bottom, at the right, under a thin line. The row, and the
   line with it, is as wide as the page's content: it keeps the page margin
   at both sides. */
.site-footer-legal {
	grid-area: legal;
	display: flex;
	justify-content: flex-end;
	padding-top: var(--space-32);
	border-top: 1px solid var(--color-line-light);
}

.site-footer-legal ul {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-8) var(--space-40);
	font: var(--type-text-s);
}

@media (max-width: 900px) {
	.site-footer::before {
		width: 40rem;
		height: 36.6rem;
	}

	.site-footer-inner {
		grid-template-columns: 1fr;
		grid-template-areas:
			"email"
			"nav"
			"lists"
			"logo"
			"legal";
		gap: var(--space-48);
		padding-block: var(--space-40) var(--space-32);
	}

	/* As wide as the page's content, with the address in the middle. */
	.site-footer .site-footer-email a {
		flex: 1;
		font: var(--type-h3);
		font-size: min(var(--font-size-h3), var(--fit-size));
		text-align: center;
	}

	.site-footer-logo img {
		width: 20.6rem;
	}

	.site-footer-legal {
		justify-content: flex-start;
	}

	.site-footer-legal ul {
		gap: var(--space-8) var(--space-24);
		font: var(--type-text-xs);
	}
}
