/**
 * Section and card styles.
 *
 * The governing constraint: only about a fifth to a third of posts carry a featured
 * image, and the ones that do often share it. So the card is typographic by default and
 * treats an image as an enhancement - the inverse of the usual image-led news grid. A
 * card with no image is the designed case, not a degraded one.
 */

/* ------------------------------------------------------------------ section */

/*
 * Every section carries its own equal padding and no outer margin, so the rhythm is the
 * same whichever sections a site happens to render.
 */
.mf-section {
	padding-block: var(--wp--preset--spacing--60);
	margin-block: 0;
}

/*
 * Backgrounds alternate white / grey by position among the sections actually rendered.
 * A fixed tint per pattern would put two grey sections side by side whenever one between
 * them auto-hides (Events on EN), which is what made them look unpadded.
 */
.mf-section:nth-child(even of .mf-section),
.mf-section--tint {
	background-color: var(--wp--preset--color--surface);
}

/* Flush against the header and footer on the homepage. */
.wp-site-blocks > .mf-home + footer {
	margin-block-start: 0;
}

/* Heading row: title left, "see all" right, hairline filling the gap between. */
.mf-section__head {
	display: flex;
	align-items: baseline;
	gap: var(--wp--preset--spacing--40);
	margin-block-end: var(--wp--preset--spacing--50);
}

.mf-section__head::after {
	content: "";
	flex: 1 1 auto;
	height: 1px;
	background-color: var(--wp--preset--color--line);
}

.mf-section__head > :first-child {
	flex: 0 0 auto;
	margin: 0;
}

.mf-section__head .mf-section__more {
	order: 3;
	flex: 0 0 auto;
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	color: var(--wp--preset--color--primary);
	text-decoration: none;
	white-space: nowrap;
}

.mf-section__more:hover,
.mf-section__more:focus-visible {
	text-decoration: underline;
}

/* Phones: long (Armenian) "see all" labels drop under the heading instead of overflowing. */
@media (max-width: 599px) {
	.mf-section__head.mf-section__head {
		flex-wrap: wrap;
		row-gap: 0.5rem;
	}

	.mf-section__head::after {
		display: none;
	}
}

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

/*
 * Applies to the list items core renders inside a post template, whether the parent
 * query is laid out as a grid or scrolled as a slider.
 */
.mf-cards .wp-block-post-template {
	list-style: none;
	margin: 0;
	padding: 0;
}

.mf-cards .wp-block-post-template > li {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	padding: var(--wp--preset--spacing--40);
	background-color: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--line);
	/* The spine: a red edge that reads as the category marker. */
	border-block-start: 3px solid var(--wp--preset--color--primary);
	transition: border-color 120ms ease;
	/* Flow layout gives every li after the first a top margin, which offsets grid rows. */
	margin: 0;
}

.mf-cards .wp-block-post-template > li:hover {
	border-color: var(--wp--preset--color--line);
	border-block-start-color: var(--wp--preset--color--primary-deep);
}

/* Meta line: date, and category when the pattern includes one. */
.mf-cards .wp-block-post-date,
.mf-cards .wp-block-post-terms {
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--muted);
	margin: 0;
}

.mf-cards .wp-block-post-terms a {
	color: var(--wp--preset--color--secondary);
	text-decoration: none;
}

.mf-cards .wp-block-post-title {
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.015em;
	margin: 0;
	/*
	 * Not flex-grown: growing a clamped box re-exposes the lines the clamp hid. The excerpt
	 * takes the slack instead, via margin-block-start: auto.
	 */
	flex: 0 0 auto;
	/* Long (often Armenian) headlines stop at three lines instead of stretching every card. */
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	overflow: hidden;
}

.mf-cards .wp-block-post-title a {
	/* Core makes this inline-block, which line-clamp counts as a single line. */
	display: inline;
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

.mf-cards .wp-block-post-title a:hover,
.mf-cards .wp-block-post-title a:focus-visible {
	color: var(--wp--preset--color--primary);
}

.mf-cards .wp-block-post-excerpt {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
	margin: 0;
	margin-block-start: auto;
}

.mf-cards .wp-block-post-excerpt__excerpt {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	overflow: hidden;
	margin: 0;
}

.mf-cards .wp-block-post-excerpt__more-text {
	display: none;
}

/*
 * Image as enhancement. Default styles above assume no image, so browsers without
 * :has() support still get a correct typographic card rather than a broken one.
 */
.mf-cards .wp-block-post-featured-image {
	margin: calc(var(--wp--preset--spacing--40) * -1);
	margin-block-end: 0.4rem;
}

.mf-cards .wp-block-post-featured-image img {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 10;
	object-fit: cover;
}

/* --------------------------------------------------------------- grid layout */

.mf-cards--grid .wp-block-post-template {
	display: grid;
	gap: var(--wp--preset--spacing--40);
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}

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

.mf-hero {
	padding-block: var(--wp--preset--spacing--70) var(--wp--preset--spacing--60);
	border-block-end: 1px solid var(--wp--preset--color--line);
}

.mf-hero__title {
	max-width: 18ch;
	margin: 0;
}

.mf-hero__lede {
	max-width: 52ch;
	margin-block-start: var(--wp--preset--spacing--40);
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.5;
	color: var(--wp--preset--color--muted);
}

/* ------------------------------------------------------------------ prose */

.mf-prose p {
	max-width: 62ch;
}

.mf-lede {
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.5;
	color: var(--wp--preset--color--contrast);
}

/* Figures worth calling out, used by the about and labor-rights sections. */
.mf-stats {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--50);
	margin-block-start: var(--wp--preset--spacing--50);
}

.mf-stat {
	flex: 1 1 8rem;
	border-block-start: 3px solid var(--wp--preset--color--primary);
	padding-block-start: 0.75rem;
}

.mf-stat__value {
	display: block;
	font-family: var(--wp--preset--font-family--display);
	font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.5rem);
	font-weight: 700;
	line-height: 1;
	color: var(--wp--preset--color--contrast);
}

.mf-stat__label {
	display: block;
	margin-block-start: 0.35rem;
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--muted);
}

@media (prefers-reduced-motion: reduce) {
	.mf-cards .wp-block-post-template > li {
		transition: none;
	}
}

/* ----------------------------------------------------------------- chrome */

/*
 * FEPS-style double header: a red bar carrying the name, social links and search, over
 * an ink bar carrying the menu. Social links are one template part ("social"), shared
 * with the footer, so they are edited in one place.
 */
.mf-header {
	margin: 0;
}

.mf-topbar {
	background-color: var(--wp--preset--color--primary-deep);
	color: var(--wp--preset--color--base);
}

.mf-topbar__inner {
	min-height: 64px;
	gap: var(--wp--preset--spacing--40);
}

.mf-topbar__title,
.mf-topbar__title a,
.mf-footer__title {
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.15;
	color: var(--wp--preset--color--base);
	text-decoration: none;
	margin: 0;
}

.mf-topbar__title {
	flex: 0 1 16rem;
}

.mf-topbar__social {
	flex: 1 1 auto;
}

/* Social icons: white glyphs that invert on hover, as on FEPS. */
.mf-social.wp-block-social-links {
	gap: 0.25rem;
	margin: 0;
}

.mf-social .wp-social-link {
	transition: background-color 120ms ease;
}

.mf-social .wp-social-link a {
	padding: 0.4rem;
}

.mf-social .wp-social-link:hover {
	transform: none;
	background-color: var(--wp--preset--color--base);
}

/*
 * The icon colour has to be set on the anchor: core colours the svg with currentColor through
 * a 0,4,1 selector, so a fill rule alone loses and the icon stays white on white.
 */
.mf-social .wp-social-link:hover .wp-block-social-link-anchor {
	color: var(--wp--preset--color--primary-deep) !important;
}

/* Search: an outlined pill that expands into a field. */
.mf-search .wp-block-search__inside-wrapper {
	border: 0;
}

.mf-search .wp-block-search__button {
	margin: 0;
	padding: 0.35rem 1rem;
	background: transparent;
	color: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--base);
	border-radius: 999px;
}

.mf-search .wp-block-search__button:hover,
.mf-search .wp-block-search__button:focus-visible {
	background-color: rgba(255, 255, 255, 0.17);
}

.mf-search .wp-block-search__button svg {
	fill: currentColor;
}

.mf-search .wp-block-search__input {
	border: 1px solid var(--wp--preset--color--base);
	border-radius: 999px 0 0 999px;
	padding-inline: 1rem;
	font-size: var(--wp--preset--font-size--small);
}

.mf-search:not(.wp-block-search__searchfield-hidden) .wp-block-search__button {
	border-radius: 0 999px 999px 0;
}

.mf-menubar {
	background-color: var(--wp--preset--color--contrast);
	padding-block: 0.5rem;
}

.mf-menubar .mf-nav {
	min-height: 48px;
	color: var(--wp--preset--color--base);
	--navigation-layout-justification-setting: center;
}

.mf-menubar .mf-nav .wp-block-navigation__container {
	gap: 0;
}

.mf-menubar .mf-nav .wp-block-navigation-item__content.wp-block-navigation-item__content {
	position: relative;
	padding: 0.8rem 1rem;
	font-family: var(--wp--preset--font-family--display);
	font-size: 0.875rem;
	font-weight: 500;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--wp--preset--color--base);
	text-decoration: none;
}

.mf-menubar .mf-nav .wp-block-navigation-item__content.wp-block-navigation-item__content:hover,
.mf-menubar .mf-nav .wp-block-navigation-item__content.wp-block-navigation-item__content:focus-visible {
	background-color: rgba(255, 255, 255, 0.1);
	text-decoration: none;
}

/* The red underline FEPS draws under the current and hovered item. */
.mf-menubar .mf-nav .wp-block-navigation-item__content::after {
	content: "";
	position: absolute;
	inset-inline: 0;
	inset-block-end: 0;
	margin-inline: auto;
	inline-size: 0;
	block-size: 2px;
	background-color: var(--wp--preset--color--primary);
	transition: inline-size 200ms ease;
}

.mf-menubar .mf-nav .wp-block-navigation-item__content:hover::after,
.mf-menubar .mf-nav .current-menu-item > .wp-block-navigation-item__content::after {
	inline-size: 60px;
}

.mf-menubar .mf-nav .wp-block-navigation__submenu-container {
	background-color: var(--wp--preset--color--primary-deep) !important;
	color: var(--wp--preset--color--base) !important;
	border: 0 !important;
	padding-block: 0.5rem;
	min-width: 14rem !important;
}

.mf-menubar .mf-nav .wp-block-navigation__submenu-container .wp-block-navigation-item__content.wp-block-navigation-item__content {
	padding: 0.6rem 1.25rem;
	font-size: 0.8125rem;
	text-transform: none;
	letter-spacing: 0;
}

.mf-menubar .mf-nav .wp-block-navigation__submenu-container .wp-block-navigation-item__content::after {
	content: none;
}

/* A parent item: keep its arrow beside the label. */
.mf-menubar .mf-nav .has-child > .wp-block-navigation-item__content.wp-block-navigation-item__content {
	padding-inline-end: 0.25rem;
}

.mf-menubar .mf-nav .wp-block-navigation__submenu-icon {
	margin-inline-end: 1rem;
}

/* Mobile: the burger sits at the right of the ink bar; the overlay is ink too. */
.mf-menubar .mf-nav .wp-block-navigation__responsive-container-open {
	margin-inline-start: auto;
	padding: 1rem 0;
	color: var(--wp--preset--color--base);
}

.mf-menubar .mf-nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
	padding: 0.5rem 0;
	font-size: var(--wp--preset--font-size--medium);
}

.mf-menubar .mf-nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__submenu-container {
	background-color: transparent !important;
}

@media (max-width: 781px) {
	.mf-menubar .mf-nav {
		min-height: 0;
		justify-content: flex-end;
	}
}

/* Small screens: the icons would crowd the name, and they are repeated in the footer. */
@media (max-width: 599px) {
	.mf-topbar__social {
		display: none;
	}
}

.mf-footer {
	margin-block-start: var(--wp--preset--spacing--70);
	padding-block: var(--wp--preset--spacing--50);
	border-block-start: 3px solid var(--wp--preset--color--primary);
	background-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

.mf-footer__inner {
	gap: var(--wp--preset--spacing--40);
}

.mf-footer__note {
	color: rgba(255, 255, 255, 0.7);
	margin-block-start: 0.25rem;
}

.mf-footer .mf-social .wp-social-link:hover .wp-block-social-link-anchor {
	color: var(--wp--preset--color--contrast) !important;
}

@media (prefers-reduced-motion: reduce) {
	.mf-menubar .mf-nav .wp-block-navigation-item__content::after,
	.mf-social .wp-social-link {
		transition: none;
	}
}

/* Stack the two-column sections on small screens. */
@media (max-width: 781px) {
	.mf-section .wp-block-columns {
		gap: var(--wp--preset--spacing--50);
	}
}
