/*
Theme Name: Lanna Foundation
Theme URI: https://lannafoundation.org/
Author: Bedford+Co.
Author URI: https://bedfordandco.net/
Description: Block theme for the Lanna Foundation. Bold contrast design: Montserrat headlines, Inter body, Blue Fusion and Baltic Sea colours.
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 7.4
Version: 1.5.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: lanna-foundation
*/

/* Shared CSS, loaded on the front end and in the block editor. Mobile first.
   Colours, sizes and spacing come from theme.json presets only. */

/* ---------- Page frame ---------- */

/* Sections stack edge to edge; each section sets its own padding. */
body .wp-site-blocks > *,
.wp-block-post-content.lanna-sections > * {
	margin-block-start: 0;
}

[id] {
	scroll-margin-top: 120px;
}

:where(a, button, summary, input, .wp-element-button):focus-visible {
	outline: 3px solid var(--wp--preset--color--primary);
	outline-offset: 3px;
}

:where(.is-style-section-navy, .is-style-section-ink, .wp-block-cover, .lanna-header .wp-block-navigation__responsive-container.is-menu-open) :focus-visible {
	outline-color: var(--wp--preset--color--accent);
}

/* ---------- Accent bar (brand divider) ---------- */

.wp-block-separator.is-style-gold-bar {
	width: 64px;
	max-width: 64px;
	height: 3px;
	border: 0;
	opacity: 1;
	margin-inline: 0;
}

.wp-block-separator.is-style-gold-bar.lanna-bar--small {
	width: 40px;
	max-width: 40px;
}

/* ---------- Eyebrow labels ---------- */

.is-style-eyebrow {
	color: var(--wp--preset--color--primary);
}

:where(.is-style-section-ink, .wp-block-cover) .is-style-eyebrow {
	color: var(--wp--preset--color--accent);
}

/* Baltic Sea text on Blue Fusion is under 3:1, so labels on blue bands stay white. */
:where(.is-style-section-navy) .is-style-eyebrow {
	color: var(--wp--preset--color--base);
}

/* ---------- Header ---------- */

.lanna-header {
	position: sticky;
	top: 0;
	z-index: 50;
	border-bottom: 1px solid var(--wp--preset--color--surface);
}

/* Below 600px the admin bar scrolls away with the page. */
.admin-bar .lanna-header {
	top: 0;
}

.lanna-header .wp-block-site-logo img {
	width: 104px;
	height: auto;
}

.lanna-header .lanna-header__social {
	display: none;
}

/* The full menu needs about 1000px: keep the menu button up to there (core switches at 600px). */
@media (max-width: 1023px) {
	.lanna-header .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
	}

	.lanna-header .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) {
		display: none;
	}
}

.lanna-header .wp-block-navigation .wp-block-navigation-item__content {
	padding-block: 8px;
}

.lanna-header .wp-block-navigation__responsive-container.is-menu-open .lanna-header__social {
	display: flex;
}

.lanna-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	padding-top: var(--wp--preset--spacing--48);
}

/* The desktop menu is right-aligned; the open overlay reads better left-aligned. */
.lanna-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content,
.lanna-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content .wp-block-navigation__container,
.lanna-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content .wp-block-navigation-item {
	align-items: flex-start;
	justify-content: flex-start;
	text-align: left;
}

.lanna-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
	font-size: var(--wp--preset--font-size--medium);
}


/* ---------- Buttons ---------- */

/* One button size everywhere: theme.json padding and type (core shrinks the padding on outline buttons), plus a shared minimum width. */
.wp-block-button .wp-block-button__link,
.wp-block-button.is-style-outline > .wp-block-button__link {
	min-width: 16rem;
	padding: 16px 32px;
	text-align: center;
}

/* Outline buttons fill with Ink on hover, matching the accent buttons' hover state. */
.wp-block-button.is-style-outline > .wp-block-button__link:hover,
.wp-block-button.is-style-outline > .wp-block-button__link:focus-visible {
	background-color: var(--wp--preset--color--contrast);
	border-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

/* The header has no room for the shared width: same height and type, width set by the label. */
.lanna-header .lanna-header__donate .wp-block-button__link {
	min-width: 0;
}

/* ---------- Social icons ---------- */

/* Monochrome icons that follow the surrounding text colour (no brand colours). */
.lanna-social.wp-block-social-links.is-style-logos-only .wp-social-link {
	color: currentColor;
}

.lanna-social.wp-block-social-links.is-style-logos-only .wp-social-link:hover {
	color: var(--wp--preset--color--accent);
}

.lanna-header .lanna-social.wp-block-social-links.is-style-logos-only .wp-social-link:hover,
.is-style-section-gold .lanna-social.wp-block-social-links.is-style-logos-only .wp-social-link:hover {
	color: var(--wp--preset--color--primary);
}

/* ---------- Announcement bar ---------- */

.lanna-announce {
	text-align: center;
}

.lanna-announce p {
	max-width: none;
}

.lanna-announce a {
	color: inherit;
	font-weight: 700;
	white-space: nowrap;
}

/* Intro text in a wide column keeps a readable line length. */
.lanna-intro > p,
.lanna-split p,
.lanna-hero p {
	max-width: 62ch;
}

/* ---------- Heroes ---------- */

.lanna-hero .wp-block-cover__inner-container {
	max-width: var(--wp--style--global--wide-size);
	margin-inline: auto;
}

.lanna-hero h1 {
	max-width: 16ch;
}

.lanna-hero--statement h1 {
	max-width: 24ch;
}

.lanna-hero p {
	max-width: 60ch;
}

/* Inner-page hero titles run 20% larger than the H1 preset; on phones they stop at 12vw
   so long single words ("Cooperative") still fit the screen. */
.lanna-page-hero h1,
.lanna-type-hero h1 {
	font-size: min(calc(var(--wp--preset--font-size--xx-large) * 1.2), 12vw);
}

.lanna-type-hero h1.has-x-large-font-size {
	font-size: calc(var(--wp--preset--font-size--x-large) * 1.2) !important;
}

/* Photo heroes on inner pages: title sits at the bottom of the photo. */
.lanna-page-hero.wp-block-cover {
	align-items: flex-end;
}

.lanna-type-hero p {
	color: var(--wp--preset--color--base);
}

@media (prefers-reduced-motion: reduce) {
	.lanna-hero .wp-block-cover__video-background {
		display: none;
	}
}

/* ---------- Cards ---------- */

/* Whole-card links: the heading link stretches over the card. */
.lanna-card {
	position: relative;
}

.lanna-card .wp-block-heading a,
.lanna-card .lanna-card__link a {
	text-decoration: none;
}

.lanna-card .wp-block-heading a::after,
.lanna-card .lanna-card__link a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

/* Image link cards on the home page. */
.lanna-card.wp-block-cover {
	padding: var(--wp--preset--spacing--32);
	overflow: hidden;
}

/* The cover's inner container is positioned, which would confine the stretched link to the text:
   oversize the link area and let the card clip it, so the whole photo is clickable. */
.lanna-card.wp-block-cover .wp-block-heading a::after {
	inset: -100vmax;
}

/* Team cards and biographies. */
.lanna-team-card .wp-block-image img,
.lanna-bio .wp-block-image img {
	width: 100%;
}

.lanna-team-card__name,
.lanna-bio .wp-block-heading {
	text-transform: uppercase;
}

.lanna-team-card__name a {
	text-decoration: none;
}

.lanna-team-card__name a:hover {
	text-decoration: underline;
}

/* Biographies read as ruled rows. */
.lanna-bios {
	border-bottom: 2px solid var(--wp--preset--color--contrast);
}

.lanna-bio {
	border-top: 2px solid var(--wp--preset--color--contrast);
}

/* Biography pop-ups (assets/js/bio-popups.js moves each .lanna-bio into a dialog). */
.lanna-bio-dialog {
	width: min(960px, calc(100vw - 32px));
	max-height: calc(100vh - 64px);
	padding: 0;
	border: 0;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	overflow-y: auto;
}

.lanna-bio-dialog::backdrop {
	background: color-mix(in srgb, var(--wp--preset--color--contrast) 80%, transparent);
}

.lanna-bio-dialog .lanna-bio {
	border: 0;
	padding: var(--wp--preset--spacing--48);
}

.lanna-bio-dialog__close {
	position: sticky;
	top: 0;
	float: right;
	z-index: 2;
	width: 56px;
	height: 56px;
	border: 0;
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	font-size: 36px;
	line-height: 1;
	cursor: pointer;
}

.lanna-bio-dialog__close:hover,
.lanna-bio-dialog__close:focus-visible {
	background: var(--wp--preset--color--primary);
}

@media (max-width: 599px) {
	.lanna-bio-dialog .lanna-bio {
		padding: var(--wp--preset--spacing--24);
	}
}

html:has(.lanna-bio-dialog[open]) {
	overflow: hidden;
}

/* ---------- Ruled lists (prices, aims) ---------- */

.wp-block-list.lanna-ruled {
	list-style: none;
	padding-left: 0;
	border-bottom: 2px solid currentColor;
	font-family: var(--wp--preset--font-family--montserrat);
	font-weight: 700;
}

.wp-block-list.lanna-ruled li {
	margin: 0;
	padding-block: var(--wp--preset--spacing--16);
	border-top: 2px solid currentColor;
}

.wp-block-list.lanna-ruled--large {
	font-size: var(--wp--preset--font-size--medium);
}

/* ---------- Contact details ---------- */

.lanna-contact-item {
	padding-top: var(--wp--preset--spacing--24);
	border-top: 2px solid var(--wp--preset--color--contrast);
	overflow-wrap: anywhere;
}

/* ---------- Edge-to-edge gallery ---------- */

.wp-block-gallery.lanna-gallery-edge {
	margin-bottom: 0;
}

/* ---------- Stats ---------- */

.lanna-stat {
	text-align: center;
}

.lanna-stat .lanna-stat__number {
	font-family: var(--wp--preset--font-family--montserrat);
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.02em;
	/* Equal-width digits so the count-up does not jitter. */
	font-variant-numeric: tabular-nums;
}

/* ---------- Blog ---------- */

.lanna-post-card .wp-block-post-title a:hover {
	text-decoration: underline;
}

.lanna-post-card .wp-block-post-featured-image {
	overflow: hidden;
}

.lanna-post-card .wp-block-post-featured-image img {
	transition: transform 0.3s ease;
}

.lanna-post-card:hover .wp-block-post-featured-image img {
	transform: scale(1.03);
}

@media (prefers-reduced-motion: reduce) {
	.lanna-post-card .wp-block-post-featured-image img {
		transition: none;
	}

	.lanna-post-card:hover .wp-block-post-featured-image img {
		transform: none;
	}
}

.wp-block-query-pagination a {
	text-decoration: none;
}

.wp-block-query-pagination .page-numbers.current {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	padding: 4px 10px;
}

.lanna-single__content img {
	height: auto;
}

/* ---------- Statement hero ---------- */

/* Lead line, headline and tail share one column width and tight spacing so they read
   as a single statement. */
.lanna-statement-hero {
	--lanna-statement-measure: 40rem;
}

.lanna-statement-hero h1 {
	max-width: var(--lanna-statement-measure);
	margin-block-start: var(--wp--preset--spacing--16);
}

.lanna-statement-hero .lanna-statement-hero__lead,
.lanna-statement-hero .lanna-statement-hero__tail {
	color: var(--wp--preset--color--base);
	max-width: var(--lanna-statement-measure);
	line-height: 1.3;
}

.lanna-statement-hero .lanna-statement-hero__tail {
	margin-block-start: var(--wp--preset--spacing--16);
}

/* Photos and video show in full colour; a gradient sits only behind the text, and a soft
   shadow keeps white type readable over bright patches. */
.lanna-hero.wp-block-cover :where(h1, h2, p),
.lanna-panel.wp-block-cover :where(h2, p) {
	text-shadow: 0 1px 16px rgba(0, 0, 0, 0.45);
}

.lanna-statement {
	letter-spacing: -0.02em;
}

/* ---------- Edge-to-edge strips and panels ---------- */

.lanna-strip .wp-block-image,
.lanna-panels .wp-block-cover,
.lanna-panel-split .wp-block-cover {
	margin: 0;
}

.lanna-strip .wp-block-image img {
	width: 100%;
}

.lanna-panels .wp-block-heading a,
.lanna-portrait .wp-block-heading a {
	text-decoration: none;
}

.lanna-panel-split {
	margin-block: 0;
}

.lanna-panel-split > .lanna-panel-media {
	display: flex;
}

/* The text panel's outer edge lines up with the wide column on large screens. */
.lanna-panel-split > .lanna-panel-text {
	padding-inline: var(--wp--preset--spacing--24);
}

@media (min-width: 782px) {
	.lanna-panel-split > .lanna-panel-text {
		padding-left: max(var(--wp--preset--spacing--64), calc((100vw - var(--wp--style--global--wide-size)) / 2));
		padding-right: var(--wp--preset--spacing--64);
	}

	.lanna-panel-split--reverse > .lanna-panel-text {
		padding-left: var(--wp--preset--spacing--64);
		padding-right: max(var(--wp--preset--spacing--64), calc((100vw - var(--wp--style--global--wide-size)) / 2));
	}
}

.lanna-panel-split .lanna-panel-photo {
	flex: 1;
	min-height: 360px;
}

/* ---------- Action rows ---------- */

.lanna-rows {
	border-bottom: 2px solid var(--wp--preset--color--contrast);
}

.lanna-row {
	position: relative;
	padding-block: var(--wp--preset--spacing--32);
	padding-inline: var(--wp--preset--spacing--16);
	border-top: 2px solid var(--wp--preset--color--contrast);
	transition: background-color 0.15s ease;
}

.lanna-row .lanna-row__title {
	flex: 1 1 100%;
}

.lanna-row .lanna-row__title a {
	text-decoration: none;
}

.lanna-row .lanna-row__text {
	flex: 1 1 0;
}

.lanna-row--link .lanna-row__title a::after {
	content: "";
	position: absolute;
	inset: 0;
}

/* A row with only a title (link lists such as giving options and job openings). */
.lanna-row--solo .lanna-row__title {
	flex: 1 1 auto;
}

.lanna-row--icon .lanna-row__icon {
	flex: 0 0 auto;
	margin: 0;
}

.lanna-row--icon .lanna-row__icon img {
	width: 56px;
	height: 56px;
	object-fit: contain;
}

/* Links inside the supporting line stay clickable above the row link. */
.lanna-row .lanna-row__text a {
	position: relative;
	z-index: 1;
}

.lanna-row--link::after {
	content: "\2192";
	font-family: var(--wp--preset--font-family--montserrat);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 700;
	line-height: 1;
	transition: transform 0.15s ease;
}

.lanna-row--link:hover,
.lanna-row--link:focus-within {
	background-color: var(--wp--preset--color--surface);
}

.lanna-row--link:hover::after,
.lanna-row--link:focus-within::after {
	transform: translateX(6px);
	color: var(--wp--preset--color--primary);
}

/* ---------- Action cards ---------- */

.lanna-action-card .wp-block-heading a {
	text-decoration: none;
}

.lanna-action-card p a {
	position: relative;
	z-index: 2;
}

/* ---------- Stories: feature and rows ---------- */

.lanna-feature .wp-block-post-title a::after,
.lanna-story-row .wp-block-post-title a::after,
.lanna-post-card .wp-block-post-title a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.lanna-feature .wp-block-post-terms,
.lanna-story-row .wp-block-post-terms,
.lanna-post-card .wp-block-post-terms {
	position: relative;
	z-index: 2;
}

.lanna-story-rows > li + li {
	margin-top: 0;
}

.lanna-story-row {
	padding-block: var(--wp--preset--spacing--32);
	border-top: 2px solid var(--wp--preset--color--contrast);
}

.lanna-feature .wp-block-post-title a:hover,
.lanna-story-row .wp-block-post-title a:hover {
	text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
	.lanna-video-band .wp-block-cover__video-background {
		display: none;
	}

	.lanna-row,
	.lanna-row--link::after {
		transition: none;
	}
}

@media (min-width: 782px) {
	.lanna-row {
		flex-wrap: nowrap;
	}

	.lanna-row .lanna-row__title {
		flex: 0 0 32%;
	}

	.lanna-row--solo .lanna-row__title {
		flex: 1 1 auto;
	}

	.lanna-sticky {
		position: sticky;
		top: 140px;
		align-self: flex-start;
	}

	.lanna-campaign__button {
		justify-content: flex-end;
	}
}

/* ---------- Footer ---------- */

.lanna-footer .wp-block-site-logo img {
	width: 180px;
	height: auto;
	/* The logo artwork is black on transparent: show it reversed on the dark footer. */
	filter: invert(1);
}

.lanna-footer .wp-block-navigation a:hover,
.lanna-footer a:hover {
	color: var(--wp--preset--color--accent);
}

.lanna-footer__legal a {
	text-decoration: none;
	font-weight: 700;
}

/* ---------- Tablet and up ---------- */

@media (min-width: 600px) {
	.admin-bar .lanna-header {
		top: 46px;
	}
}

@media (min-width: 783px) {
	.admin-bar .lanna-header {
		top: 32px;
	}
}

@media (min-width: 1024px) {
	.lanna-header .wp-block-site-logo img {
		width: 130px;
	}

	.lanna-header .lanna-header__social {
		display: flex;
	}
}

/* Columns stack below 782px (core); give stacked image/text splits room. */
@media (max-width: 781px) {
	.lanna-split .wp-block-column + .wp-block-column {
		margin-top: var(--wp--preset--spacing--16);
	}

	/* Portrait split photos would fill the screen once stacked: crop them shorter. */
	.lanna-split .wp-block-image img {
		max-height: 560px;
	}
}

/* Very small phones: let an oversized single word in a heading wrap instead of pushing the page sideways. */
@media (max-width: 359px) {
	.wp-block-heading {
		overflow-wrap: break-word;
		hyphens: auto;
	}
}

/* ---------- Contact form (Elfsight) ---------- */

/* The widget's own colour setting is orange; match the site's buttons instead. */
.eapps-widget .es-button-base-container {
	background-color: var(--wp--preset--color--accent) !important;
	color: var(--wp--preset--color--contrast) !important;
}

.eapps-widget .es-button-base-container:hover,
.eapps-widget .es-button-base-container:focus-visible {
	background-color: var(--wp--preset--color--primary) !important;
	color: var(--wp--preset--color--base) !important;
}

/* Small source photo: show the whole frame at no more than its natural size,
   instead of enlarging and cropping it to fill the panel. */
.lanna-panel-split .lanna-panel-photo--whole {
	background-color: var(--wp--preset--color--surface);
}

.lanna-panel-split .lanna-panel-photo--whole .wp-block-cover__image-background {
	object-fit: scale-down !important;
}
